You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "iverase (via GitHub)" <gi...@apache.org> on 2023/07/27 08:23:47 UTC

[GitHub] [lucene] iverase commented on a diff in pull request #12460: Allow reading binary doc values as a DataInput

iverase commented on code in PR #12460:
URL: https://github.com/apache/lucene/pull/12460#discussion_r1275913689


##########
lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java:
##########
@@ -820,6 +822,201 @@ public BytesRef binaryValue() throws IOException {
     }
   }
 
+  private abstract static class DenseDataInputDocValues extends DataInputDocValues {
+
+    final int maxDoc;
+    int doc = -1;
+
+    DenseDataInputDocValues(int maxDoc) {
+      this.maxDoc = maxDoc;
+    }
+
+    @Override
+    public int nextDoc() throws IOException {
+      return advance(doc + 1);
+    }
+
+    @Override
+    public int docID() {
+      return doc;
+    }
+
+    @Override
+    public long cost() {
+      return maxDoc;
+    }
+
+    @Override
+    public int advance(int target) throws IOException {
+      if (target >= maxDoc) {
+        return doc = NO_MORE_DOCS;
+      }
+      return doc = target;
+    }
+
+    @Override
+    public boolean advanceExact(int target) throws IOException {
+      doc = target;
+      return true;
+    }
+  }
+
+  private abstract static class SparseDataInputDocValues extends DataInputDocValues {
+
+    final IndexedDISI disi;
+
+    SparseDataInputDocValues(IndexedDISI disi) {
+      this.disi = disi;
+    }
+
+    @Override
+    public int nextDoc() throws IOException {
+      return disi.nextDoc();
+    }
+
+    @Override
+    public int docID() {
+      return disi.docID();
+    }
+
+    @Override
+    public long cost() {
+      return disi.cost();
+    }
+
+    @Override
+    public int advance(int target) throws IOException {
+      return disi.advance(target);
+    }
+
+    @Override
+    public boolean advanceExact(int target) throws IOException {
+      return disi.advanceExact(target);
+    }
+  }
+
+  private static class SlicedDataInput extends DataInput {
+
+    private final IndexInput in;
+    private int length;
+
+    private int read;

Review Comment:
   I changed to use `in#getFilePointer` but I wonder if we should remove all this low level checks similarly to `ByteArrayDataInput` so it is not slow down.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org