@Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, daysSinceEpoch); }
/** * Write byte-array to out with a vint length prefix. * @param out output stream * @param b array * @param offset offset into array * @param length length past offset * @throws IOException e */ public static void writeByteArray(final DataOutput out, final byte [] b, final int offset, final int length) throws IOException { WritableUtils.writeVInt(out, length); out.write(b, offset, length); }
/** serialize * write this object to out * length uses zero-compressed encoding * @see Writable#write(DataOutput) */ @Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, length); out.write(bytes, 0, length); }
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, id); WritableUtils.writeVLong(out, expirationDate); if (secret == null) { WritableUtils.writeVInt(out, -1); } else { byte[] keyBytes = secret.getEncoded(); WritableUtils.writeVInt(out, keyBytes.length); out.write(keyBytes); } }
private static void writeBytes(@Nullable byte[] value, ByteArrayDataOutput out) throws IOException { int length = value == null ? -1 : value.length; WritableUtils.writeVInt(out, length); if (value != null) { out.write(value, 0, value.length); } }
public void write(DataOutput out, int maxLength) throws IOException { if (length > maxLength) { throw new IOException("data was too long to write! Expected " + "less than or equal to " + maxLength + " bytes, but got " + length + " bytes."); } WritableUtils.writeVInt(out, length); out.write(bytes, 0, length); }
public static byte[] encodeDelegationTokenInformation(DelegationTokenInformation token) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); WritableUtils.writeVInt(out, token.password.length); out.write(token.password); out.writeLong(token.renewDate); out.flush(); return bos.toByteArray(); } catch (IOException ex) { throw new RuntimeException("Failed to encode token.", ex); } }
public static byte[] encodeDelegationTokenInformation(DelegationTokenInformation token) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); WritableUtils.writeVInt(out, token.password.length); out.write(token.password); out.writeLong(token.renewDate); out.flush(); return bos.toByteArray(); } catch (IOException ex) { throw new RuntimeException("Failed to encode token.", ex); } }
@Override public void write(DataOutput out) throws IOException { // write totalMonths to DataOutput WritableUtils.writeVInt(out, intervalValue.getTotalMonths()); }
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, (int) date.toEpochDay()); }
/** 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; }
/** * Write byte-array with a WritableableUtils.vint prefix. * @param out output stream to be written to * @param b array to write * @throws IOException e */ public static void writeByteArray(final DataOutput out, final byte [] b) throws IOException { if(b == null) { WritableUtils.writeVInt(out, 0); } else { writeByteArray(out, b, 0, b.length); } }
@Override public void write(DataOutput out) throws IOException { Properties props = getProps(); WritableUtils.writeVInt(out, props.size()); for(Entry<Object, Object> item: props.entrySet()) { org.apache.hadoop.io.Text.writeString(out, (String) item.getKey()); org.apache.hadoop.io.Text.writeString(out, (String) item.getValue()); WritableUtils.writeCompressedStringArray(out, updatingResource.get(item.getKey())); } }
@Override public void write(DataOutput out) throws IOException { Properties props = getProps(); WritableUtils.writeVInt(out, props.size()); for(Map.Entry<Object, Object> item: props.entrySet()) { org.apache.hadoop.io.Text.writeString(out, (String) item.getKey()); org.apache.hadoop.io.Text.writeString(out, (String) item.getValue()); WritableUtils.writeCompressedStringArray(out, updatingResource != null ? updatingResource.get(item.getKey()) : null); } }
@Override public void write(DataOutput out) throws IOException { Properties props = getProps(); WritableUtils.writeVInt(out, props.size()); for(Map.Entry<Object, Object> item: props.entrySet()) { org.apache.hadoop.io.Text.writeString(out, (String) item.getKey()); org.apache.hadoop.io.Text.writeString(out, (String) item.getValue()); WritableUtils.writeCompressedStringArray(out, updatingResource != null ? updatingResource.get(item.getKey()) : null); } }
@Override public void write(DataOutput out) throws IOException { // write totalSeconds, nanos to DataOutput WritableUtils.writeVLong(out, intervalValue.getTotalSeconds()); WritableUtils.writeVInt(out, intervalValue.getNanos()); }
private static Slice writeVintOld(SliceOutput output, long value) throws IOException { output.reset(); WritableUtils.writeVLong(output, value); Slice vLongOld = Slices.copyOf(output.slice()); output.reset(); RcFileDecoderUtils.writeVLong(output, value); Slice vLongNew = Slices.copyOf(output.slice()); assertEquals(vLongNew, vLongOld); if (value == (int) value) { output.reset(); WritableUtils.writeVInt(output, (int) value); Slice vIntOld = Slices.copyOf(output.slice()); assertEquals(vIntOld, vLongOld); output.reset(); RcFileDecoderUtils.writeVInt(output, (int) value); Slice vIntNew = Slices.copyOf(output.slice()); assertEquals(vIntNew, vLongOld); } return vLongOld; } }