private ScopedInterningLayer(@Nonnull FDBDatabase database, @Nullable KeySpacePath path, @Nonnull Supplier<Tuple> pathTuple) { super(database, path); if (path == null) { this.baseSubspace = new Subspace(); this.nodeSubspace = new Subspace(GLOBAL_SCOPE_PREFIX_BYTES); this.interningLayer = new StringInterningLayer(nodeSubspace, true); this.infoString = "ScopedInterningLayer:GLOBAL"; } else { this.baseSubspace = new Subspace(pathTuple.get()); this.nodeSubspace = baseSubspace; this.interningLayer = new StringInterningLayer(nodeSubspace, false); this.infoString = "ScopedInterningLayer:" + path.toString(); } this.stateSubspace = nodeSubspace.get(STATE_SUBSPACE_KEY_SUFFIX); this.hashCode = Objects.hash(ScopedInterningLayer.class, baseSubspace, database); }
/** * Count the items in the set. * @param tc the transaction to use to access the database * @return a future that completes to the number of items in the set */ public CompletableFuture<Long> size(ReadTransactionContext tc) { Range r = subspace.get(nlevels - 1).range(); return tc.readAsync(tr -> AsyncUtil.mapIterable(tr.getRange(r), keyValue -> decodeLong(keyValue.getValue())) .asList() .thenApply(longs -> longs.stream().reduce(0L, Long::sum))); }
private ExtendedDirectoryLayer(@Nonnull FDBDatabase database, @Nullable KeySpacePath path, @Nonnull Supplier<Tuple> pathTuple) { super(database, path); if (path == null) { this.isRootLevel = true; this.baseSubspace = DEFAULT_BASE_SUBSPACE; this.nodeSubspace = DEFAULT_NODE_SUBSPACE; this.contentSubspace = DEFAULT_CONTENT_SUBSPACE; this.infoString = "ExtendedDirectoryLayer:GLOBAL"; } else { this.isRootLevel = false; this.baseSubspace = new Subspace(pathTuple.get()); this.nodeSubspace = new Subspace(Bytes.concat(baseSubspace.getKey(), DirectoryLayer.DEFAULT_NODE_SUBSPACE.getKey())); this.contentSubspace = new Subspace(RESERVED_CONTENT_SUBSPACE_PREFIX); this.infoString = "ExtendedDirectoryLayer:" + path.toString(); } this.stateSubspace = nodeSubspace.get(STATE_SUBSPACE_KEY_SUFFIX); this.hashCode = Objects.hash(ExtendedDirectoryLayer.class, baseSubspace, database); }
levelSubspace = subspace.get(level); asyncIterator = lookupIterator(tr.getRange( KeySelector.firstGreaterOrEqual(levelSubspace.pack(rankKey)),
private ScopedDirectoryLayer(@Nonnull FDBDatabase database, @Nullable KeySpacePath path, @Nonnull Supplier<Tuple> pathTuple) { super(database, path); if (path == null) { this.baseSubspace = new Subspace(); this.contentSubspace = new Subspace(); this.infoString = "ScopedDirectoryLayer:GLOBAL"; } else { this.baseSubspace = new Subspace(pathTuple.get()); this.contentSubspace = new Subspace(RESERVED_CONTENT_SUBSPACE_PREFIX); this.infoString = "ScopedDirectoryLayer:" + path.toString(); } this.nodeSubspace = new Subspace(Bytes.concat(baseSubspace.getKey(), DirectoryLayer.DEFAULT_NODE_SUBSPACE.getKey())); this.directoryLayer = new DirectoryLayer(nodeSubspace, contentSubspace); this.stateSubspace = nodeSubspace.get(STATE_SUBSPACE_KEY_SUFFIX); this.hashCode = Objects.hash(ScopedDirectoryLayer.class, baseSubspace, database); }
return READY_FALSE; levelSubspace = subspace.get(level); asyncIterator = lookupIterator(tr.getRange(levelSubspace.pack(key), levelSubspace.range().end, ReadTransaction.ROW_LIMIT_UNLIMITED,
op = workerMap.get(tr, bmSubspace.get(mapIndex), key).thenAccept(optionalValue -> tr.mutate(MutationType.SET_VERSIONSTAMPED_KEY, getLogKey(logSubspace, mapIndex, localOrder), Tuple.from("GET", key, optionalValue.orElse(null)).pack()) );