@Override public void readFields(DataInput in) throws IOException { value = WritableUtils.readVLong(in); }
/** * Advance column state to the next now: update offsets, run lengths etc * @param selCol - index among selectedColumns * @param col - column object to update the state of. prvLength will be * set to the new read position * @throws IOException */ private void colAdvanceRow(int selCol, SelectedColumn col) throws IOException { if (col.runLength > 0) { --col.runLength; } else { int length = (int) WritableUtils.readVLong(colValLenBufferReadIn[selCol]); if (length < 0) { // we reach a runlength here, use the previous length and reset // runlength col.runLength = (~length) - 1; } else { col.prvLength = length; col.runLength = 0; } } }
/** * Advance column state to the next now: update offsets, run lengths etc * @param selCol - index among selectedColumns * @param col - column object to update the state of. prvLength will be * set to the new read position * @throws IOException */ private void colAdvanceRow(int selCol, SelectedColumn col) throws IOException { if (col.runLength > 0) { --col.runLength; } else { int length = (int) WritableUtils.readVLong(colValLenBufferReadIn[selCol]); if (length < 0) { // we reach a runlength here, use the previous length and reset // runlength col.runLength = (~length) - 1; } else { col.prvLength = length; col.runLength = 0; } } }
/** * Reads a zero-compressed encoded integer from input stream and returns it. * @param stream Binary input stream * @throws java.io.IOException * @return deserialized integer from stream. */ public static int readVInt(DataInput stream) throws IOException { long n = readVLong(stream); if ((n > Integer.MAX_VALUE) || (n < Integer.MIN_VALUE)) { throw new IOException("value too long to fit in integer"); } return (int)n; }
/** * Reads an integer from the input stream and returns it. * * This function validates that the integer is between [lower, upper], * inclusive. * * @param stream Binary input stream * @throws java.io.IOException * @return deserialized integer from stream */ public static int readVIntInRange(DataInput stream, int lower, int upper) throws IOException { long n = readVLong(stream); if (n < lower) { if (lower == 0) { throw new IOException("expected non-negative integer, got " + n); } else { throw new IOException("expected integer greater than or equal to " + lower + ", got " + n); } } if (n > upper) { throw new IOException("expected integer less or equal to " + upper + ", got " + n); } return (int)n; }
/** This constructor is there primarily to serve the sort routine that * generates a single output file with an associated index file */ public SegmentContainer(Path inName, Path indexIn) throws IOException { //get the segments from indexIn FSDataInputStream fsIndexIn = fs.open(indexIn); long end = fs.getFileStatus(indexIn).getLen(); while (fsIndexIn.getPos() < end) { long segmentOffset = WritableUtils.readVLong(fsIndexIn); long segmentLength = WritableUtils.readVLong(fsIndexIn); Path segmentName = inName; segments.add(new LinkedSegmentsDescriptor(segmentOffset, segmentLength, segmentName, this)); } fsIndexIn.close(); fs.delete(indexIn, true); numSegmentsContained = segments.size(); this.inName = inName; }
@Override public void readFields(DataInput in) throws IOException { // read totalSeconds, nanos from DataInput set(WritableUtils.readVLong(in), WritableUtils.readVInt(in)); }
/** */ @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 { byte version = in.readByte(); if (version != VERSION) { throw new IOException("Unknown version of delegation token " + version); } owner.readFields(in, Text.DEFAULT_MAX_LEN); renewer.readFields(in, Text.DEFAULT_MAX_LEN); realUser.readFields(in, Text.DEFAULT_MAX_LEN); issueDate = WritableUtils.readVLong(in); maxDate = WritableUtils.readVLong(in); sequenceNumber = WritableUtils.readVInt(in); masterKeyId = WritableUtils.readVInt(in); }
@Override public void readFields(DataInput in) throws IOException { id = WritableUtils.readVInt(in); expirationDate = WritableUtils.readVLong(in); int keyLength = WritableUtils.readVInt(in); if (keyLength < 0) { secret = null; } else { byte[] keyBytes = new byte[keyLength]; in.readFully(keyBytes); secret = AuthenticationTokenSecretManager.createSecretKey(keyBytes); } } }
event.put(metric, in.readFloat()); } else if ("long".equals(type)) { event.put(metric, WritableUtils.readVLong(in)); } else if ("double".equals(type)) { event.put(metric, in.readDouble());
private static void assertVIntRoundTrip(SliceOutput output, long value) throws IOException { Slice oldBytes = writeVintOld(output, value); long readValueOld = WritableUtils.readVLong(oldBytes.getInput()); assertEquals(readValueOld, value); long readValueNew = RcFileDecoderUtils.readVInt(oldBytes, 0); assertEquals(readValueNew, value); long readValueNewStream = RcFileDecoderUtils.readVInt(oldBytes.getInput()); assertEquals(readValueNewStream, value); }
scan = Bytes.toString(Bytes.readByteArray(in)); length = WritableUtils.readVLong(in); if (version.atLeast(Version.WITH_ENCODED_REGION_NAME)) { encodedRegionName = Bytes.toString(Bytes.readByteArray(in));
memstoreTS = WritableUtils.readVLong(source); ByteBufferUtils.writeVLong(dest, memstoreTS); } catch (IOException ex) {
@Override public Long read(DataInputStream dis) throws IOException { return WritableUtils.readVLong(dis); } }
@Override protected Long decodeUnchecked(byte[] b, int offset, int len) { DataInputStream dis = new DataInputStream(new ByteArrayInputStream(b, offset, len)); try { return WritableUtils.readVLong(dis); } catch (IOException e) { throw new ValueFormatException(e); } } }
private static Map<String,Long> readSummary(DataInputStream in, String[] symbols) throws IOException { com.google.common.collect.ImmutableMap.Builder<String,Long> imb = ImmutableMap.builder(); int numEntries = WritableUtils.readVInt(in); for (int i = 0; i < numEntries; i++) { String symbol = symbols[WritableUtils.readVInt(in)]; imb.put(symbol, WritableUtils.readVLong(in)); } return imb.build(); } }
DataInputStream data_input = new DataInputStream(byte_input); memstoreTS = WritableUtils.readVLong(data_input); buf.position(buf.position() + WritableUtils.getVIntSize(memstoreTS));