asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjaco...@apache.org
Subject asterixdb-bad git commit: Create index for result times
Date Thu, 04 May 2017 18:48:44 GMT
Repository: asterixdb-bad
Updated Branches:
  refs/heads/currentBadCluster [created] ec6dc5f49


Create index for result times


Project: http://git-wip-us.apache.org/repos/asf/asterixdb-bad/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb-bad/commit/ec6dc5f4
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb-bad/tree/ec6dc5f4
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb-bad/diff/ec6dc5f4

Branch: refs/heads/currentBadCluster
Commit: ec6dc5f49fffd3a7ddaf645aabb6f0a5a10c083b
Parents: 3dcf57c
Author: Steven Glenn Jacobs <sjaco002@ucr.edu>
Authored: Thu May 4 11:47:31 2017 -0700
Committer: Steven Glenn Jacobs <sjaco002@ucr.edu>
Committed: Thu May 4 11:47:31 2017 -0700

----------------------------------------------------------------------
 .../lang/statement/CreateChannelStatement.java  | 27 +++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb-bad/blob/ec6dc5f4/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
----------------------------------------------------------------------
diff --git a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
index 1ea8e7f..0dbc9e0 100644
--- a/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
+++ b/asterix-bad/src/main/java/org/apache/asterix/bad/lang/statement/CreateChannelStatement.java
@@ -44,6 +44,7 @@ import org.apache.asterix.bad.metadata.Channel;
 import org.apache.asterix.bad.metadata.ChannelEventsListener;
 import org.apache.asterix.bad.runtime.RepetitiveChannelOperatorDescriptor;
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
+import org.apache.asterix.common.config.DatasetConfig.IndexType;
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.functions.FunctionSignature;
@@ -56,7 +57,9 @@ import org.apache.asterix.lang.common.base.Expression;
 import org.apache.asterix.lang.common.base.Statement;
 import org.apache.asterix.lang.common.expression.CallExpr;
 import org.apache.asterix.lang.common.expression.LiteralExpr;
+import org.apache.asterix.lang.common.expression.TypeExpression;
 import org.apache.asterix.lang.common.literal.StringLiteral;
+import org.apache.asterix.lang.common.statement.CreateIndexStatement;
 import org.apache.asterix.lang.common.statement.DatasetDecl;
 import org.apache.asterix.lang.common.statement.IDatasetDetailsDecl;
 import org.apache.asterix.lang.common.statement.InsertStatement;
@@ -241,10 +244,26 @@ public class CreateChannelStatement implements IExtensionStatement {
                 new Identifier(BADConstants.BAD_DATAVERSE_NAME), resultsTypeName, null, null,
null, null,
                 new HashMap<String, String>(), new HashMap<String, String>(),
DatasetType.INTERNAL, idd, true);
 
+        //Create an index on timestamp for results
+        CreateIndexStatement createTimeIndex = new CreateIndexStatement();
+        createTimeIndex.setDatasetName(resultsName);
+        createTimeIndex.setDataverseName(new Identifier(dataverse));
+        createTimeIndex.setIndexName(new Identifier(resultsName + "TimeIndex"));
+        createTimeIndex.setIfNotExists(false);
+        createTimeIndex.setIndexType(IndexType.BTREE);
+        createTimeIndex.setEnforced(false);
+        createTimeIndex.setGramLength(0);
+        List<String> fNames = new ArrayList<>();
+        fNames.add(BADConstants.ChannelExecutionTime);
+        Pair<List<String>, TypeExpression> fields = new Pair<List<String>,
TypeExpression>(fNames, null);
+        createTimeIndex.addFieldExprPair(fields);
+        createTimeIndex.addFieldIndexIndicator(0);
+
         //Run both statements to create datasets
         ((QueryTranslator) statementExecutor).handleCreateDatasetStatement(metadataProvider,
createSubscriptionsDataset,
                 hcc);
         ((QueryTranslator) statementExecutor).handleCreateDatasetStatement(metadataProvider,
createResultsDataset, hcc);
+        ((QueryTranslator) statementExecutor).handleCreateIndexStatement(metadataProvider,
createTimeIndex, hcc);
 
     }
 
@@ -345,6 +364,7 @@ public class CreateChannelStatement implements IExtensionStatement {
                 throw new AsterixException("Channel " + channelName + " is already running");
             }
             initialize(mdTxnCtx, subscriptionsName.getValue(), resultsName.getValue());
+
             channel = new Channel(dataverse, channelName.getValue(), subscriptionsTableName,
resultsTableName, function,
                     duration);
 
@@ -356,6 +376,10 @@ public class CreateChannelStatement implements IExtensionStatement {
                 throw new AsterixException("The channel name:" + channelName + " is not available.");
             }
 
+            //Create Channel Datasets
+            createDatasets(statementExecutor, subscriptionsName, resultsName, metadataProvider,
hcc, hdc, stats,
+                    dataverse);
+
             // Now we subscribe
             if (listener == null) {
                 listener = new ChannelEventsListener(entityId);
@@ -364,9 +388,6 @@ public class CreateChannelStatement implements IExtensionStatement {
             listener.registerEventSubscriber(eventSubscriber);
             subscriberRegistered = true;
 
-            //Create Channel Datasets
-            createDatasets(statementExecutor, subscriptionsName, resultsName, metadataProvider,
hcc, hdc, stats,
-                    dataverse);
 
             //Create Channel Internal Job
             JobSpecification channeljobSpec = createChannelJob(statementExecutor, subscriptionsName,
resultsName,


Mime
View raw message