Example #1
0
 /** Write a UTF8 encoded string to out */
 public static int writeString(DataOutput out, String s) throws IOException {
   ByteBuffer bytes = encode(s);
   int length = bytes.limit();
   WritableUtils.writeVInt(out, length);
   out.write(bytes.array(), 0, length);
   return length;
 }
Example #2
0
 /**
  * Generates a string representation of the long values contained in the object. String
  * representation has commas between the string values of the longs.
  *
  * @return String representing the long values (comma separated).
  */
 @Override
 public String toString() {
   return WritableUtils.toString(this.get());
 }
Example #3
0
 /** Read a UTF8 encoded string from in */
 public static String readString(DataInput in) throws IOException {
   int length = WritableUtils.readVInt(in);
   byte[] bytes = new byte[length];
   in.readFully(bytes, 0, length);
   return decode(bytes);
 }
Example #4
0
 public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
   int n1 = WritableUtils.decodeVIntSize(b1[s1]);
   int n2 = WritableUtils.decodeVIntSize(b2[s2]);
   return compareBytes(b1, s1 + n1, l1 - n1, b2, s2 + n2, l2 - n2);
 }
Example #5
0
 /**
  * serialize write this object to out length uses zero-compressed encoding
  *
  * @see Writable#write(DataOutput)
  */
 public void write(DataOutput out) throws IOException {
   WritableUtils.writeVInt(out, length);
   out.write(bytes, 0, length);
 }
Example #6
0
 /** Skips over one Text in the input. */
 public static void skip(DataInput in) throws IOException {
   int length = WritableUtils.readVInt(in);
   WritableUtils.skipFully(in, length);
 }
Example #7
0
 /** deserialize */
 public void readFields(DataInput in) throws IOException {
   int newLength = WritableUtils.readVInt(in);
   setCapacity(newLength, false);
   in.readFully(bytes, 0, newLength);
   length = newLength;
 }