private void readValueWithoutKey(int recordIndex) throws IOException { Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf); Scanner scanner = reader.createScannerByKey(composeSortedKey(KEY, recordIndex) .getBytes(), null); byte[] vbuf1 = new byte[BUF_SIZE]; int vlen1 = scanner.entry().getValueLength(); scanner.entry().getValue(vbuf1); Assert.assertEquals(new String(vbuf1, 0, vlen1), VALUE + recordIndex); if (scanner.advance() && !scanner.atEnd()) { byte[] vbuf2 = new byte[BUF_SIZE]; int vlen2 = scanner.entry().getValueLength(); scanner.entry().getValue(vbuf2); Assert.assertEquals(new String(vbuf2, 0, vlen2), VALUE + (recordIndex + 1)); } scanner.close(); reader.close(); }
@Override public void readFully(TreeMap<Slice, Slice> data) throws IOException { scanner.rewind(); for (; !scanner.atEnd(); scanner.advance()) { Entry en = scanner.entry(); int klen = en.getKeyLength(); int vlen = en.getValueLength(); byte[] key = new byte[klen]; byte[] value = new byte[vlen]; en.getKey(key); en.getValue(value); data.put(new Slice(key, 0, key.length), new Slice(value, 0, value.length)); } }
/** * Copy value into user-supplied buffer. User supplied buffer must be * large enough to hold the whole value. The value part of the key-value * pair pointed by the current cursor is not cached and can only be * examined once. Calling any of the following functions more than once * without moving the cursor will result in exception: * {@link #getValue(byte[])}, {@link #getValue(byte[], int)}, * {@link #getValueStream}. * * @return the length of the value. Does not require * isValueLengthKnown() to be true. * @throws IOException * */ public int getValue(byte[] buf) throws IOException { return getValue(buf, 0); }
/** * Copy value into user-supplied buffer. User supplied buffer must be * large enough to hold the whole value. The value part of the key-value * pair pointed by the current cursor is not cached and can only be * examined once. Calling any of the following functions more than once * without moving the cursor will result in exception: * {@link #getValue(byte[])}, {@link #getValue(byte[], int)}, * {@link #getValueStream}. * * @return the length of the value. Does not require * isValueLengthKnown() to be true. * @throws IOException * */ public int getValue(byte[] buf) throws IOException { return getValue(buf, 0); }
/** * Copy value into user-supplied buffer. User supplied buffer must be * large enough to hold the whole value. The value part of the key-value * pair pointed by the current cursor is not cached and can only be * examined once. Calling any of the following functions more than once * without moving the cursor will result in exception: * {@link #getValue(byte[])}, {@link #getValue(byte[], int)}, * {@link #getValueStream}. * * @return the length of the value. Does not require * isValueLengthKnown() to be true. * @throws IOException * */ public int getValue(byte[] buf) throws IOException { return getValue(buf, 0); }
/** * Copy value into user-supplied buffer. User supplied buffer must be * large enough to hold the whole value. The value part of the key-value * pair pointed by the current cursor is not cached and can only be * examined once. Calling any of the following functions more than once * without moving the cursor will result in exception: * {@link #getValue(byte[])}, {@link #getValue(byte[], int)}, * {@link #getValueStream}. * * @return the length of the value. Does not require * isValueLengthKnown() to be true. * @throws IOException * */ public int getValue(byte[] buf) throws IOException { return getValue(buf, 0); }
/** * Copy value into user-supplied buffer. User supplied buffer must be * large enough to hold the whole value. The value part of the key-value * pair pointed by the current cursor is not cached and can only be * examined once. Calling any of the following functions more than once * without moving the cursor will result in exception: * {@link #getValue(byte[])}, {@link #getValue(byte[], int)}, * {@link #getValueStream}. * * @return the length of the value. Does not require * isValueLengthKnown() to be true. * @throws IOException * */ public int getValue(byte[] buf) throws IOException { return getValue(buf, 0); }
/** * Copy the key and value in one shot into BytesWritables. This is * equivalent to getKey(key); getValue(value); * * @param key * BytesWritable to hold key. * @param value * BytesWritable to hold value * @throws IOException */ public void get(BytesWritable key, BytesWritable value) throws IOException { getKey(key); getValue(value); }
/** * Copy the key and value in one shot into BytesWritables. This is * equivalent to getKey(key); getValue(value); * * @param key * BytesWritable to hold key. * @param value * BytesWritable to hold value * @throws IOException */ public void get(BytesWritable key, BytesWritable value) throws IOException { getKey(key); getValue(value); }
/** * Copy the key and value in one shot into BytesWritables. This is * equivalent to getKey(key); getValue(value); * * @param key * BytesWritable to hold key. * @param value * BytesWritable to hold value * @throws IOException */ public void get(BytesWritable key, BytesWritable value) throws IOException { getKey(key); getValue(value); }
/** * Copy the key and value in one shot into BytesWritables. This is * equivalent to getKey(key); getValue(value); * * @param key * BytesWritable to hold key. * @param value * BytesWritable to hold value * @throws IOException */ public void get(BytesWritable key, BytesWritable value) throws IOException { getKey(key); getValue(value); }
/** * Copy the key and value in one shot into BytesWritables. This is * equivalent to getKey(key); getValue(value); * * @param key * BytesWritable to hold key. * @param value * BytesWritable to hold value * @throws IOException */ public void get(BytesWritable key, BytesWritable value) throws IOException { getKey(key); getValue(value); }
@Override public boolean next() throws IOException { if (scanner.atEnd()) return false; Entry entry = scanner.entry(); keyLength = entry.getKeyLength(); checkKeyBuffer(keyLength); entry.getKey(keyBuffer); valueLength = entry.getValueLength(); checkValueBuffer(valueLength); entry.getValue(valueBuffer); scanner.advance(); return true; }
@Override public boolean next() throws IOException { if (scanner.atEnd()) return false; Entry entry = scanner.entry(); keyLength = entry.getKeyLength(); checkKeyBuffer(keyLength); entry.getKey(keyBuffer); valueLength = entry.getValueLength(); checkValueBuffer(valueLength); entry.getValue(valueBuffer); scanner.advance(); return true; }
public boolean next() throws IOException { if (scanner.atEnd()) return false; Entry entry = scanner.entry(); keyLength = entry.getKeyLength(); checkKeyBuffer(keyLength); entry.getKey(keyBuffer); valueLength = entry.getValueLength(); checkValueBuffer(valueLength); entry.getValue(valueBuffer); scanner.advance(); return true; }
public byte[] readValue(Scanner scanner) throws IOException { int valueLen = scanner.entry().getValueLength(); byte[] read = new byte[valueLen]; scanner.entry().getValue(read); return read; }
public byte[] readValue(Scanner scanner) throws IOException { int valueLen = scanner.entry().getValueLength(); byte[] read = new byte[valueLen]; scanner.entry().getValue(read); return read; }
public byte[] readValue(Scanner scanner) throws IOException { int valueLen = scanner.entry().getValueLength(); byte[] read = new byte[valueLen]; scanner.entry().getValue(read); return read; }
/** * Copy value into user-supplied buffer. User supplied buffer must be * large enough to hold the whole value. The value part of the key-value * pair pointed by the current cursor is not cached and can only be * examined once. Calling any of the following functions more than once * without moving the cursor will result in exception: * {@link #getValue(byte[])}, {@link #getValue(byte[], int)}, * {@link #getValueStream}. * * @return the length of the value. Does not require * isValueLengthKnown() to be true. * @throws IOException * */ public int getValue(byte[] buf) throws IOException { return getValue(buf, 0); }
/** * Copy the key and value in one shot into BytesWritables. This is * equivalent to getKey(key); getValue(value); * * @param key * BytesWritable to hold key. * @param value * BytesWritable to hold value * @throws IOException */ public void get(BytesWritable key, BytesWritable value) throws IOException { getKey(key); getValue(value); }