Skip to content

Commit 10d566d

Browse files
committed
some renamings
1 parent 7479fea commit 10d566d

File tree

7 files changed

+45
-45
lines changed

7 files changed

+45
-45
lines changed

fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/ByNodeStorageAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ protected <R extends NodeReference> CompletableFuture<Node<R>> fetchNodeInternal
118118
}
119119

120120
@Override
121-
public void writeLeafNodeSlot(@Nonnull final Transaction transaction, @Nonnull final DataNode node,
121+
public void writeLeafNodeSlot(@Nonnull final Transaction transaction, @Nonnull final CompactNode node,
122122
@Nonnull final ItemSlot itemSlot) {
123123
persistNode(transaction, node);
124124
}
125125

126126
@Override
127-
public void clearLeafNodeSlot(@Nonnull final Transaction transaction, @Nonnull final DataNode node,
127+
public void clearLeafNodeSlot(@Nonnull final Transaction transaction, @Nonnull final CompactNode node,
128128
@Nonnull final ItemSlot itemSlot) {
129129
persistNode(transaction, node);
130130
}
@@ -170,7 +170,7 @@ private <N extends NodeReference> Node<N> nodeFromTuple(@Nonnull final Node.Node
170170
vectorTuple = tuple.getNestedTuple(2);
171171
neighborsTuple = tuple.getNestedTuple(3);
172172
return dataNodeFromTuples(creator, primaryKey, vectorTuple, neighborsTuple);
173-
case INTERMEDIATE:
173+
case INLINING:
174174
neighborsTuple = tuple.getNestedTuple(3);
175175
return intermediateNodeFromTuples(creator, primaryKey, neighborsTuple);
176176
default:
@@ -216,7 +216,7 @@ private <N extends NodeReference> Node<N> intermediateNodeFromTuples(@Nonnull fi
216216
neighborsWithVectors.add(new NodeReferenceWithVector(neighborPrimaryKey, new Vector.HalfVector(neighborVectorHalfs)));
217217
}
218218

219-
return creator.create(NodeKind.INTERMEDIATE, primaryKey, null, neighborsWithVectors);
219+
return creator.create(NodeKind.INLINING, primaryKey, null, neighborsWithVectors);
220220
}
221221

222222
@Nonnull

fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/DataNode.java renamed to fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/CompactNode.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* DataNode.java
2+
* CompactNode.java
33
*
44
* This source file is part of the FoundationDB open source project
55
*
@@ -32,12 +32,12 @@
3232
/**
3333
* TODO.
3434
*/
35-
class DataNode extends AbstractNode<NodeReference> {
35+
class CompactNode extends AbstractNode<NodeReference> {
3636
@Nonnull
3737
private final Vector<Half> vector;
3838

39-
public DataNode(@Nonnull final Tuple primaryKey, @Nonnull final Vector<Half> vector,
40-
@Nonnull final List<NodeReference> nodeReferences) {
39+
public CompactNode(@Nonnull final Tuple primaryKey, @Nonnull final Vector<Half> vector,
40+
@Nonnull final List<NodeReference> nodeReferences) {
4141
super(primaryKey, nodeReferences);
4242
this.vector = vector;
4343
}
@@ -55,19 +55,19 @@ public Vector<Half> getVector() {
5555

5656
@Nonnull
5757
@Override
58-
public DataNode asDataNode() {
58+
public CompactNode asCompactNode() {
5959
return this;
6060
}
6161

6262
@Nonnull
6363
@Override
64-
public IntermediateNode asIntermediateNode() {
65-
throw new IllegalStateException("this is not a data node");
64+
public InliningNode asInliningNode() {
65+
throw new IllegalStateException("this is not an inlining node");
6666
}
6767

6868
@Override
6969
public NodeCreator<NodeReference> sameCreator() {
70-
return DataNode::creator;
70+
return CompactNode::creator;
7171
}
7272

7373
@Nonnull
@@ -76,7 +76,7 @@ public static Node<NodeReference> creator(@Nonnull final NodeKind nodeKind,
7676
@Nonnull final Tuple primaryKey,
7777
@Nullable final Vector<Half> vector,
7878
@Nonnull final List<? extends NodeReference> neighbors) {
79-
Verify.verify(nodeKind == NodeKind.INTERMEDIATE);
80-
return new DataNode(primaryKey, Objects.requireNonNull(vector), (List<NodeReference>)neighbors);
79+
Verify.verify(nodeKind == NodeKind.INLINING);
80+
return new CompactNode(primaryKey, Objects.requireNonNull(vector), (List<NodeReference>)neighbors);
8181
}
8282
}

fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/HNSW.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public AsyncIterator<ItemSlot> scan(@Nonnull final ReadTransaction readTransacti
498498
@Nonnull final BiPredicate<Tuple, Tuple> suffixKeyPredicate) {
499499
Preconditions.checkArgument((lastHilbertValue == null && lastKey == null) ||
500500
(lastHilbertValue != null && lastKey != null));
501-
AsyncIterator<DataNode> leafIterator =
501+
AsyncIterator<CompactNode> leafIterator =
502502
new LeafIterator(readTransaction, rootId, lastHilbertValue, lastKey, mbrPredicate, suffixKeyPredicate);
503503
return new ItemSlotIterator(leafIterator);
504504
}
@@ -544,7 +544,7 @@ private CompletableFuture<SearchResult<NodeReference>> kNearestNeighborsSearch(@
544544
return CompletableFuture.completedFuture(null);
545545
}
546546

547-
return searchLayer(DataNode::creator, readTransaction,
547+
return searchLayer(CompactNode::creator, readTransaction,
548548
ImmutableList.of(greedyState.toNodeReferenceWithDistance()), 0, efSearch,
549549
queryVector);
550550
});
@@ -564,14 +564,14 @@ private CompletableFuture<GreedyState> greedySearchLayer(@Nonnull final ReadTran
564564
new AtomicReference<>(new GreedyState(layer, entryNeighbor.getPrimaryKey(), entryNeighbor.getDistance()));
565565

566566
return AsyncUtil.whileTrue(() -> onReadListener.onAsyncRead(
567-
storageAdapter.fetchNode(IntermediateNode::creator, readTransaction,
567+
storageAdapter.fetchNode(InliningNode::creator, readTransaction,
568568
layer, greedyStateReference.get().getPrimaryKey()))
569569
.thenApply(node -> {
570570
if (node == null) {
571571
throw new IllegalStateException("unable to fetch node");
572572
}
573-
final IntermediateNode intermediateNode = node.asIntermediateNode();
574-
final List<NodeReferenceWithVector> neighbors = intermediateNode.getNeighbors();
573+
final InliningNode inliningNode = node.asInliningNode();
574+
final List<NodeReferenceWithVector> neighbors = inliningNode.getNeighbors();
575575

576576
final GreedyState currentNodeKey = greedyStateReference.get();
577577
double minDistance = currentNodeKey.getDistance();
@@ -637,7 +637,7 @@ private <N extends NodeReference> CompletableFuture<SearchResult<N>> searchLayer
637637
.thenApply(candidateNode ->
638638
Iterables.filter(candidateNode.getNeighbors(),
639639
neighbor -> !visited.contains(neighbor.getPrimaryKey())))
640-
.thenCompose(neighborReferences -> fetchSomeNeighbors(creator, readTransaction,
640+
.thenCompose(neighborReferences -> neighborhood(creator, readTransaction,
641641
layer, neighborReferences, nodeCache))
642642
.thenApply(neighborReferences -> {
643643
for (final NodeReferenceWithVector current : neighborReferences) {
@@ -701,11 +701,11 @@ private <R extends NodeReference, N extends NodeReference, U> CompletableFuture<
701701
* TODO.
702702
*/
703703
@Nonnull
704-
private <N extends NodeReference> CompletableFuture<List<NodeReferenceWithVector>> fetchSomeNeighbors(@Nonnull final Node.NodeCreator<N> creator,
705-
@Nonnull final ReadTransaction readTransaction,
706-
final int layer,
707-
@Nonnull final Iterable<? extends NodeReference> neighborReferences,
708-
@Nonnull final Map<Tuple, Node<N>> nodeCache) {
704+
private <N extends NodeReference> CompletableFuture<List<NodeReferenceWithVector>> neighborhood(@Nonnull final Node.NodeCreator<N> creator,
705+
@Nonnull final ReadTransaction readTransaction,
706+
final int layer,
707+
@Nonnull final Iterable<? extends NodeReference> neighborReferences,
708+
@Nonnull final Map<Tuple, Node<N>> nodeCache) {
709709
return fetchSomeNodesAndApply(creator, readTransaction, layer, neighborReferences,
710710
neighborReference -> {
711711
if (neighborReference instanceof NodeReferenceWithVector) {
@@ -715,10 +715,10 @@ private <N extends NodeReference> CompletableFuture<List<NodeReferenceWithVector
715715
if (neighborNode == null) {
716716
return null;
717717
}
718-
return new NodeReferenceWithVector(neighborReference.getPrimaryKey(), neighborNode.asDataNode().getVector());
718+
return new NodeReferenceWithVector(neighborReference.getPrimaryKey(), neighborNode.asCompactNode().getVector());
719719
},
720720
(neighborReference, neighborNode) ->
721-
new NodeReferenceWithVector(neighborReference.getPrimaryKey(), neighborNode.asDataNode().getVector()));
721+
new NodeReferenceWithVector(neighborReference.getPrimaryKey(), neighborNode.asCompactNode().getVector()));
722722
}
723723

724724
/**

fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/IntermediateNode.java renamed to fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/InliningNode.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* IntermediateNode.java
2+
* InliningNode.java
33
*
44
* This source file is part of the FoundationDB open source project
55
*
@@ -31,33 +31,33 @@
3131
/**
3232
* TODO.
3333
*/
34-
class IntermediateNode extends AbstractNode<NodeReferenceWithVector> {
35-
public IntermediateNode(@Nonnull final Tuple primaryKey,
36-
@Nonnull final List<NodeReferenceWithVector> neighbors) {
34+
class InliningNode extends AbstractNode<NodeReferenceWithVector> {
35+
public InliningNode(@Nonnull final Tuple primaryKey,
36+
@Nonnull final List<NodeReferenceWithVector> neighbors) {
3737
super(primaryKey, neighbors);
3838
}
3939

4040
@Nonnull
4141
@Override
4242
public NodeKind getKind() {
43-
return NodeKind.INTERMEDIATE;
43+
return NodeKind.INLINING;
4444
}
4545

4646
@Nonnull
4747
@Override
48-
public DataNode asDataNode() {
49-
throw new IllegalStateException("this is not a data node");
48+
public CompactNode asCompactNode() {
49+
throw new IllegalStateException("this is not a compact node");
5050
}
5151

5252
@Nonnull
5353
@Override
54-
public IntermediateNode asIntermediateNode() {
54+
public InliningNode asInliningNode() {
5555
return this;
5656
}
5757

5858
@Override
5959
public NodeCreator<NodeReferenceWithVector> sameCreator() {
60-
return IntermediateNode::creator;
60+
return InliningNode::creator;
6161
}
6262

6363
@Nonnull
@@ -66,7 +66,7 @@ public static Node<NodeReferenceWithVector> creator(@Nonnull final NodeKind node
6666
@Nonnull final Tuple primaryKey,
6767
@Nullable final Vector<Half> vector,
6868
@Nonnull final List<? extends NodeReference> neighbors) {
69-
Verify.verify(nodeKind == NodeKind.INTERMEDIATE);
70-
return new IntermediateNode(primaryKey, (List<NodeReferenceWithVector>)neighbors);
69+
Verify.verify(nodeKind == NodeKind.INLINING);
70+
return new InliningNode(primaryKey, (List<NodeReferenceWithVector>)neighbors);
7171
}
7272
}

fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/Node.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ public interface Node<R extends NodeReference> {
5555
Node<R> delete(@Nonnull StorageAdapter storageAdapter, int level, int slotIndex);
5656

5757
/**
58-
* Return the kind of the node, i.e. {@link NodeKind#DATA} or {@link NodeKind#INTERMEDIATE}.
58+
* Return the kind of the node, i.e. {@link NodeKind#DATA} or {@link NodeKind#INLINING}.
5959
* @return the kind of this node as a {@link NodeKind}
6060
*/
6161
@Nonnull
6262
NodeKind getKind();
6363

6464
@Nonnull
65-
DataNode asDataNode();
65+
CompactNode asCompactNode();
6666

6767
@Nonnull
68-
IntermediateNode asIntermediateNode();
68+
InliningNode asInliningNode();
6969

7070
NodeCreator<R> sameCreator();
7171

fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/NodeKind.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
public enum NodeKind {
3131
DATA((byte)0x00),
32-
INTERMEDIATE((byte)0x01);
32+
INLINING((byte)0x01);
3333

3434
private final byte serialized;
3535

@@ -49,7 +49,7 @@ static NodeKind fromSerializedNodeKind(byte serializedNodeKind) {
4949
nodeKind = NodeKind.DATA;
5050
break;
5151
case 0x01:
52-
nodeKind = NodeKind.INTERMEDIATE;
52+
nodeKind = NodeKind.INLINING;
5353
break;
5454
default:
5555
throw new IllegalArgumentException("unknown node kind");

fdb-extensions/src/main/java/com/apple/foundationdb/async/hnsw/StorageAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ <N extends NodeReference> CompletableFuture<Node<N>> fetchNode(@Nonnull Node.Nod
114114
* @param node node whose slot to persist
115115
* @param itemSlot the node slot to persist
116116
*/
117-
void writeLeafNodeSlot(@Nonnull Transaction transaction, @Nonnull DataNode node, @Nonnull ItemSlot itemSlot);
117+
void writeLeafNodeSlot(@Nonnull Transaction transaction, @Nonnull CompactNode node, @Nonnull ItemSlot itemSlot);
118118

119119
/**
120120
* Clear out a leaf node slot.
@@ -123,7 +123,7 @@ <N extends NodeReference> CompletableFuture<Node<N>> fetchNode(@Nonnull Node.Nod
123123
* @param node node whose slot is cleared out
124124
* @param itemSlot the node slot to clear out
125125
*/
126-
void clearLeafNodeSlot(@Nonnull Transaction transaction, @Nonnull DataNode node, @Nonnull ItemSlot itemSlot);
126+
void clearLeafNodeSlot(@Nonnull Transaction transaction, @Nonnull CompactNode node, @Nonnull ItemSlot itemSlot);
127127

128128
/**
129129
* Method to (re-)persist a list of nodes passed in.

0 commit comments

Comments
 (0)