Repository: lens
Updated Branches:
  refs/heads/master d1c58cbcf -> 6995962fd


LENS-1008 : Support simple iterator over HTTPResultSet for lens clients


Project: http://git-wip-us.apache.org/repos/asf/lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/6995962f
Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/6995962f
Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/6995962f

Branch: refs/heads/master
Commit: 6995962fd9386f54fa69f5a3598714bdf439ee91
Parents: d1c58cb
Author: Puneet Gupta <[email protected]>
Authored: Wed Apr 27 19:05:13 2016 +0530
Committer: Amareshwari Sriramadasu <[email protected]>
Committed: Wed Apr 27 19:05:13 2016 +0530

----------------------------------------------------------------------
 lens-client/pom.xml                             |  44 +++++
 .../java/org/apache/lens/client/LensClient.java |  59 ++++++
 .../org/apache/lens/client/LensConnection.java  |  15 ++
 .../exceptions/LensClientIOException.java       |  33 ++++
 .../client/resultset/AbstractResultSet.java     | 102 +++++++++++
 .../lens/client/resultset/CsvResultSet.java     |  38 ++++
 .../client/resultset/CsvResultSetReader.java    |  57 ++++++
 .../apache/lens/client/resultset/ResultSet.java |  46 +++++
 .../lens/client/resultset/ResultSetReader.java  |  36 ++++
 .../client/resultset/ZippedCsvResultSet.java    |  38 ++++
 .../resultset/ZippedCsvResultSetReader.java     |  37 ++++
 .../client/resultset/ZippedResultSetReader.java |  92 ++++++++++
 .../org/apache/lens/client/TestLensClient.java  | 178 +++++++++++++++++--
 .../src/test/resources/dim2-part/data.data      |   3 +
 lens-client/src/test/resources/dim_table.xml    |  48 +++++
 lens-client/src/test/resources/fact1.xml        |  51 ++++++
 .../src/test/resources/lens-client-site.xml     |  11 ++
 .../src/test/resources/local-storage.xml        |  27 +++
 lens-client/src/test/resources/sample-cube.xml  |  76 ++++++++
 lens-client/src/test/resources/test-detail.xml  |  32 ++++
 .../src/test/resources/test-dimension.xml       |  61 +++++++
 21 files changed, 1070 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/pom.xml
----------------------------------------------------------------------
diff --git a/lens-client/pom.xml b/lens-client/pom.xml
index 4fd01fb..2032cf5 100644
--- a/lens-client/pom.xml
+++ b/lens-client/pom.xml
@@ -27,6 +27,10 @@
     <version>2.6.0-beta-SNAPSHOT</version>
   </parent>
 
+  <properties>
+    <mvn.classpath.file>${pom.basedir}/target/classpath</mvn.classpath.file>
+  </properties>
+
   <artifactId>lens-client</artifactId>
   <packaging>jar</packaging>
   <name>Lens client</name>
@@ -142,5 +146,45 @@
       <groupId>org.slf4j</groupId>
       <artifactId>jcl-over-slf4j</artifactId>
     </dependency>
+    <dependency>
+      <groupId>net.sf.opencsv</groupId>
+      <artifactId>opencsv</artifactId>
+    </dependency>
   </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>build-classpath</id>
+            <phase>compile</phase>
+            <goals>
+              <goal>build-classpath</goal>
+            </goals>
+            <configuration>
+              <outputFile>${mvn.classpath.file}</outputFile>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- to use hadoop in the testutils -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <systemPropertyVariables>
+            
<hadoop.bin.path>${pom.basedir}/../lens-driver-hive/testutils/hadoop</hadoop.bin.path>
+          </systemPropertyVariables>
+          <environmentVariables>
+            <MVN_CLASSPATH_FILE>${mvn.classpath.file}</MVN_CLASSPATH_FILE>
+          </environmentVariables>
+          <argLine>-Xms256m -Xmx512m -XX:PermSize=256m 
-XX:MaxPermSize=256m</argLine>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/LensClient.java
----------------------------------------------------------------------
diff --git a/lens-client/src/main/java/org/apache/lens/client/LensClient.java 
b/lens-client/src/main/java/org/apache/lens/client/LensClient.java
index 9626820..43da691 100644
--- a/lens-client/src/main/java/org/apache/lens/client/LensClient.java
+++ b/lens-client/src/main/java/org/apache/lens/client/LensClient.java
@@ -18,9 +18,12 @@
  */
 package org.apache.lens.client;
 
+import java.io.InputStream;
+import java.nio.charset.Charset;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.ws.rs.core.Response;
 
@@ -31,9 +34,13 @@ import org.apache.lens.api.result.LensAPIResult;
 import org.apache.lens.api.util.PathValidator;
 import org.apache.lens.client.exceptions.LensAPIException;
 import org.apache.lens.client.exceptions.LensBriefErrorException;
