mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(s3vectors): return modeled fields in list summaries (#5922)
This commit is contained in:
1 parent
0a37ea830b
commit
1278fea1a4
2 files changed
+37
-15
No files matched your search
+23
-13
@@ -74,6 +74,13 @@ public class S3VectorsController {
|
||||
Object encryptionConfiguration
|
||||
) {}
|
||||
|
||||
@RegisterForReflection
|
||||
public record VectorBucketSummary(
|
||||
String vectorBucketName,
|
||||
String vectorBucketArn,
|
||||
double creationTime
|
||||
) {}
|
||||
|
||||
@RegisterForReflection
|
||||
public record ListVectorBucketsRequest(
|
||||
Integer maxResults,
|
||||
@@ -84,7 +91,7 @@ public class S3VectorsController {
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record ListVectorBucketsResponse(
|
||||
List<VectorBucketRepresentation> vectorBuckets,
|
||||
List<VectorBucketSummary> vectorBuckets,
|
||||
String nextToken
|
||||
) {}
|
||||
|
||||
@@ -141,6 +148,14 @@ public class S3VectorsController {
|
||||
Object encryptionConfiguration
|
||||
) {}
|
||||
|
||||
@RegisterForReflection
|
||||
public record IndexSummary(
|
||||
double creationTime,
|
||||
String vectorBucketName,
|
||||
String indexName,
|
||||
String indexArn
|
||||
) {}
|
||||
|
||||
@RegisterForReflection
|
||||
public record ListIndexesRequest(
|
||||
String vectorBucketName,
|
||||
@@ -153,7 +168,7 @@ public class S3VectorsController {
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record ListIndexesResponse(
|
||||
List<IndexRepresentation> indexes,
|
||||
List<IndexSummary> indexes,
|
||||
String nextToken
|
||||
) {}
|
||||
|
||||
@@ -285,9 +300,9 @@ public class S3VectorsController {
|
||||
public Response listVectorBuckets(@Context HttpHeaders headers, ListVectorBucketsRequest request) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
List<VectorBucket> buckets = service.listVectorBuckets(region);
|
||||
List<VectorBucketRepresentation> reps = buckets.stream()
|
||||
.map(b -> new VectorBucketRepresentation(b.getVectorBucketName(), b.getVectorBucketArn(),
|
||||
b.getCreationTime().toEpochMilli() / 1000.0, b.getEncryptionConfiguration()))
|
||||
List<VectorBucketSummary> reps = buckets.stream()
|
||||
.map(b -> new VectorBucketSummary(b.getVectorBucketName(), b.getVectorBucketArn(),
|
||||
b.getCreationTime().toEpochMilli() / 1000.0))
|
||||
.toList();
|
||||
return Response.ok(new ListVectorBucketsResponse(reps, null)).build();
|
||||
}
|
||||
@@ -344,17 +359,12 @@ public class S3VectorsController {
|
||||
public Response listIndexes(@Context HttpHeaders headers, ListIndexesRequest request) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
List<VectorIndex> indexes = service.listIndexes(request.vectorBucketName(), region);
|
||||
List<IndexRepresentation> reps = indexes.stream()
|
||||
.map(i -> new IndexRepresentation(
|
||||
List<IndexSummary> reps = indexes.stream()
|
||||
.map(i -> new IndexSummary(
|
||||
i.getCreationTime().toEpochMilli() / 1000.0,
|
||||
i.getVectorBucketName(),
|
||||
i.getIndexName(),
|
||||
i.getIndexArn(),
|
||||
i.getDataType(),
|
||||
i.getDimension(),
|
||||
i.getDistanceMetric(),
|
||||
null,
|
||||
null
|
||||
i.getIndexArn()
|
||||
))
|
||||
.toList();
|
||||
return Response.ok(new ListIndexesResponse(reps, null)).build();
|
||||
|
||||
+14
-2
@@ -26,6 +26,7 @@ import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -165,8 +166,19 @@ class S3VectorsSdkIntegrationTest {
|
||||
.body(Map.of("vectorBucketName", name))
|
||||
.post("/ListIndexes").then().statusCode(200).extract().path("indexes[0]");
|
||||
assertEquals(index.indexArn(), summary.get("indexArn"));
|
||||
assertFalse(summary.containsKey("metadataConfiguration"));
|
||||
assertFalse(summary.containsKey("encryptionConfiguration"));
|
||||
assertEquals(Set.of("creationTime", "vectorBucketName", "indexName", "indexArn"), summary.keySet());
|
||||
assertEquals(3, detail.get("dimension"));
|
||||
assertEquals("float32", detail.get("dataType"));
|
||||
assertEquals("cosine", detail.get("distanceMetric"));
|
||||
|
||||
List<Map<String, Object>> buckets = given().baseUri(endpoint.toString()).contentType("application/json")
|
||||
.body(Map.of()).post("/ListVectorBuckets").then().statusCode(200).extract().path("vectorBuckets");
|
||||
Map<String, Object> bucketSummary = buckets.stream()
|
||||
.filter(bucket -> name.equals(bucket.get("vectorBucketName"))).findFirst().orElseThrow();
|
||||
assertEquals(Set.of("creationTime", "vectorBucketName", "vectorBucketArn"), bucketSummary.keySet());
|
||||
VectorBucket bucket = vectors.getVectorBucket(request -> request.vectorBucketName(name)).vectorBucket();
|
||||
assertEquals(bucket.vectorBucketArn(), bucketSummary.get("vectorBucketArn"));
|
||||
assertEquals("AES256", bucket.encryptionConfiguration().sseTypeAsString());
|
||||
} finally {
|
||||
for (VectorIndex index : service.listIndexes(name, "us-east-1")) {
|
||||
vectors.deleteIndex(request -> request.vectorBucketName(name).indexName(index.getIndexName()));
|
||||
|
||||
Reference in new issue
Block a user