incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixing issue where byte[] (ByteBuffer for thrift) were not working correctly.
Date Tue, 21 Apr 2015 14:02:37 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 67984a6a7 -> 594b661ed


Fixing issue where byte[] (ByteBuffer for thrift) were not working correctly.


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

Branch: refs/heads/master
Commit: 594b661eda7ae2844fe1eb61ec8a29c9fde45247
Parents: 67984a6
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Apr 21 10:02:26 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Apr 21 10:02:26 2015 -0400

----------------------------------------------------------------------
 .../src/main/java/org/apache/blur/command/BlurObject.java | 10 +++++++++-
 .../main/java/org/apache/blur/command/CommandUtil.java    |  7 +++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/594b661e/blur-core/src/main/java/org/apache/blur/command/BlurObject.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/command/BlurObject.java b/blur-core/src/main/java/org/apache/blur/command/BlurObject.java
index 841273a..0f2c313 100644
--- a/blur-core/src/main/java/org/apache/blur/command/BlurObject.java
+++ b/blur-core/src/main/java/org/apache/blur/command/BlurObject.java
@@ -16,6 +16,7 @@
  */
 package org.apache.blur.command;
 
+import java.nio.ByteBuffer;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -162,7 +163,14 @@ public class BlurObject {
   }
 
   public byte[] getBinary(String name) {
-    return (byte[]) _valueMap.get(name);
+    Object val = _valueMap.get(name);
+    if (val instanceof ByteBuffer) {
+      ByteBuffer buff = (ByteBuffer) val;
+      byte[] temp = new byte[buff.remaining()];
+      buff.get(temp);
+      return temp;
+    }
+    return (byte[]) val;
   }
 
   public byte[] getBinary(String name, byte[] defaultVal) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/594b661e/blur-core/src/main/java/org/apache/blur/command/CommandUtil.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/command/CommandUtil.java b/blur-core/src/main/java/org/apache/blur/command/CommandUtil.java
index 1c5b652..8816b0b 100644
--- a/blur-core/src/main/java/org/apache/blur/command/CommandUtil.java
+++ b/blur-core/src/main/java/org/apache/blur/command/CommandUtil.java
@@ -1,6 +1,7 @@
 package org.apache.blur.command;
 
 import java.lang.reflect.Field;
+import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -118,6 +119,12 @@ public class CommandUtil {
     } else if (o instanceof byte[]) {
       value.setBinaryValue((byte[]) o);
       return value;
+    } else if (o instanceof ByteBuffer) {
+      ByteBuffer buff = (ByteBuffer) o;
+      byte[] temp = new byte[buff.remaining()];
+      buff.get(temp);
+      value.setBinaryValue(temp);
+      return value;
     } else if (o instanceof Double) {
       value.setDoubleValue((Double) o);
       return value;


Mime
View raw message