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/13 21:14:08 UTC
[GitHub] [incubator-pinot] Jackie-Jiang opened a new pull request #6262: Enhance forward index reader for better performance
Jackie-Jiang opened a new pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262
## Description
Enhance the forward index reader by specializing the case for each numBits (from 1 to 31) compression.
The int value reader has 3 methods:
- Bulk read 32 values
- Read value without buffer boundary check
- Read value with buffer boundary check
The new forward index reader uses the 3 methods based on the passed in doc ids:
- For sequential doc ids, use bulk read
- For non-sequential doc ids, use unchecked read if possible, and only use checked read for the last few values
We observe up to 5x improvement for the reading, detailed perf number can be found here: https://docs.google.com/spreadsheets/d/1o66G7Jw_7K4swEcp1FYCzgr0MF9JBAAM6KMGOXBSdIA/edit?usp=sharing
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang merged pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang merged pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r525535130
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/segment/index/readers/forward/FixedBitSVForwardIndexReaderV2Test.java
##########
@@ -0,0 +1,102 @@
+/**
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitSVForwardIndexReaderV2Test {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 99999;
+ private static final int NUM_DOC_IDS = 10000;
+ private static final Random RANDOM = new Random();
+
+ private final int[] _sequentialDocIds = new int[NUM_DOC_IDS];
+ private final int[] _sparseDocIds = new int[NUM_DOC_IDS];
+ private final int[] _lastSequentialDocIds = new int[NUM_DOC_IDS];
+ private final int[] _dictIdBuffer = new int[NUM_DOC_IDS];
+
+ @BeforeClass
+ public void setUp()
+ throws IOException {
+ FileUtils.forceMkdir(INDEX_DIR);
+
+ int sequentialDocId = RANDOM.nextInt(32);
Review comment:
That's why I explicitly tested reading the last doc ids (`_lastSequentialDocIds`).
Modified the test to test sequentialDocId starting from 0 - 31
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r525527827
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/segment/index/readers/forward/FixedBitSVForwardIndexReaderV2Test.java
##########
@@ -0,0 +1,102 @@
+/**
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitSVForwardIndexReaderV2Test {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 99999;
+ private static final int NUM_DOC_IDS = 10000;
Review comment:
This is the `DocIdSetPlanNode.MAX_DOC_PER_CALL`, replaced it with the constant
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] siddharthteotia commented on pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
siddharthteotia commented on pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#issuecomment-730664669
I think the JMH perf is probably a reasonable indicator of the benefit for single read APIs. However, I don't think we have added exhaustive unit tests for all numBits and different docId ranges covering all cases to ensure these are all functionally correct and won't segfault.
```
@Override
public int read(int index) {
int offset = index >>> 3;
int bitOffsetInByte = index & 0x7;
return (_dataBuffer.getByte(offset) >>> (7 - bitOffsetInByte)) & 0x1;
}
@Override
public int readUnchecked(int index) {
int offset = index >>> 3;
int bitOffsetInByte = index & 0x7;
return (_dataBuffer.getByte(offset) >>> (7 - bitOffsetInByte)) & 0x1;
}
```
For the getDictIds function:
```
@Override
public void readDictIds(int[] docIds, int length, int[] dictIdBuffer, ForwardIndexReaderContext context)
```
- Is it correct to say that new bulk read32() will be used here only if the docIDs array has sequential (consecutive) ids. Otherwise, we will use the new single read APIs?
- The readUnchecked() has the potential to segfault / core dump?
- There is a chance that perf wise, we might see -ve impact due to memcpy (especially for high throughput use cases). So for this API at least, I don't think JMH is a reasonable indicator of better performance always. It is worthwhile to do validation on a prod-like workload.
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r527311726
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/segment/index/readers/forward/FixedBitSVForwardIndexReaderV2Test.java
##########
@@ -0,0 +1,111 @@
+/**
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.plan.DocIdSetPlanNode;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitSVForwardIndexReaderV2Test {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 99_999;
Review comment:
It tests all the bits (for loop on line 77), and sequential reads starting at index 0-31, and also the last 10000 docs. IMO it is quite thorough.
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r525415391
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/segment/index/readers/forward/FixedBitSVForwardIndexReaderV2Test.java
##########
@@ -0,0 +1,102 @@
+/**
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitSVForwardIndexReaderV2Test {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 99999;
+ private static final int NUM_DOC_IDS = 10000;
+ private static final Random RANDOM = new Random();
+
+ private final int[] _sequentialDocIds = new int[NUM_DOC_IDS];
+ private final int[] _sparseDocIds = new int[NUM_DOC_IDS];
+ private final int[] _lastSequentialDocIds = new int[NUM_DOC_IDS];
+ private final int[] _dictIdBuffer = new int[NUM_DOC_IDS];
+
+ @BeforeClass
+ public void setUp()
+ throws IOException {
+ FileUtils.forceMkdir(INDEX_DIR);
+
+ int sequentialDocId = RANDOM.nextInt(32);
Review comment:
Would it be better to use explicit values instead of random?
For example, we know all the corner cases would be around bits being split across read boundaries. We can then programmatically generate all the splits. Given this is a fundamental change, I'd feel more comfortable with exhaustive testing on all corner cases explicitly tested.
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#issuecomment-729225597
> Seems like we are moving to `FixedBitSVForwardIndexReaderV2` by default. Just in case there's a production issue, the only option would be to rollback?
@mayankshriv Yes. I don't think it's worth adding a config to switch between readers. Per the perf, the new reader has way better performance in all scenarios.
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r526330285
##########
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:
V1 is replaced with V2. Will do the clean up as a separate PR
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#issuecomment-729877463
> where is the logic to decide sparse vs sequential vs dense read
In `FixedBitSVForwardIndexReaderV2`, we use bulk read only for sequential doc ids. Per the benchmark, using bulk read for dense doc ids performs worse than unchecked read, so there is no difference for reading sparse and dense doc ids
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#issuecomment-730730910
@siddharthteotia Please check my reply under the comments. I think the tests are quite thorough, and covers all the bits and different start indices.
For your questions:
> Is it correct to say that new bulk read32() will be used here only if the docIDs array has sequential (consecutive) ids. Otherwise, we will use the new single read APIs?
Yes
> The readUnchecked() has the potential to segfault / core dump?
If you use readUnchecked() for the last 2 values, it can read over the boundary (explained in the javadoc). This is handled within the `FixedBitSVForwardIndexReaderV2`
> There is a chance that perf wise, we might see -ve impact due to memcpy (especially for high throughput use cases). So for this API at least, I don't think JMH is a reasonable indicator of better performance always. It is worthwhile to do validation on a prod-like workload.
Why is memcpy involved here? The new reader won't read extra values because the bulk read is only used for sequential ids. I already asked @pradeepgv42 to try this, and he confirmed up to 45% query latency drop comparing with the current reader.
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] siddharthteotia commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
siddharthteotia commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r527226382
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/io/reader/impl/FixedBitIntReaderTest.java
##########
@@ -0,0 +1,86 @@
+/**
+ * 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.io.reader.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitIntReaderTest {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 95;
+ private static final Random RANDOM = new Random();
Review comment:
We should add tests for new APIs for all numbits right?
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] siddharthteotia commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
siddharthteotia commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r527226859
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/segment/index/readers/forward/FixedBitSVForwardIndexReaderV2Test.java
##########
@@ -0,0 +1,111 @@
+/**
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.plan.DocIdSetPlanNode;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitSVForwardIndexReaderV2Test {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 99_999;
Review comment:
We should add tests for all numBits and all possible docID ranges to ensure the new APIs are correctly decoding (and there is no possibility of segfault)
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] siddharthteotia commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
siddharthteotia commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r527226203
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/io/reader/impl/FixedBitIntReaderTest.java
##########
@@ -0,0 +1,86 @@
+/**
+ * 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.io.reader.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitIntReaderTest {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 95;
+ private static final Random RANDOM = new Random();
Review comment:
How is this covering all the numbits cases for new APIs?
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] siddharthteotia edited a comment on pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
siddharthteotia edited a comment on pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#issuecomment-731309402
> @siddharthteotia Please check my reply under the comments. I think the tests are quite thorough, and covers all the bits and different start indices.
>
> For your questions:
>
> > Is it correct to say that new bulk read32() will be used here only if the docIDs array has sequential (consecutive) ids. Otherwise, we will use the new single read APIs?
>
> Yes
>
> > The readUnchecked() has the potential to segfault / core dump?
>
> If you use readUnchecked() for the last 2 values, it can read over the boundary (explained in the javadoc). This is handled within the `FixedBitSVForwardIndexReaderV2`
>
> > There is a chance that perf wise, we might see -ve impact due to memcpy (especially for high throughput use cases). So for this API at least, I don't think JMH is a reasonable indicator of better performance always. It is worthwhile to do validation on a prod-like workload.
>
> Why is memcpy involved here? The new reader won't read extra values because the bulk read is only used for sequential ids. I already asked @pradeepgv42 to try this, and he confirmed up to 45% query latency drop comparing with the current reader.
This is a memcpy
```
`for (int i = bulkStartIndex; i < bulkEndIndex; i += 32) {
_reader.read32(i, buffer);
System.arraycopy(buffer, 0, dictIdBuffer, index, 32);
index += 32;
}`
```
Just to be on the same page, bulkRead will be used only for queries like select * without filter or any query without filter or any query with range filter on sorted column?
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#issuecomment-731349654
> > @siddharthteotia Please check my reply under the comments. I think the tests are quite thorough, and covers all the bits and different start indices.
> > For your questions:
> > > Is it correct to say that new bulk read32() will be used here only if the docIDs array has sequential (consecutive) ids. Otherwise, we will use the new single read APIs?
> >
> >
> > Yes
> > > The readUnchecked() has the potential to segfault / core dump?
> >
> >
> > If you use readUnchecked() for the last 2 values, it can read over the boundary (explained in the javadoc). This is handled within the `FixedBitSVForwardIndexReaderV2`
> > > There is a chance that perf wise, we might see -ve impact due to memcpy (especially for high throughput use cases). So for this API at least, I don't think JMH is a reasonable indicator of better performance always. It is worthwhile to do validation on a prod-like workload.
> >
> >
> > Why is memcpy involved here? The new reader won't read extra values because the bulk read is only used for sequential ids. I already asked @pradeepgv42 to try this, and he confirmed up to 45% query latency drop comparing with the current reader.
>
> This is a memcpy
>
> ```
> `for (int i = bulkStartIndex; i < bulkEndIndex; i += 32) {
> _reader.read32(i, buffer);
> System.arraycopy(buffer, 0, dictIdBuffer, index, 32);
> index += 32;
> }`
> ```
>
> Just to be on the same page, bulkRead will be used only for queries like select * without filter or any query without filter or any query with range filter on sorted column?
Yes, correct
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] codecov-io commented on pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#issuecomment-731426890
# [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6262?src=pr&el=h1) Report
> Merging [#6262](https://codecov.io/gh/apache/incubator-pinot/pull/6262?src=pr&el=desc) (e15827b) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/1beaab59b73f26c4e35f3b9bc856b03806cddf5a?el=desc) (1beaab5) will **decrease** coverage by `1.26%`.
> The diff coverage is `45.12%`.
[](https://codecov.io/gh/apache/incubator-pinot/pull/6262?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #6262 +/- ##
==========================================
- Coverage 66.44% 65.18% -1.27%
==========================================
Files 1075 1252 +177
Lines 54773 61174 +6401
Branches 8168 8859 +691
==========================================
+ Hits 36396 39878 +3482
- Misses 15700 18465 +2765
- Partials 2677 2831 +154
```
| Flag | Coverage Δ | |
|---|---|---|
| unittests | `65.18% <45.12%> (?)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/6262?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...e/pinot/broker/api/resources/PinotBrokerDebug.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtYnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9icm9rZXIvYXBpL3Jlc291cmNlcy9QaW5vdEJyb2tlckRlYnVnLmphdmE=) | `0.00% <0.00%> (-79.32%)` | :arrow_down: |
| [...ot/broker/broker/AllowAllAccessControlFactory.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtYnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9icm9rZXIvYnJva2VyL0FsbG93QWxsQWNjZXNzQ29udHJvbEZhY3RvcnkuamF2YQ==) | `71.42% <ø> (-28.58%)` | :arrow_down: |
| [.../helix/BrokerUserDefinedMessageHandlerFactory.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtYnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9icm9rZXIvYnJva2VyL2hlbGl4L0Jyb2tlclVzZXJEZWZpbmVkTWVzc2FnZUhhbmRsZXJGYWN0b3J5LmphdmE=) | `33.96% <0.00%> (-32.71%)` | :arrow_down: |
| [...ker/routing/instanceselector/InstanceSelector.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtYnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9icm9rZXIvcm91dGluZy9pbnN0YW5jZXNlbGVjdG9yL0luc3RhbmNlU2VsZWN0b3IuamF2YQ==) | `100.00% <ø> (ø)` | |
| [...ava/org/apache/pinot/client/AbstractResultSet.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtY2xpZW50cy9waW5vdC1qYXZhLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY2xpZW50L0Fic3RyYWN0UmVzdWx0U2V0LmphdmE=) | `66.66% <0.00%> (+9.52%)` | :arrow_up: |
| [.../main/java/org/apache/pinot/client/Connection.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtY2xpZW50cy9waW5vdC1qYXZhLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY2xpZW50L0Nvbm5lY3Rpb24uamF2YQ==) | `35.55% <0.00%> (-13.29%)` | :arrow_down: |
| [...inot/client/JsonAsyncHttpPinotClientTransport.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtY2xpZW50cy9waW5vdC1qYXZhLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY2xpZW50L0pzb25Bc3luY0h0dHBQaW5vdENsaWVudFRyYW5zcG9ydC5qYXZh) | `10.90% <0.00%> (-51.10%)` | :arrow_down: |
| [...not/common/assignment/InstancePartitionsUtils.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vYXNzaWdubWVudC9JbnN0YW5jZVBhcnRpdGlvbnNVdGlscy5qYXZh) | `73.80% <ø> (+0.63%)` | :arrow_up: |
| [.../apache/pinot/common/exception/QueryException.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZXhjZXB0aW9uL1F1ZXJ5RXhjZXB0aW9uLmphdmE=) | `90.27% <ø> (+5.55%)` | :arrow_up: |
| [...pinot/common/function/AggregationFunctionType.java](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vQWdncmVnYXRpb25GdW5jdGlvblR5cGUuamF2YQ==) | `98.27% <ø> (-1.73%)` | :arrow_down: |
| ... and [1097 more](https://codecov.io/gh/apache/incubator-pinot/pull/6262/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6262?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6262?src=pr&el=footer). Last update [fa7b0e4...e15827b](https://codecov.io/gh/apache/incubator-pinot/pull/6262?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r525413431
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/segment/index/readers/forward/FixedBitSVForwardIndexReaderV2Test.java
##########
@@ -0,0 +1,102 @@
+/**
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitSVForwardIndexReaderV2Test {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 99999;
+ private static final int NUM_DOC_IDS = 10000;
Review comment:
Nit suggestion: Use prime numbers?
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/segment/index/readers/forward/FixedBitSVForwardIndexReaderV2Test.java
##########
@@ -0,0 +1,102 @@
+/**
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitSVForwardIndexReaderV2Test {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 99999;
+ private static final int NUM_DOC_IDS = 10000;
+ private static final Random RANDOM = new Random();
+
+ private final int[] _sequentialDocIds = new int[NUM_DOC_IDS];
+ private final int[] _sparseDocIds = new int[NUM_DOC_IDS];
+ private final int[] _lastSequentialDocIds = new int[NUM_DOC_IDS];
+ private final int[] _dictIdBuffer = new int[NUM_DOC_IDS];
+
+ @BeforeClass
+ public void setUp()
+ throws IOException {
+ FileUtils.forceMkdir(INDEX_DIR);
+
+ int sequentialDocId = RANDOM.nextInt(32);
Review comment:
Would it be better to use explicit values instead of random?
For example, we know all the corner cases would be around bits being split across read boundaries. We can then programmatically generate all the splits.
We could have random as well as explict.
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] siddharthteotia commented on pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
siddharthteotia commented on pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#issuecomment-731309402
> @siddharthteotia Please check my reply under the comments. I think the tests are quite thorough, and covers all the bits and different start indices.
>
> For your questions:
>
> > Is it correct to say that new bulk read32() will be used here only if the docIDs array has sequential (consecutive) ids. Otherwise, we will use the new single read APIs?
>
> Yes
>
> > The readUnchecked() has the potential to segfault / core dump?
>
> If you use readUnchecked() for the last 2 values, it can read over the boundary (explained in the javadoc). This is handled within the `FixedBitSVForwardIndexReaderV2`
>
> > There is a chance that perf wise, we might see -ve impact due to memcpy (especially for high throughput use cases). So for this API at least, I don't think JMH is a reasonable indicator of better performance always. It is worthwhile to do validation on a prod-like workload.
>
> Why is memcpy involved here? The new reader won't read extra values because the bulk read is only used for sequential ids. I already asked @pradeepgv42 to try this, and he confirmed up to 45% query latency drop comparing with the current reader.
This is a memcpy?
`for (int i = bulkStartIndex; i < bulkEndIndex; i += 32) {
_reader.read32(i, buffer);
System.arraycopy(buffer, 0, dictIdBuffer, index, 32);
index += 32;
}`
Just to be on the same page, bulkRead will be used only for queries like select * without filter or any query without filter or any query with range filter on sorted column?
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r526331379
##########
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:
This is a very small array and the overhead is negligible. We create the buffer per block (10000 docs) only when bulk read is needed
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #6262:
URL: https://github.com/apache/incubator-pinot/pull/6262#discussion_r527309791
##########
File path: pinot-core/src/test/java/org/apache/pinot/core/io/reader/impl/FixedBitIntReaderTest.java
##########
@@ -0,0 +1,86 @@
+/**
+ * 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.io.reader.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Random;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.core.io.writer.impl.FixedBitSVForwardIndexWriter;
+import org.apache.pinot.core.segment.memory.PinotDataBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class FixedBitIntReaderTest {
+ private static final File INDEX_DIR = new File(FileUtils.getTempDirectory(), "FixedBitIntReaderTest");
+ private static final int NUM_VALUES = 95;
+ private static final Random RANDOM = new Random();
Review comment:
This is just the random value generator. All the bits are tested. Check the for look on line 55
----------------------------------------------------------------
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
[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #6262: Enhance forward index reader for better performance
Posted by GitBox <gi...@apache.org>.
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