You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2014/03/26 18:13:49 UTC
[5/5] git commit: ACCUMULO-2487 Fix javadoc problem (duplicate param)
from prev commit
ACCUMULO-2487 Fix javadoc problem (duplicate param) from prev commit
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a042fd20
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a042fd20
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a042fd20
Branch: refs/heads/master
Commit: a042fd2065326cbf8813ee87642acd448f0ce705
Parents: 0d0bb91
Author: Christopher Tubbs <ct...@apache.org>
Authored: Wed Mar 26 13:12:09 2014 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Wed Mar 26 13:12:09 2014 -0400
----------------------------------------------------------------------
.../org/apache/accumulo/core/data/Value.java | 128 ++++++++++---------
1 file changed, 67 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a042fd20/core/src/main/java/org/apache/accumulo/core/data/Value.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/Value.java b/core/src/main/java/org/apache/accumulo/core/data/Value.java
index b3ae5b8..2c44c15 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Value.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Value.java
@@ -25,13 +25,13 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
-import com.google.common.base.Preconditions;
-
import org.apache.accumulo.core.Constants;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
+import com.google.common.base.Preconditions;
+
/**
* A byte sequence that is usable as a key or value. Based on {@link org.apache.hadoop.io.BytesWritable} only this class is NOT resizable and DOES NOT
* distinguish between the size of the sequence and the current capacity as {@link org.apache.hadoop.io.BytesWritable} does. Hence it is comparatively
@@ -47,49 +47,50 @@ public class Value implements WritableComparable<Object> {
public Value() {
this(EMPTY, false);
}
-
+
/**
- * Creates a Value using a byte array as the initial value. The given byte
- * array is used directly as the backing array, so later changes made to the
- * array reflect into the new Value.
+ * Creates a Value using a byte array as the initial value. The given byte array is used directly as the backing array, so later changes made to the array
+ * reflect into the new Value.
*
- * @param bytes May not be null
+ * @param bytes
+ * May not be null
*/
public Value(byte[] bytes) {
this(bytes, false);
}
-
+
/**
- * Creates a Value using the bytes in a buffer as the initial value. Makes
- * a defensive copy.
+ * Creates a Value using the bytes in a buffer as the initial value. Makes a defensive copy.
*
- * @param bytes May not be null
+ * @param bytes
+ * May not be null
*/
public Value(ByteBuffer bytes) {
/* TODO ACCUMULO-2509 right now this uses the entire backing array, which must be accessible. */
this(toBytes(bytes), false);
}
-
+
/**
- * @param bytes may not be null
* @deprecated A copy of the bytes in the buffer is always made. Use {@link #Value(ByteBuffer)} instead.
*
- * @param bytes bytes of value
- * @param copy false to use the backing array of the buffer directly as the
- * backing array, true to force a copy
+ * @param bytes
+ * bytes of value (may not be null)
+ * @param copy
+ * false to use the backing array of the buffer directly as the backing array, true to force a copy
*/
@Deprecated
public Value(ByteBuffer bytes, boolean copy) {
/* TODO ACCUMULO-2509 right now this uses the entire backing array, which must be accessible. */
this(toBytes(bytes), false);
}
-
+
/**
* Creates a Value using a byte array as the initial value.
*
- * @param bytes may not be null
- * @param copy false to use the given byte array directly as the backing
- * array, true to force a copy
+ * @param bytes
+ * may not be null
+ * @param copy
+ * false to use the given byte array directly as the backing array, true to force a copy
*/
public Value(byte[] bytes, boolean copy) {
Preconditions.checkNotNull(bytes);
@@ -99,95 +100,99 @@ public class Value implements WritableComparable<Object> {
this.value = new byte[bytes.length];
System.arraycopy(bytes, 0, this.value, 0, bytes.length);
}
-
+
}
-
+
/**
* Creates a new Value based on another.
*
- * @param ibw may not be null.
+ * @param ibw
+ * may not be null.
*/
public Value(final Value ibw) {
this(ibw.get(), 0, ibw.getSize());
}
-
+
/**
- * Creates a Value based on a range in a byte array. A copy of the bytes is
- * always made.
+ * Creates a Value based on a range in a byte array. A copy of the bytes is always made.
*
- * @param newData source of copy, may not be null
- * @param offset the offset in newData to start with for valye bytes
- * @param length the number of bytes in the value
- * @throws IndexOutOfBoundsException if offset or length are invalid
+ * @param newData
+ * source of copy, may not be null
+ * @param offset
+ * the offset in newData to start with for valye bytes
+ * @param length
+ * the number of bytes in the value
+ * @throws IndexOutOfBoundsException
+ * if offset or length are invalid
*/
public Value(final byte[] newData, final int offset, final int length) {
Preconditions.checkNotNull(newData);
this.value = new byte[length];
System.arraycopy(newData, offset, this.value, 0, length);
}
-
+
/**
* Gets the byte data of this value.
*
* @return the underlying byte array directly.
*/
public byte[] get() {
- assert(null != value);
+ assert (null != value);
return this.value;
}
-
+
/**
- * Sets the byte data of this value. The given byte array is used directly as
- * the backing array, so later changes made to the array reflect into this
- * Value.
- *
- * @param b may not be null
+ * Sets the byte data of this value. The given byte array is used directly as the backing array, so later changes made to the array reflect into this Value.
+ *
+ * @param b
+ * may not be null
*/
public void set(final byte[] b) {
Preconditions.checkNotNull(b);
this.value = b;
}
-
+
/**
* Sets the byte data of this value. The given byte array is copied.
- *
- * @param b may not be null
+ *
+ * @param b
+ * may not be null
*/
public void copy(byte[] b) {
Preconditions.checkNotNull(b);
this.value = new byte[b.length];
System.arraycopy(b, 0, this.value, 0, b.length);
}
-
+
/**
* Gets the size of this value.
- *
+ *
* @return size in bytes
*/
public int getSize() {
- assert(null != value);
+ assert (null != value);
return this.value.length;
}
-
+
@Override
public void readFields(final DataInput in) throws IOException {
this.value = new byte[in.readInt()];
in.readFully(this.value, 0, this.value.length);
}
-
+
@Override
public void write(final DataOutput out) throws IOException {
out.writeInt(this.value.length);
out.write(this.value, 0, this.value.length);
}
-
+
// Below methods copied from BytesWritable
-
+
@Override
public int hashCode() {
return WritableComparator.hashBytes(value, this.value.length);
}
-
+
/**
* Define the sort order of the BytesWritable.
*
@@ -199,7 +204,7 @@ public class Value implements WritableComparable<Object> {
public int compareTo(Object right_obj) {
return compareTo(((Value) right_obj).get());
}
-
+
/**
* Compares the bytes in this object to the specified byte array
*
@@ -209,7 +214,7 @@ public class Value implements WritableComparable<Object> {
int diff = this.value.length - that.length;
return (diff != 0) ? diff : WritableComparator.compareBytes(this.value, 0, this.value.length, that, 0, that.length);
}
-
+
@Override
public boolean equals(Object right_obj) {
if (right_obj instanceof byte[]) {
@@ -220,39 +225,40 @@ public class Value implements WritableComparable<Object> {
}
return false;
}
-
+
@Override
public String toString() {
return new String(get(), Constants.UTF8);
}
-
+
/**
* A Comparator optimized for Value.
*/
public static class Comparator extends WritableComparator {
private BytesWritable.Comparator comparator = new BytesWritable.Comparator();
-
+
/** constructor */
public Comparator() {
super(Value.class);
}
-
+
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
return comparator.compare(b1, s1, l1, b2, s2, l2);
}
}
-
+
static { // register this comparator
WritableComparator.define(Value.class, new Comparator());
}
-
+
/**
* Converts a list of byte arrays to a two-dimensional array.
- *
- * @param array list of byte arrays
+ *
+ * @param array
+ * list of byte arrays
* @return two-dimensional byte array containing one given byte array per row
- */
+ */
public static byte[][] toArray(final List<byte[]> array) {
// List#toArray doesn't work on lists of byte [].
byte[][] results = new byte[array.size()][];
@@ -261,5 +267,5 @@ public class Value implements WritableComparable<Object> {
}
return results;
}
-
+
}