You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gora.apache.org by dj...@apache.org on 2023/03/12 17:08:02 UTC

[gora] branch master updated: GORA-693 Improve gora-jet test cases (#255)

This is an automated email from the ASF dual-hosted git repository.

djkevincr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/gora.git


The following commit(s) were added to refs/heads/master by this push:
     new 073d6dfa GORA-693 Improve gora-jet test cases (#255)
073d6dfa is described below

commit 073d6dfa3ae699bc8856611adb7ef531effbe8fc
Author: trisha-melani <93...@users.noreply.github.com>
AuthorDate: Sun Mar 12 22:37:56 2023 +0530

    GORA-693 Improve gora-jet test cases (#255)
    
    * GORA-693 Improve gora-jet test cases
    
    * Remove unnessary system out
---
 .../src/test/java/org/apache/gora/jet/JetTest.java | 43 +++++++++++++++++++---
 1 file changed, 37 insertions(+), 6 deletions(-)

diff --git a/gora-jet/src/test/java/org/apache/gora/jet/JetTest.java b/gora-jet/src/test/java/org/apache/gora/jet/JetTest.java
index 1f813db0..95544b32 100644
--- a/gora-jet/src/test/java/org/apache/gora/jet/JetTest.java
+++ b/gora-jet/src/test/java/org/apache/gora/jet/JetTest.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.util.Map;
 import java.util.regex.Pattern;
 
 import static com.hazelcast.jet.Traversers.traverseArray;
@@ -69,9 +70,9 @@ public class JetTest {
     resultPageView1.setUrl("How are you");
 
     ResultPageView resultPageView2 = new ResultPageView();
-    resultPageView1.setIp("88.240.129.183");
-    resultPageView1.setTimestamp(124L);
-    resultPageView1.setUrl("This is the jet engine");
+    resultPageView2.setIp("88.240.129.183");
+    resultPageView2.setTimestamp(124L);
+    resultPageView2.setUrl("This is the jet engine");
 
     dataStoreOut.put(1L,resultPageView);
     dataStoreOut.put(2L,resultPageView1);
@@ -121,10 +122,8 @@ public class JetTest {
     String ip = "";
     while (result.next()) {
       noOfOutputRecords++;
-      ip = result.get().getIp().toString();
-      assertEquals("88.240.129.183", ip);
     }
-    assertEquals(2, noOfOutputRecords);
+    assertEquals(3, noOfOutputRecords);
   }
 
   @Test
@@ -147,4 +146,36 @@ public class JetTest {
     IMap<String, Long> counts = jet.getMap("COUNTS");
     assertEquals(3L, (long)counts.get("the"));
   }
+
+  @Test
+  public void jetWordCountExtended() throws GoraException {
+    dataStoreOut = DataStoreFactory.getDataStore(Long.class, ResultPageView.class, utility.getConfiguration());
+
+    Query<Long, ResultPageView> query = dataStoreOut.newQuery();
+    JetEngine<Long, ResultPageView, Long, ResultPageView> jetEngine = new JetEngine<>();
+
+    Pattern delimiter = Pattern.compile("\\W+");
+    Pipeline p = Pipeline.create();
+    p.drawFrom(jetEngine.createDataSource(dataStoreOut, query))
+            .flatMap(e -> traverseArray(delimiter.split(e.getValue().getUrl().toString())))
+            .filter(word -> !word.isEmpty())
+            .groupingKey(wholeItem())
+            .aggregate(counting())
+            .drainTo(Sinks.map("COUNTS"));
+    JetInstance jet =  Jet.newJetInstance();;
+    jet.newJob(p).join();
+    IMap<String, Long> counts = jet.getMap("COUNTS");
+
+    assertEquals(3L, (long)counts.get("the"));
+    assertEquals(1L, (long)counts.get("This"));
+    assertEquals(1L, (long)counts.get("is"));
+    assertEquals(1L, (long)counts.get("jet"));
+    assertEquals(1L, (long)counts.get("engine"));
+    assertEquals(1L, (long)counts.get("How"));
+    assertEquals(1L, (long)counts.get("are"));
+    assertEquals(1L, (long)counts.get("you"));
+    assertEquals(1L, (long)counts.get("I"));
+    assertEquals(1L, (long)counts.get("am"));
+    assertEquals(1L, (long)counts.get("one"));
+  }
 }