gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djkevi...@apache.org
Subject [23/32] gora git commit: Update the test cases
Date Thu, 27 Jul 2017 18:45:49 GMT
Update the test cases


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

Branch: refs/heads/master
Commit: dbe962a24475a2d288e1e1ff681c21ccd05b5cbc
Parents: 390a435
Author: nishadi <ndimeshi@gmail.com>
Authored: Mon Jul 24 22:43:30 2017 +0530
Committer: nishadi <ndimeshi@gmail.com>
Committed: Mon Jul 24 22:43:30 2017 +0530

----------------------------------------------------------------------
 .../gora/aerospike/store/AerospikeStore.java    | 38 +++++++---------
 .../aerospike/store/TestAerospikeStore.java     | 47 +++++++++++++++-----
 2 files changed, 54 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/dbe962a2/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
----------------------------------------------------------------------
diff --git a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
b/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
index 56f2bdb..5b3a1b9 100644
--- a/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
+++ b/gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java
@@ -255,7 +255,7 @@ public class AerospikeStore<K, T extends PersistentBase> extends
DataStoreBase<K
     String set = aerospikeParameters.getAerospikeMapping().getSet();
 
     // Query execution without any keys
-    if (query.getStartKey() == null && query.getEndKey() == null){
+    if (query.getStartKey() == null && query.getEndKey() == null) {
 
       try (RecordSet recordSet = aerospikeClient.query(null, getStatement(namespace, set)))
{
         while (recordSet.next()) {
@@ -277,36 +277,29 @@ public class AerospikeStore<K, T extends PersistentBase> extends
DataStoreBase<K
 
     // Query execution for key ranges
     // ToDo: Implement Query execution for key ranges
-    else if (query.getStartKey() != null && query.getEndKey() != null) {
-//      Key startKey = null, endKey = null;
-//      if (query.getStartKey() != null) {
-//        startKey = getAerospikeKey(query.getStartKey());
-//      }
-//      if (query.getEndKey() != null) {
-//        endKey = getAerospikeKey(query.getEndKey());
-//      }
-
-//      boolean isSpecifiedRange = false;
+//    else if (query.getStartKey() != null && query.getEndKey() != null) {
+//
+//      // the key range filtering at the gora-module, which is not a better solution
+//      String lowerBound  = query.getStartKey().toString();
+//      String upperBound  = query.getEndKey().toString();
+//
 //      try (RecordSet recordSet = aerospikeClient.query(null, getStatement(namespace, set)))
{
 //        while (recordSet.next()) {
 //          Key key = recordSet.getKey();
 //          Record record = recordSet.getRecord();
 //
-//          if(key.userKey == getAerospikeKey(query.getStartKey()).userKey){
-//            isSpecifiedRange = true;
-//          }
-//          if(key.userKey == getAerospikeKey(query.getEndKey()).userKey){
-//            isSpecifiedRange = false;
-//          }
+//          String input = key.userKey.toString();
+//          boolean isSpecifiedRange =  input.compareToIgnoreCase(lowerBound) >= 0 &&
input
+//                  .compareToIgnoreCase(upperBound) <= 0;
 //
-//          if(isSpecifiedRange){
-//            AerospikeResultRecord aerospikeRecord = new AerospikeResultRecord(key,record);
+//          if (isSpecifiedRange) {
+//            AerospikeResultRecord aerospikeRecord = new AerospikeResultRecord(key, record);
 //            resultRecords.add(aerospikeRecord);
 //          }
 //
 //        }
-      }
-
+//      }
+//    }
     return new AerospikeQueryResult<>(this, query, resultRecords, getFieldsToQuery(null));
   }
 
@@ -320,6 +313,9 @@ public class AerospikeStore<K, T extends PersistentBase> extends
DataStoreBase<K
     return new AerospikeQuery<>(this);
   }
 
+  /**
+   * The functionality is not supported as query key ranges are not supported
+   */
   @Override
   public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws
IOException {
     return null;

http://git-wip-us.apache.org/repos/asf/gora/blob/dbe962a2/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java
----------------------------------------------------------------------
diff --git a/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java
b/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java
index 9e38e4d..9e66327 100644
--- a/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java
+++ b/gora-aerospike/src/test/java/org/apache/gora/aerospike/store/TestAerospikeStore.java
@@ -23,11 +23,14 @@ import org.apache.gora.examples.WebPageDataCreator;
 import org.apache.gora.examples.generated.WebPage;
 import org.apache.gora.query.Query;
 import org.apache.gora.store.DataStoreTestBase;
+import org.apache.gora.store.DataStoreTestUtil;
+import org.apache.gora.util.AvroUtils;
 import org.junit.ClassRule;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.testcontainers.containers.GenericContainer;
 
+import static org.apache.gora.examples.WebPageDataCreator.SORTED_URLS;
 import static org.apache.gora.examples.WebPageDataCreator.URLS;
 
 /**
@@ -88,21 +91,21 @@ public class TestAerospikeStore extends DataStoreTestBase {
   }
 
   @Test
-  @Ignore("Functionality is to be implemented in the next iteration")
+  @Ignore("Query key ranges based on primary key is not supported via the java client")
   @Override
   public void testQueryStartKey() throws Exception {
     super.testQueryStartKey();
   }
 
   @Test
-  @Ignore("Functionality is to be implemented in the next iteration")
+  @Ignore("Query key ranges based on primary key is not supported via the java client")
   @Override
   public void testQueryEndKey() throws Exception {
     super.testQueryEndKey();
   }
 
   @Test
-  @Ignore("Functionality is to be implemented in the next iteration")
+  @Ignore("Query key ranges based on primary key is not supported via the java client")
   @Override
   public void testQueryKeyRange() throws Exception {
     super.testQueryKeyRange();
@@ -121,23 +124,47 @@ public class TestAerospikeStore extends DataStoreTestBase {
   }
 
   @Test
-  @Ignore("Functionality is to be implemented in the next iteration")
   @Override
   public void testDeleteByQuery() throws Exception {
-    super.testDeleteByQuery();
+
+    // Can not use the super method as they query key ranges are not supported
+    Query<String, WebPage> query;
+    //test 1 - delete all
+    WebPageDataCreator.createWebPageData(webPageStore);
+
+    query = webPageStore.newQuery();
+
+    DataStoreTestUtil.assertNumResults(webPageStore.newQuery(), URLS.length);
+    webPageStore.deleteByQuery(query);
+    webPageStore.flush();
+    DataStoreTestUtil.assertEmptyResults(webPageStore.newQuery());
+
+
+    //test 2 - delete all
+    WebPageDataCreator.createWebPageData(webPageStore);
+
+    query = webPageStore.newQuery();
+    query.setFields(AvroUtils.getSchemaFieldNames(WebPage.SCHEMA$));
+
+    DataStoreTestUtil.assertNumResults(webPageStore.newQuery(), URLS.length);
+    webPageStore.deleteByQuery(query);
+    webPageStore.flush();
+    DataStoreTestUtil.assertEmptyResults(webPageStore.newQuery());
+
+    webPageStore.truncateSchema();
   }
 
   @Test
   @Ignore("Functionality is to be implemented in the next iteration")
   @Override
-  public void testDeleteByQueryFields() throws Exception {
-    super.testDeleteByQueryFields();
+  public void testGetPartitions() throws Exception {
+    super.testGetPartitions();
   }
 
   @Test
-  @Ignore("Functionality is to be implemented in the next iteration")
+  @Ignore("Not supported as query key ranges are not supported")
   @Override
-  public void testGetPartitions() throws Exception {
-    super.testGetPartitions();
+  public void testDeleteByQueryFields() throws Exception {
+    super.testDeleteByQueryFields();
   }
 }


Mime
View raw message