Exemple #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;
 }
 /**
  * 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());
 }
Exemple #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);
 }
Exemple #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);
 }
Exemple #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);
 }
Exemple #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);
 }
Exemple #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;
 }