Jackie-Jiang commented on code in PR #19662:
URL: https://github.com/apache/pinot/pull/19662#discussion_r4186837475
##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/store/SegmentLocalFSDirectoryTest.java:
##########
@@ -121,6 +122,74 @@ public void testWriteAndReadBackData()
}
}
+ private static SegmentDirectoryLoaderContext prefetchLoaderContext(long
maxMmapPrefetchBytes) {
+ return new SegmentDirectoryLoaderContext.Builder()
+ .setMaxMmapPrefetchBytes(maxMmapPrefetchBytes)
+ .build();
+ }
+
+ /// The prefetched-page counter is JVM-wide, so each case resets it via
[SegmentLocalFSDirectory#resetPrefetchedPages]
+ /// to get a deterministic baseline before asserting on how many pages
actually got faulted in.
+ @Test
+ public void testPrefetchLimitDisabledStillReadsData()
+ throws Exception {
+ File prefetchDir = new File(SegmentLocalFSDirectoryTest.class.getName() +
"-prefetch_disabled");
+ FileUtils.deleteQuietly(prefetchDir);
+ try {
+ FileUtils.copyDirectory(_segmentDirectory.getPath().toFile(),
prefetchDir);
+ SegmentLocalFSDirectory.resetPrefetchedPages();
+ // 0 bytes disables prefetching entirely
+ try (SegmentDirectory segmentDirectory = new
SegmentLocalFSDirectory(prefetchDir, _metadata,
+ ReadMode.mmap, prefetchLoaderContext(0))) {
+ try (SegmentDirectory.Writer writer = segmentDirectory.createWriter())
{
+ PinotDataBuffer buffer = writer.newIndexFor("noPrefetchColumn",
StandardIndexes.forward(), 1024);
+ loadData(buffer);
+ writer.save();
+ }
+ try (SegmentDirectory.Reader reader = segmentDirectory.createReader())
{
+ verifyData(reader.getIndexFor("noPrefetchColumn",
StandardIndexes.forward()));
+ }
+ Assert.assertEquals(SegmentLocalFSDirectory.getPrefetchedPages(), 0,
+ "No pages should be faulted in when the prefetch limit is 0");
+ }
+ } finally {
+ FileUtils.deleteQuietly(prefetchDir);
+ }
+ }
+
+ @Test
+ public void testSmallPrefetchLimitStillReadsData()
+ throws Exception {
+ File prefetchDir = new File(SegmentLocalFSDirectoryTest.class.getName() +
"-prefetch_small");
+ FileUtils.deleteQuietly(prefetchDir);
+ try {
+ FileUtils.copyDirectory(_segmentDirectory.getPath().toFile(),
prefetchDir);
+ SegmentLocalFSDirectory.resetPrefetchedPages();
+ // 8KB, i.e. a 2 page budget: exercises the slowdown branch that only
faults in header pages
Review Comment:
[P2, nonblocking] This 8 KiB case resets the counter and reads only one
index. With a two-page limit, that first read reaches the one-page threshold
through the normal loop; it never runs the header-only slowdown branch or the
hard-limit branch. Additional reads with counter checks of 1, then 2, then 2
would cover the behavior claimed here.
##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/store/SegmentLocalFSDirectoryTest.java:
##########
@@ -121,6 +122,74 @@ public void testWriteAndReadBackData()
}
}
+ private static SegmentDirectoryLoaderContext prefetchLoaderContext(long
maxMmapPrefetchBytes) {
+ return new SegmentDirectoryLoaderContext.Builder()
+ .setMaxMmapPrefetchBytes(maxMmapPrefetchBytes)
+ .build();
+ }
+
+ /// The prefetched-page counter is JVM-wide, so each case resets it via
[SegmentLocalFSDirectory#resetPrefetchedPages]
+ /// to get a deterministic baseline before asserting on how many pages
actually got faulted in.
+ @Test
+ public void testPrefetchLimitDisabledStillReadsData()
+ throws Exception {
+ File prefetchDir = new File(SegmentLocalFSDirectoryTest.class.getName() +
"-prefetch_disabled");
+ FileUtils.deleteQuietly(prefetchDir);
+ try {
+ FileUtils.copyDirectory(_segmentDirectory.getPath().toFile(),
prefetchDir);
+ SegmentLocalFSDirectory.resetPrefetchedPages();
+ // 0 bytes disables prefetching entirely
+ try (SegmentDirectory segmentDirectory = new
SegmentLocalFSDirectory(prefetchDir, _metadata,
+ ReadMode.mmap, prefetchLoaderContext(0))) {
+ try (SegmentDirectory.Writer writer = segmentDirectory.createWriter())
{
+ PinotDataBuffer buffer = writer.newIndexFor("noPrefetchColumn",
StandardIndexes.forward(), 1024);
+ loadData(buffer);
+ writer.save();
+ }
+ try (SegmentDirectory.Reader reader = segmentDirectory.createReader())
{
+ verifyData(reader.getIndexFor("noPrefetchColumn",
StandardIndexes.forward()));
+ }
+ Assert.assertEquals(SegmentLocalFSDirectory.getPrefetchedPages(), 0,
Review Comment:
[P3, nonblocking] The two newly added `Assert.assertEquals` calls here and
below should use a static `assertEquals` import, as required by `AGENTS.md` for
test code.
##########
pinot-spi/src/test/java/org/apache/pinot/spi/config/instance/InstanceDataManagerConfigTest.java:
##########
@@ -0,0 +1,39 @@
+/**
+ * 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.spi.config.instance;
+
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.mockito.Mockito;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class InstanceDataManagerConfigTest {
Review Comment:
[P3, nonblocking] `AGENTS.md` asks for class-level Javadoc on new classes,
covering behavior and thread-safety. Please add it for this test class.
##########
pinot-spi/src/test/java/org/apache/pinot/spi/config/instance/InstanceDataManagerConfigTest.java:
##########
@@ -0,0 +1,39 @@
+/**
+ * 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.spi.config.instance;
+
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.mockito.Mockito;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class InstanceDataManagerConfigTest {
+
+ /// Simulates an [InstanceDataManagerConfig] implementation compiled before
[#getMaxMmapPrefetchBytes()] was
+ /// added: since it's a default method, such an implementation must fall
back to it instead of throwing
+ /// `AbstractMethodError`.
+ @Test
+ public void
testGetMaxMmapPrefetchBytesDefaultsForPreexistingImplementations() {
+ InstanceDataManagerConfig config =
Mockito.mock(InstanceDataManagerConfig.class, Mockito.CALLS_REAL_METHODS);
Review Comment:
[P3, nonblocking] Please statically import `mock` rather than calling
`Mockito.mock`, per the test style in `AGENTS.md`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]