28
28
import com .apple .foundationdb .async .MoreAsyncUtil ;
29
29
import com .apple .foundationdb .subspace .Subspace ;
30
30
import com .apple .foundationdb .tuple .Tuple ;
31
- import com .christianheina .langx .half4j .Half ;
32
31
import com .google .common .base .Verify ;
33
32
import com .google .common .collect .ImmutableList ;
34
33
import com .google .common .collect .Iterables ;
@@ -239,7 +238,7 @@ public static class ConfigBuilder {
239
238
public ConfigBuilder () {
240
239
}
241
240
242
- public ConfigBuilder (@ Nonnull Random random , @ Nonnull final Metric metric , final boolean useInlining ,
241
+ public ConfigBuilder (@ Nonnull final Random random , @ Nonnull final Metric metric , final boolean useInlining ,
243
242
final int m , final int mMax , final int mMax0 , final int efSearch , final int efConstruction ,
244
243
final boolean extendCandidates , final boolean keepPrunedConnections ) {
245
244
this .random = random ;
@@ -481,7 +480,7 @@ public OnReadListener getOnReadListener() {
481
480
public CompletableFuture <? extends List <? extends NodeReferenceAndNode <? extends NodeReference >>> kNearestNeighborsSearch (@ Nonnull final ReadTransaction readTransaction ,
482
481
final int k ,
483
482
final int efSearch ,
484
- @ Nonnull final Vector < Half > queryVector ) {
483
+ @ Nonnull final Vector queryVector ) {
485
484
return StorageAdapter .fetchEntryNodeReference (readTransaction , getSubspace (), getOnReadListener ())
486
485
.thenCompose (entryPointAndLayer -> {
487
486
if (entryPointAndLayer == null ) {
@@ -572,7 +571,7 @@ private <N extends NodeReference> CompletableFuture<NodeReferenceWithDistance> g
572
571
@ Nonnull final ReadTransaction readTransaction ,
573
572
@ Nonnull final NodeReferenceWithDistance entryNeighbor ,
574
573
final int layer ,
575
- @ Nonnull final Vector < Half > queryVector ) {
574
+ @ Nonnull final Vector queryVector ) {
576
575
if (storageAdapter .getNodeKind () == NodeKind .INLINING ) {
577
576
return greedySearchInliningLayer (storageAdapter .asInliningStorageAdapter (), readTransaction , entryNeighbor , layer , queryVector );
578
577
} else {
@@ -612,7 +611,7 @@ private CompletableFuture<NodeReferenceWithDistance> greedySearchInliningLayer(@
612
611
@ Nonnull final ReadTransaction readTransaction ,
613
612
@ Nonnull final NodeReferenceWithDistance entryNeighbor ,
614
613
final int layer ,
615
- @ Nonnull final Vector < Half > queryVector ) {
614
+ @ Nonnull final Vector queryVector ) {
616
615
Verify .verify (layer > 0 );
617
616
final Metric metric = getConfig ().getMetric ();
618
617
final AtomicReference <NodeReferenceWithDistance > currentNodeReferenceAtomic =
@@ -685,7 +684,7 @@ private <N extends NodeReference> CompletableFuture<List<NodeReferenceAndNode<N>
685
684
final int layer ,
686
685
final int efSearch ,
687
686
@ Nonnull final Map <Tuple , Node <N >> nodeCache ,
688
- @ Nonnull final Vector < Half > queryVector ) {
687
+ @ Nonnull final Vector queryVector ) {
689
688
final Set <Tuple > visited = Sets .newConcurrentHashSet (NodeReference .primaryKeys (entryNeighbors ));
690
689
final Queue <NodeReferenceWithDistance > candidates =
691
690
new PriorityBlockingQueue <>(config .getM (),
@@ -995,7 +994,7 @@ public CompletableFuture<Void> insert(@Nonnull final Transaction transaction, @N
995
994
*/
996
995
@ Nonnull
997
996
public CompletableFuture <Void > insert (@ Nonnull final Transaction transaction , @ Nonnull final Tuple newPrimaryKey ,
998
- @ Nonnull final Vector < Half > newVector ) {
997
+ @ Nonnull final Vector newVector ) {
999
998
final Metric metric = getConfig ().getMetric ();
1000
999
1001
1000
final int insertionLayer = insertionLayer (getConfig ().getRandom ());
@@ -1104,7 +1103,7 @@ public CompletableFuture<Void> insertBatch(@Nonnull final Transaction transactio
1104
1103
return CompletableFuture .completedFuture (null );
1105
1104
}
1106
1105
1107
- final Vector < Half > itemVector = item .getVector ();
1106
+ final Vector itemVector = item .getVector ();
1108
1107
final int itemL = item .getLayer ();
1109
1108
1110
1109
final NodeReferenceWithDistance initialNodeReference =
@@ -1128,7 +1127,7 @@ public CompletableFuture<Void> insertBatch(@Nonnull final Transaction transactio
1128
1127
(index , currentEntryNodeReference ) -> {
1129
1128
final NodeReferenceWithLayer item = batchWithLayers .get (index );
1130
1129
final Tuple itemPrimaryKey = item .getPrimaryKey ();
1131
- final Vector < Half > itemVector = item .getVector ();
1130
+ final Vector itemVector = item .getVector ();
1132
1131
final int itemL = item .getLayer ();
1133
1132
1134
1133
final EntryNodeReference newEntryNodeReference ;
@@ -1202,7 +1201,7 @@ public CompletableFuture<Void> insertBatch(@Nonnull final Transaction transactio
1202
1201
@ Nonnull
1203
1202
private CompletableFuture <Void > insertIntoLayers (@ Nonnull final Transaction transaction ,
1204
1203
@ Nonnull final Tuple newPrimaryKey ,
1205
- @ Nonnull final Vector < Half > newVector ,
1204
+ @ Nonnull final Vector newVector ,
1206
1205
@ Nonnull final NodeReferenceWithDistance nodeReference ,
1207
1206
final int lMax ,
1208
1207
final int insertionLayer ) {
@@ -1258,7 +1257,7 @@ private <N extends NodeReference> CompletableFuture<List<NodeReferenceWithDistan
1258
1257
@ Nonnull final List <NodeReferenceWithDistance > nearestNeighbors ,
1259
1258
int layer ,
1260
1259
@ Nonnull final Tuple newPrimaryKey ,
1261
- @ Nonnull final Vector < Half > newVector ) {
1260
+ @ Nonnull final Vector newVector ) {
1262
1261
if (logger .isDebugEnabled ()) {
1263
1262
logger .debug ("begin insert key={} at layer={}" , newPrimaryKey , layer );
1264
1263
}
@@ -1490,7 +1489,7 @@ private <N extends NodeReference> CompletableFuture<List<NodeReferenceAndNode<N>
1490
1489
final int m ,
1491
1490
final boolean isExtendCandidates ,
1492
1491
@ Nonnull final Map <Tuple , Node <N >> nodeCache ,
1493
- @ Nonnull final Vector < Half > vector ) {
1492
+ @ Nonnull final Vector vector ) {
1494
1493
return extendCandidatesIfNecessary (storageAdapter , readTransaction , nearestNeighbors , layer , isExtendCandidates , nodeCache , vector )
1495
1494
.thenApply (extendedCandidates -> {
1496
1495
final List <NodeReferenceWithDistance > selected = Lists .newArrayListWithExpectedSize (m );
@@ -1575,7 +1574,7 @@ private <N extends NodeReference> CompletableFuture<List<NodeReferenceAndNode<N>
1575
1574
int layer ,
1576
1575
boolean isExtendCandidates ,
1577
1576
@ Nonnull final Map <Tuple , Node <N >> nodeCache ,
1578
- @ Nonnull final Vector < Half > vector ) {
1577
+ @ Nonnull final Vector vector ) {
1579
1578
if (isExtendCandidates ) {
1580
1579
final Metric metric = getConfig ().getMetric ();
1581
1580
@@ -1639,7 +1638,7 @@ private <N extends NodeReference> CompletableFuture<List<NodeReferenceAndNode<N>
1639
1638
*/
1640
1639
private void writeLonelyNodes (@ Nonnull final Transaction transaction ,
1641
1640
@ Nonnull final Tuple primaryKey ,
1642
- @ Nonnull final Vector < Half > vector ,
1641
+ @ Nonnull final Vector vector ,
1643
1642
final int highestLayerInclusive ,
1644
1643
final int lowestLayerExclusive ) {
1645
1644
for (int layer = highestLayerInclusive ; layer > lowestLayerExclusive ; layer --) {
@@ -1667,7 +1666,7 @@ private <N extends NodeReference> void writeLonelyNodeOnLayer(@Nonnull final Sto
1667
1666
@ Nonnull final Transaction transaction ,
1668
1667
final int layer ,
1669
1668
@ Nonnull final Tuple primaryKey ,
1670
- @ Nonnull final Vector < Half > vector ) {
1669
+ @ Nonnull final Vector vector ) {
1671
1670
storageAdapter .writeNode (transaction ,
1672
1671
storageAdapter .getNodeFactory ()
1673
1672
.create (primaryKey , vector , ImmutableList .of ()), layer ,
@@ -1777,7 +1776,7 @@ private void info(@Nonnull final Consumer<Logger> loggerConsumer) {
1777
1776
private static class NodeReferenceWithLayer extends NodeReferenceWithVector {
1778
1777
private final int layer ;
1779
1778
1780
- public NodeReferenceWithLayer (@ Nonnull final Tuple primaryKey , @ Nonnull final Vector < Half > vector ,
1779
+ public NodeReferenceWithLayer (@ Nonnull final Tuple primaryKey , @ Nonnull final Vector vector ,
1781
1780
final int layer ) {
1782
1781
super (primaryKey , vector );
1783
1782
this .layer = layer ;
0 commit comments