You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by am...@apache.org on 2016/03/16 00:36:22 UTC

[06/19] incubator-asterixdb git commit: Support Change Feeds and Ingestion of Records with MetaData

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java b/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java
index 50d8ac0..c9fc5fc 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java
@@ -19,20 +19,21 @@
 package org.apache.asterix.external.util;
 
 import java.io.File;
-import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.asterix.common.cluster.ClusterPartition;
+import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.common.utils.StoragePathUtil;
 import org.apache.asterix.om.util.AsterixClusterProperties;
 import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
 import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
 import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint.PartitionConstraintType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.api.comm.FrameHelper;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.io.FileReference;
 import org.apache.hyracks.api.io.IIOManager;
 import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
@@ -57,9 +58,9 @@ public class FeedUtils {
     }
 
     public static FileSplit[] splitsForAdapter(String dataverseName, String feedName,
-            AlgebricksPartitionConstraint partitionConstraints) throws Exception {
+            AlgebricksPartitionConstraint partitionConstraints) throws AsterixException {
         if (partitionConstraints.getPartitionConstraintType() == PartitionConstraintType.COUNT) {
-            throw new AlgebricksException("Can't create file splits for adapter with count partitioning constraints");
+            throw new AsterixException("Can't create file splits for adapter with count partitioning constraints");
         }
         File relPathFile = new File(prepareDataverseFeedName(dataverseName, feedName));
         String[] locations = null;
@@ -86,7 +87,7 @@ public class FeedUtils {
     }
 
     public static FeedLogManager getFeedLogManager(IHyracksTaskContext ctx, int partition,
-            FileSplit[] feedLogFileSplits) throws IOException {
+            FileSplit[] feedLogFileSplits) throws HyracksDataException {
         return new FeedLogManager(
                 FeedUtils.getAbsoluteFileRef(feedLogFileSplits[partition].getLocalFile().getFile().getPath(),
                         feedLogFileSplits[partition].getIODeviceId(), ctx.getIOManager()).getFile());
@@ -103,4 +104,13 @@ public class FeedUtils {
         message.flip();
         IntSerDeUtils.putInt(input.array(), FrameHelper.getTupleCountOffset(input.capacity()), tc);
     }
+
+    public static int getNumOfFields(Map<String, String> configuration) {
+        return 1;
+    }
+
+    public static String getFeedMetaTypeName(Map<String, String> configuration) {
+        return configuration.get(ExternalDataConstants.KEY_META_TYPE_NAME);
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java b/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
index 2e3b8ec..386a8cf 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
@@ -41,7 +41,7 @@ import org.apache.log4j.Logger;
 
 public class FileSystemWatcher {
 
-    private static Logger LOGGER = Logger.getLogger(FileSystemWatcher.class.getName());
+    private static final Logger LOGGER = Logger.getLogger(FileSystemWatcher.class.getName());
     private final WatchService watcher;
     private final HashMap<WatchKey, Path> keys;
     private final LinkedList<File> files = new LinkedList<File>();
@@ -54,28 +54,36 @@ public class FileSystemWatcher {
     private File current;
     private AbstractFeedDataFlowController controller;
 
-    public FileSystemWatcher(Path inputResource, String expression, boolean isFeed) throws IOException {
-        this.watcher = isFeed ? FileSystems.getDefault().newWatchService() : null;
-        this.keys = isFeed ? new HashMap<WatchKey, Path>() : null;
-        this.expression = expression;
-        this.path = inputResource;
-        this.isFeed = isFeed;
+    public FileSystemWatcher(Path inputResource, String expression, boolean isFeed) throws HyracksDataException {
+        try {
+            this.watcher = isFeed ? FileSystems.getDefault().newWatchService() : null;
+            this.keys = isFeed ? new HashMap<WatchKey, Path>() : null;
+            this.expression = expression;
+            this.path = inputResource;
+            this.isFeed = isFeed;
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
+        }
     }
 
     public void setFeedLogManager(FeedLogManager feedLogManager) {
         this.logManager = feedLogManager;
     }
 
-    public void init() throws IOException {
-        LinkedList<Path> dirs = null;
-        dirs = new LinkedList<Path>();
-        LocalFileSystemUtils.traverse(files, path.toFile(), expression, dirs);
-        it = files.iterator();
-        if (isFeed) {
-            for (Path path : dirs) {
-                register(path);
+    public void init() throws HyracksDataException {
+        try {
+            LinkedList<Path> dirs = null;
+            dirs = new LinkedList<Path>();
+            LocalFileSystemUtils.traverse(files, path.toFile(), expression, dirs);
+            it = files.iterator();
+            if (isFeed) {
+                for (Path path : dirs) {
+                    register(path);
+                }
+                resume();
             }
-            resume();
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
         }
     }
 
@@ -178,7 +186,7 @@ public class FileSystemWatcher {
     }
 
     public File next() throws IOException {
-        if (current != null && logManager != null) {
+        if ((current != null) && (logManager != null)) {
             logManager.startPartition(current.getAbsolutePath());
             logManager.endPartition();
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java b/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
index 9a72135..84ccc35 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
@@ -178,7 +178,7 @@ public class HDFSUtils {
         }
     }
 
-    public static JobConf configureHDFSJobConf(Map<String, String> configuration) throws Exception {
+    public static JobConf configureHDFSJobConf(Map<String, String> configuration) {
         JobConf conf = new JobConf();
 
         String localShortCircuitSocketPath = configuration.get(ExternalDataConstants.KEY_LOCAL_SOCKET_PATH);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/main/java/org/apache/asterix/external/util/TweetGenerator.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/util/TweetGenerator.java b/asterix-external-data/src/main/java/org/apache/asterix/external/util/TweetGenerator.java
index 3670368..b86c170 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/util/TweetGenerator.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/util/TweetGenerator.java
@@ -32,8 +32,7 @@ import org.apache.asterix.external.util.DataGenerator.TweetMessage;
 import org.apache.asterix.external.util.DataGenerator.TweetMessageIterator;
 
 public class TweetGenerator {
-
-    private static Logger LOGGER = Logger.getLogger(TweetGenerator.class.getName());
+    private static final Logger LOGGER = Logger.getLogger(TweetGenerator.class.getName());
 
     public static final String KEY_DURATION = "duration";
     public static final String KEY_TPS = "tps";
@@ -43,20 +42,20 @@ public class TweetGenerator {
 
     private static final int DEFAULT_DURATION = INFINITY;
 
-    private int duration;
+    private final int duration;
     private TweetMessageIterator tweetIterator = null;
-    private int partition;
+    private final int partition;
     private long tweetCount = 0;
     private int frameTweetCount = 0;
     private int numFlushedTweets = 0;
     private DataGenerator dataGenerator = null;
-    private ByteBuffer outputBuffer = ByteBuffer.allocate(32 * 1024);
-    private String[] fields;
+    private final ByteBuffer outputBuffer = ByteBuffer.allocate(32 * 1024);
+    private final String[] fields;
     private final List<OutputStream> subscribers;
     private final Object lock = new Object();
     private final List<OutputStream> subscribersForRemoval = new ArrayList<OutputStream>();
 
-    public TweetGenerator(Map<String, String> configuration, int partition) throws Exception {
+    public TweetGenerator(Map<String, String> configuration, int partition) {
         this.partition = partition;
         String value = configuration.get(KEY_DURATION);
         this.duration = value != null ? Integer.parseInt(value) : DEFAULT_DURATION;
@@ -70,7 +69,7 @@ public class TweetGenerator {
         String tweet = tweetMessage.getAdmEquivalent(fields) + "\n";
         tweetCount++;
         byte[] b = tweet.getBytes();
-        if (outputBuffer.position() + b.length > outputBuffer.limit()) {
+        if ((outputBuffer.position() + b.length) > outputBuffer.limit()) {
             flush();
             numFlushedTweets += frameTweetCount;
             frameTweetCount = 0;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java
index 97ebd6c..1eca7e1 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java
@@ -535,7 +535,8 @@ public class BuiltinClassAdFunctions {
                 } else if (time_arg.isRelativeTimeValue()) {
                     result.setErrorValue();
                 } else if (time_arg.isAbsoluteTimeValue(time_components)) {
-                } else if (!time_arg.isClassAdValue(splitClassAd) /*doSplitTime(time_arg, splitClassAd)*/) {
+                } else if (!time_arg
+                        .isClassAdValue(splitClassAd) /* doSplitTime(time_arg, splitClassAd) */) {
                     result.setErrorValue();
                 } else {
                     if (!splitClassAd.evaluateAttrInt("Seconds", int64)) {
@@ -1863,7 +1864,7 @@ public class BuiltinClassAdFunctions {
                 result.setErrorValue();
                 return false;
             }
-            ClassAdParser parser = new ClassAdParser();
+            ClassAdParser parser = new ClassAdParser(null, false, true, false, null, null, null);
             ExprTreeHolder expr = new ExprTreeHolder();
             try {
                 if (!parser.parseExpression(s.toString(), expr, true) || (expr.getInnerTree() == null)) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAd.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAd.java b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAd.java
index 431fa0c..df6ae0d 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAd.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAd.java
@@ -33,7 +33,6 @@ import org.apache.asterix.om.base.AMutableDouble;
 import org.apache.asterix.om.base.AMutableInt32;
 import org.apache.asterix.om.base.AMutableInt64;
 import org.apache.asterix.om.base.AMutableString;
-import org.apache.asterix.om.types.ARecordType;
 import org.apache.commons.lang3.mutable.MutableBoolean;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 
@@ -117,17 +116,13 @@ public class ClassAd extends ExprTree {
     private ClassAd newAd = null;
 
     /*
-     *  Constructors
+     * Constructors
      */
     public ClassAd() {
         chainedParentAd = null;
         alternateScope = null;
         newAd = new ClassAd(false, false);
-        parser = new ClassAdParser();
-    }
-
-    public void configure(Map<String, String> configuration, ARecordType recordType) throws IOException {
-        parser.configure(configuration, recordType);
+        parser = new ClassAdParser(null, false, true, false, null, null, null);
     }
 
     public ClassAd(boolean initializeParser, boolean initializeNewAd) {
@@ -137,7 +132,7 @@ public class ClassAd extends ExprTree {
             newAd = new ClassAd(false, false);
         }
         if (initializeParser) {
-            parser = new ClassAdParser();
+            parser = new ClassAdParser(null, false, true, false, null, null, null);
         }
     }
 
@@ -194,15 +189,18 @@ public class ClassAd extends ExprTree {
 
     //public TreeSet<CaseInsensitiveString> dirtyAttrList = new TreeSet<CaseInsensitiveString>();
 
-    /* Reference is an ordered set of Strings <The ordering uses less than ignore case>. Example below
-     *  TreeSet<String> references = new TreeSet<String>(
-     *        new Comparator<String>(){
-     *            public int compare(String o1, String o2) {
-     *    return o1.compareToIgnoreCase(o2);
-     *    }
-     *            });
+    /*
+     * Reference is an ordered set of Strings <The ordering uses less than ignore case>. Example
+     * below
+     * TreeSet<String> references = new TreeSet<String>(
+     * new Comparator<String>(){
+     * public int compare(String o1, String o2) {
+     * return o1.compareToIgnoreCase(o2);
+     * }
+     * });
      *
-     // PortReferences is a Map<ClassAd,OrderedSet<Strings>> */
+     * // PortReferences is a Map<ClassAd,OrderedSet<Strings>>
+     */
 
     public boolean copyFrom(ClassAd ad) throws HyracksDataException {
 
@@ -555,10 +553,12 @@ public class ClassAd extends ExprTree {
     }
 
     public ExprTree lookup(CaseInsensitiveString name) {
-        /*System.out.println("Lookup Printing all attributes with their values:");
-        for (Entry<String, ExprTree> entry : attrList.entrySet()) {
-            System.out.println(entry.getKey() + ":" + entry.getValue().getKind());
-        }*/
+        /*
+         * System.out.println("Lookup Printing all attributes with their values:");
+         * for (Entry<String, ExprTree> entry : attrList.entrySet()) {
+         * System.out.println(entry.getKey() + ":" + entry.getValue().getKind());
+         * }
+         */
         ExprTree attr = attrList.get(name);
         if (attr != null) {
             return attr;
@@ -861,7 +861,7 @@ public class ClassAd extends ExprTree {
     public boolean evaluateExpr(String buf, Value result) throws HyracksDataException {
         boolean successfully_evaluated;
         ExprTreeHolder tree = new ExprTreeHolder();
-        ClassAdParser parser = new ClassAdParser();
+        ClassAdParser parser = new ClassAdParser(null, false, true, false, null, null, null);
 
         try {
             if (parser.parseExpression(buf, tree)) {
@@ -927,15 +927,18 @@ public class ClassAd extends ExprTree {
         return (evaluateAttr(attr, val) && val.isBooleanValueEquiv(b));
     }
 
-    /* Reference is an ordered set of Strings <The ordering uses less than ignore case>. Example below
-     *  TreeSet<String> references = new TreeSet<String>(
-     *        new Comparator<String>(){
-     *            public int compare(String o1, String o2) {
-     *    return o1.compareToIgnoreCase(o2);
-     *    }
-     *            });
+    /*
+     * Reference is an ordered set of Strings <The ordering uses less than ignore case>. Example
+     * below
+     * TreeSet<String> references = new TreeSet<String>(
+     * new Comparator<String>(){
+     * public int compare(String o1, String o2) {
+     * return o1.compareToIgnoreCase(o2);
+     * }
+     * });
      *
-     // PortReferences is a Map<ClassAd,OrderedSet<Strings>> */
+     * // PortReferences is a Map<ClassAd,OrderedSet<Strings>>
+     */
 
     public boolean getExternalReferences(ExprTree tree, TreeSet<String> refs, boolean fullNames)
             throws HyracksDataException {
@@ -1256,15 +1259,18 @@ public class ClassAd extends ExprTree {
         }
     }
 
-    /* Reference is an ordered set of Strings <The ordering uses less than ignore case>. Example below
-     *  TreeSet<String> references = new TreeSet<String>(
-     *        new Comparator<String>(){
-     *            public int compare(String o1, String o2) {
-     *    return o1.compareToIgnoreCase(o2);
-     *    }
-     *            });
+    /*
+     * Reference is an ordered set of Strings <The ordering uses less than ignore case>. Example
+     * below
+     * TreeSet<String> references = new TreeSet<String>(
+     * new Comparator<String>(){
+     * public int compare(String o1, String o2) {
+     * return o1.compareToIgnoreCase(o2);
+     * }
+     * });
      *
-     // PortReferences is a Map<ClassAd,OrderedSet<Strings>> */
+     * // PortReferences is a Map<ClassAd,OrderedSet<Strings>>
+     */
     public boolean getInternalReferences(ExprTree tree, TreeSet<String> refs, boolean fullNames)
             throws HyracksDataException {
         EvalState state = new EvalState();
@@ -1560,6 +1566,6 @@ public class ClassAd extends ExprTree {
     }
 
     public void createParser() {
-        parser = new ClassAdParser();
+        parser = new ClassAdParser(null, false, true, false, null, null, null);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdParserTest.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdParserTest.java b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdParserTest.java
index b0e0925..1c135f5 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdParserTest.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdParserTest.java
@@ -50,7 +50,7 @@ public class ClassAdParserTest extends TestCase {
     /**
      *
      */
-    public void testApp() {
+    public void test() {
         try {
             // test here
             ClassAd pAd = new ClassAd();

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java
index 926c40e..57b0dcd 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java
@@ -19,7 +19,6 @@
 package org.apache.asterix.external.classad.test;
 
 import java.nio.file.Paths;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -32,7 +31,6 @@ import org.apache.asterix.external.classad.Value;
 import org.apache.asterix.external.input.record.reader.stream.SemiStructuredRecordReader;
 import org.apache.asterix.external.input.stream.LocalFileSystemInputStream;
 import org.apache.asterix.external.library.ClassAdParser;
-import org.apache.asterix.external.util.ExternalDataConstants;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -59,27 +57,19 @@ public class ClassAdToADMTest extends TestCase {
     /**
      *
      */
-    public void testApp() {
+    public void test() {
         try {
             // test here
             ClassAd pAd = new ClassAd();
             String[] files = new String[] { "/jobads.txt" };
-            ClassAdParser parser = new ClassAdParser();
+            ClassAdParser parser = new ClassAdParser(null, false, true, false, null, null, null);
             CharArrayLexerSource lexerSource = new CharArrayLexerSource();
             for (String path : files) {
-                SemiStructuredRecordReader recordReader = new SemiStructuredRecordReader();
-                HashMap<String, String> configuration = new HashMap<String, String>();
-                configuration.put(ExternalDataConstants.KEY_RECORD_START, "[");
-                configuration.put(ExternalDataConstants.KEY_RECORD_END, "]");
-                recordReader.configure(configuration);
                 LocalFileSystemInputStream in = new LocalFileSystemInputStream(
                         Paths.get(getClass().getResource(path).toURI()), null, false);
-                in.configure(configuration);
-                recordReader.setInputStream(in);
+                SemiStructuredRecordReader recordReader = new SemiStructuredRecordReader(in, null, "[", "]");
                 Value val = new Value();
-                int i = 0;
                 while (recordReader.hasNext()) {
-                    i++;
                     val.clear();
                     IRawRecord<char[]> record = recordReader.next();
                     lexerSource.setNewSource(record.get());

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTest.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTest.java b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTest.java
index f972f45..b9f32f5 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTest.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTest.java
@@ -48,7 +48,7 @@ public class ClassAdUnitTest extends TestCase {
     /**
      * Rigourous Test :-)
      */
-    public void testApp() {
+    public void test() {
         String[] args = { "", "-d", "-vv", "-all" };
         try {
             ClassAdUnitTester.test(args.length, args);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java
index 5b1e0b5..cec9299 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java
@@ -273,7 +273,7 @@ public class ClassAdUnitTester {
      * @throws IOException
      *********************************************************************/
     public static void testParsing(Parameters parameters, Results results) throws IOException {
-        ClassAdParser parser = new ClassAdParser();
+        ClassAdParser parser = new ClassAdParser(null, false, true, false, null, null, null);
         ExprTree tree;
 
         // My goal is to ensure that these expressions don't crash
@@ -316,7 +316,7 @@ public class ClassAdUnitTester {
      * @throws IOException
      *********************************************************************/
     public static void testClassad(Parameters parameters, Results results) throws IOException {
-        ClassAdParser parser = new ClassAdParser();
+        ClassAdParser parser = new ClassAdParser(null, false, true, false, null, null, null);
         boolean haveAttribute;
         boolean success;
 
@@ -574,7 +574,7 @@ public class ClassAdUnitTester {
 
         /* ----- Test an ExprList bug that Nate Mueller found ----- */
         ClassAd classad;
-        ClassAdParser parser = new ClassAdParser();
+        ClassAdParser parser = new ClassAdParser(null, false, true, false, null, null, null);
         MutableBoolean b = new MutableBoolean();
         boolean haveAttribute;
         boolean canEvaluate;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/FunctionalTester.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/FunctionalTester.java b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/FunctionalTester.java
index f4cf9db..c9ce47c 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/FunctionalTester.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/FunctionalTester.java
@@ -909,7 +909,7 @@ public class FunctionalTester {
     public static ExprTree get_expr(AMutableString line, State state, Parameters parameters) throws IOException {
         int offset;
         ExprTree tree;
-        ClassAdParser parser = new ClassAdParser();
+        ClassAdParser parser = new ClassAdParser(null, false, true, false, null, null, null);
         StringLexerSource lexer_source = new StringLexerSource(line.getStringValue());
 
         tree = parser.parseExpression(lexer_source, false);
@@ -932,7 +932,7 @@ public class FunctionalTester {
     public static void get_two_exprs(AMutableString line, ExprTreeHolder tree1, ExprTreeHolder tree2, State state,
             Parameters parameters) throws IOException {
         int offset;
-        ClassAdParser parser = new ClassAdParser();
+        ClassAdParser parser = new ClassAdParser(null, false, true, false, null, null, null);
         StringLexerSource lexer_source = new StringLexerSource(line.getStringValue());
 
         tree1.setInnerTree(parser.parseExpression(lexer_source, false));

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/generator/test/DCPGeneratorTest.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/generator/test/DCPGeneratorTest.java b/asterix-external-data/src/test/java/org/apache/asterix/external/generator/test/DCPGeneratorTest.java
new file mode 100644
index 0000000..14b6ed1
--- /dev/null
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/generator/test/DCPGeneratorTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.external.generator.test;
+
+import org.apache.asterix.external.api.IRawRecord;
+import org.apache.asterix.external.input.record.RecordWithMetadataAndPK;
+import org.apache.asterix.external.input.record.converter.DCPRequestToRecordWithMetadataAndPKConverter;
+import org.apache.asterix.external.input.record.reader.kv.KVTestReader;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
+import org.junit.Test;
+
+import com.couchbase.client.core.message.dcp.DCPRequest;
+
+public class DCPGeneratorTest {
+
+    @Test
+    public void runTest() throws Exception {
+        try (KVTestReader cbreader = new KVTestReader(0, "TestBucket",
+                new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, 150, 0, 0)) {
+            final UTF8StringPointable pointable = new UTF8StringPointable();
+            final DCPRequestToRecordWithMetadataAndPKConverter converter = new DCPRequestToRecordWithMetadataAndPKConverter();
+            while (cbreader.hasNext()) {
+                final IRawRecord<DCPRequest> dcp = cbreader.next();
+                final RecordWithMetadataAndPK<char[]> record = converter.convert(dcp);
+                if (record.getRecord().size() == 0) {
+                    pointable.set(record.getMetadata(0).getByteArray(), 1, record.getMetadata(0).getLength());
+                } else {
+                    pointable.set(record.getMetadata(0).getByteArray(), 1, record.getMetadata(0).getLength());
+                }
+            }
+        } catch (final Throwable th) {
+            System.err.println("TEST FAILED");
+            th.printStackTrace();
+            throw th;
+        }
+        System.err.println("TEST PASSED.");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java b/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
index 2882083..d6db6c2 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
@@ -35,7 +35,6 @@ import org.apache.asterix.builders.OrderedListBuilder;
 import org.apache.asterix.builders.RecordBuilderFactory;
 import org.apache.asterix.builders.UnorderedListBuilder;
 import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.external.api.IExternalDataSourceFactory.DataSourceType;
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.external.classad.AMutableCharArrayString;
@@ -70,8 +69,6 @@ import org.apache.asterix.external.classad.object.pool.OperationPool;
 import org.apache.asterix.external.classad.object.pool.TokenValuePool;
 import org.apache.asterix.external.classad.object.pool.ValuePool;
 import org.apache.asterix.external.parser.AbstractDataParser;
-import org.apache.asterix.external.util.ExternalDataConstants;
-import org.apache.asterix.external.util.ExternalDataUtils;
 import org.apache.asterix.om.base.ABoolean;
 import org.apache.asterix.om.base.AMutableInt32;
 import org.apache.asterix.om.types.AOrderedListType;
@@ -124,14 +121,20 @@ public class ClassAdParser extends AbstractDataParser implements IRecordDataPars
     private boolean oldFormat = false;
     private StringLexerSource stringLexerSource = new StringLexerSource("");
 
-    public ClassAdParser(ARecordType recordType) {
+    public ClassAdParser(ARecordType recordType, boolean oldFormat, boolean evaluateExpr, boolean keepBoth,
+            String exprPrefix, String exprSuffix, String exprFieldNameSuffix) {
         this.recordType = recordType;
         this.currentSource = new CharArrayLexerSource();
-    }
-
-    public ClassAdParser() {
-        this.recordType = null;
-        this.currentSource = new CharArrayLexerSource();
+        this.recordType = recordType;
+        this.oldFormat = oldFormat;
+        if (oldFormat) {
+            rootAd.createParser();
+        }
+        this.keepBoth = keepBoth;
+        this.evaluateExpr = evaluateExpr;
+        this.exprPrefix = exprPrefix;
+        this.exprSuffix = exprSuffix;
+        this.exprFieldNameSuffix = exprFieldNameSuffix;
     }
 
     /***********************************
@@ -565,7 +568,6 @@ public class ClassAdParser extends AbstractDataParser implements IRecordDataPars
     }
 
     private String mismatchErrorMessage = "Mismatch Type, expecting a value of type ";
-    private Map<String, String> configuration;
 
     private boolean checkType(ATypeTag expectedTypeTag, IAType aObjectType) throws IOException {
         return getTargetTypeTag(expectedTypeTag, aObjectType) != null;
@@ -1695,55 +1697,6 @@ public class ClassAdParser extends AbstractDataParser implements IRecordDataPars
     }
 
     @Override
-    public DataSourceType getDataSourceType() {
-        return ExternalDataUtils.isDataSourceStreamProvider(configuration) ? DataSourceType.STREAM
-                : DataSourceType.RECORDS;
-    }
-
-    @Override
-    public void configure(Map<String, String> configuration, ARecordType recordType) throws IOException {
-        this.recordType = recordType;
-        this.configuration = configuration;
-        String parserConfig = configuration.get(ClassAdParserFactory.KEY_OLD_FORMAT);
-        if (parserConfig != null && parserConfig.equalsIgnoreCase(ExternalDataConstants.TRUE)) {
-            oldFormat = true;
-            rootAd.createParser();
-        }
-        parserConfig = configuration.get(ExternalDataConstants.KEY_READER);
-        if (parserConfig != null && parserConfig.equalsIgnoreCase(ExternalDataConstants.READER_LINE_SEPARATED)) {
-            oldFormat = true;
-            rootAd.createParser();
-        }
-
-        parserConfig = configuration.get(ClassAdParserFactory.KEY_EVALUATE);
-        if (parserConfig != null && parserConfig.equalsIgnoreCase("false")) {
-            evaluateExpr = false;
-            keepBoth = false;
-        }
-        parserConfig = configuration.get(ClassAdParserFactory.KEY_KEEP_EXPR);
-        if (parserConfig != null && parserConfig.equalsIgnoreCase("false")) {
-            keepBoth = false;
-            evaluateExpr = true;
-        }
-        parserConfig = configuration.get(ClassAdParserFactory.KEY_EXPR_PREFIX);
-        if (parserConfig != null && parserConfig.trim().length() > 0) {
-            exprPrefix = parserConfig;
-        }
-        parserConfig = configuration.get(ClassAdParserFactory.KEY_EXPR_SUFFIX);
-        if (parserConfig != null && parserConfig.trim().length() > 0) {
-            exprSuffix = parserConfig;
-        }
-        parserConfig = configuration.get(ClassAdParserFactory.KEY_EXPR_NAME_SUFFIX);
-        if (parserConfig != null && parserConfig.trim().length() > 0) {
-            exprFieldNameSuffix = parserConfig;
-        }
-        if (!oldFormat) {
-            configuration.put(ExternalDataConstants.KEY_RECORD_START, "[");
-            configuration.put(ExternalDataConstants.KEY_RECORD_END, "]");
-        }
-    }
-
-    @Override
     public void parse(IRawRecord<? extends char[]> record, DataOutput out) throws IOException {
         try {
             if (oldFormat) {
@@ -1775,9 +1728,4 @@ public class ClassAdParser extends AbstractDataParser implements IRecordDataPars
             throw new HyracksDataException(e);
         }
     }
-
-    @Override
-    public Class<? extends char[]> getRecordClass() {
-        return char[].class;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParserFactory.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParserFactory.java b/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParserFactory.java
index 97982df..5064992 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParserFactory.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParserFactory.java
@@ -19,10 +19,10 @@
 package org.apache.asterix.external.library;
 
 import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.Map;
 
-import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.external.api.IExternalDataSourceFactory.DataSourceType;
 import org.apache.asterix.external.api.IRecordDataParser;
 import org.apache.asterix.external.api.IRecordDataParserFactory;
 import org.apache.asterix.external.util.ExternalDataConstants;
@@ -39,37 +39,36 @@ public class ClassAdParserFactory implements IRecordDataParserFactory<char[]> {
     public static final String KEY_EXPR_PREFIX = "expr-prefix";
     public static final String KEY_EXPR_SUFFIX = "expr-suffix";
     public static final String KEY_EXPR_NAME_SUFFIX = "expr-name-suffix";
-
     private ARecordType recordType;
     private Map<String, String> configuration;
     private boolean oldFormat = false;
+    private boolean evaluateExpr = true;
+    private boolean keepBoth;
+    private String exprPrefix;
+    private String exprSuffix;
+    private String exprFieldNameSuffix;
 
-    private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
+    private void writeObject(ObjectOutputStream stream) throws IOException {
         stream.writeObject(recordType);
         stream.writeObject(configuration);
     }
 
     @SuppressWarnings("unchecked")
-    private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
+    private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
         recordType = (ARecordType) stream.readObject();
         configuration = (Map<String, String>) stream.readObject();
     }
 
     @Override
-    public DataSourceType getDataSourceType() throws AsterixException {
-        return DataSourceType.RECORDS;
-    }
-
-    @Override
-    public void configure(Map<String, String> configuration) throws Exception {
+    public void configure(Map<String, String> configuration) {
         this.configuration = configuration;
         // is old format?
         String parserConfig = configuration.get(KEY_OLD_FORMAT);
-        if (parserConfig != null && parserConfig.equalsIgnoreCase(ExternalDataConstants.TRUE)) {
+        if ((parserConfig != null) && parserConfig.equalsIgnoreCase(ExternalDataConstants.TRUE)) {
             oldFormat = true;
         }
-        parserConfig = configuration.get(ExternalDataConstants.KEY_READER);
-        if (parserConfig != null && parserConfig.equalsIgnoreCase(ExternalDataConstants.READER_LINE_SEPARATED)) {
+        parserConfig = configuration.get(ExternalDataConstants.KEY_FORMAT);
+        if ((parserConfig != null) && parserConfig.equalsIgnoreCase(ExternalDataConstants.FORMAT_LINE_SEPARATED)) {
             oldFormat = true;
         }
         if (!oldFormat) {
@@ -77,6 +76,30 @@ public class ClassAdParserFactory implements IRecordDataParserFactory<char[]> {
             configuration.put(ExternalDataConstants.KEY_RECORD_END, "]");
         }
 
+        parserConfig = configuration.get(ClassAdParserFactory.KEY_EVALUATE);
+        if ((parserConfig != null) && parserConfig.equalsIgnoreCase("false")) {
+            evaluateExpr = false;
+            keepBoth = false;
+        }
+        parserConfig = configuration.get(ClassAdParserFactory.KEY_KEEP_EXPR);
+        if ((parserConfig != null) && parserConfig.equalsIgnoreCase("false")) {
+            keepBoth = false;
+            evaluateExpr = true;
+        }
+
+        parserConfig = configuration.get(ClassAdParserFactory.KEY_EXPR_PREFIX);
+        if ((parserConfig != null) && (parserConfig.trim().length() > 0)) {
+            exprPrefix = parserConfig;
+        }
+        parserConfig = configuration.get(ClassAdParserFactory.KEY_EXPR_SUFFIX);
+        if ((parserConfig != null) && (parserConfig.trim().length() > 0)) {
+            exprSuffix = parserConfig;
+        }
+
+        parserConfig = configuration.get(ClassAdParserFactory.KEY_EXPR_NAME_SUFFIX);
+        if ((parserConfig != null) && (parserConfig.trim().length() > 0)) {
+            exprFieldNameSuffix = parserConfig;
+        }
     }
 
     @Override
@@ -85,11 +108,9 @@ public class ClassAdParserFactory implements IRecordDataParserFactory<char[]> {
     }
 
     @Override
-    public IRecordDataParser<char[]> createRecordParser(IHyracksTaskContext ctx)
-            throws HyracksDataException, AsterixException, IOException {
-        ClassAdParser parser = new ClassAdParser(recordType);
-        parser.configure(configuration, recordType);
-        return parser;
+    public IRecordDataParser<char[]> createRecordParser(IHyracksTaskContext ctx) throws HyracksDataException {
+        return new ClassAdParser(recordType, oldFormat, evaluateExpr, keepBoth, exprPrefix, exprSuffix,
+                exprFieldNameSuffix);
     }
 
     @Override
@@ -97,4 +118,8 @@ public class ClassAdParserFactory implements IRecordDataParserFactory<char[]> {
         return char[].class;
     }
 
+    @Override
+    public void setMetaType(ARecordType metaType) {
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapter.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapter.java b/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapter.java
index 2fc289b..c362969 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapter.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapter.java
@@ -28,15 +28,16 @@ import java.util.concurrent.Executors;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.asterix.external.api.IFeedAdapter;
+import org.apache.asterix.external.dataset.adapter.FeedAdapter;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.api.comm.IFrameWriter;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.std.file.ITupleParser;
 import org.apache.hyracks.dataflow.std.file.ITupleParserFactory;
 
-public class TestTypedAdapter implements IFeedAdapter {
+public class TestTypedAdapter extends FeedAdapter {
 
     private static final long serialVersionUID = 1L;
 
@@ -56,6 +57,7 @@ public class TestTypedAdapter implements IFeedAdapter {
 
     public TestTypedAdapter(ITupleParserFactory parserFactory, ARecordType sourceDatatype, IHyracksTaskContext ctx,
             Map<String, String> configuration, int partition) throws IOException {
+        super(null);
         pos = new PipedOutputStream();
         pis = new PipedInputStream(pos);
         this.configuration = configuration;
@@ -64,7 +66,7 @@ public class TestTypedAdapter implements IFeedAdapter {
     }
 
     @Override
-    public void start(int partition, IFrameWriter writer) throws Exception {
+    public void start(int partition, IFrameWriter writer) throws HyracksDataException {
         generator = new DummyGenerator(configuration, pos);
         ExecutorService executor = Executors.newSingleThreadExecutor();
         executor.execute(generator);
@@ -137,7 +139,7 @@ public class TestTypedAdapter implements IFeedAdapter {
     }
 
     @Override
-    public boolean stop() throws Exception {
+    public boolean stop() {
         generator.stop();
         return true;
     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapterFactory.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapterFactory.java b/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapterFactory.java
index 6b11d21..9082a72 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapterFactory.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/library/adapter/TestTypedAdapterFactory.java
@@ -18,9 +18,11 @@
  */
 package org.apache.asterix.external.library.adapter;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.external.api.IAdapterFactory;
 import org.apache.asterix.external.api.IDataSourceAdapter;
 import org.apache.asterix.external.api.IExternalDataSourceFactory;
@@ -56,29 +58,28 @@ public class TestTypedAdapterFactory implements IAdapterFactory {
     }
 
     @Override
-    public AlgebricksAbsolutePartitionConstraint getPartitionConstraint() throws Exception {
+    public AlgebricksAbsolutePartitionConstraint getPartitionConstraint() throws AsterixException {
         clusterLocations = IExternalDataSourceFactory.getPartitionConstraints(clusterLocations, 1);
         return clusterLocations;
     }
 
     @Override
-    public IDataSourceAdapter createAdapter(IHyracksTaskContext ctx, int partition) throws Exception {
+    public IDataSourceAdapter createAdapter(IHyracksTaskContext ctx, int partition) throws HyracksDataException {
         final String nodeId = ctx.getJobletContext().getApplicationContext().getNodeId();
-        ITupleParserFactory tupleParserFactory = new ITupleParserFactory() {
+        final ITupleParserFactory tupleParserFactory = new ITupleParserFactory() {
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ITupleParser createTupleParser(final IHyracksTaskContext ctx) throws HyracksDataException {
+            public ITupleParser createTupleParser(IHyracksTaskContext ctx) throws HyracksDataException {
                 ADMDataParser parser;
                 ITupleForwarder forwarder;
                 ArrayTupleBuilder tb;
                 try {
-                    parser = new ADMDataParser();
+                    parser = new ADMDataParser(outputType, true);
                     forwarder = DataflowUtils.getTupleForwarder(configuration,
                             FeedUtils.getFeedLogManager(ctx, partition,
                                     FeedUtils.splitsForAdapter(ExternalDataUtils.getDataverse(configuration),
                                             ExternalDataUtils.getFeedName(configuration), nodeId, partition)));
-                    forwarder.configure(configuration);
                     tb = new ArrayTupleBuilder(1);
                 } catch (Exception e) {
                     throw new HyracksDataException(e);
@@ -88,7 +89,6 @@ public class TestTypedAdapterFactory implements IAdapterFactory {
                     @Override
                     public void parse(InputStream in, IFrameWriter writer) throws HyracksDataException {
                         try {
-                            parser.configure(configuration, outputType);
                             parser.setInputStream(in);
                             forwarder.initialize(ctx, writer);
                             while (true) {
@@ -107,7 +107,11 @@ public class TestTypedAdapterFactory implements IAdapterFactory {
                 };
             }
         };
-        return new TestTypedAdapter(tupleParserFactory, outputType, ctx, configuration, partition);
+        try {
+            return new TestTypedAdapter(tupleParserFactory, outputType, ctx, configuration, partition);
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
+        }
     }
 
     @Override
@@ -116,9 +120,8 @@ public class TestTypedAdapterFactory implements IAdapterFactory {
     }
 
     @Override
-    public void configure(Map<String, String> configuration, ARecordType outputType) throws Exception {
+    public void configure(Map<String, String> configuration, ARecordType outputType, ARecordType metaType) {
         this.configuration = configuration;
         this.outputType = outputType;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ADMDataParserTest.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ADMDataParserTest.java b/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ADMDataParserTest.java
index 4303442..6f36eab 100644
--- a/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ADMDataParserTest.java
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/ADMDataParserTest.java
@@ -21,6 +21,7 @@ package org.apache.asterix.external.parser.test;
 import java.io.ByteArrayOutputStream;
 import java.io.DataOutput;
 import java.io.DataOutputStream;
+import java.io.IOException;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.asterix.external.parser.ADMDataParser;
@@ -35,7 +36,7 @@ import junit.extensions.PA;
 public class ADMDataParserTest {
 
     @Test
-    public void test() {
+    public void test() throws IOException {
         String[] dates = { "-9537-08-04", "9656-06-03", "-9537-04-04", "9656-06-04", "-9537-10-04", "9626-09-05" };
         AMutableDate[] parsedDates = new AMutableDate[] { new AMutableDate(-4202630), new AMutableDate(2807408),
                 new AMutableDate(-4202752), new AMutableDate(2807409), new AMutableDate(-4202569),
@@ -58,7 +59,7 @@ public class ADMDataParserTest {
         AtomicInteger errorCount = new AtomicInteger(0);
         for (int i = 0; i < threads.length; ++i) {
             threads[i] = new Thread(new Runnable() {
-                ADMDataParser parser = new ADMDataParser();
+                ADMDataParser parser = new ADMDataParser(null, true);
                 ByteArrayOutputStream bos = new ByteArrayOutputStream();
                 DataOutput dos = new DataOutputStream(bos);
 
@@ -69,16 +70,16 @@ public class ADMDataParserTest {
                         while (round++ < 10000) {
                             // Test parseDate.
                             for (int index = 0; index < dates.length; ++index) {
-                                PA.invokeMethod(parser, "parseDate(java.lang.String, java.io.DataOutput)",
-                                        dates[index], dos);
+                                PA.invokeMethod(parser, "parseDate(java.lang.String, java.io.DataOutput)", dates[index],
+                                        dos);
                                 AMutableDate aDate = (AMutableDate) PA.getValue(parser, "aDate");
                                 Assert.assertTrue(aDate.equals(parsedDates[index]));
                             }
 
                             // Tests parseTime.
                             for (int index = 0; index < times.length; ++index) {
-                                PA.invokeMethod(parser, "parseTime(java.lang.String, java.io.DataOutput)",
-                                        times[index], dos);
+                                PA.invokeMethod(parser, "parseTime(java.lang.String, java.io.DataOutput)", times[index],
+                                        dos);
                                 AMutableTime aTime = (AMutableTime) PA.getValue(parser, "aTime");
                                 Assert.assertTrue(aTime.equals(parsedTimes[index]));
                             }
@@ -112,5 +113,4 @@ public class ADMDataParserTest {
         // Asserts no failure.
         Assert.assertTrue(errorCount.get() == 0);
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/d3338f66/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/RecordWithMetaTest.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/RecordWithMetaTest.java b/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/RecordWithMetaTest.java
new file mode 100644
index 0000000..521cee0
--- /dev/null
+++ b/asterix-external-data/src/test/java/org/apache/asterix/external/parser/test/RecordWithMetaTest.java
@@ -0,0 +1,149 @@
+/*
+ * 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.external.parser.test;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.asterix.external.api.IRawRecord;
+import org.apache.asterix.external.input.record.converter.CSVToRecordWithMetadataAndPKConverter;
+import org.apache.asterix.external.input.record.reader.stream.QuotedLineRecordReader;
+import org.apache.asterix.external.input.stream.LocalFileSystemInputStream;
+import org.apache.asterix.external.parser.ADMDataParser;
+import org.apache.asterix.external.parser.RecordWithMetadataParser;
+import org.apache.asterix.external.util.ExternalDataConstants;
+import org.apache.asterix.formats.nontagged.AqlADMPrinterFactoryProvider;
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.commons.io.FileUtils;
+import org.apache.hyracks.algebricks.data.IPrinter;
+import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class RecordWithMetaTest {
+    private static ARecordType recordType;
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    @Test
+    public void runTest() throws Exception {
+        File file = new File("target/beer.adm");
+        File expected = new File(getClass().getResource("/results/beer.txt").toURI().getPath());
+        try {
+            FileUtils.deleteQuietly(file);
+            PrintStream printStream = new PrintStream(Files.newOutputStream(Paths.get(file.toURI())));
+            // create key type
+            IAType[] keyTypes = { BuiltinType.ASTRING };
+            String keyName = "id";
+            List<String> keyNameAsList = new ArrayList<>(1);
+            keyNameAsList.add(keyName);
+            // create record type
+            String[] recordFieldNames = {};
+            IAType[] recordFieldTypes = {};
+            recordType = new ARecordType("value", recordFieldNames, recordFieldTypes, true);
+            // create the meta type
+            String[] metaFieldNames = { keyName, "flags", "expiration", "cas", "rev", "vbid", "dtype" };
+            IAType[] metaFieldTypes = { BuiltinType.ASTRING, BuiltinType.AINT32, BuiltinType.AINT64, BuiltinType.AINT64,
+                    BuiltinType.AINT32, BuiltinType.AINT32, BuiltinType.AINT32 };
+            ARecordType metaType = new ARecordType("meta", metaFieldNames, metaFieldTypes, true);
+            int valueIndex = 4;
+            char delimiter = ',';
+            int numOfTupleFields = 3;
+            int[] pkIndexes = { 0 };
+            int[] pkIndicators = { 1 };
+
+            // create input stream
+            LocalFileSystemInputStream inputStream = new LocalFileSystemInputStream(
+                    Paths.get(getClass().getResource("/beer.csv").toURI()).toAbsolutePath(), null, false);
+
+            // create reader record reader
+            QuotedLineRecordReader lineReader = new QuotedLineRecordReader(true, inputStream, null,
+                    ExternalDataConstants.DEFAULT_QUOTE);
+            // create csv with json record reader
+            CSVToRecordWithMetadataAndPKConverter recordConverter = new CSVToRecordWithMetadataAndPKConverter(
+                    valueIndex, delimiter, metaType, recordType, pkIndicators, pkIndexes, keyTypes);
+            // create the value parser <ADM in this case>
+            ADMDataParser valueParser = new ADMDataParser(recordType, false);
+            // create parser.
+            RecordWithMetadataParser parser = new RecordWithMetadataParser(metaType, valueParser, recordConverter);
+
+            // create serializer deserializer and printer factories
+            ISerializerDeserializer[] serdes = new ISerializerDeserializer[keyTypes.length + 2];
+            IPrinterFactory[] printerFactories = new IPrinterFactory[keyTypes.length + 2];
+            for (int i = 0; i < keyTypes.length; i++) {
+                serdes[i + 2] = AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(keyTypes[i]);
+                printerFactories[i + 2] = AqlADMPrinterFactoryProvider.INSTANCE.getPrinterFactory(keyTypes[i]);
+            }
+            serdes[0] = AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(recordType);
+            serdes[1] = AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(metaType);
+            printerFactories[0] = AqlADMPrinterFactoryProvider.INSTANCE.getPrinterFactory(recordType);
+            printerFactories[1] = AqlADMPrinterFactoryProvider.INSTANCE.getPrinterFactory(metaType);
+            // create output descriptor 
+            IPrinter[] printers = new IPrinter[printerFactories.length];
+
+            for (int i = 0; i < printerFactories.length; i++) {
+                printers[i] = printerFactories[i].createPrinter();
+            }
+
+            ArrayTupleBuilder tb = new ArrayTupleBuilder(numOfTupleFields);
+            while (lineReader.hasNext()) {
+                IRawRecord<char[]> record = lineReader.next();
+                tb.reset();
+                parser.parse(record, tb.getDataOutput());
+                tb.addFieldEndOffset();
+                parser.parseMeta(tb.getDataOutput());
+                tb.addFieldEndOffset();
+                parser.appendPK(tb);
+                //print tuple
+                printTuple(tb, printers, printStream);
+
+            }
+            lineReader.close();
+            printStream.close();
+            Assert.assertTrue(FileUtils.contentEquals(file, expected));
+        } catch (Throwable th) {
+            System.err.println("TEST FAILED");
+            th.printStackTrace();
+            throw th;
+        } finally {
+            FileUtils.deleteQuietly(file);
+        }
+        System.err.println("TEST PASSED.");
+    }
+
+    private void printTuple(ArrayTupleBuilder tb, IPrinter[] printers, PrintStream printStream)
+            throws HyracksDataException {
+        int[] offsets = tb.getFieldEndOffsets();
+        for (int i = 0; i < printers.length; i++) {
+            int offset = i == 0 ? 0 : offsets[i - 1];
+            int length = i == 0 ? offsets[0] : offsets[i] - offsets[i - 1];
+            printers[i].print(tb.getByteArray(), offset, length, printStream);
+            printStream.println();
+        }
+    }
+}