From f5e050bd008d6d1c4107dc903cb4d1211e3976a4 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 9 Jun 2021 18:59:14 +0200 Subject: [PATCH] LUCENE-9992: Update expectations about vectors with no values. --- .../lucene/codecs/simpletext/SimpleTextVectorWriter.java | 4 +--- .../apache/lucene/codecs/asserting/AssertingVectorFormat.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextVectorWriter.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextVectorWriter.java index e000daa610c..308bd53dfbe 100644 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextVectorWriter.java +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextVectorWriter.java @@ -80,9 +80,7 @@ public class SimpleTextVectorWriter extends VectorWriter { docIds.add(docV); } long vectorDataLength = vectorData.getFilePointer() - vectorDataOffset; - if (vectorDataLength > 0) { - writeMeta(fieldInfo, vectorDataOffset, vectorDataLength, docIds); - } + writeMeta(fieldInfo, vectorDataOffset, vectorDataLength, docIds); } private void writeVectorValue(VectorValues vectors) throws IOException { diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingVectorFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingVectorFormat.java index bae55293d57..836ebc35bc8 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingVectorFormat.java +++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingVectorFormat.java @@ -91,7 +91,7 @@ public class AssertingVectorFormat extends VectorFormat { VectorValues values = delegate.getVectorValues(field); if (values != null) { assert values.docID() == -1; - assert values.size() > 0; + assert values.size() >= 0; assert values.dimension() > 0; assert values.similarityFunction() != null; }