accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1333115 - in /accumulo/trunk: ./ core/ core/src/main/java/org/apache/accumulo/core/data/Value.java core/src/test/java/org/apache/accumulo/core/iterators/user/WholeRowIteratorTest.java server/ src/
Date Wed, 02 May 2012 17:14:19 GMT
Author: ecn
Date: Wed May  2 17:14:19 2012
New Revision: 1333115

URL: http://svn.apache.org/viewvc?rev=1333115&view=rev
Log:
ACCUMULO-266 remove IBW cruft in Value

Modified:
    accumulo/trunk/   (props changed)
    accumulo/trunk/core/   (props changed)
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/data/Value.java
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/WholeRowIteratorTest.java
    accumulo/trunk/server/   (props changed)
    accumulo/trunk/src/   (props changed)

Propchange: accumulo/trunk/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.4:r1333109

Propchange: accumulo/trunk/core/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.4/core:r1333109

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/data/Value.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/data/Value.java?rev=1333115&r1=1333114&r2=1333115&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/data/Value.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/data/Value.java Wed May  2
17:14:19 2012
@@ -20,11 +20,10 @@ package org.apache.accumulo.core.data;
  * limitations under the License.
  */
 
-import java.io.ByteArrayOutputStream;
+import static org.apache.accumulo.core.util.ByteBufferUtil.toBytes;
 
 import java.io.DataInput;
 import java.io.DataOutput;
-import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
@@ -32,15 +31,10 @@ import java.util.List;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.hadoop.io.BytesWritable;
-import org.apache.hadoop.io.DataInputBuffer;
-import org.apache.hadoop.io.LongWritable;
-import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.io.WritableComparator;
 import org.apache.log4j.Logger;
 
