>From Ali Alsuliman <[email protected]>:

Ali Alsuliman has uploaded this change for review. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17399 )


Change subject: [ASTERIXDB-3119][*DB][IDX] Make local ordering property only on 
SKs
......................................................................

[ASTERIXDB-3119][*DB][IDX] Make local ordering property only on SKs

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

Details:
For now, make the local ordering property of query-index() on
only the secondary keys.

Change-Id: I8afb2b197da19b45b91507280652f2171b40e9c4
---
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexRewriter.java
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexDatasource.java
2 files changed, 28 insertions(+), 7 deletions(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/99/17399/1

diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexDatasource.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexDatasource.java
index f43588e..cf2b891 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexDatasource.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexDatasource.java
@@ -56,13 +56,16 @@
     private final Dataset ds;
     private final String indexName;
     private final AlgebricksAbsolutePartitionConstraint storageLocations;
+    private final int numSecKeys;

     public QueryIndexDatasource(Dataset ds, String indexName, INodeDomain 
domain,
-            AlgebricksAbsolutePartitionConstraint storageLocations, 
ARecordType recType) throws AlgebricksException {
+            AlgebricksAbsolutePartitionConstraint storageLocations, 
ARecordType recType, int numSecKeys)
+            throws AlgebricksException {
         super(createQueryIndexDataSourceId(ds, indexName), 
QueryIndexRewriter.QUERY_INDEX, domain, recType);
         this.ds = ds;
         this.indexName = indexName;
         this.storageLocations = storageLocations;
+        this.numSecKeys = numSecKeys;
     }

     @Override
@@ -109,12 +112,12 @@
     public IDataSourcePropertiesProvider getPropertiesProvider() {
         return scanVariables -> {
             List<ILocalStructuralProperty> propsLocal = new ArrayList<>(1);
-            int numScanKeys = scanVariables.size();
-            List<OrderColumn> scanKeys = new ArrayList<>(numScanKeys);
-            for (int i = 0; i < numScanKeys; i++) {
-                scanKeys.add(new OrderColumn(scanVariables.get(i), 
OrderOperator.IOrder.OrderKind.ASC));
+            //TODO(ali): consider primary keys?
+            List<OrderColumn> secKeys = new ArrayList<>(numSecKeys);
+            for (int i = 0; i < numSecKeys; i++) {
+                secKeys.add(new OrderColumn(scanVariables.get(i), 
OrderOperator.IOrder.OrderKind.ASC));
             }
-            propsLocal.add(new LocalOrderProperty(scanKeys));
+            propsLocal.add(new LocalOrderProperty(secKeys));
             return new StructuralPropertiesVector(new 
RandomPartitioningProperty(domain), propsLocal);
         };
     }
diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexRewriter.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexRewriter.java
index 1906fcf..e0ff9c2 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexRewriter.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/QueryIndexRewriter.java
@@ -128,7 +128,8 @@
                 (AlgebricksAbsolutePartitionConstraint) 
secIdxHelper.getSecondaryPartitionConstraint();
         INodeDomain domain = mp.findNodeDomain(ds.getNodeGroupName());
         ARecordType recType = computeRecType(f, mp, null, null, null);
-        return new QueryIndexDatasource(ds, idx.getIndexName(), domain, 
secPartitionConstraint, recType);
+        int numSecKeys = ((Index.ValueIndexDetails) 
idx.getIndexDetails()).getKeyFieldNames().size();
+        return new QueryIndexDatasource(ds, idx.getIndexName(), domain, 
secPartitionConstraint, recType, numSecKeys);
     }

     private ARecordType computeRecType(AbstractFunctionCallExpression f, 
MetadataProvider metadataProvider,

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17399
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb
Gerrit-Branch: neo
Gerrit-Change-Id: I8afb2b197da19b45b91507280652f2171b40e9c4
Gerrit-Change-Number: 17399
Gerrit-PatchSet: 1
Gerrit-Owner: Ali Alsuliman <[email protected]>
Gerrit-MessageType: newchange

Reply via email to