private void checkBlockIndex(int count, int recordIndex, int blockIndexExpected) throws IOException { Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf); Scanner scanner = reader.createScanner(); scanner.seekTo(composeSortedKey(KEY, count, recordIndex).getBytes()); Assert.assertEquals(blockIndexExpected, scanner.currentLocation .getBlockIndex()); scanner.close(); reader.close(); }
private void checkBlockIndex(int recordIndex, int blockIndexExpected) throws IOException { Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf); Scanner scanner = reader.createScanner(); scanner.seekTo(composeSortedKey(KEY, recordIndex).getBytes()); Assert.assertEquals(blockIndexExpected, scanner.currentLocation .getBlockIndex()); scanner.close(); reader.close(); }
private void checkBlockIndex(int recordIndex, int blockIndexExpected) throws IOException { Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf); Scanner scanner = reader.createScanner(); scanner.seekTo(composeSortedKey(KEY, recordIndex).getBytes()); Assert.assertEquals(blockIndexExpected, scanner.currentLocation .getBlockIndex()); scanner.close(); reader.close(); }
Location locate(Scanner scanner, byte[] key) throws IOException { if (scanner.seekTo(key) == true) { return scanner.currentLocation; } return scanner.endLocation; }
/** * Rewind to the first entry in the scanner. The entry returned by the * previous entry() call will be invalid. * * @throws IOException */ public void rewind() throws IOException { seekTo(beginLocation); }
/** * Move the cursor to the first entry whose key is greater than or equal * to the input key. Synonymous to seekTo(key, 0, key.length). The entry * returned by the previous entry() call will be invalid. * * @param key * The input key * @return true if we find an equal key. * @throws IOException */ public boolean seekTo(byte[] key) throws IOException { return seekTo(key, 0, key.length); }
/** * Move the cursor to the first entry whose key is greater than or equal * to the input key. Synonymous to seekTo(key, 0, key.length). The entry * returned by the previous entry() call will be invalid. * * @param key * The input key * @return true if we find an equal key. * @throws IOException */ public boolean seekTo(byte[] key) throws IOException { return seekTo(key, 0, key.length); }
Location locate(Scanner scanner, byte[] key) throws IOException { if (scanner.seekTo(key) == true) { return scanner.currentLocation; } return scanner.endLocation; }
/** * Rewind to the first entry in the scanner. The entry returned by the * previous entry() call will be invalid. * * @throws IOException */ public void rewind() throws IOException { seekTo(beginLocation); }
Location locate(Scanner scanner, byte[] key) throws IOException { if (scanner.seekTo(key) == true) { return scanner.currentLocation; } return scanner.endLocation; }
/** * Rewind to the first entry in the scanner. The entry returned by the * previous entry() call will be invalid. * * @throws IOException */ public void rewind() throws IOException { seekTo(beginLocation); }
/** * Rewind to the first entry in the scanner. The entry returned by the * previous entry() call will be invalid. * * @throws IOException */ public void rewind() throws IOException { seekTo(beginLocation); }
/** * Rewind to the first entry in the scanner. The entry returned by the * previous entry() call will be invalid. * * @throws IOException */ public void rewind() throws IOException { seekTo(beginLocation); }
/** * Constructor * * @param reader * The TFile reader object. * @param beginKey * Begin key of the scan. If null, scan from the first <K,V> * entry of the TFile. * @param endKey * End key of the scan. If null, scan up to the last <K, V> entry * of the TFile. * @throws IOException */ protected Scanner(Reader reader, RawComparable beginKey, RawComparable endKey) throws IOException { this(reader, (beginKey == null) ? reader.begin() : reader .getBlockContainsKey(beginKey, false), reader.end()); if (beginKey != null) { inBlockAdvance(beginKey, false); beginLocation.set(currentLocation); } if (endKey != null) { seekTo(endKey, false); endLocation.set(currentLocation); seekTo(beginLocation); } }
private boolean seekTo(RawComparable key, boolean beyond) throws IOException { Location l = reader.getBlockContainsKey(key, beyond); if (l.compareTo(beginLocation) < 0) { l = beginLocation; } else if (l.compareTo(endLocation) >= 0) { seekTo(endLocation); return false; } // check if what we are seeking is in the later part of the current // block. if (atEnd() || (l.getBlockIndex() != currentLocation.getBlockIndex()) || (compareCursorKeyTo(key) >= 0)) { // sorry, we must seek to a different location first. seekTo(l); } return inBlockAdvance(key, beyond); }
/** * Move the cursor to the first entry whose key is greater than or equal * to the input key. The entry returned by the previous entry() call will * be invalid. * * @param key * The input key * @param keyOffset * offset in the key buffer. * @param keyLen * key buffer length. * @return true if we find an equal key; false otherwise. * @throws IOException */ public boolean seekTo(byte[] key, int keyOffset, int keyLen) throws IOException { return seekTo(new ByteArray(key, keyOffset, keyLen), false); }
/** * Move the cursor to the first entry whose key is greater than or equal * to the input key. The entry returned by the previous entry() call will * be invalid. * * @param key * The input key * @param keyOffset * offset in the key buffer. * @param keyLen * key buffer length. * @throws IOException */ public void lowerBound(byte[] key, int keyOffset, int keyLen) throws IOException { seekTo(new ByteArray(key, keyOffset, keyLen), false); }
/** * Move the cursor to the first entry whose key is strictly greater than * the input key. The entry returned by the previous entry() call will be * invalid. * * @param key * The input key * @param keyOffset * offset in the key buffer. * @param keyLen * key buffer length. * @throws IOException */ public void upperBound(byte[] key, int keyOffset, int keyLen) throws IOException { seekTo(new ByteArray(key, keyOffset, keyLen), true); }
/** * Move the cursor to the first entry whose key is greater than or equal * to the input key. Synonymous to seekTo(key, 0, key.length). The entry * returned by the previous entry() call will be invalid. * * @param key * The input key * @return true if we find an equal key. * @throws IOException */ public boolean seekTo(byte[] key) throws IOException { return seekTo(key, 0, key.length); }
/** * Rewind to the first entry in the scanner. The entry returned by the * previous entry() call will be invalid. * * @throws IOException */ public void rewind() throws IOException { seekTo(beginLocation); }