You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/11/18 16:06:37 UTC

[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #6262: Enhance forward index reader for better performance

kishoreg commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r525581871



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/segment/index/readers/forward/FixedBitSVForwardIndexReaderV2.java
##########
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.segment.index.readers.forward;
+
+import org.apache.pinot.core.io.reader.impl.FixedBitIntReader;
+import org.apache.pinot.core.segment.index.readers.ForwardIndexReader;
+import org.apache.pinot.core.segment.index.readers.ForwardIndexReaderContext;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+
+
+/**
+ * Bit-compressed dictionary-encoded forward index reader for single-value columns. The values returned are dictionary
+ * ids.
+ */
+public final class FixedBitSVForwardIndexReaderV2 implements ForwardIndexReader<ForwardIndexReaderContext> {
+  private final FixedBitIntReader _reader;
+  private final int _numDocs;
+
+  public FixedBitSVForwardIndexReaderV2(PinotDataBuffer dataBuffer, int numDocs, int numBitsPerValue) {
+    _reader = FixedBitIntReader.getReader(dataBuffer, numBitsPerValue);
+    _numDocs = numDocs;
+  }
+
+  @Override
+  public boolean isDictionaryEncoded() {
+    return true;
+  }
+
+  @Override
+  public boolean isSingleValue() {
+    return true;
+  }
+
+  @Override
+  public DataType getValueType() {
+    return DataType.INT;
+  }
+
+  @Override
+  public int getDictId(int docId, ForwardIndexReaderContext context) {
+    return _reader.read(docId);
+  }
+
+  @Override
+  public void readDictIds(int[] docIds, int length, int[] dictIdBuffer, ForwardIndexReaderContext context) {
+    int firstDocId = docIds[0];
+    int lastDocId = docIds[length - 1];
+    int index = 0;
+
+    // Use bulk read if the doc ids are sequential
+    if (lastDocId - firstDocId + 1 == length && length >= 64) {
+      int[] buffer = new int[32];

Review comment:
       should we use some cached int arrays here?

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/segment/index/loader/invertedindex/TextIndexHandler.java
##########
@@ -51,7 +51,7 @@
 import org.apache.pinot.core.segment.index.readers.ForwardIndexReaderContext;
 import org.apache.pinot.core.segment.index.readers.StringDictionary;
 import org.apache.pinot.core.segment.index.readers.forward.BaseChunkSVForwardIndexReader.ChunkReaderContext;
-import org.apache.pinot.core.segment.index.readers.forward.FixedBitSVForwardIndexReader;
+import org.apache.pinot.core.segment.index.readers.forward.FixedBitSVForwardIndexReaderV2;

Review comment:
       do we need V1 V2?




----------------------------------------------------------------
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org