Replace C-style arrays (#70)
diff --git a/src/main/java/org/apache/accumulo/testing/continuous/ContinuousIngest.java b/src/main/java/org/apache/accumulo/testing/continuous/ContinuousIngest.java
index a65e46f..65779d9 100644
--- a/src/main/java/org/apache/accumulo/testing/continuous/ContinuousIngest.java
+++ b/src/main/java/org/apache/accumulo/testing/continuous/ContinuousIngest.java
@@ -148,10 +148,10 @@
// back to the row from insert (N - flushInterval). The array below is
// used to keep
// track of this.
- long prevRows[] = new long[flushInterval];
- long firstRows[] = new long[flushInterval];
- int firstColFams[] = new int[flushInterval];
- int firstColQuals[] = new int[flushInterval];
+ long[] prevRows = new long[flushInterval];
+ long[] firstRows = new long[flushInterval];
+ int[] firstColFams = new int[flushInterval];
+ int[] firstColQuals = new int[flushInterval];
long lastFlushTime = System.currentTimeMillis();
@@ -285,7 +285,7 @@
int dataLen = ingestInstanceId.length + 16 + (prevRow == null ? 0 : prevRow.length) + 3;
if (cksum != null)
dataLen += 8;
- byte val[] = new byte[dataLen];
+ byte[] val = new byte[dataLen];
System.arraycopy(ingestInstanceId, 0, val, 0, ingestInstanceId.length);
int index = ingestInstanceId.length;
val[index++] = ':';
diff --git a/src/main/java/org/apache/accumulo/testing/continuous/ContinuousWalk.java b/src/main/java/org/apache/accumulo/testing/continuous/ContinuousWalk.java
index 6cc0e9c..11291b1 100644
--- a/src/main/java/org/apache/accumulo/testing/continuous/ContinuousWalk.java
+++ b/src/main/java/org/apache/accumulo/testing/continuous/ContinuousWalk.java
@@ -124,7 +124,7 @@
return pr;
}
- static int getPrevRowOffset(byte val[]) {
+ static int getPrevRowOffset(byte[] val) {
if (val.length == 0)
throw new IllegalArgumentException();
if (val[53] != ':')
@@ -151,7 +151,7 @@
return null;
}
- private static int getChecksumOffset(byte val[]) {
+ private static int getChecksumOffset(byte[] val) {
if (val[val.length - 1] != ':') {
if (val[val.length - 9] != ':')
throw new IllegalArgumentException(new String(val, UTF_8));
diff --git a/src/main/java/org/apache/accumulo/testing/continuous/TimeBinner.java b/src/main/java/org/apache/accumulo/testing/continuous/TimeBinner.java
index 83e42aa..f231294 100644
--- a/src/main/java/org/apache/accumulo/testing/continuous/TimeBinner.java
+++ b/src/main/java/org/apache/accumulo/testing/continuous/TimeBinner.java
@@ -94,7 +94,7 @@
while ((line = in.readLine()) != null) {
try {
- String tokens[] = line.split("\\s+");
+ String[] tokens = line.split("\\s+");
long time = (long) Double.parseDouble(tokens[opts.timeColumn]);
double data = Double.parseDouble(tokens[opts.dataColumn]);
diff --git a/src/main/java/org/apache/accumulo/testing/ingest/TestIngest.java b/src/main/java/org/apache/accumulo/testing/ingest/TestIngest.java
index 7241578..4fb90ee 100644
--- a/src/main/java/org/apache/accumulo/testing/ingest/TestIngest.java
+++ b/src/main/java/org/apache/accumulo/testing/ingest/TestIngest.java
@@ -154,14 +154,14 @@
return bytevals;
}
- private static byte ROW_PREFIX[] = "row_".getBytes(UTF_8);
- private static byte COL_PREFIX[] = "col_".getBytes(UTF_8);
+ private static byte[] ROW_PREFIX = "row_".getBytes(UTF_8);
+ private static byte[] COL_PREFIX = "col_".getBytes(UTF_8);
public static Text generateRow(int rowid, int startRow) {
return new Text(FastFormat.toZeroPaddedString(rowid + startRow, 10, 10, ROW_PREFIX));
}
- public static byte[] genRandomValue(Random random, byte dest[], int seed, int row, int col) {
+ public static byte[] genRandomValue(Random random, byte[] dest, int seed, int row, int col) {
random.setSeed((row ^ seed) ^ col);
random.nextBytes(dest);
toPrintableChars(dest);
@@ -201,7 +201,7 @@
byte[][] bytevals = generateValues(opts.dataSize);
- byte randomValue[] = new byte[opts.dataSize];
+ byte[] randomValue = new byte[opts.dataSize];
Random random = new Random();
long bytesWritten = 0;
@@ -256,7 +256,7 @@
if (opts.delete) {
writer.append(key, new Value(new byte[0]));
} else {
- byte value[];
+ byte[] value;
if (opts.random != null) {
value = genRandomValue(random, randomValue, opts.random.intValue(),
rowid + opts.startRow, j);
@@ -279,7 +279,7 @@
else
m.putDelete(colf, colq, opts.columnVisibility);
} else {
- byte value[];
+ byte[] value;
if (opts.random != null) {
value = genRandomValue(random, randomValue, opts.random.intValue(),
rowid + opts.startRow, j);
diff --git a/src/main/java/org/apache/accumulo/testing/ingest/VerifyIngest.java b/src/main/java/org/apache/accumulo/testing/ingest/VerifyIngest.java
index dd9aa18..992a982 100644
--- a/src/main/java/org/apache/accumulo/testing/ingest/VerifyIngest.java
+++ b/src/main/java/org/apache/accumulo/testing/ingest/VerifyIngest.java
@@ -93,7 +93,7 @@
long bytesRead = 0;
long t1 = System.currentTimeMillis();
- byte randomValue[] = new byte[opts.dataSize];
+ byte[] randomValue = new byte[opts.dataSize];
Random random = new Random();
Key endKey = new Key(new Text("row_" + String.format("%010d", opts.rows + opts.startRow)));
@@ -121,7 +121,7 @@
val = iter.next().getValue().get();
}
- byte ev[];
+ byte[] ev;
if (opts.random != null) {
ev = TestIngest.genRandomValue(random, randomValue, opts.random, expectedRow,
expectedCol);
@@ -192,7 +192,7 @@
break;
}
- byte value[];
+ byte[] value;
if (opts.random != null) {
value = TestIngest.genRandomValue(random, randomValue, opts.random, expectedRow,
colNum);
diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Merge.java b/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Merge.java
index cc898c3..242d795 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Merge.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Merge.java
@@ -45,7 +45,7 @@
public static Text[] getRandomTabletRange(State state) {
Random rand = (Random) state.get("rand");
- Text points[] = {getRandomRow(rand), getRandomRow(rand),};
+ Text[] points = {getRandomRow(rand), getRandomRow(rand),};
Arrays.sort(points);
if (rand.nextInt(10) == 0) {
points[0] = null;
diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Verify.java b/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Verify.java
index ac469ad..552adbc 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Verify.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Verify.java
@@ -114,7 +114,7 @@
String tableName;
}
- public static void main(String args[]) throws Exception {
+ public static void main(String[] args) throws Exception {
Opts opts = new Opts();
opts.parseArgs(Verify.class.getName(), args);
try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) {
diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/Config.java b/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/Config.java
index 7c35899..3353403 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/Config.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/Config.java
@@ -120,7 +120,7 @@
}
lastSetting = state.getOkIfAbsent(LAST_TABLE_SETTING);
if (lastSetting != null) {
- String parts[] = lastSetting.toString().split(",");
+ String[] parts = lastSetting.toString().split(",");
String table = parts[0];
int choice = Integer.parseInt(parts[1]);
Property property = tableSettings[choice].property;
@@ -142,7 +142,7 @@
}
lastSetting = state.getOkIfAbsent(LAST_NAMESPACE_SETTING);
if (lastSetting != null) {
- String parts[] = lastSetting.toString().split(",");
+ String[] parts = lastSetting.toString().split(",");
String namespace = parts[0];
int choice = Integer.parseInt(parts[1]);
Property property = tableSettings[choice].property;
diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/Replication.java b/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/Replication.java
index cb60e11..664bdb4 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/Replication.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/concurrent/Replication.java
@@ -93,7 +93,7 @@
// Make a source and destination table
final String sourceTable = ("repl-source-" + UUID.randomUUID()).replace('-', '_');
final String destTable = ("repl-dest-" + UUID.randomUUID()).replace('-', '_');
- final String tables[] = new String[] {sourceTable, destTable};
+ final String[] tables = new String[] {sourceTable, destTable};
for (String tableName : tables) {
log.debug("creating " + tableName);
diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/shard/Grep.java b/src/main/java/org/apache/accumulo/testing/randomwalk/shard/Grep.java
index 3f289d0..2ba0397 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/shard/Grep.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/shard/Grep.java
@@ -47,7 +47,7 @@
String dataTableName = (String) state.get("docTableName");
Random rand = (Random) state.get("rand");
- Text words[] = new Text[rand.nextInt(4) + 2];
+ Text[] words = new Text[rand.nextInt(4) + 2];
for (int i = 0; i < words.length; i++) {
words[i] = new Text(Insert.generateRandomWord(rand));
diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/shard/Search.java b/src/main/java/org/apache/accumulo/testing/randomwalk/shard/Search.java
index 75bb392..77963e6 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/shard/Search.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/shard/Search.java
@@ -61,7 +61,7 @@
while (searchTerms.size() < numSearchTerms)
searchTerms.add(tokens[rand.nextInt(tokens.length)]);
- Text columns[] = new Text[searchTerms.size()];
+ Text[] columns = new Text[searchTerms.size()];
int index = 0;
for (String term : searchTerms) {
columns[index++] = new Text(term);