-import static org.apache.accumulo.core.util.ByteBufferUtil.toBytes;
-
 /**
  * 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 its comparatively
@@ -151,7 +145,6 @@ public class Value implements WritableCo
     return this.value.length;
   }
   
-  /** {@inheritDoc} */
   public void readFields(final DataInput in) throws IOException {
     this.value = new byte[in.readInt()];
     in.readFully(this.value, 0, this.value.length);
@@ -207,7 +200,7 @@ public class Value implements WritableCo
   @Override
   public String toString() {
     try {
-      return Value.bytesToString(this.value);
+      return new String(get(), Constants.VALUE_ENCODING);
     } catch (UnsupportedEncodingException e) {
       log.error(e.toString());
       return null;
@@ -247,87 +240,4 @@ public class Value implements WritableCo
     return results;
   }
   
-  /**
-   * Convert a long value to a byte array
-   */
-  public static byte[] longToBytes(long val) throws IOException {
-    return getBytes(new LongWritable(val));
-  }
-  
-  /**
-   * Converts a byte array to a long value
-   */
-  public static long bytesToLong(byte[] bytes) throws IOException {
-    if (bytes == null || bytes.length == 0) {
-      return -1L;
-    }
-    return ((LongWritable) getWritable(bytes, new LongWritable())).get();
-  }
-  
-  /**
-   * Converts a string to a byte array in a consistent manner.
-   */
-  public static byte[] stringToBytes(String s) throws UnsupportedEncodingException {
-    if (s == null) {
-      throw new IllegalArgumentException("string cannot be null");
-    }
-    return s.getBytes(Constants.VALUE_ENCODING);
-  }
-  
-  /**
-   * Converts a byte array to a string in a consistent manner.
-   */
-  public static String bytesToString(byte[] bytes) throws UnsupportedEncodingException {
-    if (bytes == null || bytes.length == 0) {
-      return "";
-    }
-    return new String(bytes, Constants.VALUE_ENCODING);
-  }
-  
-  /**
-   * @return The bytes of <code>w</code> gotten by running its {@link Writable#write(java.io.DataOutput)}
method.
-   * @see #getWritable(byte[], Writable)
-   */
-  public static byte[] getBytes(final Writable w) throws IOException {
-    if (w == null) {
-      throw new IllegalArgumentException("Writable cannot be null");
-    }
-    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
-    DataOutputStream out = new DataOutputStream(byteStream);
-    try {
-      w.write(out);
-      out.close();
-      out = null;
-      return byteStream.toByteArray();
-    } finally {
-      if (out != null) {
-        out.close();
-      }
-    }
-  }
-  
-  /**
-   * Set bytes into the passed Writable by calling its {@link Writable#readFields(java.io.DataInput)}.
-   * 
-   * @param w
-   *          An empty Writable (usually made by calling the null-arg constructor).
-   * @return The passed Writable after its readFields has been called fed by the passed <code>bytes</code>
array or IllegalArgumentException if passed null or
-   *         an empty <code>bytes</code> array.
-   */
-  public static Writable getWritable(final byte[] bytes, final Writable w) throws IOException
{
-    if (bytes == null || bytes.length == 0) {
-      throw new IllegalArgumentException("Can't build a writable with empty " + "bytes array");
-    }
-    if (w == null) {
-      throw new IllegalArgumentException("Writable cannot be null");
-    }
-    DataInputBuffer in = new DataInputBuffer();
-    try {
-      in.reset(bytes, bytes.length);
-      w.readFields(in);
-      return w;
-    } finally {
-      in.close();
-    }
-  }
 }

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/WholeRowIteratorTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/WholeRowIteratorTest.java?rev=1333115&r1=1333114&r2=1333115&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/WholeRowIteratorTest.java
(original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/WholeRowIteratorTest.java
Wed May  2 17:14:19 2012
@@ -18,9 +18,9 @@ package org.apache.accumulo.core.iterato
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
@@ -34,7 +34,6 @@ import org.apache.accumulo.core.data.Val
 import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 import org.apache.accumulo.core.iterators.SortedMapIterator;
 import org.apache.accumulo.core.iterators.system.MultiIterator;
-import org.apache.accumulo.core.iterators.user.WholeRowIterator;
 import org.apache.hadoop.io.Text;
 
 public class WholeRowIteratorTest extends TestCase {
@@ -43,17 +42,17 @@ public class WholeRowIteratorTest extend
     SortedMap<Key,Value> map = new TreeMap<Key,Value>();
     SortedMap<Key,Value> map2 = new TreeMap<Key,Value>();
     final Map<Text,Boolean> toInclude = new HashMap<Text,Boolean>();
-    map.put(new Key(new Text("r1"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 1l),
new Value(Value.getBytes(new Text("val1"))));
-    map.put(new Key(new Text("r1"), new Text("cf1"), new Text("cq2"), new Text("cv1"), 2l),
new Value(Value.getBytes(new Text("val2"))));
-    map.put(new Key(new Text("r2"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 3l),
new Value(Value.getBytes(new Text("val3"))));
-    map.put(new Key(new Text("r2"), new Text("cf2"), new Text("cq1"), new Text("cv1"), 4l),
new Value(Value.getBytes(new Text("val4"))));
-    map.put(new Key(new Text("r3"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 5l),
new Value(Value.getBytes(new Text("val4"))));
-    map.put(new Key(new Text("r3"), new Text("cf1"), new Text("cq1"), new Text("cv2"), 6l),
new Value(Value.getBytes(new Text("val4"))));
-    map.put(new Key(new Text("r4"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 7l),
new Value(Value.getBytes(new Text(""))));
-    map.put(new Key(new Text("r4"), new Text("cf1"), new Text("cq1"), new Text(""), 8l),
new Value(Value.getBytes(new Text("val1"))));
-    map.put(new Key(new Text("r4"), new Text("cf1"), new Text(""), new Text("cv1"), 9l),
new Value(Value.getBytes(new Text("val1"))));
-    map.put(new Key(new Text("r4"), new Text(""), new Text("cq1"), new Text("cv1"), 10l),
new Value(Value.getBytes(new Text("val1"))));
-    map.put(new Key(new Text(""), new Text("cf1"), new Text("cq1"), new Text("cv1"), 11l),
new Value(Value.getBytes(new Text("val1"))));
+    map.put(new Key(new Text("r1"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 1l),
new Value("val1".getBytes()));
+    map.put(new Key(new Text("r1"), new Text("cf1"), new Text("cq2"), new Text("cv1"), 2l),
new Value("val2".getBytes()));
+    map.put(new Key(new Text("r2"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 3l),
new Value("val3".getBytes()));
+    map.put(new Key(new Text("r2"), new Text("cf2"), new Text("cq1"), new Text("cv1"), 4l),
new Value("val4".getBytes()));
+    map.put(new Key(new Text("r3"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 5l),
new Value("val4".getBytes()));
+    map.put(new Key(new Text("r3"), new Text("cf1"), new Text("cq1"), new Text("cv2"), 6l),
new Value("val4".getBytes()));
+    map.put(new Key(new Text("r4"), new Text("cf1"), new Text("cq1"), new Text("cv1"), 7l),
new Value("".getBytes()));
+    map.put(new Key(new Text("r4"), new Text("cf1"), new Text("cq1"), new Text(""), 8l),
new Value("val1".getBytes()));
+    map.put(new Key(new Text("r4"), new Text("cf1"), new Text(""), new Text("cv1"), 9l),
new Value("val1".getBytes()));
+    map.put(new Key(new Text("r4"), new Text(""), new Text("cq1"), new Text("cv1"), 10l),
new Value("val1".getBytes()));
+    map.put(new Key(new Text(""), new Text("cf1"), new Text("cq1"), new Text("cv1"), 11l),
new Value("val1".getBytes()));
     boolean b = true;
     int trueCount = 0;
     for (Key k : map.keySet()) {

Propchange: accumulo/trunk/server/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.4/server:r1333109

Propchange: accumulo/trunk/src/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.4/src:r1333109



Mime
View raw message