apurtell commented on code in PR #2624:
URL: https://github.com/apache/phoenix/pull/2624#discussion_r4199504972


##########
phoenix-core-server/src/main/java/org/apache/phoenix/iterate/VectorDistanceOrderedResultIterator.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.phoenix.iterate;
+
+import java.util.List;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.OrderByExpression;
+import org.apache.phoenix.expression.function.DistanceFunction;
+import org.apache.phoenix.schema.SortOrder;
+import org.apache.phoenix.schema.tuple.Tuple;
+import org.apache.phoenix.schema.types.PDouble;
+
+import 
org.apache.phoenix.thirdparty.com.google.common.collect.MinMaxPriorityQueue;
+
+/**
+ * Server side top-N result iterator optimizing single ascending distance 
ordering via bounded
+ * evaluation. Tracks candidate pool distances of size {@code max(limit, 
ceil(limit * oversample))}
+ * and supplies the worst candidate distance as an upper bound to the distance 
function, enabling
+ * early termination during component accumulation. Candidates exceeding the 
upper bound are pruned
+ * from the sort queue.
+ */
+public class VectorDistanceOrderedResultIterator extends OrderedResultIterator 
{
+
+  private final DistanceFunction distance;
+  private final MinMaxPriorityQueue<Double> pool;
+  private final int poolSize;
+
+  public VectorDistanceOrderedResultIterator(ResultIterator delegate,
+    List<OrderByExpression> orderByExpressions, boolean spoolingEnabled, long 
thresholdBytes,
+    int limit, int estimatedRowSize, long pageSizeMs, Scan scan, RegionInfo 
regionInfo,
+    double oversampleFactor) {
+    super(delegate, orderByExpressions, spoolingEnabled, thresholdBytes, 
limit, null,
+      estimatedRowSize, pageSizeMs, scan, regionInfo);

Review Comment:
   Acknowledged. I don't think OVERSAMPLE actually adds much to the design, so 
will simply remove it. 



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

Reply via email to