This commit is contained in:
Andrea Cavalli 2022-08-03 18:23:26 +02:00
parent faa2a71597
commit 907a30dc2b
2 changed files with 16 additions and 14 deletions

View File

@ -16,7 +16,7 @@ import org.jetbrains.annotations.Nullable;
*/ */
public class LLRange extends SimpleResource { public class LLRange extends SimpleResource {
private static final LLRange RANGE_ALL = new LLRange((Buffer) null, (Buffer) null, (Buffer) null); private static final LLRange RANGE_ALL = new LLRange( null, null, (Buffer) null, false);
@Nullable @Nullable
private final Buffer min; private final Buffer min;
@Nullable @Nullable
@ -24,16 +24,16 @@ public class LLRange extends SimpleResource {
@Nullable @Nullable
private final Buffer single; private final Buffer single;
private LLRange(Send<Buffer> min, Send<Buffer> max, Send<Buffer> single) { private LLRange(Send<Buffer> min, Send<Buffer> max, Send<Buffer> single, boolean closeable) {
super(); super(closeable);
assert single == null || (min == null && max == null); assert single == null || (min == null && max == null);
this.min = min != null ? min.receive().makeReadOnly() : null; this.min = min != null ? min.receive().makeReadOnly() : null;
this.max = max != null ? max.receive().makeReadOnly() : null; this.max = max != null ? max.receive().makeReadOnly() : null;
this.single = single != null ? single.receive().makeReadOnly() : null; this.single = single != null ? single.receive().makeReadOnly() : null;
} }
private LLRange(Buffer min, Buffer max, Buffer single) { private LLRange(Buffer min, Buffer max, Buffer single, boolean closeable) {
super(); super(closeable);
assert single == null || (min == null && max == null); assert single == null || (min == null && max == null);
this.min = min != null ? min.makeReadOnly() : null; this.min = min != null ? min.makeReadOnly() : null;
this.max = max != null ? max.makeReadOnly() : null; this.max = max != null ? max.makeReadOnly() : null;
@ -41,31 +41,31 @@ public class LLRange extends SimpleResource {
} }
public static LLRange all() { public static LLRange all() {
return RANGE_ALL.copy(); return RANGE_ALL;
} }
public static LLRange from(Send<Buffer> min) { public static LLRange from(Send<Buffer> min) {
return new LLRange(min, null, null); return new LLRange(min, null, null, true);
} }
public static LLRange to(Send<Buffer> max) { public static LLRange to(Send<Buffer> max) {
return new LLRange(null, max, null); return new LLRange(null, max, null, true);
} }
public static LLRange single(Send<Buffer> single) { public static LLRange single(Send<Buffer> single) {
return new LLRange(null, null, single); return new LLRange(null, null, single, true);
} }
public static LLRange singleUnsafe(Buffer single) { public static LLRange singleUnsafe(Buffer single) {
return new LLRange(null, null, single); return new LLRange(null, null, single, true);
} }
public static LLRange of(Send<Buffer> min, Send<Buffer> max) { public static LLRange of(Send<Buffer> min, Send<Buffer> max) {
return new LLRange(min, max, null); return new LLRange(min, max, null, true);
} }
public static LLRange ofUnsafe(Buffer min, Buffer max) { public static LLRange ofUnsafe(Buffer min, Buffer max) {
return new LLRange(min, max, null); return new LLRange(min, max, null, true);
} }
public boolean isAll() { public boolean isAll() {
@ -224,7 +224,8 @@ public class LLRange extends SimpleResource {
// todo: use a read-only copy // todo: use a read-only copy
return new LLRange(min != null ? min.copy().send() : null, return new LLRange(min != null ? min.copy().send() : null,
max != null ? max.copy().send() : null, max != null ? max.copy().send() : null,
single != null ? single.copy().send(): null single != null ? single.copy().send() : null,
true
); );
} }
} }

View File

@ -26,6 +26,7 @@ import org.rocksdb.RocksDBException;
import org.rocksdb.WriteBatch; import org.rocksdb.WriteBatch;
import org.rocksdb.WriteOptions; import org.rocksdb.WriteOptions;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
public class HugePqPriorityQueue<T> extends SimpleResource public class HugePqPriorityQueue<T> extends SimpleResource
implements PriorityQueue<T>, Reversable<ReversableResourceIterable<T>>, ReversableResourceIterable<T> { implements PriorityQueue<T>, Reversable<ReversableResourceIterable<T>>, ReversableResourceIterable<T> {
@ -339,7 +340,7 @@ public class HugePqPriorityQueue<T> extends SimpleResource
if (rocksIterWithReadOpts != null) { if (rocksIterWithReadOpts != null) {
rocksIterWithReadOpts.close(); rocksIterWithReadOpts.close();
} }
}).concatMapIterable(item -> item); }).subscribeOn(Schedulers.boundedElastic()).concatMapIterable(item -> item);
} }
@Override @Override