+import org.apache.lens.client.exceptions.LensClientIOException;
 import org.apache.lens.client.model.BriefError;
 import org.apache.lens.client.model.IdBriefErrorTemplate;
 import org.apache.lens.client.model.IdBriefErrorTemplateKey;
+import org.apache.lens.client.resultset.CsvResultSet;
+import org.apache.lens.client.resultset.ResultSet;
+import org.apache.lens.client.resultset.ZippedCsvResultSet;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,6 +71,14 @@ public class LensClient {
   @Getter
   private PathValidator pathValidator;
 
+  public static final String QUERY_RESULT_SPLIT_INTO_MULTIPLE = 
"lens.query.result.split.multiple";
+
+  public static final String QUERY_OUTPUT_WRITE_HEADER_ENABLED = 
"lens.query.output.write.header";
+
+  public static final String QUERY_OUTPUT_ENCODING = 
"lens.query.output.charset.encoding";
+
+  public static final char DEFAULT_RESULTSET_DELIMITER = ',';
+
   public static Logger getCliLogger() {
     return LoggerFactory.getLogger(CLILOGGER);
   }
@@ -212,6 +227,50 @@ public class LensClient {
     return statement.getHttpResultSet(statement.getQuery(q));
   }
 
+  /**
+   * Gets the ResultSet for the query represented by queryHandle.
+   *
+   * @param queryHandle : query hanlde
+   * @return
+   * @throws LensClientIOException
+   */
+  public ResultSet getHttpResultSet(QueryHandle queryHandle) throws 
LensClientIOException {
+    Map<String, String> paramsMap = this.connection.getConnectionParamsAsMap();
+    String isSplitFileEnabled = 
paramsMap.get(QUERY_RESULT_SPLIT_INTO_MULTIPLE);
+    String isHeaderEnabled = paramsMap.get(QUERY_OUTPUT_WRITE_HEADER_ENABLED);
+    String encoding = paramsMap.get(QUERY_OUTPUT_ENCODING);
+    return getHttpResultSet(queryHandle, Charset.forName(encoding), 
Boolean.parseBoolean(isHeaderEnabled),
+      DEFAULT_RESULTSET_DELIMITER, Boolean.parseBoolean(isSplitFileEnabled));
+  }
+
+  /**
+   * Gets the ResultSet for the query represented by queryHandle.
+   *
+   * @param queryHandle : query handle.
+   * @param encoding  : resultset encoding.
+   * @param isHeaderPresent : whether the resultset has header row included.
+   * @param delimiter : delimiter used to seperate columns of resultset.
+   * @param isResultZipped : whether the resultset is zipped.
+   * @return
+   * @throws LensClientIOException
+   */
+  public ResultSet getHttpResultSet(QueryHandle queryHandle, Charset encoding, 
boolean isHeaderPresent, char delimiter,
+    boolean isResultZipped) throws LensClientIOException {
+    InputStream resultStream = null;
+    try {
+      Response response = 
statement.getHttpResultSet(statement.getQuery(queryHandle));
+      resultStream = response.readEntity(InputStream.class);
+    } catch (Exception e) {
+      throw new LensClientIOException("Error while getting resultset", e);
+    }
+
+    if (isResultZipped) {
+      return new ZippedCsvResultSet(resultStream, encoding, isHeaderPresent, 
delimiter);
+    } else {
+      return new CsvResultSet(resultStream, encoding, isHeaderPresent, 
delimiter);
+    }
+  }
+
   public LensStatement getLensStatement(QueryHandle query) {
     return this.statementMap.get(query);
   }

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/LensConnection.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/LensConnection.java 
b/lens-client/src/main/java/org/apache/lens/client/LensConnection.java
index d67e64e..0c2557c 100644
--- a/lens-client/src/main/java/org/apache/lens/client/LensConnection.java
+++ b/lens-client/src/main/java/org/apache/lens/client/LensConnection.java
@@ -19,8 +19,10 @@
 package org.apache.lens.client;
 
 import java.net.ConnectException;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.ws.rs.ProcessingException;
@@ -311,6 +313,19 @@ public class LensConnection {
     return value.getElements();
   }
 
+  public Map<String, String> getConnectionParamsAsMap() {
+    List<String> params = getConnectionParams();
+    Map<String, String> paramsMap = new HashMap<String, String>(params.size());
+    String[] paramKeyAndValue;
+    for (String param : params) {
+      paramKeyAndValue = param.split("=");
+      if (paramKeyAndValue.length == 2) {
+        paramsMap.put(paramKeyAndValue[0], paramKeyAndValue[1]);
+      }
+    }
+    return paramsMap;
+  }
+
   public LensConnectionParams getLensConnectionParams() {
     return this.params;
   }

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/exceptions/LensClientIOException.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/exceptions/LensClientIOException.java
 
b/lens-client/src/main/java/org/apache/lens/client/exceptions/LensClientIOException.java
new file mode 100644
index 0000000..139cb7e
--- /dev/null
+++ 
b/lens-client/src/main/java/org/apache/lens/client/exceptions/LensClientIOException.java
@@ -0,0 +1,33 @@
+/**
+ * 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.lens.client.exceptions;
+
+import java.io.IOException;
+
+public class LensClientIOException extends IOException {
+
+  public LensClientIOException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public LensClientIOException(String message) {
+    super(message);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/resultset/AbstractResultSet.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/resultset/AbstractResultSet.java
 
b/lens-client/src/main/java/org/apache/lens/client/resultset/AbstractResultSet.java
new file mode 100644
index 0000000..4110e7e
--- /dev/null
+++ 
b/lens-client/src/main/java/org/apache/lens/client/resultset/AbstractResultSet.java
@@ -0,0 +1,102 @@
+/**
+ * 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.lens.client.resultset;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+
+import org.apache.lens.client.exceptions.LensClientIOException;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public abstract class AbstractResultSet implements ResultSet {
+
+  @Getter
+  private InputStream inStream;
+  @Getter
+  private Charset encoding;
+  @Getter
+  private char delimiter;
+  @Getter
+  private boolean isHeaderRowPresent;
+
+  protected ResultSetReader reader;
+  protected int totalRowsRead;
+  protected String[] columnNames;
+
+  public AbstractResultSet(InputStream inStream, Charset encoding, boolean 
isHeaderRowPresent, char delimiter)
+    throws LensClientIOException {
+    this.inStream = inStream;
+    this.encoding = encoding;
+    this.isHeaderRowPresent = isHeaderRowPresent;
+    this.delimiter = delimiter;
+    init();
+  }
+
+  protected void init() throws LensClientIOException {
+    reader = createResultSetReader();
+    if (isHeaderRowPresent && reader.next()) {
+      columnNames = reader.getRow();
+      log.info("Resultset column names : " + Arrays.asList(columnNames));
+    }
+  }
+
+  /**
+   * Creates a reader which be used for reading rows of resultset.
+   */
+  protected abstract ResultSetReader createResultSetReader() throws 
LensClientIOException;
+
+  @Override
+  public String[] getColumnNames() throws LensClientIOException {
+    return columnNames;
+  }
+
+  @Override
+  public boolean next() throws LensClientIOException {
+    boolean hasNext = reader.next();
+    if (hasNext) {
+      totalRowsRead++;
+    } else {
+      close();
+    }
+    return hasNext;
+  }
+
+  @Override
+  public String[] getRow() throws LensClientIOException {
+    return reader.getRow();
+  }
+
+  /**
+   * Called after the last row form the result set is read.
+   */
+  protected void close() throws LensClientIOException {
+    log.info("Total rows from resultset : " + totalRowsRead);
+    try {
+      inStream.close();
+    } catch (IOException e) {
+      log.error("Error while closing result stream", e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/resultset/CsvResultSet.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/resultset/CsvResultSet.java 
b/lens-client/src/main/java/org/apache/lens/client/resultset/CsvResultSet.java
new file mode 100644
index 0000000..2a986ec
--- /dev/null
+++ 
b/lens-client/src/main/java/org/apache/lens/client/resultset/CsvResultSet.java
@@ -0,0 +1,38 @@
+/**
+ * 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.lens.client.resultset;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.lens.client.exceptions.LensClientIOException;
+
+public class CsvResultSet extends AbstractResultSet {
+
+  public CsvResultSet(InputStream in, Charset encoding, boolean 
isHeaderRowPresent, char delimiter)
+    throws LensClientIOException {
+    super(in, encoding, isHeaderRowPresent, delimiter);
+  }
+
+  @Override
+  protected ResultSetReader createResultSetReader() throws 
LensClientIOException {
+    return new CsvResultSetReader(getInStream(), getEncoding(), 
getDelimiter());
+  }
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/resultset/CsvResultSetReader.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/resultset/CsvResultSetReader.java
 
b/lens-client/src/main/java/org/apache/lens/client/resultset/CsvResultSetReader.java
new file mode 100644
index 0000000..ca31d0a
--- /dev/null
+++ 
b/lens-client/src/main/java/org/apache/lens/client/resultset/CsvResultSetReader.java
@@ -0,0 +1,57 @@
+/**
+ * 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.lens.client.resultset;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+
+import org.apache.lens.client.exceptions.LensClientIOException;
+
+import au.com.bytecode.opencsv.CSVReader;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class CsvResultSetReader implements ResultSetReader {
+
+  CSVReader reader;
+  String[] nextLine;
+
+  CsvResultSetReader(InputStream is, Charset encoding, char delimiter) {
+    reader = new CSVReader(new InputStreamReader(is, encoding), delimiter);
+  }
+
+  @Override
+  public String[] getRow() {
+    return nextLine;
+  }
+
+  @Override
+  public boolean next() throws LensClientIOException {
+    try {
+      nextLine = reader.readNext();
+    } catch (IOException e) {
+      log.error("Error while reading result set row", e);
+      throw new LensClientIOException("Error while reading result set row", e);
+    }
+    return nextLine != null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/resultset/ResultSet.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/resultset/ResultSet.java 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ResultSet.java
new file mode 100644
index 0000000..7c70595
--- /dev/null
+++ b/lens-client/src/main/java/org/apache/lens/client/resultset/ResultSet.java
@@ -0,0 +1,46 @@
+/**
+ * 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.lens.client.resultset;
+
+import org.apache.lens.client.exceptions.LensClientIOException;
+
+/**
+ * This interface represents the query ResultSet that the clients can iterate 
over
+ */
+public interface ResultSet{
+
+  /**
+   * Returns true if next row is present in result set and moves the cursor to 
that row.
+   *
+   * @throws LensClientIOException
+   */
+  boolean next() throws LensClientIOException;
+
+  /**
+   * @return column values for the current row
+   */
+  String[] getRow() throws LensClientIOException;
+
+  /**
+   * Returns the column names for this result set if available otherwise null 
is returned
+   * @throws LensClientIOException
+   */
+  String[] getColumnNames() throws LensClientIOException;
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/resultset/ResultSetReader.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/resultset/ResultSetReader.java
 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ResultSetReader.java
new file mode 100644
index 0000000..da4db67
--- /dev/null
+++ 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ResultSetReader.java
@@ -0,0 +1,36 @@
+/**
+ * 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.lens.client.resultset;
+
+import org.apache.lens.client.exceptions.LensClientIOException;
+
+public interface ResultSetReader {
+  /**
+   * Returns column values for the current row.
+   * @throws LensClientIOException
+   */
+  String[] getRow() throws LensClientIOException;
+
+  /**
+   * Returns true if next row is present in result set and moves the cursor to 
that row.
+   * @throws LensClientIOException
+   */
+  boolean next() throws LensClientIOException;
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedCsvResultSet.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedCsvResultSet.java
 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedCsvResultSet.java
new file mode 100644
index 0000000..17e4f87
--- /dev/null
+++ 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedCsvResultSet.java
@@ -0,0 +1,38 @@
+/**
+ * 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.lens.client.resultset;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.lens.client.exceptions.LensClientIOException;
+
+public class ZippedCsvResultSet extends AbstractResultSet{
+
+  public ZippedCsvResultSet(InputStream inStream, Charset encoding, boolean 
isHeaderRowPresent, char delimiter)
+    throws LensClientIOException {
+    super(inStream, encoding, isHeaderRowPresent, delimiter);
+  }
+
+  @Override
+  protected ResultSetReader createResultSetReader() throws 
LensClientIOException {
+    return new ZippedCsvResultSetReader(getInStream(), getEncoding(), 
getDelimiter(), isHeaderRowPresent());
+  }
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedCsvResultSetReader.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedCsvResultSetReader.java
 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedCsvResultSetReader.java
new file mode 100644
index 0000000..1474b90
--- /dev/null
+++ 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedCsvResultSetReader.java
@@ -0,0 +1,37 @@
+/**
+ * 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.lens.client.resultset;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.lens.client.exceptions.LensClientIOException;
+
+public class ZippedCsvResultSetReader extends ZippedResultSetReader {
+  public ZippedCsvResultSetReader(InputStream inStream, Charset encoding, char 
delimiter, boolean isHeaderRowPresent)
+    throws LensClientIOException {
+    super(inStream, encoding, delimiter, isHeaderRowPresent);
+  }
+
+  @Override
+  protected ResultSetReader createEntryReader() throws LensClientIOException {
+    return new CsvResultSetReader(getZipStream(), getEncoding(), 
getDelimiter());
+  }
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedResultSetReader.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedResultSetReader.java
 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedResultSetReader.java
new file mode 100644
index 0000000..12ce00a
--- /dev/null
+++ 
b/lens-client/src/main/java/org/apache/lens/client/resultset/ZippedResultSetReader.java
@@ -0,0 +1,92 @@
+/**
+ * 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.lens.client.resultset;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.lens.client.exceptions.LensClientIOException;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public abstract class ZippedResultSetReader implements ResultSetReader {
+
+  @Getter
+  private ZipInputStream zipStream;
+  @Getter
+  private Charset encoding;
+  @Getter
+  private char delimiter;
+  @Getter
+  private boolean isHeaderRowPresent;
+
+  private ResultSetReader actualReader;
+
+  public ZippedResultSetReader(InputStream inStream, Charset encoding, char 
delimiter, boolean isHeaderRowPresent)
+    throws LensClientIOException {
+
+    this.zipStream = new ZipInputStream(inStream);
+    this.encoding = encoding;
+    this.delimiter = delimiter;
+    this.isHeaderRowPresent = isHeaderRowPresent;
+
+    getNextEntry(); // Move the cursor to the first entyry in the zip
+    this.actualReader = createEntryReader();
+  }
+
+  @Override
+  public String[] getRow() throws LensClientIOException {
+    return actualReader.getRow();
+  }
+
+  @Override
+  public boolean next() throws LensClientIOException {
+    if (actualReader.next()) {
+      return true;
+    } else if (getNextEntry() != null) {
+      actualReader = createEntryReader(); //created reader for getRow entry in 
zip file
+      if (isHeaderRowPresent) {
+        actualReader.next(); //skip the header row in all but first entry
+      }
+      return next();
+    }
+    return false;
+  }
+
+  private ZipEntry getNextEntry() throws LensClientIOException {
+    try {
+      ZipEntry entry = zipStream.getNextEntry();
+      if (entry != null) {
+        log.info("Reading entry :" + entry.getName());
+      }
+      return entry;
+    } catch (IOException e) {
+      log.error("Unable to read zip entry", e);
+      throw new LensClientIOException("Unable to read zip entry", e);
+    }
+  }
+
+  protected abstract ResultSetReader createEntryReader() throws 
LensClientIOException;
+}

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/java/org/apache/lens/client/TestLensClient.java
----------------------------------------------------------------------
diff --git 
a/lens-client/src/test/java/org/apache/lens/client/TestLensClient.java 
b/lens-client/src/test/java/org/apache/lens/client/TestLensClient.java
index 7a00f65..6e638f1 100644
--- a/lens-client/src/test/java/org/apache/lens/client/TestLensClient.java
+++ b/lens-client/src/test/java/org/apache/lens/client/TestLensClient.java
@@ -18,23 +18,30 @@
  */
 package org.apache.lens.client;
 
+import static org.testng.Assert.*;
+
+import java.io.File;
 import java.net.URI;
+import java.util.*;
 
 import javax.ws.rs.core.UriBuilder;
+import javax.xml.datatype.DatatypeFactory;
 
+import org.apache.lens.api.APIResult;
+import org.apache.lens.api.metastore.*;
+import org.apache.lens.api.query.QueryHandle;
+import org.apache.lens.client.exceptions.LensClientIOException;
+import org.apache.lens.client.resultset.ResultSet;
 import org.apache.lens.server.LensAllApplicationJerseyTest;
 import org.apache.lens.server.api.LensConfConstants;
 
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.metastore.api.Database;
-import org.apache.hadoop.hive.ql.metadata.Hive;
-
 import org.testng.Assert;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
+
+import lombok.extern.slf4j.Slf4j;
 
 @Test(groups = "unit-test")
+@Slf4j
 public class TestLensClient extends LensAllApplicationJerseyTest {
   private static final String TEST_DB = TestLensClient.class.getSimpleName();
 
@@ -48,24 +55,77 @@ public class TestLensClient extends 
LensAllApplicationJerseyTest {
     return 
UriBuilder.fromUri("http://localhost/";).port(getTestPort()).path("/lensapi").build();
   }
 
+  private LensClient client;
+
   @BeforeTest
   public void setUp() throws Exception {
     super.setUp();
 
-    Hive hive = Hive.get(new HiveConf());
-    Database db = new Database();
-    db.setName(TEST_DB);
-    hive.createDatabase(db, true);
+    client = new LensClient();
+    client.createDatabase(TEST_DB, true);
+    assertTrue(client.setDatabase(TEST_DB));
+
+    log.debug("Creating cube sample-cube");
+    APIResult result = 
client.createCube("target/test-classes/sample-cube.xml");
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    log.debug("Creating storage local");
+    result = client.createStorage("target/test-classes/local-storage.xml");
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    log.debug("Creating dimension test_dim");
+    result = client.createDimension("target/test-classes/test-dimension.xml");
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    log.debug("Creating dimension test_detail");
+    result = client.createDimension("target/test-classes/test-detail.xml");
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    log.debug("Creating dimension table dim_table for dimension test_dim");
+    result = client.createDimensionTable("target/test-classes/dim_table.xml");
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    log.debug("adding partition to dim_table");
+    XPartition xp = new XPartition();
+    xp.setFactOrDimensionTableName("dim_table");
+    xp.setLocation(new 
File("target/test-classes/dim2-part").getAbsolutePath());
+    xp.setUpdatePeriod(XUpdatePeriod.HOURLY);
+    XTimePartSpec timePart = new XTimePartSpec();
+    XTimePartSpecElement partElement = new XTimePartSpecElement();
+    partElement.setKey("dt");
+    
partElement.setValue(DatatypeFactory.newInstance().newXMLGregorianCalendar(new 
GregorianCalendar()));
+    timePart.getPartSpecElement().add(partElement);
+    xp.setTimePartitionSpec(timePart);
+    result = client.addPartitionToDim("dim_table", "local", xp);
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
   }
 
+
   @AfterTest
   public void tearDown() throws Exception {
-    super.tearDown();
 
-    Hive hive = Hive.get(new HiveConf());
-    hive.dropDatabase(TEST_DB);
+    APIResult result = client.dropDimensionTable("dim_table", true);
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    result = client.dropDimension("test_dim");
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    result = client.dropStorage("local");
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    result = client.dropCube("sample_cube");
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    result = client.dropDatabase(TEST_DB, true);
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
+
+    result = client.closeConnection();
+    assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
   }
 
+  /**
+   * Creates a new client and tests database creation and deletion
+   */
   @Test
   public void testClient() throws Exception {
     LensClientConfig lensClientConfig = new LensClientConfig();
@@ -76,10 +136,100 @@ public class TestLensClient extends 
LensAllApplicationJerseyTest {
     LensClient client = new LensClient(lensClientConfig);
     Assert.assertEquals(client.getCurrentDatabae(), TEST_DB,
       "current database");
+
     client.createDatabase("testclientdb", true);
     Assert.assertTrue(client.getAllDatabases().contains("testclientdb"));
     client.dropDatabase("testclientdb", false);
     Assert.assertFalse(client.getAllDatabases().contains("testclientdb"));
+
     Assert.assertTrue(RequestTestFilter.isAccessed(), "RequestTestFilter not 
invoked");
   }
+
+  @DataProvider(name = "testIterableHttpResultSetDP")
+  public Object[][] testIterableHttpResultSetDP() {
+    Object[][] testCases = new Object[7][];
+
+    String query = "cube select id,name from test_dim";
+
+    //**** Test server and driver Persist with Split and Header Enbaled
+    testCases[0] = new Object[]{query, createConf(true, true, true, 1, true), 
true, 2, 3};
+
+    //**** Test server and driver Persist with Split disabled and Header 
Enbaled
+    testCases[1] = new Object[]{query, createConf(true, true, false, 0, true), 
false, 2, 3};
+
+    //**** Test server and driver Persist with Split disabled and Header 
disabled
+    testCases[2] = new Object[]{query, createConf(true, true, false, 0, 
false), false, 0, 3};
+
+    //**** Test server Persist with Split enabled and Header enabled
+    testCases[3] = new Object[]{query, createConf(false, true, true, 1, true), 
true, 2, 3};
+
+    //**** Test server Persist with Split disabled and Header disabled
+    testCases[4] = new Object[]{query, createConf(false, true, false, 0, 
false), false, 0, 3};
+
+    String emptyQuery = "cube select id,name from test_dim where id = -999";
+    //**** Test server and driver Persist with Split and Header Enbaled
+    testCases[5] = new Object[]{emptyQuery, createConf(true, true, true, 1, 
true), true, 2, 0};
+
+    //**** Test server and driver Persist with Split and Header disabled
+    testCases[6] = new Object[]{emptyQuery, createConf(true, true, true, 1, 
false), true, 0, 0};
+
+    return testCases;
+  }
+
+  private Map<String, String> createConf(boolean persistInDriver, boolean 
persistInServer, boolean split,
+    int splitRows, boolean writeHeader) {
+    Map<String, String> queryConf = new HashMap<String, String>();
+    queryConf.put("lens.query.enable.persistent.resultset.indriver", "" + 
persistInDriver);
+    queryConf.put("lens.query.enable.persistent.resultset", "" + 
persistInServer);
+    queryConf.put("lens.query.result.split.multiple", "" + split);
+    queryConf.put("lens.query.result.split.multiple.maxrows", "" + splitRows);
+    queryConf.put("lens.query.output.write.header", "" + writeHeader);
+    queryConf.put("lens.query.result.output.dir.format",
+      "ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'"
+        + " WITH SERDEPROPERTIES ('serialization.null.format'='-NA-',"
+        + " 'field.delim'=','  ) STORED AS TEXTFILE ");
+    return queryConf;
+  }
+
+  @Test(dataProvider = "testIterableHttpResultSetDP")
+  public void testHttpResultSet(String query, Map<String, String> queryConf, 
boolean isResultZipped,
+    int columnNamesExpected, int rowsExpected) throws Exception {
+
+    for (Map.Entry<String, String> e : queryConf.entrySet()) {
+      client.setConnectionParam(e.getKey(), e.getValue());
+    }
+    QueryHandle handle = client.executeQueryAsynch(query, "testQuery");
+    client.getStatement().waitForQueryToComplete(handle);
+    assertTrue(client.getStatement().wasQuerySuccessful());
+
+    ResultSet result = null;
+    boolean isHeaderRowPresent = columnNamesExpected > 0 ? true : false;
+    result = client.getHttpResultSet(handle);
+
+    assertNotNull(result);
+    validateResult(result, columnNamesExpected, rowsExpected);
+  }
+
+  private void validateResult(ResultSet result, int columnsExepected, int 
rowsExpected) throws LensClientIOException {
+    if (columnsExepected > 0) {
+      assertNotNull(result.getColumnNames());
+      List columnNames = Arrays.asList(result.getColumnNames());
+      compare(result.getColumnNames(), new String[]{"test_dim.id", 
"test_dim.name"});
+    } else {
+      assertNull(result.getColumnNames());
+    }
+
+    if (rowsExpected > 0) {
+      assertTrue(result.next());
+      compare(result.getRow(), new String[]{"1", "first"});
+      assertTrue(result.next());
+      compare(result.getRow(), new String[]{"2", "two"});
+      assertTrue(result.next());
+      compare(result.getRow(), new String[]{"3", "three"});
+    }
+  }
+
+  private void compare(String[] actualArr, String[] expectedArr) {
+    assertTrue(Arrays.equals(actualArr, expectedArr));
+  }
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/resources/dim2-part/data.data
----------------------------------------------------------------------
diff --git a/lens-client/src/test/resources/dim2-part/data.data 
b/lens-client/src/test/resources/dim2-part/data.data
new file mode 100644
index 0000000..b67d62d
--- /dev/null
+++ b/lens-client/src/test/resources/dim2-part/data.data
@@ -0,0 +1,3 @@
+1,first,this is one,11
+2,two,this is two,22
+3,three,this is three,33

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/resources/dim_table.xml
----------------------------------------------------------------------
diff --git a/lens-client/src/test/resources/dim_table.xml 
b/lens-client/src/test/resources/dim_table.xml
new file mode 100644
index 0000000..eb4ddfc
--- /dev/null
+++ b/lens-client/src/test/resources/dim_table.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<x_dimension_table dimension_name="test_dim" table_name="dim_table" 
weight="100.0" xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <columns>
+    <column comment="ID" name="id" _type="INT"/>
+    <column comment="name" name="name" _type="STRING"/>
+    <column comment="more details" name="detail" _type="STRING"/>
+    <column comment="d2 ID" name="d2id" _type="INT"/>
+  </columns>
+  <properties>
+    <property name="dim1.prop" value="d1"/>
+  </properties>
+  <storage_tables>
+    <storage_table>
+      <update_periods>
+        <update_period>HOURLY</update_period>
+      </update_periods>
+      <storage_name>local</storage_name>
+      <table_desc external="true" field_delimiter=","
+        table_location="${project.build.directory}/metastore/examples/local">
+        <part_cols>
+          <column comment="Time column" name="dt" _type="STRING"/>
+        </part_cols>
+        <time_part_cols>dt</time_part_cols>
+      </table_desc>
+    </storage_table>
+  </storage_tables>
+</x_dimension_table>

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/resources/fact1.xml
----------------------------------------------------------------------
diff --git a/lens-client/src/test/resources/fact1.xml 
b/lens-client/src/test/resources/fact1.xml
new file mode 100644
index 0000000..b18a393
--- /dev/null
+++ b/lens-client/src/test/resources/fact1.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<x_fact_table cube_name="sample_cube" name="fact1" weight="100.0" 
xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <columns>
+    <column comment="" name="dim1" _type="INT"/>
+    <column comment="" name="measure1" _type="BIGINT"/>
+    <column comment="" name="measure2" _type="INT"/>
+    <column comment="" name="measure3" _type="FLOAT"/>
+  </columns>
+  <properties>
+    <property name="fact1.prop" value="f1"/>
+    <property name="cube.fact.is.aggregated" value="true"/>
+  </properties>
+  <storage_tables>
+    <storage_table>
+      <update_periods>
+        <update_period>HOURLY</update_period>
+        <update_period>DAILY</update_period>
+        <update_period>MONTHLY</update_period>
+      </update_periods>
+      <storage_name>fact_local</storage_name>
+      <table_desc external="true" field_delimiter=","
+        
table_location="${project.build.directory}/metastore/examples/fact1_local">
+        <part_cols>
+          <column comment="Time column" name="dt" _type="STRING"/>
+        </part_cols>
+        <time_part_cols>dt</time_part_cols>
+      </table_desc>
+    </storage_table>
+  </storage_tables>
+</x_fact_table>

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/resources/lens-client-site.xml
----------------------------------------------------------------------
diff --git a/lens-client/src/test/resources/lens-client-site.xml 
b/lens-client/src/test/resources/lens-client-site.xml
index b356e5e..add36e8 100644
--- a/lens-client/src/test/resources/lens-client-site.xml
+++ b/lens-client/src/test/resources/lens-client-site.xml
@@ -30,4 +30,15 @@
         <value>org.apache.lens.client.RequestTestFilter</value>
         <description>Implementation class for Request Filter</description>
     </property>
+    <property>
+        <name>lens.server.base.url</name>
+        <value>http://localhost:10056/lensapi</value>
+        <description>The base url for the lens server</description>
+    </property>
+
+    <property>
+        <name>lens.client.query.poll.interval</name>
+        <value>1000</value>
+        <description>Interval at which query progress will be polled. Interval 
has to be given in milliseconds</description>
+    </property>
 </configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/resources/local-storage.xml
----------------------------------------------------------------------
diff --git a/lens-client/src/test/resources/local-storage.xml 
b/lens-client/src/test/resources/local-storage.xml
new file mode 100644
index 0000000..6551375
--- /dev/null
+++ b/lens-client/src/test/resources/local-storage.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<x_storage classname="org.apache.lens.cube.metadata.HDFSStorage" name="local" 
xmlns="uri:lens:cube:0.1"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <properties>
+    <property name="storage.url" value="file:///" />
+  </properties>
+</x_storage>

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/resources/sample-cube.xml
----------------------------------------------------------------------
diff --git a/lens-client/src/test/resources/sample-cube.xml 
b/lens-client/src/test/resources/sample-cube.xml
new file mode 100644
index 0000000..9bcf177
--- /dev/null
+++ b/lens-client/src/test/resources/sample-cube.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<x_base_cube name="sample_cube" xmlns="uri:lens:cube:0.1" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <properties>
+    <property name="sample_cube.prop" value="sample" />
+    <property name="cube.sample_cube.timed.dimensions.list" value="dt" />
+  </properties>
+  <measures>
+    <measure name="measure1" _type="BIGINT" />
+    <measure name="measure2" _type="INT" default_aggr="SUM" />
+    <measure name="measure3" _type="FLOAT" default_aggr="MAX" 
start_time='2013-12-12T00:00:00' />
+    <measure name="measure4" _type="DOUBLE" default_aggr="MIN" />
+  </measures>
+  <dim_attributes>
+    <dim_attribute name="dim1" _type="INT" />
+    <dim_attribute name="dim2" _type="INT" start_time='2013-12-01T00:00:00' />
+    <dim_attribute name="dim3" _type="INT"/>
+    <dim_attribute name="dimDetail" _type="string" description="City name to 
which the customer belongs"
+                   display_string="Customer City">
+      <chain_ref_column chain_name="testdimchain" ref_col="detail" />
+      <chain_ref_column chain_name="testdetailchain" ref_col="name" />
+    </dim_attribute>
+  </dim_attributes>
+  <expressions>
+    <expression name="expr_msr5" _type="DOUBLE">
+      <expr_spec expr = "measure3 + measure4" end_time='2013-12-12T00:00:00'/>
+      <expr_spec expr = "measure3 + measure4 + 0.01" 
start_time='2013-12-12T00:00:00'/>
+    </expression>
+  </expressions>
+  <join_chains>
+    <join_chain name="testdimchain">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="sample_cube" column="dim1" />
+              <to table="test_dim" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+    <join_chain name="testdetailchain">
+      <paths>
+        <path>
+          <edges>
+            <edge>
+              <from table="sample_cube" column="dim2" />
+              <to table="test_detail" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+  </join_chains>
+</x_base_cube>

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/resources/test-detail.xml
----------------------------------------------------------------------
diff --git a/lens-client/src/test/resources/test-detail.xml 
b/lens-client/src/test/resources/test-detail.xml
new file mode 100644
index 0000000..0d619d9
--- /dev/null
+++ b/lens-client/src/test/resources/test-detail.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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 theT
+  specific language governing permissions and limitations
+  under the License.
+
+-->
+<x_dimension name="test_detail" xmlns="uri:lens:cube:0.1" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <attributes>
+    <dim_attribute name="id" _type="INT" />
+    <dim_attribute name="name" _type="STRING" />
+  </attributes>
+
+  <properties>
+    <property name="dimension.test_dim.timed.dimension" value="dt" />
+  </properties>
+</x_dimension>

http://git-wip-us.apache.org/repos/asf/lens/blob/6995962f/lens-client/src/test/resources/test-dimension.xml
----------------------------------------------------------------------
diff --git a/lens-client/src/test/resources/test-dimension.xml 
b/lens-client/src/test/resources/test-dimension.xml
new file mode 100644
index 0000000..01de8e6
--- /dev/null
+++ b/lens-client/src/test/resources/test-dimension.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<x_dimension name="test_dim" xmlns="uri:lens:cube:0.1" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+  <attributes>
+    <dim_attribute name="id" _type="INT" />
+    <dim_attribute name="name" _type="STRING" />
+    <dim_attribute name="detail" _type="STRING" 
start_time='2013-12-01T00:00:00' />
+    <dim_attribute name="d2id" _type="INT" start_time='2013-12-01T00:00:00'/>
+    <dim_attribute name="inline" _type="STRING" >
+      <values>A</values>
+      <values>B</values>
+      <values>C</values>
+    </dim_attribute>
+    <dim_attribute name="location">
+      <hierarchy>
+        <dim_attribute name="zipcode" _type="INT" />
+        <dim_attribute name="city" _type="STRING" />
+        <dim_attribute name="state" _type="STRING" />
+      </hierarchy>
+    </dim_attribute>
+  </attributes>
+
+  <join_chains>
+    <join_chain name="dim2chain">
+      <paths>
+        <path>
+         <edges>
+            <edge>
+              <from table="test_dim" column="d2id" />
+              <to table="test_detail" column="id" />
+            </edge>
+          </edges>
+        </path>
+      </paths>
+    </join_chain>
+  </join_chains>
+  <properties>
+    <property name="test_dim.prop" value="test" />
+    <property name="dimension.test_dim.timed.dimension" value="dt" />
+  </properties>
+</x_dimension>

Reply via email to