diff --git a/src/main/java/io/anserini/collection/JsonDenseVectorCollection.java b/src/main/java/io/anserini/collection/JsonDenseVectorCollection.java index 5fcebb302..1a69da85f 100644 --- a/src/main/java/io/anserini/collection/JsonDenseVectorCollection.java +++ b/src/main/java/io/anserini/collection/JsonDenseVectorCollection.java @@ -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. @@ -43,7 +42,8 @@ public FileSegment createFileSegment(Path p) } @Override - public FileSegment createFileSegment(BufferedReader bufferedReader) throws IOException { + public FileSegment createFileSegment(BufferedReader bufferedReader) + throws IOException { return new JsonDenseVectorCollection.Segment<>(bufferedReader); } @@ -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<>(); } diff --git a/src/main/java/io/anserini/collection/JsonVectorCollection.java b/src/main/java/io/anserini/collection/JsonVectorCollection.java index 8daab1217..5516cefe8 100644 --- a/src/main/java/io/anserini/collection/JsonVectorCollection.java +++ b/src/main/java/io/anserini/collection/JsonVectorCollection.java @@ -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 { public JsonVectorCollection(Path path) { @@ -40,8 +39,7 @@ public FileSegment createFileSegment(Path p) thro } @Override - public FileSegment createFileSegment(BufferedReader bufferedReader) - throws IOException { + public FileSegment createFileSegment(BufferedReader bufferedReader) throws IOException { return new JsonVectorCollection.Segment<>(bufferedReader); } @@ -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()) { diff --git a/src/test/java/io/anserini/collection/JsonVectorCollectionTest.java b/src/test/java/io/anserini/collection/JsonVectorCollectionTest.java index 4a9a0c794..4f567fc76 100644 --- a/src/test/java/io/anserini/collection/JsonVectorCollectionTest.java +++ b/src/test/java/io/anserini/collection/JsonVectorCollectionTest.java @@ -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 { @Override