geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject [geode-examples] branch develop updated: GEODE-3789: rename a test data class and fix some typos and grammars This closes #35
Date Thu, 26 Oct 2017 23:51:40 GMT
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-examples.git


The following commit(s) were added to refs/heads/develop by this push:
     new 0c21f6c  GEODE-3789: rename a test data class and fix some typos and grammars This
closes #35
0c21f6c is described below

commit 0c21f6c3ecf2a3634743acf9bc59b962d3d02be2
Author: zhouxh <gzhou@pivotal.io>
AuthorDate: Thu Oct 26 15:10:52 2017 -0700

    GEODE-3789: rename a test data class and fix some typos and grammars
    This closes #35
---
 lucene/README.md                                   | 12 ++++++------
 lucene/scripts/start.gfsh                          |  2 +-
 .../lucene/{ZipAndPhone.java => Contact.java}      | 20 ++++++++++----------
 .../apache/geode/examples/lucene/EmployeeData.java | 12 ++++++------
 .../org/apache/geode/examples/lucene/Example.java  | 22 ++++++++++------------
 5 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/lucene/README.md b/lucene/README.md
index 2044a2a..77aa0c2 100644
--- a/lucene/README.md
+++ b/lucene/README.md
@@ -73,15 +73,15 @@ will also be retrieved from the region and printed to the console.
      // Do a compound search on last name and email using analyzerIndex
         gfsh>search lucene --name=analyzerIndex --region=example-region --queryStrings="lastName:hall~
AND email:Kris.Call@example.com" --defaultField=lastName
 
-     // Do a compound search on nested object with both 5035330001 AND 5036430001 in either
home or office. 
-     // Note: 5035330001 is one of his home phone, 5036430001 is one of his office phone.

-        gfsh>search lucene --name=nestedObjectIndex --region=/example-region --queryString="5035330001
AND 5036430001" --defaultField=zipAndPhoneBook.phones
+     // Do a compound search on nested object with both 5035330001 AND 5036430001 in contacts
+     // Note: 5035330001 is the phone number of one of the contacts, 5036430001 is phone
number of another contact. Since they are both contacts of this employee, it will lead to
this employee. 
+        gfsh>search lucene --name=nestedObjectIndex --region=/example-region --queryString="5035330001
AND 5036430001" --defaultField=contacts.phoneNumbers
 
-     // If query on 5035330001 AND 5036430002, it will not find the person, because the 2
phone numbers belong to different person's entry. 
-        gfsh>search lucene --name=nestedObjectIndex --region=/example-region --queryString="5035330001
AND 5036430002" --defaultField=zipAndPhoneBook.phones
+     // If query on 5035330001 AND 5036430002, it will not find the person, because the 2
phone numbers belong to different people's contacts. 
+        gfsh>search lucene --name=nestedObjectIndex --region=/example-region --queryString="5035330001
AND 5036430002" --defaultField=contacts.phoneNumbers
 
      // If query on 5035330001 OR 5036430002, it will find 2 people's entries
-        gfsh>search lucene --name=nestedObjectIndex --region=/example-region --queryString="5035330001
OR 5036430002" --defaultField=zipAndPhoneBook.phones
+        gfsh>search lucene --name=nestedObjectIndex --region=/example-region --queryString="5035330001
OR 5036430002" --defaultField=contacts.phoneNumbers
 
 3. Examine the Lucene index statistics
 
diff --git a/lucene/scripts/start.gfsh b/lucene/scripts/start.gfsh
index ab25abf..b3d17bd 100644
--- a/lucene/scripts/start.gfsh
+++ b/lucene/scripts/start.gfsh
@@ -26,7 +26,7 @@ create lucene index --name=simpleIndex --region=example-region --field=firstName
 create lucene index --name=analyzerIndex --region=example-region --field=lastName,email --analyzer=DEFAULT,org.apache.lucene.analysis.core.KeywordAnalyzer
 
 ## nestedObjectIndex will index on nested objects or collection objects
-create lucene index --name=nestedObjectIndex --region=example-region --field=zipAndPhoneBook.phones
--serializer=org.apache.geode.cache.lucene.FlatFormatSerializer
+create lucene index --name=nestedObjectIndex --region=example-region --field=contacts.phoneNumbers
--serializer=org.apache.geode.cache.lucene.FlatFormatSerializer
 
 create region --name=example-region --type=PARTITION --enable-statistics=true
 
diff --git a/lucene/src/main/java/org/apache/geode/examples/lucene/ZipAndPhone.java b/lucene/src/main/java/org/apache/geode/examples/lucene/Contact.java
similarity index 72%
rename from lucene/src/main/java/org/apache/geode/examples/lucene/ZipAndPhone.java
rename to lucene/src/main/java/org/apache/geode/examples/lucene/Contact.java
index 4aa5b04..7d53d87 100644
--- a/lucene/src/main/java/org/apache/geode/examples/lucene/ZipAndPhone.java
+++ b/lucene/src/main/java/org/apache/geode/examples/lucene/Contact.java
@@ -17,25 +17,25 @@ package org.apache.geode.examples.lucene;
 import java.io.Serializable;
 import java.util.Arrays;
 
