asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject [1/2] asterixdb git commit: [ASTERIXDB-2182][SQL] Change merge policy syntax
Date Sat, 02 Dec 2017 03:43:22 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master c04b47783 -> f3aa19fb1


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp
index fd65d71..589e7f9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp
@@ -82,8 +82,13 @@ create type typeTweet if not exists as open{
 };
 
 create dataset Tweet(typeTweet) primary key id
-using compaction policy prefix (("max-mergable-component-size"="32768"),("max-tolerance-component-count"="32"))
-with filter on create_at;
+with filter on create_at
+with {
+  "merge-policy": {
+    "name": "prefix",
+    "parameters": { "max-mergable-component-size": 32768, "max-tolerance-component-count": 32 }
+  }
+};
 
 create index text_idx if not exists on Tweet(`text`) type btree;
 create index state_idx if not exists on Tweet(geo_tag.stateID) type btree;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp
index caa7ca4..b42d017 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp
@@ -31,5 +31,9 @@ create type TestOpenType as open {
 
 create dataset TestOpen(TestOpenType)
 primary key c_id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`="16384"),(`max-tolerance-component-count`="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp
index 872e1bc..edfa1d3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp
@@ -35,11 +35,19 @@ create type MyRecord as closed {
 
 create dataset UpsertTo(MyRecord)
 primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 
 
 create dataset UpsertFrom(MyRecord)
 primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp
index d1db047..6095171 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp
@@ -34,9 +34,17 @@ salary:double
 };
 
 create dataset UpsertTo(TestType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 
 create dataset UpsertFrom(TestType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp
index f54ab2b..0b2b260 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp
@@ -30,10 +30,18 @@ create type DBLPType as closed {
 
 create dataset UpsertToDBLP(DBLPType)
 primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 
 create dataset UpsertFromDBLP(DBLPType)
 primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp
index cc33f84..4cc2324 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp
@@ -33,11 +33,19 @@ create type MyRecord as closed {
 };
 
 create dataset UpsertTo(MyRecord)
- primary key id
- using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+primary key id
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 
 create dataset UpsertFrom(MyRecord)
- primary key id
- using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+primary key id
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index a4cf64a..1c85ff9 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -133,6 +133,12 @@ public class ErrorCode {
     public static final int COMPILATION_FAILED_DUE_TO_REPLICATE_OP = 1054;
     public static final int COMPILATION_INCOMPATIBLE_FUNCTION_LANGUAGE = 1055;
     public static final int TOO_MANY_OPTIONS_FOR_FUNCTION = 1056;
+    public static final int EXPRESSION_NOT_SUPPORTED_IN_CONSTANT_RECORD = 1057;
+    public static final int LITERAL_TYPE_NOT_SUPPORTED_IN_CONSTANT_RECORD = 1058;
+    public static final int UNSUPPORTED_WITH_FIELD = 1059;
+    public static final int WITH_FIELD_MUST_BE_OF_TYPE = 1060;
+    public static final int WITH_FIELD_MUST_CONTAIN_SUB_FIELD = 1061;
+    public static final int MERGE_POLICY_PARAMETER_INVALID_TYPE = 1062;
 
     // Feed errors
     public static final int DATAFLOW_ILLEGAL_STATE = 3001;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index 39a74ff..61d8291 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -119,6 +119,12 @@
 1054 = Compilation failed due to some problem in the query plan.
 1055 = Incompatible function language. Expect %1$s, but %2$s found.
 1056 = Too many options were specified for %1$s
+1057 = Expression of type %1$s is not supported in constant record
+1058 = Literal of type %1$s is not supported in constant record
+1059 = Field \"%1$s\" unsupported in the with clause
+1060 = Field \"%1$s\" in the with clause must be of type %2$s
+1061 = Field \"%1$s\" in the with clause must contain sub field \"%2$s\"
+1062 = Merge policy parameters cannot be of type %1$s
 
 # Feed Errors
 3001 = Illegal state.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql
index be29328..bdce483 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql
@@ -61,12 +61,20 @@ create type FragileType as closed {
 /* Create dataset for loading raw Fragile data */
 create dataset Fragile_raw (FragileTypeRaw)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 
 /* Create dataset for cleaned Fragile data */
 create dataset Fragile (FragileType)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql
index 9443205..0fa78f2 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql
@@ -62,11 +62,20 @@ create type FragileType as closed {
 /* Create dataset for loading raw Fragile data */
 create dataset Fragile_raw (FragileTypeRaw)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
+
 
 /* Create dataset for cleaned Fragile data */
 create dataset Fragile (FragileType)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql
index 618c6b1..b27ec90 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql
@@ -60,12 +60,20 @@ create type FragileType as closed {
 /* Create dataset for loading raw Fragile data */
 create dataset Fragile_raw (FragileTypeRaw)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 
 /* Create dataset for cleaned Fragile data */
 create dataset Fragile (FragileType)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql
index b1f61e2..c79a54c 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql
@@ -62,12 +62,20 @@ create type FragileType as closed {
 /* Create dataset for loading raw Fragile data */
 create dataset Fragile_raw (FragileTypeRaw)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 
 /* Create dataset for cleaned Fragile data */
 create dataset Fragile (FragileType)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql
index 69a6c9d..e473591 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql
@@ -62,12 +62,20 @@ create type FragileType as closed {
 /* Create dataset for loading raw Fragile data */
 create dataset Fragile_raw (FragileTypeRaw)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 
 /* Create dataset for cleaned Fragile data */
 create dataset Fragile (FragileType)
 primary key row_id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {
+  "merge-policy": {
+    "name": "correlated-prefix",
+    "parameters": { "max-mergable-component-size": 16384, "max-tolerance-component-count": 3 }
+  }
+};
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
index 59ed8ae..5c7c6f2 100644
--- a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
+++ b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
@@ -440,16 +440,15 @@ DatasetDecl DatasetSpecification() throws ParseException:
   Pair<Identifier,Identifier> typeComponents = null;
   String adapterName = null;
   Map<String,String> properties = null;
-  Map<String,String> compactionPolicyProperties = null;
   FunctionSignature appliedFunction = null;
   Pair<List<Integer>, List<List<String>>> primaryKeyFields = null;
   String nodeGroupName = null;
   Map<String,String> hints = new HashMap<String,String>();
   DatasetDecl dsetDecl = null;
   boolean autogenerated = false;
-  String compactionPolicy = null;
   Pair<Integer, List<String>> filterField = null;
   Pair<Identifier,Identifier> metaTypeComponents = new Pair<Identifier, Identifier>(null, null);
+  RecordConstructor withRecord = null;
 }
 {
   (
@@ -459,24 +458,27 @@ DatasetDecl DatasetSpecification() throws ParseException:
     <USING> adapterName = AdapterName() properties = Configuration()
     ( <ON> nodeGroupName = Identifier() )?
     ( <HINTS> hints = Properties() )?
-    ( <USING> <COMPACTION> <POLICY> compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )?
+    ( <WITH> withRecord = RecordConstructor() )?
       {
         ExternalDetailsDecl edd = new ExternalDetailsDecl();
         edd.setAdapter(adapterName);
         edd.setProperties(properties);
-        dsetDecl = new DatasetDecl(nameComponents.first,
-                                   nameComponents.second,
-                                   typeComponents.first,
-                                   typeComponents.second,
-                                   metaTypeComponents.first,
-                                   metaTypeComponents.second,
-                                   nodeGroupName != null? new Identifier(nodeGroupName): null,
-                                   compactionPolicy,
-                                   compactionPolicyProperties,
-                                   hints,
-                                   DatasetType.EXTERNAL,
-                                   edd,
-                                   ifNotExists);
+        try{
+            dsetDecl = new DatasetDecl(nameComponents.first,
+              nameComponents.second,
+              typeComponents.first,
+              typeComponents.second,
+              metaTypeComponents.first,
+              metaTypeComponents.second,
+              nodeGroupName != null? new Identifier(nodeGroupName): null,
+              hints,
+              DatasetType.EXTERNAL,
+              edd,
+              withRecord,
+              ifNotExists);
+       } catch (CompilationException e){
+           throw new ParseException(e.getMessage());
+       }
       }
 
     | ( <INTERNAL> )?
@@ -498,8 +500,8 @@ DatasetDecl DatasetSpecification() throws ParseException:
     ( <AUTOGENERATED> { autogenerated = true; } )?
     ( <ON> nodeGroupName = Identifier() )?
     ( <HINTS> hints = Properties() )?
-    ( <USING> <COMPACTION> <POLICY> compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )?
-    ( <WITH> <FILTER> <ON> filterField = NestedField() )?
+    ( LOOKAHEAD(2) <WITH> <FILTER> <ON> filterField = NestedField() )?
+    ( <WITH> withRecord = RecordConstructor() )?
       {
         if(filterField!=null && filterField.first!=0){
           throw new ParseException("A filter field can only be a field in the main record of the dataset.");
@@ -508,19 +510,22 @@ DatasetDecl DatasetSpecification() throws ParseException:
                                                           primaryKeyFields.first,
                                                           autogenerated,
                                                           filterField == null? null : filterField.second);
-        dsetDecl = new DatasetDecl(nameComponents.first,
+        try{
+          dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
                                    typeComponents.first,
                                    typeComponents.second,
                                    metaTypeComponents.first,
                                    metaTypeComponents.second,
                                    nodeGroupName != null ? new Identifier(nodeGroupName) : null,
-                                   compactionPolicy,
-                                   compactionPolicyProperties,
                                    hints,
                                    DatasetType.INTERNAL,
                                    idd,
+                                   withRecord,
                                    ifNotExists);
+        } catch (CompilationException e){
+           throw new ParseException(e.getMessage());
+        }
       }
   )
     {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
index 1ca8ac4..c0beef4 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
@@ -38,9 +38,9 @@ public abstract class Literal implements Serializable {
         LONG
     }
 
-    abstract public Object getValue();
+    public abstract Object getValue();
 
-    abstract public Type getLiteralType();
+    public abstract Type getLiteralType();
 
     public String getStringValue() {
         return getValue().toString();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java
index 2a527d5..ca5dd57 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java
@@ -19,12 +19,12 @@
 package org.apache.asterix.lang.common.expression;
 
 import java.util.List;
+import java.util.Objects;
 
 import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.lang.common.base.AbstractExpression;
 import org.apache.asterix.lang.common.base.Expression;
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
-import org.apache.commons.lang3.ObjectUtils;
 
 public class ListConstructor extends AbstractExpression {
     private List<Expression> exprList;
@@ -72,7 +72,7 @@ public class ListConstructor extends AbstractExpression {
 
     @Override
     public int hashCode() {
-        return ObjectUtils.hashCodeMulti(exprList, type);
+        return Objects.hash(exprList, type);
     }
 
     @Override
@@ -84,6 +84,6 @@ public class ListConstructor extends AbstractExpression {
             return false;
         }
         ListConstructor target = (ListConstructor) object;
-        return ObjectUtils.equals(exprList, target.exprList) && ObjectUtils.equals(type, target.type);
+        return Objects.equals(exprList, target.exprList) && Objects.equals(type, target.type);
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java
index 095f098..0c3fdb1 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java
@@ -18,11 +18,22 @@
  */
 package org.apache.asterix.lang.common.expression;
 
+import java.util.Objects;
+
 import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.lang.common.base.AbstractExpression;
 import org.apache.asterix.lang.common.base.Literal;
+import org.apache.asterix.lang.common.literal.DoubleLiteral;
+import org.apache.asterix.lang.common.literal.LongIntegerLiteral;
+import org.apache.asterix.lang.common.literal.StringLiteral;
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
-import org.apache.commons.lang3.ObjectUtils;
+import org.apache.asterix.object.base.AdmBigIntNode;
+import org.apache.asterix.object.base.AdmBooleanNode;
+import org.apache.asterix.object.base.AdmDoubleNode;
+import org.apache.asterix.object.base.AdmNullNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
 
 public class LiteralExpr extends AbstractExpression {
     private Literal value;
@@ -55,7 +66,7 @@ public class LiteralExpr extends AbstractExpression {
 
     @Override
     public int hashCode() {
-        return ObjectUtils.hashCode(value);
+        return Objects.hashCode(value);
     }
 
     @Override
@@ -67,6 +78,6 @@ public class LiteralExpr extends AbstractExpression {
             return false;
         }
         LiteralExpr target = (LiteralExpr) object;
-        return ObjectUtils.equals(value, target.value);
+        return Objects.equals(value, target.value);
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java
index 1aa8ff1..cce92e6 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java
@@ -19,11 +19,11 @@
 package org.apache.asterix.lang.common.expression;
 
 import java.util.List;
+import java.util.Objects;
 
 import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.lang.common.base.AbstractExpression;
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
-import org.apache.commons.lang3.ObjectUtils;
 
 public class RecordConstructor extends AbstractExpression {
     private List<FieldBinding> fbList;
@@ -57,7 +57,7 @@ public class RecordConstructor extends AbstractExpression {
 
     @Override
     public int hashCode() {
-        return ObjectUtils.hashCode(fbList);
+        return Objects.hashCode(fbList);
     }
 
     @Override
@@ -69,6 +69,6 @@ public class RecordConstructor extends AbstractExpression {
             return false;
         }
         RecordConstructor target = (RecordConstructor) object;
-        return ObjectUtils.equals(fbList, target.fbList);
+        return Objects.equals(fbList, target.fbList);
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java
index f362c15..5812b19 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java
@@ -23,9 +23,9 @@ import org.apache.commons.lang.ObjectUtils;
 
 public class DoubleLiteral extends Literal {
     private static final long serialVersionUID = -5685491458356989250L;
-    private Double value;
+    private double value;
 
-    public DoubleLiteral(Double value) {
+    public DoubleLiteral(double value) {
         super();
         this.value = value;
     }
@@ -35,6 +35,10 @@ public class DoubleLiteral extends Literal {
         return value;
     }
 
+    public double getDoubleValue() {
+        return value;
+    }
+
     public void setValue(Double value) {
         this.value = value;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java
index 66164d1..5e00cb8 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java
@@ -35,6 +35,10 @@ public class LongIntegerLiteral extends Literal {
         return value;
     }
 
+    public long getLongValue() {
+        return value;
+    }
+
     public void setValue(Long value) {
         this.value = value;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java
index 79d1774..e63dae6 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java
@@ -18,34 +18,47 @@
  */
 package org.apache.asterix.lang.common.statement;
 
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.expression.RecordConstructor;
 import org.apache.asterix.lang.common.struct.Identifier;
+import org.apache.asterix.lang.common.util.ExpressionUtils;
+import org.apache.asterix.lang.common.util.MergePolicyUtils;
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
+import org.apache.asterix.object.base.AdmObjectNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 
 public class DatasetDecl implements Statement {
+    protected static final String[] WITH_OBJECT_FIELDS = new String[] { MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME };
+    protected static final Set<String> WITH_OBJECT_FIELDS_SET = new HashSet<>(Arrays.asList(WITH_OBJECT_FIELDS));
+
     protected final Identifier name;
     protected final Identifier dataverse;
     protected final Identifier itemTypeDataverse;
     protected final Identifier itemTypeName;
+    protected final Identifier metaItemTypeDataverse;
+    protected final Identifier metaItemTypeName;
     protected final Identifier nodegroupName;
-    protected final String compactionPolicy;
-    protected final Map<String, String> compactionPolicyProperties;
     protected final DatasetType datasetType;
     protected final IDatasetDetailsDecl datasetDetailsDecl;
     protected final Map<String, String> hints;
+    private final AdmObjectNode withObjectNode;
     protected final boolean ifNotExists;
 
-    protected final Identifier metaItemTypeDataverse;
-    protected final Identifier metaItemTypeName;
-
     public DatasetDecl(Identifier dataverse, Identifier name, Identifier itemTypeDataverse, Identifier itemTypeName,
             Identifier metaItemTypeDataverse, Identifier metaItemTypeName, Identifier nodeGroupName,
-            String compactionPolicy, Map<String, String> compactionPolicyProperties, Map<String, String> hints,
-            DatasetType datasetType, IDatasetDetailsDecl idd, boolean ifNotExists) {
+            Map<String, String> hints, DatasetType datasetType, IDatasetDetailsDecl idd, RecordConstructor withRecord,
+            boolean ifNotExists) throws CompilationException {
         this.dataverse = dataverse;
         this.name = name;
         this.itemTypeName = itemTypeName;
@@ -61,9 +74,15 @@ public class DatasetDecl implements Statement {
             this.metaItemTypeDataverse = metaItemTypeDataverse;
         }
         this.nodegroupName = nodeGroupName;
-        this.compactionPolicy = compactionPolicy;
-        this.compactionPolicyProperties = compactionPolicyProperties;
         this.hints = hints;
+        try {
+            this.withObjectNode = withRecord == null ? null : ExpressionUtils.toNode(withRecord);
+        } catch (CompilationException e) {
+            throw e;
+        } catch (AlgebricksException e) {
+            // TODO(tillw) make signatures throw Algebricks exceptions
+            throw new CompilationException(e);
+        }
         this.ifNotExists = ifNotExists;
         this.datasetType = datasetType;
         this.datasetDetailsDecl = idd;
@@ -121,12 +140,68 @@ public class DatasetDecl implements Statement {
         return nodegroupName;
     }
 
-    public String getCompactionPolicy() {
-        return compactionPolicy;
+    public String getCompactionPolicy() throws CompilationException {
+        AdmObjectNode mergePolicy = getMergePolicyObject();
+        if (mergePolicy == null) {
+            return null;
+        }
+        IAdmNode mergePolicyName = mergePolicy.get(MergePolicyUtils.MERGE_POLICY_NAME_PARAMETER_NAME);
+        if (mergePolicyName == null) {
+            throw new CompilationException(ErrorCode.WITH_FIELD_MUST_CONTAIN_SUB_FIELD,
+                    MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME, MergePolicyUtils.MERGE_POLICY_NAME_PARAMETER_NAME);
+        }
+        if (mergePolicyName.getType() != ATypeTag.STRING) {
+            throw new CompilationException(ErrorCode.WITH_FIELD_MUST_BE_OF_TYPE,
+                    MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME + '.'
+                            + MergePolicyUtils.MERGE_POLICY_NAME_PARAMETER_NAME,
+                    ATypeTag.STRING);
+        }
+        return ((AdmStringNode) mergePolicyName).get();
+    }
+
+    private static AdmObjectNode validateWithObject(AdmObjectNode withObject) throws CompilationException {
+        if (withObject == null) {
+            return null;
+        }
+        for (String name : withObject.getFieldNames()) {
+            if (!WITH_OBJECT_FIELDS_SET.contains(name)) {
+                throw new CompilationException(ErrorCode.UNSUPPORTED_WITH_FIELD, name);
+            }
+        }
+        return withObject;
+    }
+
+    private AdmObjectNode getMergePolicyObject() throws CompilationException {
+        if (withObjectNode == null) {
+            return null;
+        }
+        IAdmNode mergePolicy = validateWithObject(withObjectNode).get(MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME);
+        if (mergePolicy == null) {
+            return null;
+        }
+        if (!mergePolicy.isObject()) {
+            throw new CompilationException(ErrorCode.WITH_FIELD_MUST_BE_OF_TYPE,
+                    MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME, ATypeTag.OBJECT);
+        }
+        return (AdmObjectNode) mergePolicy;
     }
 
-    public Map<String, String> getCompactionPolicyProperties() {
-        return compactionPolicyProperties;
+    public Map<String, String> getCompactionPolicyProperties() throws CompilationException {
+        AdmObjectNode mergePolicy = getMergePolicyObject();
+        if (mergePolicy == null) {
+            return null;
+        }
+        IAdmNode mergePolicyParameters = mergePolicy.get(MergePolicyUtils.MERGE_POLICY_PARAMETERS_PARAMETER_NAME);
+        if (mergePolicyParameters == null) {
+            return null;
+        }
+        if (mergePolicyParameters.getType() != ATypeTag.OBJECT) {
+            throw new CompilationException(ErrorCode.WITH_FIELD_MUST_BE_OF_TYPE,
+                    MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME + '.'
+                            + MergePolicyUtils.MERGE_POLICY_PARAMETERS_PARAMETER_NAME,
+                    ATypeTag.OBJECT);
+        }
+        return MergePolicyUtils.toProperties((AdmObjectNode) mergePolicyParameters);
     }
 
     public Map<String, String> getHints() {
@@ -156,4 +231,8 @@ public class DatasetDecl implements Statement {
         return Category.DDL;
     }
 
+    public AdmObjectNode getWithObjectNode() {
+        return withObjectNode;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
new file mode 100644
index 0000000..25f9d07
--- /dev/null
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
@@ -0,0 +1,101 @@
+/*
+ * 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.asterix.lang.common.util;
+
+import java.util.List;
+
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.lang.common.base.Expression;
+import org.apache.asterix.lang.common.base.Literal;
+import org.apache.asterix.lang.common.expression.FieldBinding;
+import org.apache.asterix.lang.common.expression.ListConstructor;
+import org.apache.asterix.lang.common.expression.LiteralExpr;
+import org.apache.asterix.lang.common.expression.RecordConstructor;
+import org.apache.asterix.lang.common.literal.DoubleLiteral;
+import org.apache.asterix.lang.common.literal.LongIntegerLiteral;
+import org.apache.asterix.lang.common.literal.StringLiteral;
+import org.apache.asterix.object.base.AdmArrayNode;
+import org.apache.asterix.object.base.AdmBigIntNode;
+import org.apache.asterix.object.base.AdmBooleanNode;
+import org.apache.asterix.object.base.AdmDoubleNode;
+import org.apache.asterix.object.base.AdmNullNode;
+import org.apache.asterix.object.base.AdmObjectNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+public class ExpressionUtils {
+    private ExpressionUtils() {
+    }
+
+    public static IAdmNode toNode(Expression expr) throws AlgebricksException {
+        switch (expr.getKind()) {
+            case LIST_CONSTRUCTOR_EXPRESSION:
+                return toNode((ListConstructor) expr);
+            case LITERAL_EXPRESSION:
+                return toNode((LiteralExpr) expr);
+            case RECORD_CONSTRUCTOR_EXPRESSION:
+                return toNode((RecordConstructor) expr);
+            default:
+                throw new CompilationException(ErrorCode.EXPRESSION_NOT_SUPPORTED_IN_CONSTANT_RECORD, expr.getKind());
+        }
+    }
+
+    public static AdmObjectNode toNode(RecordConstructor recordConstructor) throws AlgebricksException {
+        AdmObjectNode node = new AdmObjectNode();
+        final List<FieldBinding> fbList = recordConstructor.getFbList();
+        for (int i = 0; i < fbList.size(); i++) {
+            FieldBinding binding = fbList.get(i);
+            String key = LangRecordParseUtil.exprToStringLiteral(binding.getLeftExpr()).getStringValue();
+            IAdmNode value = ExpressionUtils.toNode(binding.getRightExpr());
+            node.set(key, value);
+        }
+        return node;
+    }
+
+    private static IAdmNode toNode(ListConstructor listConstructor) throws AlgebricksException {
+        final List<Expression> exprList = listConstructor.getExprList();
+        AdmArrayNode array = new AdmArrayNode(exprList.size());
+        for (int i = 0; i < exprList.size(); i++) {
+            array.add(ExpressionUtils.toNode(exprList.get(i)));
+        }
+        return array;
+    }
+
+    private static IAdmNode toNode(LiteralExpr literalExpr) throws AlgebricksException {
+        final Literal value = literalExpr.getValue();
+        final Literal.Type literalType = value.getLiteralType();
+        switch (literalType) {
+            case DOUBLE:
+                return new AdmDoubleNode(((DoubleLiteral) value).getDoubleValue());
+            case FALSE:
+            case TRUE:
+                return AdmBooleanNode.get((Boolean) value.getValue());
+            case LONG:
+                return new AdmBigIntNode(((LongIntegerLiteral) value).getLongValue());
+            case NULL:
+                return AdmNullNode.INSTANCE;
+            case STRING:
+                return new AdmStringNode(((StringLiteral) value).getValue());
+            default:
+                throw new CompilationException(ErrorCode.LITERAL_TYPE_NOT_SUPPORTED_IN_CONSTANT_RECORD, literalType);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
index 080e2c4..c4b23ef 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
@@ -26,6 +26,7 @@ import java.util.Map;
 
 import org.apache.asterix.builders.OrderedListBuilder;
 import org.apache.asterix.builders.RecordBuilder;
+import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
 import org.apache.asterix.lang.common.base.Expression;
@@ -56,22 +57,22 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 public class LangRecordParseUtil {
     private static final String NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE =
             "JSON record can only have expressions [%1$s, %2$s, %3$s]";
-    private static final ISerializerDeserializer<ADouble> doubleSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ADOUBLE);
-    private static final ISerializerDeserializer<AString> stringSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ASTRING);
-    private static final ISerializerDeserializer<AInt64> intSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.AINT64);
-    private static final ISerializerDeserializer<ABoolean> booleanSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ABOOLEAN);
-    private static final ISerializerDeserializer<ANull> nullSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ANULL);
+    private static final ISerializerDeserializer<ADouble> doubleSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADOUBLE);
+    private static final ISerializerDeserializer<AString> stringSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
+    private static final ISerializerDeserializer<AInt64> intSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
+    private static final ISerializerDeserializer<ABoolean> booleanSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ABOOLEAN);
+    private static final ISerializerDeserializer<ANull> nullSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ANULL);
 
     private LangRecordParseUtil() {
     }
 
     private static void parseExpression(Expression expr, ArrayBackedValueStorage serialized)
-            throws HyracksDataException {
+            throws HyracksDataException, CompilationException {
         switch (expr.getKind()) {
             case LITERAL_EXPRESSION:
                 parseLiteral((LiteralExpr) expr, serialized);
@@ -84,14 +85,15 @@ public class LangRecordParseUtil {
                 break;
             default:
                 throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                        NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE, new Serializable[] { Expression.Kind.LITERAL_EXPRESSION
-                                .toString(), Expression.Kind.RECORD_CONSTRUCTOR_EXPRESSION.toString(),
+                        NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE,
+                        new Serializable[] { Expression.Kind.LITERAL_EXPRESSION.toString(),
+                                Expression.Kind.RECORD_CONSTRUCTOR_EXPRESSION.toString(),
                                 Expression.Kind.LIST_CONSTRUCTOR_EXPRESSION.toString() });
         }
     }
 
     public static void parseRecord(RecordConstructor recordValue, ArrayBackedValueStorage serialized, boolean tagged,
-            List<Pair<String, String>> defaults) throws HyracksDataException {
+            List<Pair<String, String>> defaults) throws HyracksDataException, CompilationException {
         AMutableString fieldNameString = new AMutableString(null);
         ArrayBackedValueStorage fieldName = new ArrayBackedValueStorage();
         ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
@@ -106,8 +108,8 @@ public class LangRecordParseUtil {
             // get key
             fieldNameString.setValue(exprToStringLiteral(fb.getLeftExpr()).getStringValue());
             if (!fieldNames.add(fieldNameString.getStringValue())) {
-                throw new HyracksDataException("Field " + fieldNameString.getStringValue()
-                        + " was specified multiple times");
+                throw new HyracksDataException(
+                        "Field " + fieldNameString.getStringValue() + " was specified multiple times");
             }
             stringSerde.serialize(fieldNameString, fieldName.getDataOutput());
             // get value
@@ -127,25 +129,25 @@ public class LangRecordParseUtil {
         recordBuilder.write(serialized.getDataOutput(), tagged);
     }
 
-    public static Literal exprToStringLiteral(Expression expr) throws HyracksDataException {
+    public static Literal exprToStringLiteral(Expression expr) throws CompilationException {
         if (expr.getKind() != Expression.Kind.LITERAL_EXPRESSION) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                    "Expected expression can only be of type %1$s", Expression.Kind.LITERAL_EXPRESSION);
+            throw new CompilationException(ErrorCode.PARSE_ERROR, "Expected expression can only be of type %1$s",
+                    Expression.Kind.LITERAL_EXPRESSION);
         }
         LiteralExpr keyLiteralExpr = (LiteralExpr) expr;
         Literal keyLiteral = keyLiteralExpr.getValue();
         if (keyLiteral.getLiteralType() != Literal.Type.STRING) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                    "Expected Literal can only be of type %1$s", Literal.Type.STRING);
+            throw new CompilationException(ErrorCode.PARSE_ERROR, "Expected Literal can only be of type %1$s",
+                    Literal.Type.STRING);
         }
         return keyLiteral;
     }
 
     private static void parseList(ListConstructor valueExpr, ArrayBackedValueStorage serialized)
-            throws HyracksDataException {
+            throws CompilationException, HyracksDataException {
         if (valueExpr.getType() != ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                    "JSON List can't be of type %1$s", valueExpr.getType());
+            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "JSON List can't be of type %1$s",
+                    valueExpr.getType());
         }
         ArrayBackedValueStorage serializedValue = new ArrayBackedValueStorage();
         OrderedListBuilder listBuilder = new OrderedListBuilder();
@@ -187,13 +189,12 @@ public class LangRecordParseUtil {
                 stringSerde.serialize(new AString((String) value.getValue()), serialized.getDataOutput());
                 break;
             default:
-                throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                        "Unknown Literal Type %1$s", value.getLiteralType());
+                throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "Unknown Literal Type %1$s",
+                        value.getLiteralType());
         }
     }
 
-    public static void recordToMap(Map<String, String> map, ARecord record)
-            throws AlgebricksException {
+    public static void recordToMap(Map<String, String> map, ARecord record) throws AlgebricksException {
         String[] keys = record.getType().getFieldNames();
         for (int i = 0; i < keys.length; i++) {
             String key = keys[i];

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/MergePolicyUtils.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/MergePolicyUtils.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/MergePolicyUtils.java
new file mode 100644
index 0000000..6bb5c36
--- /dev/null
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/MergePolicyUtils.java
@@ -0,0 +1,67 @@
+/*
+ * 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.asterix.lang.common.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.object.base.AdmObjectNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
+
+public class MergePolicyUtils {
+    public static final String MERGE_POLICY_PARAMETER_NAME = "merge-policy";
+    public static final String MERGE_POLICY_NAME_PARAMETER_NAME = "name";
+    public static final String MERGE_POLICY_PARAMETERS_PARAMETER_NAME = "parameters";
+
+    private MergePolicyUtils() {
+    }
+
+    /**
+     * Convert the parameters object to a Map<String,String>
+     * This method should go away once we store the with object as it is in storage
+     *
+     * @param parameters
+     *            the parameters passed for the merge policy in the with clause
+     * @return the parameters as a map
+     */
+    public static Map<String, String> toProperties(AdmObjectNode parameters) throws CompilationException {
+        Map<String, String> map = new HashMap<>();
+        for (Entry<String, IAdmNode> field : parameters.getFields()) {
+            IAdmNode value = field.getValue();
+            switch (value.getType()) {
+                case BOOLEAN:
+                case DOUBLE:
+                case BIGINT:
+                    map.put(field.getKey(), value.toString());
+                    break;
+                case STRING:
+                    map.put(field.getKey(), ((AdmStringNode) value).get());
+                    break;
+                default:
+                    throw new CompilationException(ErrorCode.MERGE_POLICY_PARAMETER_INVALID_TYPE, value.getType());
+            }
+        }
+        return map;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
index 21a4b76..ea81865 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
@@ -109,8 +109,8 @@ public class FormatPrintVisitor implements ILangVisitor<Void, Integer> {
     private final static String FEED = " feed ";
     private final static String DEFAULT_DATAVERSE_FORMAT = "org.apache.asterix.runtime.formats.NonTaggedDataFormat";
     protected final PrintWriter out;
-    protected Set<Character> validIdentifierChars = new HashSet<Character>();
-    protected Set<Character> validIdentifierStartChars = new HashSet<Character>();
+    protected Set<Character> validIdentifierChars = new HashSet<>();
+    protected Set<Character> validIdentifierStartChars = new HashSet<>();
     protected String dataverseSymbol = " dataverse ";
     protected String datasetSymbol = " dataset ";
     protected String assignSymbol = ":=";
@@ -361,7 +361,7 @@ public class FormatPrintVisitor implements ILangVisitor<Void, Integer> {
     @Override
     public Void visit(FunctionDecl fd, Integer step) throws CompilationException {
         out.print(skip(step) + "declare function " + generateFullName(null, fd.getSignature().getName()) + "(");
-        List<Identifier> parameters = new ArrayList<Identifier>();
+        List<Identifier> parameters = new ArrayList<>();
         parameters.addAll(fd.getParamList());
         printDelimitedIdentifiers(parameters, COMMA);
         out.println(") {");
@@ -492,13 +492,6 @@ public class FormatPrintVisitor implements ILangVisitor<Void, Integer> {
             out.print(" hints ");
             printProperties(hints);
         }
-        if (dd.getCompactionPolicy() != null) {
-            out.print(" using compaction policy " + revertStringToQuoted(dd.getCompactionPolicy()));
-            Map<String, String> compactionPolicyProperties = dd.getCompactionPolicyProperties();
-            if (compactionPolicyProperties != null && compactionPolicyProperties.size() > 0) {
-                printConfiguration(compactionPolicyProperties);
-            }
-        }
         if (dd.getDatasetType() == DatasetType.INTERNAL) {
             List<String> filterField = ((InternalDetailsDecl) dd.getDatasetDetailsDecl()).getFilterField();
             if (filterField != null && filterField.size() > 0) {
@@ -506,6 +499,10 @@ public class FormatPrintVisitor implements ILangVisitor<Void, Integer> {
                 printNestField(filterField);
             }
         }
+        if (dd.getWithObjectNode() != null) {
+            out.print(" with ");
+            out.print(dd.getWithObjectNode().toString());
+        }
         out.println(SEMICOLON);
         out.println();
         return null;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index 7ac8c57..c5d6d26 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -493,16 +493,15 @@ DatasetDecl DatasetSpecification() throws ParseException:
   Pair<Identifier,Identifier> typeComponents = null;
   String adapterName = null;
   Map<String,String> properties = null;
-  Map<String,String> compactionPolicyProperties = null;
   FunctionSignature appliedFunction = null;
   Pair<List<Integer>, List<List<String>>> primaryKeyFields = null;
   String nodeGroupName = null;
   Map<String,String> hints = new HashMap<String,String>();
   DatasetDecl dsetDecl = null;
   boolean autogenerated = false;
-  String compactionPolicy = null;
   Pair<Integer, List<String>> filterField = null;
   Pair<Identifier,Identifier> metaTypeComponents = new Pair<Identifier, Identifier>(null, null);
+  RecordConstructor withRecord = null;
 }
 {
   (
@@ -510,13 +509,14 @@ DatasetDecl DatasetSpecification() throws ParseException:
     <LEFTPAREN> typeComponents = TypeName() <RIGHTPAREN>
     ifNotExists = IfNotExists()
     <USING> adapterName = AdapterName() properties = Configuration()
-    (<ON> nodeGroupName = Identifier() )?
+    ( <ON> nodeGroupName = Identifier() )?
     ( <HINTS> hints = Properties() )?
-    ( <USING> <COMPACTION> <POLICY> compactionPolicy = CompactionPolicy() (LOOKAHEAD(1) compactionPolicyProperties = Configuration())? )?
+    ( <WITH> withRecord = RecordConstructor() )?
       {
         ExternalDetailsDecl edd = new ExternalDetailsDecl();
         edd.setAdapter(adapterName);
         edd.setProperties(properties);
+        try{
         dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
                                    typeComponents.first,
@@ -524,12 +524,14 @@ DatasetDecl DatasetSpecification() throws ParseException:
                                    metaTypeComponents.first,
                                    metaTypeComponents.second,
                                    nodeGroupName != null? new Identifier(nodeGroupName): null,
-                                   compactionPolicy,
-                                   compactionPolicyProperties,
                                    hints,
                                    DatasetType.EXTERNAL,
                                    edd,
+                                   withRecord,
                                    ifNotExists);
+        } catch (CompilationException e){
+           throw new ParseException(e.getMessage());
+        }
       }
 
     | ( <INTERNAL> )?
@@ -551,8 +553,8 @@ DatasetDecl DatasetSpecification() throws ParseException:
     (<AUTOGENERATED> { autogenerated = true; } )?
     (<ON> nodeGroupName = Identifier() )?
     ( <HINTS> hints = Properties() )?
-    ( <USING> <COMPACTION> <POLICY> compactionPolicy = CompactionPolicy() (LOOKAHEAD(1) compactionPolicyProperties = Configuration())? )?
     ( LOOKAHEAD(2) <WITH> <FILTER> <ON>  filterField = NestedField() )?
+    ( <WITH> withRecord = RecordConstructor() )?
       {
         if(filterField!=null && filterField.first!=0){
           throw new ParseException("A filter field can only be a field in the main record of the dataset.");
@@ -561,6 +563,7 @@ DatasetDecl DatasetSpecification() throws ParseException:
                                                           primaryKeyFields.first,
                                                           autogenerated,
                                                           filterField == null? null : filterField.second);
+        try{
         dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
                                    typeComponents.first,
@@ -568,12 +571,14 @@ DatasetDecl DatasetSpecification() throws ParseException:
                                    metaTypeComponents.first,
                                    metaTypeComponents.second,
                                    nodeGroupName != null ? new Identifier(nodeGroupName) : null,
-                                   compactionPolicy,
-                                   compactionPolicyProperties,
                                    hints,
                                    DatasetType.INTERNAL,
                                    idd,
+                                   withRecord,
                                    ifNotExists);
+        } catch (CompilationException e){
+           throw new ParseException(e.getMessage());
+        }
       }
   )
     {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
new file mode 100644
index 0000000..e489cd5
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
@@ -0,0 +1,77 @@
+/*
+ * 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.asterix.object.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmArrayNode implements IAdmNode {
+    private final List<IAdmNode> children;
+
+    public AdmArrayNode() {
+        children = new ArrayList<>();
+    }
+
+    public AdmArrayNode(int initialCapacity) {
+        children = new ArrayList<>(initialCapacity);
+    }
+
+    public IAdmNode set(int index, boolean value) {
+        return set(index, AdmBooleanNode.get(value));
+    }
+
+    public void add(boolean value) {
+        add(AdmBooleanNode.get(value));
+    }
+
+    public void add(IAdmNode value) {
+        if (value == null) {
+            value = AdmNullNode.INSTANCE; // NOSONAR
+        }
+        children.add(value);
+    }
+
+    public IAdmNode set(int index, IAdmNode value) {
+        if (value == null) {
+            value = AdmNullNode.INSTANCE; // NOSONAR
+        }
+        return children.set(index, value);
+    }
+
+    public IAdmNode get(int index) {
+        return children.get(index);
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.ARRAY;
+    }
+
+    @Override
+    public void reset() {
+        children.clear();
+    }
+
+    @Override
+    public String toString() {
+        return children.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
new file mode 100644
index 0000000..0006668
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
@@ -0,0 +1,55 @@
+/*
+ * 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.asterix.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmBigIntNode implements IAdmNode {
+    private long value;
+
+    public AdmBigIntNode() {
+    }
+
+    public AdmBigIntNode(long value) {
+        this.value = value;
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.BIGINT;
+    }
+
+    public void set(long value) {
+        this.value = value;
+    }
+
+    public long get() {
+        return value;
+    }
+
+    @Override
+    public void reset() {
+        value = 0;
+    }
+
+    @Override
+    public String toString() {
+        return Long.toString(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
new file mode 100644
index 0000000..aeebd86
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
@@ -0,0 +1,59 @@
+/*
+ * 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.asterix.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmBooleanNode implements IAdmNode {
+
+    public static final AdmBooleanNode TRUE = new AdmBooleanNode(true);
+    public static final AdmBooleanNode FALSE = new AdmBooleanNode(false);
+    private final boolean value;
+
+    private AdmBooleanNode(boolean value) {
+        this.value = value;
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.BOOLEAN;
+    }
+
+    public boolean get() {
+        return value;
+    }
+
+    @Override
+    public void reset() {
+        // Nothing to do
+    }
+
+    public static AdmBooleanNode get(boolean value) {
+        return value ? TRUE : FALSE;
+    }
+
+    public static AdmBooleanNode get(Boolean value) {
+        return value.booleanValue() ? TRUE : FALSE;
+    }
+
+    @Override
+    public String toString() {
+        return Boolean.toString(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
new file mode 100644
index 0000000..0150b4e
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
@@ -0,0 +1,56 @@
+/*
+ * 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.asterix.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmDoubleNode implements IAdmNode {
+    private double value;
+
+    public AdmDoubleNode() {
+
+    }
+
+    public AdmDoubleNode(double value) {
+        this.value = value;
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.DOUBLE;
+    }
+
+    public void set(double value) {
+        this.value = value;
+    }
+
+    public double get() {
+        return value;
+    }
+
+    @Override
+    public void reset() {
+        value = 0;
+    }
+
+    @Override
+    public String toString() {
+        return Double.toString(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
new file mode 100644
index 0000000..2804ca3
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
@@ -0,0 +1,44 @@
+/*
+ * 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.asterix.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmNullNode implements IAdmNode {
+
+    public static final AdmNullNode INSTANCE = new AdmNullNode();
+
+    private AdmNullNode() {
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.NULL;
+    }
+
+    @Override
+    public void reset() {
+        // Nothing to reset
+    }
+
+    @Override
+    public String toString() {
+        return "null";
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
new file mode 100644
index 0000000..e35b28f
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
@@ -0,0 +1,95 @@
+/*
+ * 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.asterix.object.base;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+/**
+ * An adm object instance
+ */
+public class AdmObjectNode implements IAdmNode {
+    private final Map<String, IAdmNode> children;
+
+    public AdmObjectNode() {
+        children = new HashMap<>();
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.OBJECT;
+    }
+
+    public int size() {
+        return children.size();
+    }
+
+    public IAdmNode get(String fieldName) {
+        return children.get(fieldName);
+    }
+
+    public Set<String> getFieldNames() {
+        return children.keySet();
+    }
+
+    public Set<Entry<String, IAdmNode>> getFields() {
+        return children.entrySet();
+    }
+
+    public AdmObjectNode set(String fieldName, IAdmNode value) {
+        if (value == null) {
+            value = AdmNullNode.INSTANCE; // NOSONAR
+        }
+        children.put(fieldName, value);
+        return this;
+    }
+
+    public IAdmNode remove(String fieldName) {
+        return children.remove(fieldName);
+    }
+
+    @Override
+    public void reset() {
+        children.clear();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("{");
+        int count = 0;
+        for (Map.Entry<String, IAdmNode> en : children.entrySet()) {
+            if (count > 0) {
+                sb.append(",");
+            }
+            ++count;
+            sb.append('"');
+            sb.append(en.getKey());
+            sb.append('"');
+            sb.append(':');
+            sb.append(en.getValue().toString());
+        }
+        sb.append("}");
+        return sb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
new file mode 100644
index 0000000..4c92f09
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
@@ -0,0 +1,52 @@
+/*
+ * 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.asterix.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmStringNode implements IAdmNode {
+    private String value;
+
+    public AdmStringNode() {
+    }
+
+    public AdmStringNode(String value) {
+        this.value = value;
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.STRING;
+    }
+
+    public String get() {
+        return value;
+    }
+
+    @Override
+    public void reset() {
+        value = null;
+    }
+
+    @Override
+    public String toString() {
+        return "\"" + value + "\"";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f3aa19fb/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
new file mode 100644
index 0000000..c382fd2
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
@@ -0,0 +1,65 @@
+/*
+ * 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.asterix.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+/**
+ * An interface representing an adm node
+ */
+public interface IAdmNode {
+
+    /**
+     * @return true if the object is a value, false if the object is a container
+     */
+    default boolean isValueNode() {
+        switch (getType()) {
+            case ARRAY:
+            case OBJECT:
+            case MULTISET:
+                return false;
+            default:
+                return true;
+        }
+    }
+
+    /**
+     * @return true if the object is an array, false otherwise
+     */
+    default boolean isArray() {
+        return getType() == ATypeTag.ARRAY;
+    }
+
+    /**
+     * @return true if the object is an adm object, false otherwise
+     */
+    default boolean isObject() {
+        return getType() == ATypeTag.OBJECT;
+    }
+
+    /**
+     * @return the type tag of the object
+     */
+    ATypeTag getType();
+
+    /**
+     * reset the node
+     */
+    void reset();
+}


Mime
View raw message