/** * Returns the number of items to follow in the current array or map. Returns * 0 if there are no more items in the current array and the array/map has * ended. * * @throws IOException */ protected long doReadItemCount() throws IOException { long result = readLong(); if (result < 0) { readLong(); // Consume byte-count if present result = -result; } return result; }
/** * Returns the number of items to follow in the current array or map. Returns * 0 if there are no more items in the current array and the array/map has * ended. * * @throws IOException */ protected long doReadItemCount() throws IOException { long result = readLong(); if (result < 0) { readLong(); // Consume byte-count if present result = -result; } return result; }
boolean hasNextBlock() { try { if (availableBlock) return true; if (vin.isEnd()) return false; blockRemaining = vin.readLong(); // read block count blockSize = vin.readLong(); // read block size if (blockSize > Integer.MAX_VALUE || blockSize < 0) { throw new IOException("Block size invalid or too large for this " + "implementation: " + blockSize); } blockCount = blockRemaining; availableBlock = true; return true; } catch (EOFException eof) { return false; } catch (IOException e) { throw new AvroRuntimeException(e); } }
boolean hasNextBlock() { try { if (availableBlock) return true; if (vin.isEnd()) return false; blockRemaining = vin.readLong(); // read block count blockSize = vin.readLong(); // read block size if (blockSize > Integer.MAX_VALUE || blockSize < 0) { throw new IOException("Block size invalid or too large for this " + "implementation: " + blockSize); } blockCount = blockRemaining; availableBlock = true; return true; } catch (EOFException eof) { return false; } catch (IOException e) { throw new AvroRuntimeException(e); } }
/** Return the next datum in the file. */ @Override public synchronized D next(D reuse) throws IOException { while (blockCount == 0) { // at start of block if (in.tell() == in.length()) // at eof return null; skipSync(); // skip a sync blockCount = vin.readLong(); // read blockCount if (blockCount == FOOTER_BLOCK) { seek(vin.readLong()+in.tell()); // skip a footer } } blockCount--; return reader.read(reuse, vin); }
/** Return the next datum in the file. */ @Override public synchronized D next(D reuse) throws IOException { while (blockCount == 0) { // at start of block if (in.tell() == in.length()) // at eof return null; skipSync(); // skip a sync blockCount = vin.readLong(); // read blockCount if (blockCount == FOOTER_BLOCK) { seek(vin.readLong()+in.tell()); // skip a footer } } blockCount--; return reader.read(reuse, vin); }
@Override public Utf8 readString(Utf8 old) throws IOException { long length = readLong(); if (length > MAX_ARRAY_SIZE) { throw new UnsupportedOperationException("Cannot read strings longer than " + MAX_ARRAY_SIZE + " bytes"); } if (length < 0L) { throw new AvroRuntimeException("Malformed data. Length is negative: " + length); } Utf8 result = (old != null ? old : new Utf8()); result.setByteLength((int) length); if (0L != length) { doReadBytes(result.getBytes(), 0, (int) length); } return result; }
/** * Reads the count of items in the current array or map and skip those items, * if possible. If it could skip the items, keep repeating until there are no * more items left in the array or map. If items cannot be skipped (because * byte count to skip is not found in the stream) return the count of the * items found. The client needs to skip the items individually. * * @return Zero if there are no more items to skip and end of array/map is * reached. Positive number if some items are found that cannot be * skipped and the client needs to skip them individually. * @throws IOException */ private long doSkipItems() throws IOException { long result = readInt(); while (result < 0) { long bytecount = readLong(); doSkipBytes(bytecount); result = readInt(); } return result; }
/** * Reads the count of items in the current array or map and skip those items, * if possible. If it could skip the items, keep repeating until there are no * more items left in the array or map. If items cannot be skipped (because * byte count to skip is not found in the stream) return the count of the * items found. The client needs to skip the items individually. * * @return Zero if there are no more items to skip and end of array/map is * reached. Positive number if some items are found that cannot be * skipped and the client needs to skip them individually. * @throws IOException */ private long doSkipItems() throws IOException { long result = readInt(); while (result < 0) { long bytecount = readLong(); doSkipBytes(bytecount); result = readInt(); } return result; }
@Override public JsonToken decodeLongToken() throws IOException { _numberLong = _decoder.readLong(); _numTypesValid = NR_LONG; return JsonToken.VALUE_NUMBER_INT; }
@Override public long decodeLong() throws IOException { return _decoder.readLong(); }
@Override public void skipLong() throws IOException { // ints use variable-length zigzagging; alas, no native skipping _decoder.readLong(); }
/** * Returns the number of items to follow in the current array or map. Returns * 0 if there are no more items in the current array and the array/map has * ended. * * @throws IOException */ protected long doReadItemCount() throws IOException { long result = readLong(); if (result < 0) { readLong(); // Consume byte-count if present result = -result; } return result; }
/** * Returns the number of items to follow in the current array or map. Returns * 0 if there are no more items in the current array and the array/map has * ended. * * @throws IOException */ protected long doReadItemCount() throws IOException { long result = readLong(); if (result < 0) { readLong(); // Consume byte-count if present result = -result; } return result; }
/** * Returns the number of items to follow in the current array or map. Returns * 0 if there are no more items in the current array and the array/map has * ended. * * @throws IOException */ protected long doReadItemCount() throws IOException { long result = readLong(); if (result < 0) { readLong(); // Consume byte-count if present result = -result; } return result; }
/** * Returns the number of items to follow in the current array or map. Returns * 0 if there are no more items in the current array and the array/map has * ended. * * @throws IOException */ protected long doReadItemCount() throws IOException { long result = readLong(); if (result < 0) { readLong(); // Consume byte-count if present result = -result; } return result; }
boolean hasNextBlock() { try { if (availableBlock) return true; if (vin.isEnd()) return false; blockRemaining = vin.readLong(); // read block count blockSize = vin.readLong(); // read block size if (blockSize > Integer.MAX_VALUE || blockSize < 0) { throw new IOException("Block size invalid or too large for this " + "implementation: " + blockSize); } availableBlock = true; return true; } catch (EOFException eof) { return false; } catch (IOException e) { throw new AvroRuntimeException(e); } }
@Override public JsonToken readValue(AvroParserImpl parser, BinaryDecoder decoder) throws IOException { return parser.setNumber(decoder.readLong()); } }
/** Return the next datum in the file. */ @Override public synchronized D next(D reuse) throws IOException { while (blockCount == 0) { // at start of block if (in.tell() == in.length()) // at eof return null; skipSync(); // skip a sync blockCount = vin.readLong(); // read blockCount if (blockCount == FOOTER_BLOCK) { seek(vin.readLong()+in.tell()); // skip a footer } } blockCount--; return reader.read(reuse, vin); }
/** Return the next datum in the file. */ @Override public synchronized D next(D reuse) throws IOException { while (blockCount == 0) { // at start of block if (in.tell() == in.length()) // at eof return null; skipSync(); // skip a sync blockCount = vin.readLong(); // read blockCount if (blockCount == FOOTER_BLOCK) { seek(vin.readLong()+in.tell()); // skip a footer } } blockCount--; return reader.read(reuse, vin); }