geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [1/3] incubator-geode git commit: Minor fixes
Date Tue, 17 May 2016 00:04:36 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1392 f3f8a81a9 -> 95e2e8317


Minor fixes


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

Branch: refs/heads/feature/GEODE-1392
Commit: e19a278ebcc6df8dbf99815482f625fdfebf74ba
Parents: f3f8a81
Author: Kirk Lund <klund@pivotal.io>
Authored: Mon May 16 13:39:46 2016 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Mon May 16 13:39:46 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/util/BlobHelper.java       | 72 ++++++--------------
 1 file changed, 21 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e19a278e/geode-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
index 28252c3..a2ba434 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/util/BlobHelper.java
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.gemstone.gemfire.internal.util;
 
 import java.io.IOException;
@@ -26,19 +25,17 @@ import com.gemstone.gemfire.internal.ByteArrayDataInput;
 import com.gemstone.gemfire.internal.DSCODE;
 import com.gemstone.gemfire.internal.HeapDataOutputStream;
 import com.gemstone.gemfire.internal.Version;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
 import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
 import com.gemstone.gemfire.pdx.internal.PdxInputStream;
 
 /**
  * A "blob" is a serialized representation of an object into a byte[].
- * BlobHelper provides utility methods for
- * serializing and deserializing the object.
- * 
- * 
+ * BlobHelper provides utility methods for serializing and deserializing the
+ * object.
+ *
+ * TODO: compare performance with org.apache.commons.lang.SerializationUtils
  */
-
 public class BlobHelper {
 
   /**
@@ -50,12 +47,10 @@ public class BlobHelper {
   }
 
   /**
-   * A blob is a serialized Object.  This method serializes the
-   * object into a blob and returns the byte array that contains the blob.
+   * A blob is a serialized Object.  This method serializes the object into a
+   * blob and returns the byte array that contains the blob.
    */
-  public static byte[] serializeToBlob(Object obj, Version version)
-  throws IOException
-  {
+  public static byte[] serializeToBlob(Object obj, Version version) throws IOException {
     final long start = startSerialization();
     HeapDataOutputStream hdos = new HeapDataOutputStream(version);
     DataSerializer.writeObject(obj, hdos);
@@ -65,45 +60,32 @@ public class BlobHelper {
   }
 
   /**
-   * A blob is a serialized Object.  This method serializes the
-   * object into the given HeapDataOutputStream.
+   * A blob is a serialized Object.  This method serializes the object into
+   * the given HeapDataOutputStream.
    */
-  public static void serializeTo(Object obj, HeapDataOutputStream hdos)
-    throws IOException
-  {
+  public static void serializeTo(Object obj, HeapDataOutputStream hdos) throws IOException
{
     final int startBytes = hdos.size();
     final long start = startSerialization();
     DataSerializer.writeObject(obj, hdos);
     endSerialization(start, hdos.size()-startBytes);
   }
-                                                                        
-
 
   /**
-   * A blob is a serialized Object.  This method 
-   * returns the deserialized object.
+   * A blob is a serialized Object.  This method returns the deserialized
+   * object.
    */
-  public static Object deserializeBlob(byte[] blob) throws IOException,
-      ClassNotFoundException {
+  public static Object deserializeBlob(byte[] blob) throws IOException, ClassNotFoundException
{
     return deserializeBlob(blob, null, null);
   }
 
   /**
-   * A blob is a serialized Object.  This method 
-   * returns the deserialized object.
+   * A blob is a serialized Object.  This method returns the deserialized
+   * object.
    */
-  public static Object deserializeBlob(byte[] blob, Version version,
-      ByteArrayDataInput in) throws IOException, ClassNotFoundException {
+  public static Object deserializeBlob(byte[] blob, Version version, ByteArrayDataInput in)
throws IOException, ClassNotFoundException {
     Object result;
     final long start = startDeserialization();
-    /*
-    final StaticSystemCallbacks sysCb;
-    if (version != null && (sysCb = GemFireCacheImpl.FactoryStatics
-        .systemCallbacks) != null) {
-      // may need to change serialized shape for SQLFire
-      result = sysCb.fromVersion(blob, true, version, in);
-    }
-    else*/ if (blob.length > 0 && blob[0] == DSCODE.PDX) {
+    if (blob.length > 0 && blob[0] == DSCODE.PDX) {
       // If the first byte of blob indicates a pdx then wrap
       // blob in a PdxInputStream instead.
       // This will prevent us from making a copy of the byte[]
@@ -121,24 +103,13 @@ public class BlobHelper {
       result = DataSerializer.readObject(in);
     }
     endDeserialization(start, blob.length);
-    // this causes a small performance drop in d-no-ack performance tests
-//    if (dis.available() != 0) {
-//      LogWriterI18n lw = InternalDistributedSystem.getLoggerI18n();
-//      if (lw != null && lw.warningEnabled()) {
-//        lw.warning(
-//            LocalizedStrings.BlobHelper_DESERIALIZATION_OF_A_0_DID_NOT_READ_1_BYTES_THIS_INDICATES_A_LOGIC_ERROR_IN_THE_SERIALIZATION_CODE_FOR_THIS_CLASS,
-//            new Object[] {((result!=null) ? result.getClass().getName() : "NULL"), Integer.valueOf(dis.available())});
  
-//            
-//      }
-//    }
     return result;
   }
 
   /**
-   * A blob is a serialized Object.  This method 
-   * returns the deserialized object.
-   * If a PdxInstance is returned then it will refer to Chunk's off-heap memory
-   * with an unretained reference.
+   * A blob is a serialized Object.  This method returns the deserialized
+   * object. If a PdxInstance is returned then it will refer to Chunk's
+   * off-heap memory with an unretained reference.
    */
   public static @Unretained Object deserializeOffHeapBlob(StoredObject blob) throws IOException,
ClassNotFoundException {
     Object result;
@@ -152,8 +123,7 @@ public class BlobHelper {
     return result;
   }
 
-  public static Object deserializeBuffer(ByteArrayDataInput in, int numBytes)
-      throws IOException, ClassNotFoundException {
+  public static Object deserializeBuffer(ByteArrayDataInput in, int numBytes) throws IOException,
ClassNotFoundException {
     final long start = startDeserialization();
     Object result = DataSerializer.readObject(in);
     endDeserialization(start, numBytes);


Mime
View raw message