Skip to content

Commit dc370af

Browse files
committed
removed efSearch from HNSW
1 parent a804023 commit dc370af

File tree

2 files changed

+14
-25
lines changed
  • fdb-extensions/src

2 files changed

+14
-25
lines changed

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

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public class HNSW {
9191
public static final int DEFAULT_M = 16;
9292
public static final int DEFAULT_M_MAX = DEFAULT_M;
9393
public static final int DEFAULT_M_MAX_0 = 2 * DEFAULT_M;
94-
public static final int DEFAULT_EF_SEARCH = 100;
9594
public static final int DEFAULT_EF_CONSTRUCTION = 200;
9695
public static final boolean DEFAULT_EXTEND_CANDIDATES = false;
9796
public static final boolean DEFAULT_KEEP_PRUNED_CONNECTIONS = false;
@@ -123,7 +122,6 @@ public static class Config {
123122
private final int m;
124123
private final int mMax;
125124
private final int mMax0;
126-
private final int efSearch;
127125
private final int efConstruction;
128126
private final boolean extendCandidates;
129127
private final boolean keepPrunedConnections;
@@ -135,22 +133,20 @@ protected Config() {
135133
this.m = DEFAULT_M;
136134
this.mMax = DEFAULT_M_MAX;
137135
this.mMax0 = DEFAULT_M_MAX_0;
138-
this.efSearch = DEFAULT_EF_SEARCH;
139136
this.efConstruction = DEFAULT_EF_CONSTRUCTION;
140137
this.extendCandidates = DEFAULT_EXTEND_CANDIDATES;
141138
this.keepPrunedConnections = DEFAULT_KEEP_PRUNED_CONNECTIONS;
142139
}
143140

144141
protected Config(@Nonnull final Random random, @Nonnull final Metric metric, final boolean useInlining,
145-
final int m, final int mMax, final int mMax0, final int efSearch, final int efConstruction,
142+
final int m, final int mMax, final int mMax0, final int efConstruction,
146143
final boolean extendCandidates, final boolean keepPrunedConnections) {
147144
this.random = random;
148145
this.metric = metric;
149146
this.useInlining = useInlining;
150147
this.m = m;
151148
this.mMax = mMax;
152149
this.mMax0 = mMax0;
153-
this.efSearch = efSearch;
154150
this.efConstruction = efConstruction;
155151
this.extendCandidates = extendCandidates;
156152
this.keepPrunedConnections = keepPrunedConnections;
@@ -182,10 +178,6 @@ public int getMMax0() {
182178
return mMax0;
183179
}
184180

185-
public int getEfSearch() {
186-
return efSearch;
187-
}
188-
189181
public int getEfConstruction() {
190182
return efConstruction;
191183
}
@@ -201,15 +193,15 @@ public boolean isKeepPrunedConnections() {
201193
@Nonnull
202194
public ConfigBuilder toBuilder() {
203195
return new ConfigBuilder(getRandom(), getMetric(), isUseInlining(), getM(), getMMax(), getMMax0(),
204-
getEfSearch(), getEfConstruction(), isExtendCandidates(), isKeepPrunedConnections());
196+
getEfConstruction(), isExtendCandidates(), isKeepPrunedConnections());
205197
}
206198

207199
@Override
208200
@Nonnull
209201
public String toString() {
210202
return "Config[metric=" + getMetric() + "isUseInlining" + isUseInlining() + "M=" + getM() +
211-
" , MMax=" + getMMax() + " , MMax0=" + getMMax0() + ", efSearch=" + getEfSearch() +
212-
", efConstruction=" + getEfConstruction() + ", isExtendCandidates=" + isExtendCandidates() +
203+
" , MMax=" + getMMax() + " , MMax0=" + getMMax0() + ", efConstruction=" + getEfConstruction() +
204+
", isExtendCandidates=" + isExtendCandidates() +
213205
", isKeepPrunedConnections=" + isKeepPrunedConnections() + "]";
214206
}
215207
}
@@ -230,7 +222,6 @@ public static class ConfigBuilder {
230222
private int m = DEFAULT_M;
231223
private int mMax = DEFAULT_M_MAX;
232224
private int mMax0 = DEFAULT_M_MAX_0;
233-
private int efSearch = DEFAULT_EF_SEARCH;
234225
private int efConstruction = DEFAULT_EF_CONSTRUCTION;
235226
private boolean extendCandidates = DEFAULT_EXTEND_CANDIDATES;
236227
private boolean keepPrunedConnections = DEFAULT_KEEP_PRUNED_CONNECTIONS;
@@ -239,15 +230,14 @@ public ConfigBuilder() {
239230
}
240231

241232
public ConfigBuilder(@Nonnull final Random random, @Nonnull final Metric metric, final boolean useInlining,
242-
final int m, final int mMax, final int mMax0, final int efSearch, final int efConstruction,
233+
final int m, final int mMax, final int mMax0, final int efConstruction,
243234
final boolean extendCandidates, final boolean keepPrunedConnections) {
244235
this.random = random;
245236
this.metric = metric;
246237
this.useInlining = useInlining;
247238
this.m = m;
248239
this.mMax = mMax;
249240
this.mMax0 = mMax0;
250-
this.efSearch = efSearch;
251241
this.efConstruction = efConstruction;
252242
this.extendCandidates = extendCandidates;
253243
this.keepPrunedConnections = keepPrunedConnections;
@@ -314,15 +304,6 @@ public ConfigBuilder setMMax0(final int mMax0) {
314304
return this;
315305
}
316306

317-
public int getEfSearch() {
318-
return efSearch;
319-
}
320-
321-
public ConfigBuilder setEfSearch(final int efSearch) {
322-
this.efSearch = efSearch;
323-
return this;
324-
}
325-
326307
public int getEfConstruction() {
327308
return efConstruction;
328309
}
@@ -351,7 +332,7 @@ public ConfigBuilder setKeepPrunedConnections(final boolean keepPrunedConnection
351332
}
352333

353334
public Config build() {
354-
return new Config(getRandom(), getMetric(), isUseInlining(), getM(), getMMax(), getMMax0(), getEfSearch(),
335+
return new Config(getRandom(), getMetric(), isUseInlining(), getM(), getMMax(), getMMax0(),
355336
getEfConstruction(), isExtendCandidates(), isKeepPrunedConnections());
356337
}
357338
}

fdb-extensions/src/test/java/com/apple/foundationdb/async/hnsw/HNSWTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import java.util.concurrent.TimeUnit;
6969
import java.util.concurrent.atomic.AtomicLong;
7070
import java.util.function.Function;
71+
import java.util.stream.Collectors;
7172
import java.util.stream.LongStream;
7273
import java.util.stream.Stream;
7374

@@ -255,6 +256,13 @@ public void testBasicInsert(final long seed, final boolean useInlining, final bo
255256
TimeUnit.NANOSECONDS.toMillis(endTs - beginTs),
256257
onReadListener.getNodeCountByLayer(), onReadListener.getBytesReadByLayer(),
257258
String.format(Locale.ROOT, "%.2f", recall * 100.0d));
259+
260+
final Set<Long> usedIds =
261+
LongStream.range(0, 1000)
262+
.boxed()
263+
.collect(Collectors.toSet());
264+
265+
hnsw.scanLayer(db, 0, 100, node -> Assertions.assertTrue(usedIds.remove(node.getPrimaryKey().getLong(0))));
258266
}
259267

260268
private int basicInsertBatch(final HNSW hnsw, final int batchSize,

0 commit comments

Comments
 (0)