You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/01/31 05:01:53 UTC
[01/10] git commit: ACCUMULO-2292 Remove unnecessary imports
Updated Branches:
refs/heads/2292-findbugs [created] d1f139eb4
ACCUMULO-2292 Remove unnecessary imports
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/3636136b
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3636136b
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3636136b
Branch: refs/heads/2292-findbugs
Commit: 3636136bf37dea47cf870287fb95e83a9105973e
Parents: cfc7fec
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 15:34:13 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 17:19:27 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/trace/instrument/CountSamplerTest.java | 2 --
.../org/apache/accumulo/trace/instrument/PerformanceTest.java | 2 --
.../java/org/apache/accumulo/trace/instrument/TracerTest.java | 3 ---
3 files changed, 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3636136b/trace/src/test/java/org/apache/accumulo/trace/instrument/CountSamplerTest.java
----------------------------------------------------------------------
diff --git a/trace/src/test/java/org/apache/accumulo/trace/instrument/CountSamplerTest.java b/trace/src/test/java/org/apache/accumulo/trace/instrument/CountSamplerTest.java
index 78df4b6..7b5e970 100644
--- a/trace/src/test/java/org/apache/accumulo/trace/instrument/CountSamplerTest.java
+++ b/trace/src/test/java/org/apache/accumulo/trace/instrument/CountSamplerTest.java
@@ -17,8 +17,6 @@
package org.apache.accumulo.trace.instrument;
import org.junit.Assert;
-
-import org.apache.accumulo.trace.instrument.CountSampler;
import org.junit.Test;
public class CountSamplerTest {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3636136b/trace/src/test/java/org/apache/accumulo/trace/instrument/PerformanceTest.java
----------------------------------------------------------------------
diff --git a/trace/src/test/java/org/apache/accumulo/trace/instrument/PerformanceTest.java b/trace/src/test/java/org/apache/accumulo/trace/instrument/PerformanceTest.java
index 8f88469..2e5aaa5 100644
--- a/trace/src/test/java/org/apache/accumulo/trace/instrument/PerformanceTest.java
+++ b/trace/src/test/java/org/apache/accumulo/trace/instrument/PerformanceTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.accumulo.trace.instrument;
-import org.apache.accumulo.trace.instrument.Span;
-import org.apache.accumulo.trace.instrument.Trace;
import org.junit.Test;
public class PerformanceTest {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/3636136b/trace/src/test/java/org/apache/accumulo/trace/instrument/TracerTest.java
----------------------------------------------------------------------
diff --git a/trace/src/test/java/org/apache/accumulo/trace/instrument/TracerTest.java b/trace/src/test/java/org/apache/accumulo/trace/instrument/TracerTest.java
index 0288241..7dbdc83 100644
--- a/trace/src/test/java/org/apache/accumulo/trace/instrument/TracerTest.java
+++ b/trace/src/test/java/org/apache/accumulo/trace/instrument/TracerTest.java
@@ -28,9 +28,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.accumulo.trace.instrument.Span;
-import org.apache.accumulo.trace.instrument.Trace;
-import org.apache.accumulo.trace.instrument.Tracer;
import org.apache.accumulo.trace.instrument.receivers.SpanReceiver;
import org.apache.accumulo.trace.instrument.thrift.TraceWrap;
import org.apache.accumulo.trace.thrift.TInfo;
[02/10] git commit: ACCUMULO-2292 Fix findbugs errors in trace module
Posted by el...@apache.org.
ACCUMULO-2292 Fix findbugs errors in trace module
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/cfc7fecc
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/cfc7fecc
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/cfc7fecc
Branch: refs/heads/2292-findbugs
Commit: cfc7feccad3c52af162d56243733a0204dbc95b6
Parents: 5fe2ccc
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 15:29:40 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 17:19:27 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/trace/instrument/TraceRunnable.java | 9 +++++++++
.../accumulo/trace/instrument/receivers/ZooSpanClient.java | 4 +++-
2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfc7fecc/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java
index a13f2be..41c765d 100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/TraceRunnable.java
@@ -48,6 +48,15 @@ public class TraceRunnable implements Runnable, Comparable<TraceRunnable> {
}
}
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof TraceRunnable) {
+ return 0 == this.compareTo((TraceRunnable) o);
+ }
+
+ return false;
+ }
+
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public int compareTo(TraceRunnable o) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfc7fecc/trace/src/main/java/org/apache/accumulo/trace/instrument/receivers/ZooSpanClient.java
----------------------------------------------------------------------
diff --git a/trace/src/main/java/org/apache/accumulo/trace/instrument/receivers/ZooSpanClient.java b/trace/src/main/java/org/apache/accumulo/trace/instrument/receivers/ZooSpanClient.java
index d6db906..049b2a2 100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/receivers/ZooSpanClient.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/receivers/ZooSpanClient.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.trace.instrument.receivers;
import java.io.IOException;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -38,6 +39,7 @@ public class ZooSpanClient extends SendSpansViaThrift {
private static final Logger log = Logger.getLogger(ZooSpanClient.class);
private static final int TOTAL_TIME_WAIT_CONNECT_MS = 10 * 1000;
private static final int TIME_WAIT_CONNECT_CHECK_MS = 100;
+ private static final Charset UTF8 = Charset.forName("UTF-8");
ZooKeeper zoo = null;
final String path;
@@ -108,7 +110,7 @@ public class ZooSpanClient extends SendSpansViaThrift {
List<String> hosts = new ArrayList<String>();
for (String child : children) {
byte[] data = zoo.getData(path + "/" + child, null, null);
- hosts.add(new String(data));
+ hosts.add(new String(data, UTF8));
}
this.hosts.clear();
this.hosts.addAll(hosts);
[10/10] git commit: Make Comparators Serializable too, UTF8,
and entrySet instead of keySet
Posted by el...@apache.org.
Make Comparators Serializable too, UTF8, and entrySet instead of keySet
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d1f139eb
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d1f139eb
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d1f139eb
Branch: refs/heads/2292-findbugs
Commit: d1f139eb498b93c7e3e2c127b611e2cce080cd0d
Parents: 8b56d74
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 23:00:39 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 23:00:39 2014 -0500
----------------------------------------------------------------------
.../apache/accumulo/core/file/BloomFilterLayer.java | 5 +++--
.../core/file/rfile/bcfile/CompareUtils.java | 9 +++++++--
.../core/file/rfile/bcfile/TFileDumper.java | 3 ++-
.../core/iterators/ColumnFamilyCounter.java | 3 ++-
.../accumulo/core/iterators/IteratorUtil.java | 6 ++++--
.../accumulo/core/iterators/LongCombiner.java | 5 +++--
.../accumulo/core/iterators/conf/ColumnSet.java | 5 +++--
.../core/iterators/user/BigDecimalCombiner.java | 5 +++--
.../accumulo/core/iterators/user/GrepIterator.java | 3 ++-
.../core/iterators/user/IntersectingIterator.java | 11 ++++++-----
.../core/iterators/user/LargeRowFilter.java | 3 ++-
.../accumulo/core/iterators/user/RegExFilter.java | 3 ++-
.../core/iterators/user/RowDeletingIterator.java | 3 ++-
.../core/iterators/user/SummingArrayCombiner.java | 5 +++--
.../core/iterators/user/TransformingIterator.java | 16 +++++++++-------
15 files changed, 53 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java b/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java
index e79da37..01485d3 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java
@@ -36,6 +36,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.bloomfilter.DynamicBloomFilter;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.ConfigurationCopy;
@@ -433,8 +434,8 @@ public class BloomFilterLayer {
for (Integer i : vals) {
String fi = String.format("%010d", i);
- bmfw.append(new org.apache.accumulo.core.data.Key(new Text("r" + fi), new Text("cf1")), new Value(("v" + fi).getBytes()));
- bmfw.append(new org.apache.accumulo.core.data.Key(new Text("r" + fi), new Text("cf2")), new Value(("v" + fi).getBytes()));
+ bmfw.append(new org.apache.accumulo.core.data.Key(new Text("r" + fi), new Text("cf1")), new Value(("v" + fi).getBytes(Constants.UTF8)));
+ bmfw.append(new org.apache.accumulo.core.data.Key(new Text("r" + fi), new Text("cf2")), new Value(("v" + fi).getBytes(Constants.UTF8)));
}
long t2 = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/CompareUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/CompareUtils.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/CompareUtils.java
index 9dba4b1..0e2bb17 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/CompareUtils.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/CompareUtils.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.core.file.rfile.bcfile;
+import java.io.Serializable;
import java.util.Comparator;
import org.apache.hadoop.io.RawComparator;
@@ -68,7 +69,9 @@ class CompareUtils {
}
}
- public static final class ScalarComparator implements Comparator<Scalar> {
+ public static final class ScalarComparator implements Comparator<Scalar>, Serializable {
+ private static final long serialVersionUID = 1L;
+
@Override
public int compare(Scalar o1, Scalar o2) {
long diff = o1.magnitude() - o2.magnitude();
@@ -80,7 +83,9 @@ class CompareUtils {
}
}
- public static final class MemcmpRawComparator implements RawComparator<Object> {
+ public static final class MemcmpRawComparator implements RawComparator<Object>, Serializable {
+ private static final long serialVersionUID = 1L;
+
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
return WritableComparator.compareBytes(b1, s1, l1, b2, s2, l2);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/TFileDumper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/TFileDumper.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/TFileDumper.java
index d5b0a1b..9b9cd51 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/TFileDumper.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/TFileDumper.java
@@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.file.rfile.bcfile.BCFile.BlockRegion;
import org.apache.accumulo.core.file.rfile.bcfile.BCFile.MetaIndexEntry;
import org.apache.accumulo.core.file.rfile.bcfile.TFile.TFileIndexEntry;
@@ -208,7 +209,7 @@ class TFileDumper {
out.printf("%X", b);
}
} else {
- out.print(new String(key, 0, sampleLen));
+ out.print(new String(key, 0, sampleLen, Constants.UTF8));
}
if (sampleLen < key.length) {
out.print("...");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/ColumnFamilyCounter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/ColumnFamilyCounter.java b/core/src/main/java/org/apache/accumulo/core/iterators/ColumnFamilyCounter.java
index f780868..b187808 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/ColumnFamilyCounter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/ColumnFamilyCounter.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Map;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.ByteSequence;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Range;
@@ -58,7 +59,7 @@ public class ColumnFamilyCounter implements SortedKeyValueIterator<Key,Value> {
}
this.key = new Key(currentRow.toArray(), currentColf.toArray(), new byte[0], new byte[0], ts);
- this.value = new Value(Integer.toString(count).getBytes());
+ this.value = new Value(Integer.toString(count).getBytes(Constants.UTF8));
} else {
this.key = null;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java
index 049f854..1d58c2f 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.core.iterators;
import java.io.IOException;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -54,8 +55,9 @@ public class IteratorUtil {
majc, minc, scan;
}
- public static class IterInfoComparator implements Comparator<IterInfo> {
-
+ public static class IterInfoComparator implements Comparator<IterInfo>, Serializable {
+ private static final long serialVersionUID = 1L;
+
@Override
public int compare(IterInfo o1, IterInfo o2) {
return (o1.priority < o2.priority ? -1 : (o1.priority == o2.priority ? 0 : 1));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
index da23699..a4efec9 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
@@ -23,6 +23,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
@@ -178,13 +179,13 @@ public abstract class LongCombiner extends TypedValueCombiner<Long> {
public static class StringEncoder implements Encoder<Long> {
@Override
public byte[] encode(Long v) {
- return Long.toString(v).getBytes();
+ return Long.toString(v).getBytes(Constants.UTF8);
}
@Override
public Long decode(byte[] b) {
try {
- return Long.parseLong(new String(b));
+ return Long.parseLong(new String(b, Constants.UTF8));
} catch (NumberFormatException nfe) {
throw new ValueFormatException(nfe);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java b/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java
index 93c1d37..985216c 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/conf/ColumnSet.java
@@ -20,6 +20,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.iterators.conf.ColumnUtil.ColFamHashKey;
import org.apache.accumulo.core.iterators.conf.ColumnUtil.ColHashKey;
@@ -135,7 +136,7 @@ public class ColumnSet {
static Text decode(String s) {
Text t = new Text();
- byte[] sb = s.getBytes();
+ byte[] sb = s.getBytes(Constants.UTF8);
// very inefficient code
for (int i = 0; i < sb.length; i++) {
@@ -143,7 +144,7 @@ public class ColumnSet {
t.append(new byte[] {sb[i]}, 0, 1);
} else {
byte hex[] = new byte[] {sb[++i], sb[++i]};
- String hs = new String(hex);
+ String hs = new String(hex, Constants.UTF8);
int b = Integer.parseInt(hs, 16);
t.append(new byte[] {(byte) b}, 0, 1);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java
index b037e17..dfea550 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/BigDecimalCombiner.java
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
import java.util.Iterator;
import java.util.Map;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.IteratorEnvironment;
@@ -102,13 +103,13 @@ public abstract class BigDecimalCombiner extends TypedValueCombiner<BigDecimal>
public static class BigDecimalEncoder implements org.apache.accumulo.core.iterators.TypedValueCombiner.Encoder<BigDecimal> {
@Override
public byte[] encode(BigDecimal v) {
- return v.toString().getBytes();
+ return v.toString().getBytes(Constants.UTF8);
}
@Override
public BigDecimal decode(byte[] b) throws ValueFormatException {
try {
- return new BigDecimal(new String(b));
+ return new BigDecimal(new String(b, Constants.UTF8));
} catch (NumberFormatException nfe) {
throw new ValueFormatException(nfe);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
index ab8ca84..4f8207c 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/GrepIterator.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.ByteSequence;
import org.apache.accumulo.core.data.Key;
@@ -88,7 +89,7 @@ public class GrepIterator extends Filter {
@Override
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
super.init(source, options, env);
- term = options.get("term").getBytes();
+ term = options.get("term").getBytes(Constants.UTF8);
}
/**
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
index dbad38f..447200b 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/IntersectingIterator.java
@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Map;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.ArrayByteSequence;
import org.apache.accumulo.core.data.ByteSequence;
@@ -111,7 +112,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
}
public String getTermString() {
- return (this.term == null) ? new String("Iterator") : this.term.toString();
+ return (this.term == null) ? "Iterator" : this.term.toString();
}
}
@@ -391,7 +392,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
protected static String encodeColumns(Text[] columns) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < columns.length; i++) {
- sb.append(new String(Base64.encodeBase64(TextUtil.getBytes(columns[i]))));
+ sb.append(new String(Base64.encodeBase64(TextUtil.getBytes(columns[i])), Constants.UTF8));
sb.append('\n');
}
return sb.toString();
@@ -409,14 +410,14 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
else
bytes[i] = 0;
}
- return new String(Base64.encodeBase64(bytes));
+ return new String(Base64.encodeBase64(bytes), Constants.UTF8);
}
protected static Text[] decodeColumns(String columns) {
String[] columnStrings = columns.split("\n");
Text[] columnTexts = new Text[columnStrings.length];
for (int i = 0; i < columnStrings.length; i++) {
- columnTexts[i] = new Text(Base64.decodeBase64(columnStrings[i].getBytes()));
+ columnTexts[i] = new Text(Base64.decodeBase64(columnStrings[i].getBytes(Constants.UTF8)));
}
return columnTexts;
}
@@ -430,7 +431,7 @@ public class IntersectingIterator implements SortedKeyValueIterator<Key,Value> {
if (flags == null)
return null;
- byte[] bytes = Base64.decodeBase64(flags.getBytes());
+ byte[] bytes = Base64.decodeBase64(flags.getBytes(Constants.UTF8));
boolean[] bFlags = new boolean[bytes.length];
for (int i = 0; i < bytes.length; i++) {
if (bytes[i] == 1)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
index d79604c..fdad848 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.ArrayByteSequence;
import org.apache.accumulo.core.data.ByteSequence;
@@ -44,7 +45,7 @@ import org.apache.hadoop.io.Text;
*/
public class LargeRowFilter implements SortedKeyValueIterator<Key,Value>, OptionDescriber {
- public static final Value SUPPRESS_ROW_VALUE = new Value("SUPPRESS_ROW".getBytes());
+ public static final Value SUPPRESS_ROW_VALUE = new Value("SUPPRESS_ROW".getBytes(Constants.UTF8));
private static final ByteSequence EMPTY = new ArrayByteSequence(new byte[] {});
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
index b110d34..3f5669e 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.ByteSequence;
import org.apache.accumulo.core.data.Key;
@@ -192,7 +193,7 @@ public class RegExFilter extends Filter {
this.encoding = options.get(ENCODING);
if ("".equals(this.encoding))
encoding = ENCODING_DEFAULT;
- new String("test".getBytes(), encoding);
+ new String("test".getBytes(Constants.UTF8), encoding);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("invalid encoding " + ENCODING + ":" + this.encoding, e);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/user/RowDeletingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/RowDeletingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/RowDeletingIterator.java
index b139096..45860eb 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/RowDeletingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/RowDeletingIterator.java
@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.ArrayByteSequence;
import org.apache.accumulo.core.data.ByteSequence;
import org.apache.accumulo.core.data.Key;
@@ -48,7 +49,7 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
public class RowDeletingIterator implements SortedKeyValueIterator<Key,Value> {
- public static final Value DELETE_ROW_VALUE = new Value("DEL_ROW".getBytes());
+ public static final Value DELETE_ROW_VALUE = new Value("DEL_ROW".getBytes(Constants.UTF8));
private SortedKeyValueIterator<Key,Value> source;
private boolean propogateDeletes;
private ByteSequence currentRow;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java
index 0ab0cc0..77c829a 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java
@@ -27,6 +27,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
@@ -207,12 +208,12 @@ public class SummingArrayCombiner extends TypedValueCombiner<List<Long>> {
sb.append(",");
sb.append(Long.toString(la.get(i)));
}
- return sb.toString().getBytes();
+ return sb.toString().getBytes(Constants.UTF8);
}
@Override
public List<Long> decode(byte[] b) {
- String[] longstrs = new String(b).split(",");
+ String[] longstrs = new String(b, Constants.UTF8).split(",");
List<Long> la = new ArrayList<Long>(longstrs.length);
for (String s : longstrs) {
if (s.length() == 0)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1f139eb/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
index f439437..8835b1c 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
@@ -24,8 +24,10 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.data.ByteSequence;
@@ -110,7 +112,7 @@ abstract public class TransformingIterator extends WrappingIterator implements O
if (scanning) {
String auths = options.get(AUTH_OPT);
if (auths != null && !auths.isEmpty()) {
- ve = new VisibilityEvaluator(new Authorizations(auths.getBytes()));
+ ve = new VisibilityEvaluator(new Authorizations(auths.getBytes(Constants.UTF8)));
visibleCache = new LRUMap(100);
}
}
@@ -141,15 +143,15 @@ abstract public class TransformingIterator extends WrappingIterator implements O
@Override
public boolean validateOptions(Map<String,String> options) {
- for (String opt : options.keySet()) {
+ for (Entry<String,String> option : options.entrySet()) {
try {
- if (opt.equals(AUTH_OPT)) {
- new Authorizations(options.get(opt).getBytes());
- } else if (opt.equals(MAX_BUFFER_SIZE_OPT)) {
- AccumuloConfiguration.getMemoryInBytes(options.get(opt));
+ if (option.getKey().equals(AUTH_OPT)) {
+ new Authorizations(option.getValue().getBytes(Constants.UTF8));
+ } else if (option.getKey().equals(MAX_BUFFER_SIZE_OPT)) {
+ AccumuloConfiguration.getMemoryInBytes(option.getValue());
}
} catch (Exception e) {
- throw new IllegalArgumentException("Failed to parse opt " + opt + " " + options.get(opt), e);
+ throw new IllegalArgumentException("Failed to parse opt " + option.getKey() + " " + option.getValue(), e);
}
}
[07/10] git commit: More String UTF8 charsets and add Serializable to
the Comparator to make sure the TreeMap is thus also serializable.
Posted by el...@apache.org.
More String UTF8 charsets and add Serializable to the Comparator to make sure the TreeMap is thus also serializable.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/6770ed97
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/6770ed97
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/6770ed97
Branch: refs/heads/2292-findbugs
Commit: 6770ed97233dc5d148764708a6d77216d1005119
Parents: 40c3319
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 17:37:37 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 17:37:37 2014 -0500
----------------------------------------------------------------------
.../main/java/org/apache/accumulo/core/client/impl/Tables.java | 6 +++---
.../apache/accumulo/core/client/impl/TabletLocatorImpl.java | 5 ++++-
.../main/java/org/apache/accumulo/core/client/impl/Writer.java | 3 ++-
3 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6770ed97/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
index d1b10d4..07f75e0 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
@@ -53,9 +53,9 @@ public class Tables {
byte[] tblPath = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAME);
if (tblPath != null) {
if (nameAsKey)
- tableMap.put(new String(tblPath), tableId);
+ tableMap.put(new String(tblPath, Constants.UTF8), tableId);
else
- tableMap.put(tableId, new String(tblPath));
+ tableMap.put(tableId, new String(tblPath, Constants.UTF8));
}
}
@@ -112,7 +112,7 @@ public class Tables {
if (state == null)
return TableState.UNKNOWN;
- return TableState.valueOf(new String(state));
+ return TableState.valueOf(new String(state, Constants.UTF8));
}
public static long getCacheResetCount() {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6770ed97/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
index ea9c73d..f510549 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.core.client.impl;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -57,8 +58,10 @@ public class TabletLocatorImpl extends TabletLocator {
// putting null, put MAX_TEXT
static final Text MAX_TEXT = new Text();
- private static class EndRowComparator implements Comparator<Text> {
+ private static class EndRowComparator implements Comparator<Text>, Serializable {
+ private static final long serialVersionUID = 1L;
+
public int compare(Text o1, Text o2) {
int ret;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6770ed97/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java
index cec700d..7353e54 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.core.client.impl;
import org.apache.accumulo.trace.instrument.Tracer;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Instance;
@@ -87,7 +88,7 @@ public class Writer {
TabletLocation tabLoc = TabletLocator.getInstance(instance, table).locateTablet(new Text(m.getRow()), false, true, credentials);
if (tabLoc == null) {
- log.trace("No tablet location found for row " + new String(m.getRow()));
+ log.trace("No tablet location found for row " + new String(m.getRow(), Constants.UTF8));
UtilWaitThread.sleep(500);
continue;
}
[09/10] git commit: More utf8,
avoid unnecessary String creation and Long creation.
Posted by el...@apache.org.
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 <el...@apache.org>
Authored: Thu Jan 30 21:53:18 2014 -0500
Committer: Josh Elser <el...@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);
}
}
[06/10] git commit: Eliminiate an extra string creation unnecessarily
Posted by el...@apache.org.
Eliminiate an extra string creation unnecessarily
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/40c3319d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/40c3319d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/40c3319d
Branch: refs/heads/2292-findbugs
Commit: 40c3319d0e384be92565f64000496c4b7b575fac
Parents: 4fa2e62
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 17:23:19 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 17:23:19 2014 -0500
----------------------------------------------------------------------
.../apache/accumulo/core/client/impl/ServerClient.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/40c3319d/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
index 0e301a5..5b97941 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ServerClient.java
@@ -140,11 +140,13 @@ public class ServerClient {
for (String tserver : zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTSERVERS)) {
String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + tserver;
byte[] data = ZooUtil.getLockData(zc, path);
- if (data != null && !new String(data).equals("master"))
- servers.add(new ThriftTransportKey(
- new ServerServices(new String(data)).getAddressString(Service.TSERV_CLIENT),
- conf.getPort(Property.TSERV_CLIENTPORT),
- rpcTimeout));
+ if (data != null) {
+ String tserverData = new String(data, Constants.UTF8);
+ if (!tserverData.equals("master")) {
+ servers.add(new ThriftTransportKey(new ServerServices(tserverData).getAddressString(Service.TSERV_CLIENT), conf.getPort(Property.TSERV_CLIENTPORT),
+ rpcTimeout));
+ }
+ }
}
boolean opened = false;
[05/10] git commit: Change keySet iterator to an entrySet iterator to
avoid an extra get call on the Map
Posted by el...@apache.org.
Change keySet iterator to an entrySet iterator to avoid an extra get call on the Map
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4fa2e62d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4fa2e62d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4fa2e62d
Branch: refs/heads/2292-findbugs
Commit: 4fa2e62deb420a2f0b4afadf2a39be846cd295f2
Parents: cbf8a9f
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 16:36:43 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 17:19:52 2014 -0500
----------------------------------------------------------------------
.../accumulo/core/client/admin/TableOperationsImpl.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/4fa2e62d/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
index 3f5ac8c..307243d 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
@@ -1236,13 +1236,13 @@ public class TableOperationsImpl extends TableOperationsHelper {
try {
FileSystem fs = FileUtil.getFileSystem(CachedConfiguration.getInstance(), instance.getConfiguration());
- ;
+
Map<String,String> props = getExportedProps(fs, new Path(importDir, Constants.EXPORT_FILE));
- for (String propKey : props.keySet()) {
- if (Property.isClassProperty(propKey) && !props.get(propKey).contains(Constants.CORE_PACKAGE_NAME)) {
+ for (Entry<String,String> prop : props.entrySet()) {
+ if (Property.isClassProperty(prop.getKey()) && !prop.getValue().contains(Constants.CORE_PACKAGE_NAME)) {
Logger.getLogger(this.getClass()).info(
- "Imported table sets '" + propKey + "' to '" + props.get(propKey) + "'. Ensure this class is on Accumulo classpath.");
+ "Imported table sets '" + prop.getKey() + "' to '" + prop.getValue() + "'. Ensure this class is on Accumulo classpath.");
}
}
[03/10] git commit: Lots of Constants.UTF8 usages on String
constructor and toBytes() calls
Posted by el...@apache.org.
Lots of Constants.UTF8 usages on String constructor and toBytes() calls
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/cbf8a9fa
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/cbf8a9fa
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/cbf8a9fa
Branch: refs/heads/2292-findbugs
Commit: cbf8a9fa3578eab71a236d0b4eb45f941aab3476
Parents: a11dae7
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 16:04:08 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 17:19:28 2014 -0500
----------------------------------------------------------------------
.../accumulo/core/client/ZooKeeperInstance.java | 8 +++---
.../client/admin/InstanceOperationsImpl.java | 2 +-
.../core/client/admin/TableOperationsImpl.java | 30 ++++++++++----------
3 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cbf8a9fa/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java b/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
index 46a7307..5197262 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
@@ -164,13 +164,13 @@ public class ZooKeeperInstance implements Instance {
OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up master location in zoocache.");
byte[] loc = ZooUtil.getLockData(zooCache, masterLocPath);
- opTimer.stop("Found master at " + (loc == null ? null : new String(loc)) + " in %DURATION%");
+ opTimer.stop("Found master at " + (loc == null ? null : new String(loc, Constants.UTF8)) + " in %DURATION%");
if (loc == null) {
return Collections.emptyList();
}
- return Collections.singletonList(new String(loc));
+ return Collections.singletonList(new String(loc, Constants.UTF8));
}
@Override
@@ -179,13 +179,13 @@ public class ZooKeeperInstance implements Instance {
OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up root tablet location in zookeeper.");
byte[] loc = zooCache.get(zRootLocPath);
- opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc)) + " in %DURATION%");
+ opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc, Constants.UTF8)) + " in %DURATION%");
if (loc == null) {
return null;
}
- return new String(loc).split("\\|")[0];
+ return new String(loc, Constants.UTF8).split("\\|")[0];
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cbf8a9fa/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
index ea833e0..156fa3a 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperationsImpl.java
@@ -135,7 +135,7 @@ public class InstanceOperationsImpl implements InstanceOperations {
List<String> copy = new ArrayList<String>(children);
Collections.sort(copy);
byte[] data = cache.get(path + "/" + candidate + "/" + copy.get(0));
- if (data != null && !"master".equals(new String(data))) {
+ if (data != null && !"master".equals(new String(data, Constants.UTF8))) {
results.add(candidate);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cbf8a9fa/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
index fdb7014..3f5ac8c 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
@@ -201,7 +201,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public void create(String tableName, boolean limitVersion, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException {
ArgumentChecker.notNull(tableName, timeType);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(timeType.name().getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)), ByteBuffer.wrap(timeType.name().getBytes(Constants.UTF8)));
Map<String,String> opts = IteratorUtil.generateInitialTableProperties(limitVersion);
@@ -500,7 +500,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
ArgumentChecker.notNull(tableName);
ByteBuffer EMPTY = ByteBuffer.allocate(0);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
: TextUtil.getByteBuffer(end));
Map<String,String> opts = new HashMap<String,String>();
try {
@@ -516,7 +516,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
ArgumentChecker.notNull(tableName);
ByteBuffer EMPTY = ByteBuffer.allocate(0);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
: TextUtil.getByteBuffer(end));
Map<String,String> opts = new HashMap<String,String>();
try {
@@ -643,7 +643,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
ArgumentChecker.notNull(tableName);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)));
Map<String,String> opts = new HashMap<String,String>();
try {
@@ -675,7 +675,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
if (!Collections.disjoint(propertiesToExclude, propertiesToSet.keySet()))
throw new IllegalArgumentException("propertiesToSet and propertiesToExclude not disjoint");
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(srcTableId.getBytes()), ByteBuffer.wrap(newTableName.getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(srcTableId.getBytes(Constants.UTF8)), ByteBuffer.wrap(newTableName.getBytes(Constants.UTF8)));
Map<String,String> opts = new HashMap<String,String>();
for (Entry<String,String> entry : propertiesToSet.entrySet()) {
if (entry.getKey().startsWith(CLONE_EXCLUDE_PREFIX))
@@ -710,7 +710,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
TableExistsException {
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(oldTableName.getBytes()), ByteBuffer.wrap(newTableName.getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(oldTableName.getBytes(Constants.UTF8)), ByteBuffer.wrap(newTableName.getBytes(Constants.UTF8)));
Map<String,String> opts = new HashMap<String,String>();
doTableOperation(TableOperation.RENAME, args, opts);
}
@@ -764,7 +764,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
if (flush)
_flush(tableId, start, end, true);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes()), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes(Constants.UTF8)), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY
: TextUtil.getByteBuffer(end), ByteBuffer.wrap(IteratorUtil.encodeIteratorSettings(iterators)));
Map<String,String> opts = new HashMap<String,String>();
@@ -780,7 +780,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
String tableId = Tables.getTableId(instance, tableName);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getBytes(Constants.UTF8)));
Map<String,String> opts = new HashMap<String,String>();
try {
@@ -1110,8 +1110,8 @@ public class TableOperationsImpl extends TableOperationsHelper {
throw new AccumuloException("Bulk import failure directory " + failPath + " is not empty");
}
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(dirPath.toString().getBytes()),
- ByteBuffer.wrap(failPath.toString().getBytes()), ByteBuffer.wrap((setTime + "").getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)), ByteBuffer.wrap(dirPath.toString().getBytes(Constants.UTF8)),
+ ByteBuffer.wrap(failPath.toString().getBytes(Constants.UTF8)), ByteBuffer.wrap((setTime + "").getBytes(Constants.UTF8)));
Map<String,String> opts = new HashMap<String,String>();
try {
@@ -1138,7 +1138,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
ArgumentChecker.notNull(tableName);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)));
Map<String,String> opts = new HashMap<String,String>();
try {
@@ -1162,7 +1162,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
@Override
public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
ArgumentChecker.notNull(tableName);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)));
Map<String,String> opts = new HashMap<String,String>();
try {
@@ -1214,7 +1214,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
ZipEntry zipEntry;
while ((zipEntry = zis.getNextEntry()) != null) {
if (zipEntry.getName().equals(Constants.EXPORT_TABLE_CONFIG_FILE)) {
- BufferedReader in = new BufferedReader(new InputStreamReader(zis));
+ BufferedReader in = new BufferedReader(new InputStreamReader(zis, Constants.UTF8));
String line;
while ((line = in.readLine()) != null) {
String sa[] = line.split("=", 2);
@@ -1250,7 +1250,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
Logger.getLogger(this.getClass()).warn("Failed to check if imported table references external java classes : " + ioe.getMessage());
}
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(importDir.getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)), ByteBuffer.wrap(importDir.getBytes(Constants.UTF8)));
Map<String,String> opts = Collections.emptyMap();
@@ -1267,7 +1267,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
ArgumentChecker.notNull(tableName, exportDir);
- List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(exportDir.getBytes()));
+ List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)), ByteBuffer.wrap(exportDir.getBytes(Constants.UTF8)));
Map<String,String> opts = Collections.emptyMap();
[08/10] git commit: Fix an InputFormatBase blunder,
add defensive copies, and lots of UTF8
Posted by el...@apache.org.
Fix an InputFormatBase blunder, add defensive copies, and lots of UTF8
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0df56927
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0df56927
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0df56927
Branch: refs/heads/2292-findbugs
Commit: 0df5692789da48996c47d3f960a1c05bf40e533d
Parents: 6770ed9
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 21:45:30 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 21:45:30 2014 -0500
----------------------------------------------------------------------
.../accumulo/core/client/mapred/InputFormatBase.java | 2 +-
.../core/client/mapreduce/InputFormatBase.java | 14 +++++++-------
.../core/client/mapreduce/RangeInputSplit.java | 6 +++---
.../mapreduce/lib/partition/RangePartitioner.java | 7 +++++--
.../client/mapreduce/lib/util/InputConfigurator.java | 12 ++++++------
.../apache/accumulo/core/client/mock/MockShell.java | 5 +++--
.../core/client/security/tokens/PasswordToken.java | 2 +-
.../accumulo/core/conf/DefaultConfiguration.java | 8 +++++---
8 files changed, 31 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0df56927/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java
index 8cc4d18..ae361de 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java
@@ -619,7 +619,7 @@ public abstract class InputFormatBase<K,V> implements InputFormat<K,V> {
Connector conn = instance.getConnector(principal, token);
log.debug("Creating scanner for table: " + table);
log.debug("Authorizations are: " + authorizations);
- if (isOfflineScan(job)) {
+ if (isOffline) {
String tokenClass = token.getClass().getCanonicalName();
ByteBuffer tokenBuffer = ByteBuffer.wrap(CredentialHelper.toBytes(token));
scanner = new OfflineScanner(instance, new TCredentials(principal, tokenClass, tokenBuffer, instance.getInstanceID()), Tables.getTableId(instance,
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0df56927/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
index 4c57d1d..4516176 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
@@ -631,7 +631,7 @@ public abstract class InputFormatBase<K,V> extends InputFormat<K,V> {
Connector conn = instance.getConnector(principal, token);
log.debug("Creating scanner for table: " + table);
log.debug("Authorizations are: " + authorizations);
- if (isOfflineScan(attempt)) {
+ if (isOffline) {
String tokenClass = token.getClass().getCanonicalName();
ByteBuffer tokenBuffer = ByteBuffer.wrap(CredentialHelper.toBytes(token));
scanner = new OfflineScanner(instance, new TCredentials(principal, tokenClass, tokenBuffer, instance.getInstanceID()), Tables.getTableId(instance,
@@ -1180,8 +1180,8 @@ public abstract class InputFormatBase<K,V> extends InputFormat<K,V> {
List<IteratorSetting> iteratorSettings = InputConfigurator.getIterators(CLASS, conf);
List<AccumuloIterator> deprecatedIterators = new ArrayList<AccumuloIterator>(iteratorSettings.size());
for (IteratorSetting setting : iteratorSettings) {
- AccumuloIterator deprecatedIter = new AccumuloIterator(new String(setting.getPriority() + AccumuloIterator.FIELD_SEP + setting.getIteratorClass()
- + AccumuloIterator.FIELD_SEP + setting.getName()));
+ AccumuloIterator deprecatedIter = new AccumuloIterator(setting.getPriority() + AccumuloIterator.FIELD_SEP + setting.getIteratorClass()
+ + AccumuloIterator.FIELD_SEP + setting.getName());
deprecatedIterators.add(deprecatedIter);
}
return deprecatedIterators;
@@ -1198,8 +1198,8 @@ public abstract class InputFormatBase<K,V> extends InputFormat<K,V> {
for (Entry<String,String> opt : setting.getOptions().entrySet()) {
String deprecatedOption;
try {
- deprecatedOption = new String(setting.getName() + AccumuloIteratorOption.FIELD_SEP + URLEncoder.encode(opt.getKey(), "UTF-8")
- + AccumuloIteratorOption.FIELD_SEP + URLEncoder.encode(opt.getValue(), "UTF-8"));
+ deprecatedOption = setting.getName() + AccumuloIteratorOption.FIELD_SEP + URLEncoder.encode(opt.getKey(), "UTF-8")
+ + AccumuloIteratorOption.FIELD_SEP + URLEncoder.encode(opt.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
@@ -1250,7 +1250,7 @@ public abstract class InputFormatBase<K,V> extends InputFormat<K,V> {
@Override
public String toString() {
- return new String(priority + FIELD_SEP + iteratorClass + FIELD_SEP + iteratorName);
+ return priority + FIELD_SEP + iteratorClass + FIELD_SEP + iteratorName;
}
}
@@ -1299,7 +1299,7 @@ public abstract class InputFormatBase<K,V> extends InputFormat<K,V> {
@Override
public String toString() {
try {
- return new String(iteratorName + FIELD_SEP + URLEncoder.encode(key, "UTF-8") + FIELD_SEP + URLEncoder.encode(value, "UTF-8"));
+ return iteratorName + FIELD_SEP + URLEncoder.encode(key, "UTF-8") + FIELD_SEP + URLEncoder.encode(value, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0df56927/core/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java
index 75f140b..73c9b59 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java
@@ -67,7 +67,7 @@ public class RangeInputSplit extends InputSplit implements Writable {
public RangeInputSplit(Range range, String[] locations) {
this.range = range;
- this.locations = locations;
+ setLocations(locations);
}
public Range getRange() {
@@ -138,7 +138,7 @@ public class RangeInputSplit extends InputSplit implements Writable {
@Override
public String[] getLocations() throws IOException {
- return locations;
+ return Arrays.copyOf(locations, locations.length);
}
@Override
@@ -368,7 +368,7 @@ public class RangeInputSplit extends InputSplit implements Writable {
}
public void setLocations(String[] locations) {
- this.locations = locations;
+ this.locations = Arrays.copyOf(locations, locations.length);
}
public Boolean isMockInstance() {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0df56927/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/partition/RangePartitioner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/partition/RangePartitioner.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/partition/RangePartitioner.java
index 920bd5b..e29c791 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/partition/RangePartitioner.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/partition/RangePartitioner.java
@@ -17,14 +17,17 @@
package org.apache.accumulo.core.client.mapreduce.lib.partition;
import java.io.BufferedReader;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.net.URI;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;
+import org.apache.accumulo.core.Constants;
import org.apache.commons.codec.binary.Base64;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
@@ -87,10 +90,10 @@ public class RangePartitioner extends Partitioner<Text,Writable> implements Conf
for (Path path : cf) {
if (path.toUri().getPath().endsWith(cutFileName.substring(cutFileName.lastIndexOf('/')))) {
TreeSet<Text> cutPoints = new TreeSet<Text>();
- Scanner in = new Scanner(new BufferedReader(new FileReader(path.toString())));
+ Scanner in = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(path.toString()), Constants.UTF8)));
try {
while (in.hasNextLine())
- cutPoints.add(new Text(Base64.decodeBase64(in.nextLine().getBytes())));
+ cutPoints.add(new Text(Base64.decodeBase64(in.nextLine().getBytes(Constants.UTF8))));
} finally {
in.close();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0df56927/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
index b0e649b..d9e313c 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
@@ -138,7 +138,7 @@ public class InputConfigurator extends ConfiguratorBase {
*/
public static Authorizations getScanAuthorizations(Class<?> implementingClass, Configuration conf) {
String authString = conf.get(enumToConfKey(implementingClass, ScanOpts.AUTHORIZATIONS));
- return authString == null ? Constants.NO_AUTHS : new Authorizations(authString.getBytes());
+ return authString == null ? Constants.NO_AUTHS : new Authorizations(authString.getBytes(Constants.UTF8));
}
/**
@@ -216,9 +216,9 @@ public class InputConfigurator extends ConfiguratorBase {
if (column.getFirst() == null)
throw new IllegalArgumentException("Column family can not be null");
- String col = new String(Base64.encodeBase64(TextUtil.getBytes(column.getFirst())));
+ String col = new String(Base64.encodeBase64(TextUtil.getBytes(column.getFirst())), Constants.UTF8);
if (column.getSecond() != null)
- col += ":" + new String(Base64.encodeBase64(TextUtil.getBytes(column.getSecond())));
+ col += ":" + new String(Base64.encodeBase64(TextUtil.getBytes(column.getSecond())), Constants.UTF8);
columnStrings.add(col);
}
@@ -258,8 +258,8 @@ public class InputConfigurator extends ConfiguratorBase {
for (String col : serialized) {
int idx = col.indexOf(":");
- Text cf = new Text(idx < 0 ? Base64.decodeBase64(col.getBytes(Charset.forName("UTF-8"))) : Base64.decodeBase64(col.substring(0, idx).getBytes(Charset.forName("UTF-8"))));
- Text cq = idx < 0 ? null : new Text(Base64.decodeBase64(col.substring(idx + 1).getBytes()));
+ Text cf = new Text(idx < 0 ? Base64.decodeBase64(col.getBytes(Constants.UTF8)) : Base64.decodeBase64(col.substring(0, idx).getBytes(Constants.UTF8)));
+ Text cq = idx < 0 ? null : new Text(Base64.decodeBase64(col.substring(idx + 1).getBytes(Constants.UTF8)));
columns.add(new Pair<Text,Text>(cf, cq));
}
return columns;
@@ -323,7 +323,7 @@ public class InputConfigurator extends ConfiguratorBase {
try {
while (tokens.hasMoreTokens()) {
String itstring = tokens.nextToken();
- ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(itstring.getBytes()));
+ ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(itstring.getBytes(Constants.UTF8)));
list.add(new IteratorSetting(new DataInputStream(bais)));
bais.close();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0df56927/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java
index 4469d5c..c97e2b4 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockShell.java
@@ -24,6 +24,7 @@ import java.io.Writer;
import jline.ConsoleReader;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.commons.cli.CommandLine;
@@ -77,7 +78,7 @@ public class MockShell extends Shell {
printInfo();
if (execFile != null) {
- java.util.Scanner scanner = new java.util.Scanner(new File(execFile));
+ java.util.Scanner scanner = new java.util.Scanner(new File(execFile), Constants.UTF8.name());
try {
while (scanner.hasNextLine() && !hasExited()) {
execCommand(scanner.nextLine(), true, isVerbose());
@@ -137,6 +138,6 @@ public class MockShell extends Shell {
sb.append(command).append(NEWLINE);
}
- return new ByteArrayInputStream(sb.toString().getBytes());
+ return new ByteArrayInputStream(sb.toString().getBytes(Constants.UTF8));
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0df56927/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java b/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java
index 50d6938..9386b56 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java
@@ -40,7 +40,7 @@ public class PasswordToken implements AuthenticationToken {
private byte[] password = null;
public byte[] getPassword() {
- return password;
+ return Arrays.copyOf(password, password.length);
}
/**
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0df56927/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
index 58f446d..d653274 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
@@ -20,11 +20,13 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.TreeMap;
+import org.apache.accumulo.core.Constants;
import org.apache.log4j.Logger;
public class DefaultConfiguration extends AccumuloConfiguration {
@@ -62,7 +64,7 @@ public class DefaultConfiguration extends AccumuloConfiguration {
int n;
try {
while ((n = data.read(buffer)) > 0)
- doc.print(new String(buffer, 0, n));
+ doc.print(new String(buffer, 0, n, Constants.UTF8));
} catch (IOException e) {
e.printStackTrace();
return;
@@ -176,9 +178,9 @@ public class DefaultConfiguration extends AccumuloConfiguration {
/*
* Generate documentation for conf/accumulo-site.xml file usage
*/
- public static void main(String[] args) throws FileNotFoundException {
+ public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
if (args.length == 2 && args[0].equals("--generate-doc")) {
- generateDocumentation(new PrintStream(args[1]));
+ generateDocumentation(new PrintStream(args[1], Constants.UTF8.name()));
} else {
throw new IllegalArgumentException("Usage: " + DefaultConfiguration.class.getName() + " --generate-doc <filename>");
}
[04/10] git commit: ACCUMULO-2292 Use the constant utf8 Charset
already defined.
Posted by el...@apache.org.
ACCUMULO-2292 Use the constant utf8 Charset already defined.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a11dae7d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a11dae7d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a11dae7d
Branch: refs/heads/2292-findbugs
Commit: a11dae7dabaf8db710149c8def7ec863a715331d
Parents: 3636136
Author: Josh Elser <el...@apache.org>
Authored: Thu Jan 30 16:03:43 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jan 30 17:19:28 2014 -0500
----------------------------------------------------------------------
core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a11dae7d/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
index 7d5d0b8..ff31003 100644
--- a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
+++ b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
@@ -16,7 +16,6 @@
*/
package org.apache.accumulo.core.cli;
-import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -80,12 +79,12 @@ public class ClientOpts extends Help {
public byte[] value;
public Password(String dfault) {
- value = dfault.getBytes(Charset.forName("UTF-8"));
+ value = dfault.getBytes(Constants.UTF8);
}
@Override
public String toString() {
- return new String(value);
+ return new String(value, Constants.UTF8);
}
}