From 45e1141c1c7288b33aa171e4bb8dbb832dd15f29 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Fri, 27 May 2022 14:20:19 -0400 Subject: [PATCH] Visit point values once (#85499) (#87194) Closes #85484 Closes #86723 --- .../diskusage/IndexDiskUsageAnalyzer.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/diskusage/IndexDiskUsageAnalyzer.java b/server/src/main/java/org/elasticsearch/action/admin/indices/diskusage/IndexDiskUsageAnalyzer.java index 84b55c5d2fc09..33cb9a409e6f7 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/diskusage/IndexDiskUsageAnalyzer.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/diskusage/IndexDiskUsageAnalyzer.java @@ -54,7 +54,6 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -386,27 +385,13 @@ void analyzePoints(SegmentReader reader, IndexDiskUsageStats stats) throws IOExc directory.resetBytesRead(); if (field.getPointDimensionCount() > 0) { final PointValues values = pointsReader.getValues(field.name); - values.intersect( - new PointsVisitor(values.getMinPackedValue(), values.getNumIndexDimensions(), values.getBytesPerDimension()) - ); - values.intersect( - new PointsVisitor(values.getMaxPackedValue(), values.getNumIndexDimensions(), values.getBytesPerDimension()) - ); + values.intersect(new PointsVisitor()); stats.addPoints(field.name, directory.getBytesRead()); } } } private class PointsVisitor implements PointValues.IntersectVisitor { - private final byte[] point; - private final int numDims; - private final int bytesPerDim; - - PointsVisitor(byte[] point, int numDims, int bytesPerDim) { - this.point = point; - this.numDims = numDims; - this.bytesPerDim = bytesPerDim; - } @Override public void visit(int docID) throws IOException { @@ -420,13 +405,6 @@ public void visit(int docID, byte[] packedValue) throws IOException { @Override public PointValues.Relation compare(byte[] minPackedValue, byte[] maxPackedValue) { - for (int dim = 0; dim < numDims; dim++) { - int offset = dim * bytesPerDim; - if (Arrays.compareUnsigned(minPackedValue, offset, offset + bytesPerDim, point, offset, offset + bytesPerDim) > 0 - || Arrays.compareUnsigned(maxPackedValue, offset, offset + bytesPerDim, point, offset, offset + bytesPerDim) < 0) { - return PointValues.Relation.CELL_OUTSIDE_QUERY; - } - } return PointValues.Relation.CELL_CROSSES_QUERY; } }