jpountz commented on a change in pull request #569: LUCENE-8687: Optimise radix 
partitioning for points on heap
URL: https://github.com/apache/lucene-solr/pull/569#discussion_r255006701
 
 

 ##########
 File path: 
lucene/core/src/java/org/apache/lucene/util/bkd/BKDRadixSelector.java
 ##########
 @@ -82,30 +82,40 @@ public BKDRadixSelector(int numDim, int bytesPerDim, int 
maxPointsSortInHeap, Di
    * the split happens. The method destroys the original writer.
    *
    */
-  public byte[] select(PointWriter points, PointWriter left, PointWriter 
right, long from, long to, long partitionPoint, int dim) throws IOException {
+  public byte[] select(PathSlice points, PathSlice[] slices, long from, long 
to, long partitionPoint, int dim, int dimCommonPrefix) throws IOException {
     checkArgs(from, to, partitionPoint);
 
+    assert slices.length == 2;
+
     //If we are on heap then we just select on heap
-    if (points instanceof HeapPointWriter) {
-      return heapSelect((HeapPointWriter) points, left, right, dim, 
Math.toIntExact(from), Math.toIntExact(to),  Math.toIntExact(partitionPoint), 
0);
+    if (points.writer instanceof HeapPointWriter) {
+      byte[] partition = heapRadixSelect((HeapPointWriter) points.writer, dim, 
Math.toIntExact(from), Math.toIntExact(to),  Math.toIntExact(partitionPoint), 
dimCommonPrefix);
+      slices[0] = new PathSlice(points.writer, from, partitionPoint - from);
+      slices[1] = new PathSlice(points.writer, partitionPoint, to - 
partitionPoint);
+      return partition;
     }
 
     //reset histogram
     for (int i = 0; i < bytesSorted; i++) {
       Arrays.fill(histogram[i], 0);
     }
-    OfflinePointWriter offlinePointWriter = (OfflinePointWriter) points;
+    OfflinePointWriter offlinePointWriter = (OfflinePointWriter) points.writer;
 
-    //find common prefix, it does already set histogram values if needed
-    int commonPrefix = findCommonPrefix(offlinePointWriter, from, to, dim);
+    //find common prefix from dimCommonPrefix, it does already set histogram 
values if needed
+    int commonPrefix = findCommonPrefix(offlinePointWriter, from, to, dim, 
dimCommonPrefix);
 
-    //if all equals we just partition the data
-    if (commonPrefix ==  bytesSorted) {
-      partition(offlinePointWriter, left,  right, null, from, to, dim, 
commonPrefix - 1, partitionPoint);
-      return partitionPointFromCommonPrefix();
+    try (PointWriter left = getPointWriter(partitionPoint - from, "left" + 
dim);
+         PointWriter right = getPointWriter(to - partitionPoint, "right" + 
dim)) {
+      slices[0] = new PathSlice(left, 0, partitionPoint - from);
+      slices[1] = new PathSlice(right, 0, to - partitionPoint);
+      //if all equals we just offlinePartition the data
 
 Review comment:
   bad search/replace?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to