/** Read a UTF8 encoded string with a maximum size */ public static String readString(DataInput in, int maxLength) throws IOException { int length = WritableUtils.readVIntInRange(in, 0, maxLength); byte [] bytes = new byte[length]; in.readFully(bytes, 0, length); return decode(bytes); }
/** */ @Override public void readFields(DataInput in) throws IOException { keyId = WritableUtils.readVInt(in); expiryDate = WritableUtils.readVLong(in); int len = WritableUtils.readVIntInRange(in, -1, MAX_KEY_LEN); if (len == -1) { keyBytes = null; } else { keyBytes = new byte[len]; in.readFully(keyBytes); } }
/** Read a UTF8 encoded string with a maximum size */ public static String readString(DataInput in, int maxLength) throws IOException { int length = WritableUtils.readVIntInRange(in, 0, maxLength); byte [] bytes = new byte[length]; in.readFully(bytes, 0, length); return decode(bytes); }
/** Read a UTF8 encoded string with a maximum size */ public static String readString(DataInput in, int maxLength) throws IOException { int length = WritableUtils.readVIntInRange(in, 0, maxLength); byte [] bytes = new byte[length]; in.readFully(bytes, 0, length); return decode(bytes); }
/** Read a UTF8 encoded string with a maximum size */ public static String readString(DataInput in, int maxLength) throws IOException { int length = WritableUtils.readVIntInRange(in, 0, maxLength); byte [] bytes = new byte[length]; in.readFully(bytes, 0, length); return decode(bytes); }
/** Read a UTF8 encoded string with a maximum size */ public static String readString(DataInput in, int maxLength) throws IOException { int length = WritableUtils.readVIntInRange(in, 0, maxLength); byte [] bytes = new byte[length]; in.readFully(bytes, 0, length); return decode(bytes); }
/** */ @Override public void readFields(DataInput in) throws IOException { keyId = WritableUtils.readVInt(in); expiryDate = WritableUtils.readVLong(in); int len = WritableUtils.readVIntInRange(in, -1, MAX_KEY_LEN); if (len == -1) { keyBytes = null; } else { keyBytes = new byte[len]; in.readFully(keyBytes); } }
/** */ @Override public void readFields(DataInput in) throws IOException { keyId = WritableUtils.readVInt(in); expiryDate = WritableUtils.readVLong(in); int len = WritableUtils.readVIntInRange(in, -1, MAX_KEY_LEN); if (len == -1) { keyBytes = null; } else { keyBytes = new byte[len]; in.readFully(keyBytes); } }
/** */ @Override public void readFields(DataInput in) throws IOException { keyId = WritableUtils.readVInt(in); expiryDate = WritableUtils.readVLong(in); int len = WritableUtils.readVIntInRange(in, -1, MAX_KEY_LEN); if (len == -1) { keyBytes = null; } else { keyBytes = new byte[len]; in.readFully(keyBytes); } }
/** */ @Override public void readFields(DataInput in) throws IOException { keyId = WritableUtils.readVInt(in); expiryDate = WritableUtils.readVLong(in); int len = WritableUtils.readVIntInRange(in, -1, MAX_KEY_LEN); if (len == -1) { keyBytes = null; } else { keyBytes = new byte[len]; in.readFully(keyBytes); } }
@Override public void readFields(DataInput in) throws IOException { this.cache = null; expiryDate = WritableUtils.readVLong(in); keyId = WritableUtils.readVInt(in); userId = WritableUtils.readString(in); blockPoolId = WritableUtils.readString(in); blockId = WritableUtils.readVLong(in); int length = WritableUtils.readVIntInRange(in, 0, AccessMode.class.getEnumConstants().length); for (int i = 0; i < length; i++) { modes.add(WritableUtils.readEnum(in, AccessMode.class)); } }
@Override public void readFields(DataInput in) throws IOException { this.cache = null; expiryDate = WritableUtils.readVLong(in); keyId = WritableUtils.readVInt(in); userId = WritableUtils.readString(in); blockPoolId = WritableUtils.readString(in); blockId = WritableUtils.readVLong(in); int length = WritableUtils.readVIntInRange(in, 0, AccessMode.class.getEnumConstants().length); for (int i = 0; i < length; i++) { modes.add(WritableUtils.readEnum(in, AccessMode.class)); } }
@VisibleForTesting void readFieldsLegacy(DataInput in) throws IOException { expiryDate = WritableUtils.readVLong(in); keyId = WritableUtils.readVInt(in); userId = WritableUtils.readString(in); blockPoolId = WritableUtils.readString(in); blockId = WritableUtils.readVLong(in); int length = WritableUtils.readVIntInRange(in, 0, AccessMode.class.getEnumConstants().length); for (int i = 0; i < length; i++) { modes.add(WritableUtils.readEnum(in, AccessMode.class)); } length = WritableUtils.readVInt(in); StorageType[] readStorageTypes = new StorageType[length]; for (int i = 0; i < length; i++) { readStorageTypes[i] = WritableUtils.readEnum(in, StorageType.class); } storageTypes = readStorageTypes; length = WritableUtils.readVInt(in); String[] readStorageIds = new String[length]; for (int i = 0; i < length; i++) { readStorageIds[i] = WritableUtils.readString(in); } storageIds = readStorageIds; useProto = false; }
public static void testReadInRange(long val, int lower, int upper, boolean expectSuccess) throws IOException { DataOutputBuffer buf = new DataOutputBuffer(); DataInputBuffer inbuf = new DataInputBuffer(); WritableUtils.writeVLong(buf, val); try { inbuf.reset(buf.getData(), 0, buf.getLength()); long val2 = WritableUtils.readVIntInRange(inbuf, lower, upper); if (!expectSuccess) { fail("expected readVIntInRange to throw an exception"); } assertEquals(val, val2); } catch(IOException e) { if (expectSuccess) { LOG.error("unexpected exception:", e); fail("readVIntInRange threw an unexpected exception"); } } }
public static void testReadInRange(long val, int lower, int upper, boolean expectSuccess) throws IOException { DataOutputBuffer buf = new DataOutputBuffer(); DataInputBuffer inbuf = new DataInputBuffer(); WritableUtils.writeVLong(buf, val); try { inbuf.reset(buf.getData(), 0, buf.getLength()); long val2 = WritableUtils.readVIntInRange(inbuf, lower, upper); if (!expectSuccess) { fail("expected readVIntInRange to throw an exception"); } assertEquals(val, val2); } catch(IOException e) { if (expectSuccess) { LOG.error("unexpected exception:", e); fail("readVIntInRange threw an unexpected exception"); } } }