accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [09/10] git commit: More utf8, avoid unnecessary String creation and Long creation.
Date Fri, 31 Jan 2014 04:02:01 GMT
More utf8, avoid unnecessary String creation and Long creation.


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

Branch: refs/heads/2292-findbugs
Commit: 8b56d7489f53d84c43f1e676e356e19c70020563
Parents: 0df5692
Author: Josh Elser <elserj@apache.org>
Authored: Thu Jan 30 21:53:18 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Thu Jan 30 21:53:18 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/accumulo/core/data/ArrayByteSequence.java  | 6 ++++--
 core/src/main/java/org/apache/accumulo/core/data/Column.java   | 5 +++--
 .../main/java/org/apache/accumulo/core/data/ColumnUpdate.java  | 6 +++---
 core/src/main/java/org/apache/accumulo/core/data/KeyValue.java | 4 +++-
 4 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b56d748/core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java b/core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java
index d44a7a6..99e588d 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java
@@ -18,6 +18,8 @@ package org.apache.accumulo.core.data;
 
 import java.io.Serializable;
 
+import org.apache.accumulo.core.Constants;
+
 public class ArrayByteSequence extends ByteSequence implements Serializable {
   
   private static final long serialVersionUID = 1L;
@@ -45,7 +47,7 @@ public class ArrayByteSequence extends ByteSequence implements Serializable
{
   }
   
   public ArrayByteSequence(String s) {
-    this(s.getBytes());
+    this(s.getBytes(Constants.UTF8));
   }
   
   @Override
@@ -103,6 +105,6 @@ public class ArrayByteSequence extends ByteSequence implements Serializable
{
   }
   
   public String toString() {
-    return new String(data, offset, length);
+    return new String(data, offset, length, Constants.UTF8);
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b56d748/core/src/main/java/org/apache/accumulo/core/data/Column.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/Column.java b/core/src/main/java/org/apache/accumulo/core/data/Column.java
index a56c01d..054899f 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Column.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Column.java
@@ -23,6 +23,7 @@ import java.io.DataOutput;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.data.thrift.TColumn;
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.io.WritableComparator;
@@ -158,8 +159,8 @@ public class Column implements WritableComparable<Column> {
   }
   
   public String toString() {
-    return new String(columnFamily == null ? new byte[0] : columnFamily) + ":" + new String(columnQualifier
== null ? new byte[0] : columnQualifier) + ":"
-        + new String(columnVisibility == null ? new byte[0] : columnVisibility);
+    return new String(columnFamily == null ? new byte[0] : columnFamily, Constants.UTF8)
+ ":" + new String(columnQualifier == null ? new byte[0] : columnQualifier, Constants.UTF8)
+ ":"
+        + new String(columnVisibility == null ? new byte[0] : columnVisibility, Constants.UTF8);
   }
   
   public TColumn toThrift() {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b56d748/core/src/main/java/org/apache/accumulo/core/data/ColumnUpdate.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/ColumnUpdate.java b/core/src/main/java/org/apache/accumulo/core/data/ColumnUpdate.java
index 691ec0e..bfba00f 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/ColumnUpdate.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/ColumnUpdate.java
@@ -87,8 +87,8 @@ public class ColumnUpdate {
   
   @Override
   public String toString() {
-    return new String(Arrays.toString(columnFamily)) + ":" + new String(Arrays.toString(columnQualifier))
+ " ["
-        + new String(Arrays.toString(columnVisibility)) + "] " + (hasTimestamp ? timestamp
: "NO_TIME_STAMP") + " " + Arrays.toString(val) + " " + deleted;
+    return Arrays.toString(columnFamily) + ":" + Arrays.toString(columnQualifier) + " ["
+        + Arrays.toString(columnVisibility) + "] " + (hasTimestamp ? timestamp : "NO_TIME_STAMP")
+ " " + Arrays.toString(val) + " " + deleted;
   }
   
   @Override
@@ -104,7 +104,7 @@ public class ColumnUpdate {
   @Override
   public int hashCode() {
     return Arrays.hashCode(columnFamily) + Arrays.hashCode(columnQualifier) + Arrays.hashCode(columnVisibility)
-        + (hasTimestamp ? (Boolean.TRUE.hashCode() + new Long(timestamp).hashCode()) : Boolean.FALSE.hashCode())
+        + (hasTimestamp ? (Boolean.TRUE.hashCode() + Long.valueOf(timestamp).hashCode())
: Boolean.FALSE.hashCode())
         + (deleted ? Boolean.TRUE.hashCode() : (Boolean.FALSE.hashCode() + Arrays.hashCode(val)));
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b56d748/core/src/main/java/org/apache/accumulo/core/data/KeyValue.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/KeyValue.java b/core/src/main/java/org/apache/accumulo/core/data/KeyValue.java
index cc48322..90b2d7c 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/KeyValue.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/KeyValue.java
@@ -21,6 +21,8 @@ import static org.apache.accumulo.core.util.ByteBufferUtil.toBytes;
 import java.nio.ByteBuffer;
 import java.util.Map;
 
+import org.apache.accumulo.core.Constants;
+
 public class KeyValue implements Map.Entry<Key,Value> {
   
   public Key key;
@@ -52,7 +54,7 @@ public class KeyValue implements Map.Entry<Key,Value> {
   }
   
   public String toString() {
-    return key + " " + new String(value);
+    return key + " " + new String(value, Constants.UTF8);
   }
   
 }


Mime
View raw message