geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@apache.org
Subject [15/49] geode git commit: GEODE-2617: use DataSeriazableFixedID to implement
Date Fri, 17 Mar 2017 20:10:50 GMT
GEODE-2617: use DataSeriazableFixedID to implement


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

Branch: refs/heads/feature/GEODE-2420
Commit: aa9ced53d4f7351cac99e44622a2ee9011927b89
Parents: ce5523f
Author: zhouxh <gzhou@pivotal.io>
Authored: Thu Mar 9 09:54:42 2017 -0800
Committer: Ken Howe <khowe@pivotal.io>
Committed: Fri Mar 17 13:09:44 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/DataSerializableFixedID.java |  1 +
 .../geode/cache/lucene/LuceneResultStruct.java  |  4 +--
 .../lucene/internal/LuceneResultStructImpl.java | 37 +++++++++++++++++++-
 .../lucene/internal/LuceneServiceImpl.java      |  3 ++
 4 files changed, 41 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/aa9ced53/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
index 63a95a5..18f382b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
@@ -811,6 +811,7 @@ public interface DataSerializableFixedID extends SerializationVersions
{
   public static final short WAIT_UNTIL_FLUSHED_FUNCTION_CONTEXT = 2177;
   public static final short DESTROY_LUCENE_INDEX_MESSAGE = 2178;
   public static final short LUCENE_PAGE_RESULTS = 2179;
+  public static final short LUCENE_RESULT_STRUCT = 2180;
 
   // NOTE, codes > 65535 will take 4 bytes to serialize
 

http://git-wip-us.apache.org/repos/asf/geode/blob/aa9ced53/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
index 5d2184e..4a6481f 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
@@ -14,8 +14,6 @@
  */
 package org.apache.geode.cache.lucene;
 
-import java.io.Serializable;
-
 import org.apache.geode.annotations.Experimental;
 
 /**
@@ -23,7 +21,7 @@ import org.apache.geode.annotations.Experimental;
  * 
  */
 @Experimental
-public interface LuceneResultStruct<K, V> extends Serializable {
+public interface LuceneResultStruct<K, V> {
 
   /**
    * @return The region key of the entry matching the query

http://git-wip-us.apache.org/repos/asf/geode/blob/aa9ced53/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
index 6c31025..708ac1e 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneResultStructImpl.java
@@ -15,13 +15,23 @@
 
 package org.apache.geode.cache.lucene.internal;
 
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.geode.DataSerializer;
 import org.apache.geode.cache.lucene.LuceneResultStruct;
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.Version;
 
-public class LuceneResultStructImpl<K, V> implements LuceneResultStruct<K, V>
{
+public class LuceneResultStructImpl<K, V>
+    implements LuceneResultStruct<K, V>, DataSerializableFixedID {
   K key;
   V value;
   float score;
 
+  public LuceneResultStructImpl() {}
+
   public LuceneResultStructImpl(K key, V value, float score) {
     this.key = key;
     this.value = value;
@@ -81,4 +91,29 @@ public class LuceneResultStructImpl<K, V> implements LuceneResultStruct<K,
V> {
   public String toString() {
     return "LuceneResultStructImpl [key=" + key + ", value=" + value + ", score=" + score
+ "]";
   }
+
+  @Override
+  public Version[] getSerializationVersions() {
+    return null;
+  }
+
+  @Override
+  public int getDSFID() {
+    return LUCENE_RESULT_STRUCT;
+  }
+
+  @Override
+  public void toData(DataOutput out) throws IOException {
+    DataSerializer.writeObject(key, out);
+    DataSerializer.writeObject(value, out);
+    out.writeFloat(score);
+  }
+
+  @Override
+  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
+    key = DataSerializer.readObject(in);
+    value = DataSerializer.readObject(in);
+    score = in.readFloat();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/aa9ced53/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index 5c908f5..a212094 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -381,6 +381,9 @@ public class LuceneServiceImpl implements InternalLuceneService {
         DestroyLuceneIndexMessage.class);
 
     DSFIDFactory.registerDSFID(DataSerializableFixedID.LUCENE_PAGE_RESULTS, PageResults.class);
+
+    DSFIDFactory.registerDSFID(DataSerializableFixedID.LUCENE_RESULT_STRUCT,
+        LuceneResultStructImpl.class);
   }
 
   public Collection<LuceneIndexCreationProfile> getAllDefinedIndexes() {


Mime
View raw message