@Override public ByteBuffer getValue() { if (atEnd) return null; return delegate.getValue(); }
private int readAndCheckbytes(HFileScanner scanner, int start, int n) throws IOException { String value = "value"; int i = start; for (; i < (start + n); i++) { ByteBuffer key = ByteBuffer.wrap(((KeyValue)scanner.getKey()).getKey()); ByteBuffer val = scanner.getValue(); String keyStr = String.format(localFormatter, Integer.valueOf(i)); String valStr = value + keyStr; KeyValue kv = new KeyValue(Bytes.toBytes(keyStr), Bytes.toBytes("family"), Bytes.toBytes("qual"), Bytes.toBytes(valStr)); byte[] keyBytes = new KeyValue.KeyOnlyKeyValue(Bytes.toBytes(key), 0, Bytes.toBytes(key).length).getKey(); assertTrue("bytes for keys do not match " + keyStr + " " + Bytes.toString(Bytes.toBytes(key)), Arrays.equals(kv.getKey(), keyBytes)); byte [] valBytes = Bytes.toBytes(val); assertTrue("bytes for vals do not match " + valStr + " " + Bytes.toString(valBytes), Arrays.equals(Bytes.toBytes(valStr), valBytes)); if (!scanner.next()) { break; } } assertEquals(i, start + n - 1); return (start + n); }
if (scanner.seekTo(kv) >= 0) { ByteBuffer bbkey = ByteBuffer.wrap(((KeyValue) scanner.getKey()).getKey()); ByteBuffer bbval = scanner.getValue(); totalBytes += bbkey.limit(); totalBytes += bbval.limit();
checkSeekTo(keys, scanner, i); checkKeyValue("i=" + i, keys[i], values[i], ByteBuffer.wrap(((KeyValue) scanner.getKey()).getKey()), scanner.getValue()); checkSeekTo(keys, scanner, i); checkKeyValue("i=" + i, keys[i], values[i], ByteBuffer.wrap(((KeyValue) scanner.getKey()).getKey()), scanner.getValue());
public ByteBuffer getValue() { if (atEnd) return null; return delegate.getValue(); }
public ByteBuffer getValue() { if (atEnd) return null; return delegate.getValue(); }
@Override public ByteBuffer get(byte[] key) throws IOException { assert key != null; HFileScanner seek = reader.getScanner(false, true); if (seek.seekTo(key) == 0) { return seek.getValue(); } return null; }
@Override public ByteBuffer get(byte[] key) throws IOException { assert key != null; HFileScanner seek = reader.getScanner(false, true); if (seek.seekTo(key) == 0) { return seek.getValue(); } return null; }
private void populateKV(long nextStartTime, boolean scanSuccessful) { if (!scanSuccessful) { //end of file reached. collect stats and return scanStat.endIteration(0, nextStartTime); return; } prefetchedKey = scan.getKey(); prefetchedValue = scan.getValue(); if (to != null) { // TODO Optimization? Perform int comparison instead of byte[]. Identify // offset of key greater than two. int compare = -1; compare = scan.getReader().getComparator().compare (prefetchedKey.array(), prefetchedKey.arrayOffset(), prefetchedKey.remaining(), to, 0, to.length); if (compare > 0 || (compare == 0 && !toInclusive)) { prefetchedKey = null; prefetchedValue = null; return; } } // account for bytes read and time spent int byteCount = prefetchedKey.remaining() + prefetchedValue.remaining(); scanStat.endIteration(byteCount, nextStartTime); }
private void populateKV(long nextStartTime, boolean scanSuccessful) { if (!scanSuccessful) { //end of file reached. collect stats and return scanStat.endIteration(0, nextStartTime); return; } prefetchedKey = scan.getKey(); prefetchedValue = scan.getValue(); if (to != null) { // TODO Optimization? Perform int comparison instead of byte[]. Identify // offset of key greater than two. int compare = -1; compare = scan.getReader().getComparator().compare (prefetchedKey.array(), prefetchedKey.arrayOffset(), prefetchedKey.remaining(), to, 0, to.length); if (compare > 0 || (compare == 0 && !toInclusive)) { prefetchedKey = null; prefetchedValue = null; return; } } // account for bytes read and time spent int byteCount = prefetchedKey.remaining() + prefetchedValue.remaining(); scanStat.endIteration(byteCount, nextStartTime); }
@Override public ByteBuffer next() { long startNext = sopConfig.getStatistics().getScan().beginIteration(); if (!hasNext()) { throw new NoSuchElementException(); } foundNext = false; key = scan.getKey(); value = scan.getValue(); int len = key.remaining() + value.remaining(); bytes += len; sopConfig.getStatistics().getScan().endIteration(len, startNext); return key; }
private int readAndCheckbytes(HFileScanner scanner, int start, int n) throws IOException { String value = "value"; int i = start; for (; i < (start + n); i++) { ByteBuffer key = ByteBuffer.wrap(((KeyValue)scanner.getKey()).getKey()); ByteBuffer val = scanner.getValue(); String keyStr = String.format(localFormatter, Integer.valueOf(i)); String valStr = value + keyStr; KeyValue kv = new KeyValue(Bytes.toBytes(keyStr), Bytes.toBytes("family"), Bytes.toBytes("qual"), Bytes.toBytes(valStr)); byte[] keyBytes = new KeyValue.KeyOnlyKeyValue(Bytes.toBytes(key), 0, Bytes.toBytes(key).length).getKey(); assertTrue("bytes for keys do not match " + keyStr + " " + Bytes.toString(Bytes.toBytes(key)), Arrays.equals(kv.getKey(), keyBytes)); byte [] valBytes = Bytes.toBytes(val); assertTrue("bytes for vals do not match " + valStr + " " + Bytes.toString(valBytes), Arrays.equals(Bytes.toBytes(valStr), valBytes)); if (!scanner.next()) { break; } } assertEquals(i, start + n - 1); return (start + n); }
if (scanner.seekTo(kv) >= 0) { ByteBuffer bbkey = ByteBuffer.wrap(((KeyValue) scanner.getKey()).getKey()); ByteBuffer bbval = scanner.getValue(); totalBytes += bbkey.limit(); totalBytes += bbval.limit();
@Override public ByteBuffer read(byte[] key) throws IOException { assert key != null; if (logger.finestEnabled()) { logger.finest(String.format("Reading key %s from %s", Hex.toHex(key), path)); } long start = sopConfig.getStatistics().getRead().begin(); try { HFileScanner seek = reader.getScanner(true, true); if (seek.seekTo(key) == 0) { ByteBuffer val = seek.getValue(); sopConfig.getStatistics().getRead().end(val.remaining(), start); return val; } sopConfig.getStatistics().getRead().end(start); sopConfig.getStatistics().getBloom().falsePositive(); return null; } catch (IOException e) { sopConfig.getStatistics().getRead().error(start); throw (IOException) e.fillInStackTrace(); } }
checkSeekTo(keys, scanner, i); checkKeyValue("i=" + i, keys[i], values[i], ByteBuffer.wrap(((KeyValue) scanner.getKey()).getKey()), scanner.getValue()); checkSeekTo(keys, scanner, i); checkKeyValue("i=" + i, keys[i], values[i], ByteBuffer.wrap(((KeyValue) scanner.getKey()).getKey()), scanner.getValue());