-public class ZipAndPhone implements Serializable {
-  private int zip;
-  private String[] phones;
+public class Contact implements Serializable {
+  private String name;
+  private String[] phoneNumbers;
 
-  ZipAndPhone(int zip, String[] phones) {
-    this.zip = zip;
-    this.phones = phones;
+  Contact(String name, String[] phoneNumbers) {
+    this.name = name;
+    this.phoneNumbers = phoneNumbers;
   }
 
-  public int getZip() {
-    return this.zip;
+  public String getName() {
+    return this.name;
   }
 
   public String[] getPhones() {
-    return this.phones;
+    return this.phoneNumbers;
   }
 
   @Override
   public String toString() {
-    return "(zip=" + zip + ", phones=" + Arrays.toString(phones) + ")";
+    return "(name=" + name + ", phones=" + Arrays.toString(phoneNumbers) + ")";
   }
 }
diff --git a/lucene/src/main/java/org/apache/geode/examples/lucene/EmployeeData.java b/lucene/src/main/java/org/apache/geode/examples/lucene/EmployeeData.java
index 27893a9..c116342 100644
--- a/lucene/src/main/java/org/apache/geode/examples/lucene/EmployeeData.java
+++ b/lucene/src/main/java/org/apache/geode/examples/lucene/EmployeeData.java
@@ -26,17 +26,17 @@ public class EmployeeData implements Serializable {
   private String email;
   private int salary;
   private int hoursPerWeek;
-  private Collection<ZipAndPhone> zipAndPhoneBook;
+  private Collection<Contact> contacts;
 
   public EmployeeData(String firstName, String lastName, int emplNumber, String email, int
salary,
-      int hoursPerWeek, Collection<ZipAndPhone> zipAndPhoneBook) {
+      int hoursPerWeek, Collection<Contact> contacts) {
     this.firstName = firstName;
     this.lastName = lastName;
     this.emplNumber = emplNumber;
     this.email = email;
     this.salary = salary;
     this.hoursPerWeek = hoursPerWeek;
-    this.zipAndPhoneBook = zipAndPhoneBook;
+    this.contacts = contacts;
   }
 
   public String getFirstName() {
@@ -63,14 +63,14 @@ public class EmployeeData implements Serializable {
     return hoursPerWeek;
   }
 
-  public Collection<ZipAndPhone> getZipAndPhones() {
-    return this.zipAndPhoneBook;
+  public Collection<Contact> getContacts() {
+    return this.contacts;
   }
 
   @Override
   public String toString() {
     return "EmployeeData [firstName=" + firstName + ", lastName=" + lastName + ", emplNumber="
         + emplNumber + ", email= " + email + ", salary=" + salary + ", hoursPerWeek=" + hoursPerWeek
-        + ", zipAndPhoneBook=" + zipAndPhoneBook + "]";
+        + ", contacts=" + contacts + "]";
   }
 }
diff --git a/lucene/src/main/java/org/apache/geode/examples/lucene/Example.java b/lucene/src/main/java/org/apache/geode/examples/lucene/Example.java
index c26cd5e..ab57042 100644
--- a/lucene/src/main/java/org/apache/geode/examples/lucene/Example.java
+++ b/lucene/src/main/java/org/apache/geode/examples/lucene/Example.java
@@ -64,16 +64,16 @@ public class Example {
   private static void queryNestedObject(ClientCache cache) throws LuceneQueryException {
     LuceneService lucene = LuceneServiceProvider.get(cache);
     LuceneQuery<Integer, EmployeeData> query = lucene.createLuceneQueryFactory().create(
-        NESTEDOBJECT_INDEX, EXAMPLE_REGION, "5035330001 AND 5036430001", "zipAndPhoneBook.phones");
-    System.out.println(
-        "Employees with both phone number 5035330001 and 5036330001 either in office or home:
"
-            + query.findValues());
+        NESTEDOBJECT_INDEX, EXAMPLE_REGION, "5035330001 AND 5036430001", "contacts.phoneNumbers");
+    System.out.println("Employees with phone number 5035330001 and 5036430001 in their contacts:
"
+        + query.findValues());
   }
 
   public static void insertValues(Map<Integer, EmployeeData> region) {
     // insert values into the region
     String[] firstNames = "Alex,Bertie,Kris,Dale,Frankie,Jamie,Morgan,Pat,Ricky,Taylor".split(",");
     String[] lastNames = "Able,Bell,Call,Driver,Forth,Jive,Minnow,Puts,Reliable,Tack".split(",");
+    String[] contactNames = "Jack,John,Tom,William,Nick,Jason,Daniel,Sue,Mary,Mark".split(",");
     int salaries[] = new int[] {60000, 80000, 75000, 90000, 100000};
     int hours[] = new int[] {40, 40, 40, 30, 20};
     int emplNumber = 10000;
@@ -85,17 +85,15 @@ public class Example {
       int salary = salaries[index % 5];
       int hoursPerWeek = hours[index % 5];
 
-      // create a home zipAndPhone with zip=9700x, phones=503533000x, 503633000x;
-      // an office zipAndPhone with zip=9800x, phones=503543000x, 503643000x
-      ArrayList<ZipAndPhone> zipAndPhoneBook = new ArrayList();
-      ZipAndPhone home = new ZipAndPhone(97000 + index,
+      ArrayList<Contact> contacts = new ArrayList();
+      Contact contact1 = new Contact(contactNames[index] + " Jr",
           new String[] {"50353" + (30000 + index), "50363" + (30000 + index)});
-      ZipAndPhone office = new ZipAndPhone(98000 + index,
+      Contact contact2 = new Contact(contactNames[index],
           new String[] {"50354" + (30000 + index), "50364" + (30000 + index)});
-      zipAndPhoneBook.add(home);
-      zipAndPhoneBook.add(office);
+      contacts.add(contact1);
+      contacts.add(contact2);
       EmployeeData val = new EmployeeData(firstNames[index], lastNames[index], emplNumber,
email,
-          salary, hoursPerWeek, zipAndPhoneBook);
+          salary, hoursPerWeek, contacts);
       region.put(key, val);
     }
   }

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message