Michael Blow has submitted this change and it was merged.

Change subject: [NO ISSUE][COMP] Ensure Consistent Locations in Splits and 
Constraints
......................................................................


[NO ISSUE][COMP] Ensure Consistent Locations in Splits and Constraints

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- This change ensures that the splits provider and constraints
  have the same order of locations to avoid a possibility where
  splits of a node are assigned to another node.

Change-Id: Id969251eb17bfb5139bc656b1e5025c2742d5318
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2872
Reviewed-by: Michael Blow <[email protected]>
Sonar-Qube: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
---
M 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java
M 
hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java
2 files changed, 6 insertions(+), 2 deletions(-)

Approvals:
  Jenkins: Verified; No violations found
  Michael Blow: Looks good to me, approved



diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java
index aa2c7af..63e29ce 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java
@@ -21,6 +21,8 @@
 import java.io.File;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Comparator;
 
 import org.apache.asterix.common.cluster.ClusterPartition;
 import org.apache.asterix.common.storage.ResourceReference;
@@ -39,12 +41,15 @@
 public class StoragePathUtil {
 
     private static final Logger LOGGER = LogManager.getLogger();
+    private static final Comparator<FileSplit> FILE_SPLIT_COMPARATOR =
+            
Comparator.comparing(FileSplit::getNodeName).thenComparing(FileSplit::getPath);
 
     private StoragePathUtil() {
     }
 
     public static Pair<IFileSplitProvider, AlgebricksPartitionConstraint> 
splitProviderAndPartitionConstraints(
             FileSplit[] splits) {
+        Arrays.sort(splits, FILE_SPLIT_COMPARATOR);
         IFileSplitProvider splitProvider = new 
ConstantFileSplitProvider(splits);
         String[] loc = new String[splits.length];
         for (int p = 0; p < splits.length; p++) {
diff --git 
a/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java
 
b/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java
index 1bb217a..7a1bb28 100644
--- 
a/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java
+++ 
b/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java
@@ -27,8 +27,7 @@
     private final String[] locations;
 
     public AlgebricksAbsolutePartitionConstraint(String[] locations) {
-        this.locations = locations.clone();
-        Arrays.sort(this.locations);
+        this.locations = locations;
     }
 
     @Override

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2872
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id969251eb17bfb5139bc656b1e5025c2742d5318
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <[email protected]>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Michael Blow <[email protected]>

Reply via email to