Skip to content

Commit 4cfef2a

Browse files
committed
changes to StorageAdapter needed for vector samples
1 parent f9369b4 commit 4cfef2a

File tree

5 files changed

+331
-108
lines changed

5 files changed

+331
-108
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* AccessInfo.java
3+
*
4+
* This source file is part of the FoundationDB open source project
5+
*
6+
* Copyright 2015-2025 Apple Inc. and the FoundationDB project authors
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
package com.apple.foundationdb.async.hnsw;
22+
23+
import com.apple.foundationdb.linear.RealVector;
24+
25+
import javax.annotation.Nonnull;
26+
import javax.annotation.Nullable;
27+
28+
class AccessInfo {
29+
@Nonnull
30+
private final EntryNodeReference entryNodeReference;
31+
32+
@Nullable
33+
private final RealVector centroid;
34+
35+
public AccessInfo(@Nonnull final EntryNodeReference entryNodeReference, @Nullable final RealVector centroid) {
36+
this.entryNodeReference = entryNodeReference;
37+
this.centroid = centroid;
38+
}
39+
40+
@Nonnull
41+
public EntryNodeReference getEntryNodeReference() {
42+
return entryNodeReference;
43+
}
44+
45+
@Nullable
46+
public RealVector getCentroid() {
47+
return centroid;
48+
}
49+
50+
@Nonnull
51+
public AccessInfo withNewEntryNodeReference(@Nonnull final EntryNodeReference entryNodeReference) {
52+
return new AccessInfo(entryNodeReference, centroid);
53+
}
54+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* AggregatedVector.java
3+
*
4+
* This source file is part of the FoundationDB open source project
5+
*
6+
* Copyright 2015-2025 Apple Inc. and the FoundationDB project authors
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
package com.apple.foundationdb.async.hnsw;
22+
23+
import com.apple.foundationdb.linear.RealVector;
24+
25+
import javax.annotation.Nonnull;
26+
27+
public class AggregatedVector {
28+
private final int partialCount;
29+
@Nonnull
30+
private final RealVector partialVector;
31+
32+
public AggregatedVector(final int partialCount, @Nonnull final RealVector partialVector) {
33+
this.partialCount = partialCount;
34+
this.partialVector = partialVector;
35+
}
36+
37+
public int getPartialCount() {
38+
return partialCount;
39+
}
40+
41+
@Nonnull
42+
public RealVector getPartialVector() {
43+
return partialVector;
44+
}
45+
46+
@Override
47+
public final boolean equals(final Object o) {
48+
if (!(o instanceof AggregatedVector)) {
49+
return false;
50+
}
51+
52+
final AggregatedVector that = (AggregatedVector)o;
53+
return partialCount == that.partialCount && partialVector.equals(that.partialVector);
54+
}
55+
56+
@Override
57+
public int hashCode() {
58+
int result = partialCount;
59+
result = 31 * result + partialVector.hashCode();
60+
return result;
61+
}
62+
63+
@Override
64+
public String toString() {
65+
return "AggregatedVector[" + partialCount + ", " + partialVector + "]";
66+
}
67+
}

0 commit comments

Comments
 (0)