accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [3/3] git commit: Merge branch '1.6.0-SNAPSHOT'
Date Sat, 22 Mar 2014 01:02:41 GMT
Merge branch '1.6.0-SNAPSHOT'

Conflicts:
	core/src/main/java/org/apache/accumulo/core/data/Value.java


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

Branch: refs/heads/master
Commit: c5b8335d31c7f318a903c52dc6d4195f9642137e
Parents: a03071c f2920c2
Author: Sean Busbey <busbey@cloudera.com>
Authored: Fri Mar 21 19:50:05 2014 -0500
Committer: Sean Busbey <busbey@cloudera.com>
Committed: Fri Mar 21 19:50:05 2014 -0500

----------------------------------------------------------------------
 .../org/apache/accumulo/core/data/Value.java    | 42 ++++++++++----------
 .../apache/accumulo/core/data/ValueTest.java    | 33 ++++++++++++---
 2 files changed, 49 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/c5b8335d/core/src/main/java/org/apache/accumulo/core/data/Value.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/data/Value.java
index ec07411,11e60e1..b3ae5b8
--- a/core/src/main/java/org/apache/accumulo/core/data/Value.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Value.java
@@@ -36,42 -38,38 +38,45 @@@ import org.apache.hadoop.io.WritableCom
   * 'immutable'.
   */
  public class Value implements WritableComparable<Object> {
+   private static final byte[] EMPTY = new byte[0];
    protected byte[] value;
-   
+ 
    /**
 -   * Create a zero-size sequence.
 +   * Creates a zero-size sequence.
     */
    public Value() {
-     super();
+     this(EMPTY, false);
    }
    
    /**
 -   * Create a Value using the byte array as the initial 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 bytes of value
+    * @param bytes May not be null
     */
    public Value(byte[] bytes) {
      this(bytes, false);
    }
    
    /**
 -   * Create a Value using a copy of the ByteBuffer's content.
 +   * Creates a Value using the bytes in a buffer as the initial value. Makes
 +   * a defensive copy.
     * 
-    * @param bytes bytes of value
+    * @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
     */
    @Deprecated
    public Value(ByteBuffer bytes, boolean copy) {
@@@ -79,13 -78,12 +85,14 @@@
    }
    
    /**
 -   * Create a Value based on the given bytes.
 +   * Creates a Value using a byte array as the initial value.
 +   * 
-    * @param bytes bytes of value
+    * @param bytes may not be null
 -   * @param copy signal if Value must make its own copy of bytes, or if it can use the array
directly.
 +   * @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);
      if (!copy) {
        this.value = bytes;
      } else {
@@@ -96,74 -94,60 +103,69 @@@
    }
    
    /**
 -   * Set the new Value to a copy of the contents of the passed <code>ibw</code>.
 +   * Creates a new Value based on another.
     * 
-    * @param ibw original Value
+    * @param ibw may not be null.
     */
    public Value(final Value ibw) {
      this(ibw.get(), 0, ibw.getSize());
    }
    
    /**
 -   * Set the value to a copy of the given byte range
 +   * Creates a Value based on a range in a byte array. A copy of the bytes is
 +   * always made.
     * 
-    * @param newData byte array containing value bytes
+    * @param newData source of copy, may not be null
 -   * @param offset
 -   *          the offset in newData to start at
 -   * @param length
 -   *          the number of bytes to copy
 +   * @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 value bytes
-    * @throws IllegalStateException if this object is uninitialized because it
-    * was not read correctly from a data stream
+    * @return the underlying byte array directly.
     */
    public byte[] get() {
-     if (this.value == null) {
-       throw new IllegalStateException("Uninitialized. Null constructor " + "called w/o accompanying
readFields invocation");
-     }
+     assert(null != value);
      return this.value;
    }
    
    /**
 -   * @param b Use passed bytes as backing array for this instance, 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 bytes of value
++   * @param b may not be null
     */
    public void set(final byte[] b) {
+     Preconditions.checkNotNull(b);
      this.value = b;
    }
    
    /**
 -   * 
 -   * @param b copy the given byte array, may not be null.
 +   * Sets the byte data of this value. The given byte array is copied.
 +   *
-    * @param b bytes of value
++   * @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);
    }
    
    /**
 -   * @return the current size of the underlying buffer.
 +   * Gets the size of this value.
 +   *
 +   * @return size in bytes
-    * @throws IllegalStateException if this object is uninitialized because it
-    * was not read correctly from a data stream
     */
    public int getSize() {
-     if (this.value == null) {
-       throw new IllegalStateException("Uninitialized. Null constructor " + "called w/o accompanying
readFields invocation");
-     }
+     assert(null != value);
      return this.value.length;
    }
    


Mime
View raw message