Skip to content

Commit

Permalink
fixes jan 16 comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-4 committed Jan 17, 2025
1 parent e06031e commit 2e5ff74
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.Map;


/**
* A document collection for encoded dense vectors for ANN (HNSW) search.
* The "vector" field are concatenated into the "contents" field for indexing.
Expand All @@ -43,7 +42,8 @@ public FileSegment<JsonDenseVectorCollection.Document> createFileSegment(Path p)
}

@Override
public FileSegment<JsonDenseVectorCollection.Document> createFileSegment(BufferedReader bufferedReader) throws IOException {
public FileSegment<JsonDenseVectorCollection.Document> createFileSegment(BufferedReader bufferedReader)
throws IOException {
return new JsonDenseVectorCollection.Segment<>(bufferedReader);
}

Expand Down Expand Up @@ -75,14 +75,14 @@ public Document(JsonNode json) {
this.id = json.get("docid").asText();
this.contents = json.get("vector").toString();
JsonNode vectorNode = json.get("vector");
if (vectorNode != null && vectorNode.isArray()) {
vectorData = new float[vectorNode.size()];
for (int i = 0; i < vectorNode.size(); i++) {
vectorData[i] = (float) vectorNode.get(i).asDouble();
}
} else {
vectorData = null;
if (vectorNode != null && vectorNode.isArray()) {
vectorData = new float[vectorNode.size()];
for (int i = 0; i < vectorNode.size(); i++) {
vectorData[i] = (float) vectorNode.get(i).asDouble();
}
} else {
vectorData = null;
}
// We're not going to index any other fields, so just initialize an empty map.
this.fields = new HashMap<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import java.nio.file.Path;

/**
* A JSON document collection where the user can specify directly the vector to
* be indexed.
* A JSON document collection where the user can specify directly the vector to be indexed.
*/
public class JsonVectorCollection extends DocumentCollection<JsonVectorCollection.Document> {
public JsonVectorCollection(Path path) {
Expand All @@ -40,8 +39,7 @@ public FileSegment<JsonVectorCollection.Document> createFileSegment(Path p) thro
}

@Override
public FileSegment<JsonVectorCollection.Document> createFileSegment(BufferedReader bufferedReader)
throws IOException {
public FileSegment<JsonVectorCollection.Document> createFileSegment(BufferedReader bufferedReader) throws IOException {
return new JsonVectorCollection.Segment<>(bufferedReader);
}

Expand All @@ -67,8 +65,7 @@ public static class Document extends JsonCollection.Document {
public Document(JsonNode json) {
super(json);

// We're going to take the map associated with "vector" and generate
// pseudo-document.
// We're going to take the map associated with "vector" and generate pseudo-document.
JsonNode vectorNode = json.get("vector");

if (vectorNode.isArray()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.Map;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.junit.Assert.assertArrayEquals;;

public abstract class JsonVectorCollectionTest extends DocumentCollectionTest<JsonVectorCollection.Document> {
@Override
Expand Down

0 comments on commit 2e5ff74

Please sign in to comment.