Add Alternator vector search support#145
Conversation
34f937b to
ee7b8b2
Compare
|
|
||
| @Override | ||
| public void cancel() { | ||
| upstream.cancel(); |
There was a problem hiding this comment.
Comparing to ResponseCompressionInterceptor there is no recording of cancellation. AI says that ResponseCompressionInterceptor.DecompressingSubscriber does it correctly:
private boolean cancelled;
@Override
public void onNext(ByteBuffer byteBuffer) {
if (isCancelled()) { return; } // ← stops buffering
...
}
@Override
public void onComplete() {
...
if (!isCancelled()) {
downstream.onComplete(); // ← only emits if not cancelled
}
}
@Override
public void cancel() {
cancelled = true; // ← records cancellation
upstream.cancel();
}
| return context.httpRequest(); | ||
| } | ||
| return context.httpRequest().toBuilder() | ||
| .putHeader("Content-Length", String.valueOf(modifiedBytes.length)) |
There was a problem hiding this comment.
GzipRequestInterceptor doesn't set Content-Length. AI says that SDK fills in Content-Length, but only when it's absent. So now in case of VectorSearch + compression Content-Length is wrong. Either all interceptors should set it or none.
|
Regarding conversions of FLOAT32VECTOR consider also some kind of compatibility switch in client. Default: Keep the current behavior. Opt-in: preserve mode Map<String, AttributeValue> item = client.getItem(request).item();
client.putItem(PutItemRequest.builder().tableName("copy").item(item).build());In preserve mode, float[] values = Float32Vector.toFloats(item.get("embedding")); // decodes B-magic or converts List of Numbers
List<AttributeValue> numbers = Float32Vector.toNumberList(item.get("embedding")); // directly returns List of Numbers or converts B-magicBoth forms can be distinguished explicitly: |
Replaces #87.
This carries the vector search support from #87, scoped to the vector API/client integration work:
com.scylladb.alternator.vectorsearchrequest/response support forVectorIndexes,VectorIndexUpdates,VectorSearch,FLOAT32VECTOR, and query scores.VectorSearchInterceptorin the sync and async Alternator client builders.Split out of this PR:
vector-1.Tests:
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 PATH=/usr/lib/jvm/java-11-openjdk-amd64/bin:$PATH mvn -q fmt:checkJAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 PATH=/usr/lib/jvm/java-11-openjdk-amd64/bin:$PATH mvn -q -Dtest=VectorSearchInterceptorTest,VectorSearchHttpInterceptorTest testJAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 PATH=/usr/lib/jvm/java-11-openjdk-amd64/bin:$PATH mvn -q test