/** * check whether we have already successfully obtained the key. It also * initializes the valueInputStream. */ void checkKey() throws IOException { if (klen >= 0) return; if (atEnd()) { throw new EOFException("No key-value to read"); } klen = -1; vlen = -1; valueChecked = false; klen = Utils.readVInt(blkReader); blkReader.readFully(keyBuffer, 0, klen); valueBufferInputStream.reset(blkReader); if (valueBufferInputStream.isLastChunk()) { vlen = valueBufferInputStream.getRemain(); } }
public void testNoDataEntry() throws IOException { if (skip) return; closeOutput(); Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf); Assert.assertTrue(reader.isSorted()); Scanner scanner = reader.createScanner(); Assert.assertTrue(scanner.atEnd()); scanner.close(); reader.close(); }
/** * check whether we have already successfully obtained the key. It also * initializes the valueInputStream. */ void checkKey() throws IOException { if (klen >= 0) return; if (atEnd()) { throw new EOFException("No key-value to read"); } klen = -1; vlen = -1; valueChecked = false; klen = Utils.readVInt(blkReader); blkReader.readFully(keyBuffer, 0, klen); valueBufferInputStream.reset(blkReader); if (valueBufferInputStream.isLastChunk()) { vlen = valueBufferInputStream.getRemain(); } }
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); }
/** * Parses the given file and writes its contents into the outputWriter for all logs in it. * * @param inputPath * @param outputWriter * @throws IOException */ void parseOneFile(final Path inputPath, final Writer outputWriter) throws IOException { try (final TFile.Reader.Scanner scanner = this.getScanner(inputPath)) { while (!scanner.atEnd()) { new LogFileEntry(scanner.entry()).write(outputWriter); scanner.advance(); } } }
@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)); } }
/** * Parses the given file and stores the logs for each container in a file named after the container in the given. * outputFolder * * @param inputPath * @param outputFolder * @throws IOException */ void parseOneFile(final Path inputPath, final File outputFolder) throws IOException { try (final TFile.Reader.Scanner scanner = this.getScanner(inputPath)) { while (!scanner.atEnd()) { new LogFileEntry(scanner.entry()).write(outputFolder); scanner.advance(); } } }
/** * Parses the given file and stores the logs for each container in a file named after the container in the given * outputFolder * * @param inputPath * @param outputFolder * @throws IOException */ void parseOneFile(final Path inputPath, final File outputFolder) throws IOException { try (final TFile.Reader.Scanner scanner = this.getScanner(inputPath)) { while (!scanner.atEnd()) { new LogFileEntry(scanner.entry()).write(outputFolder); scanner.advance(); } } }
public boolean hasNext() { return !scanner.atEnd(); }
public boolean hasNext() { return !scanner.atEnd(); }
/** * Parses the given file and writes its contents into the outputWriter for all logs in it. * * @param inputPath * @param outputWriter * @throws IOException */ void parseOneFile(final Path inputPath, final Writer outputWriter) throws IOException { try (final TFile.Reader.Scanner scanner = this.getScanner(inputPath)) { while (!scanner.atEnd()) { new LogFileEntry(scanner.entry()).write(outputWriter); scanner.advance(); } } }
@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 hasNext() { return !scanner.atEnd(); }
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 hasNext() { return !scanner.atEnd(); } }
@Test public void testNoDataEntry() throws IOException { if (skip) return; closeOutput(); Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf); Assert.assertTrue(reader.isSorted()); Scanner scanner = reader.createScanner(); Assert.assertTrue(scanner.atEnd()); scanner.close(); reader.close(); }
@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; }
@Test public void testNoDataEntry() throws IOException { if (skip) return; closeOutput(); Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf); Assert.assertTrue(reader.isSorted()); Scanner scanner = reader.createScanner(); Assert.assertTrue(scanner.atEnd()); scanner.close(); reader.close(); }
/** * Move the cursor to the next key-value pair. The entry returned by the * previous entry() call will be invalid. * * @return true if the cursor successfully moves. False when cursor is * already at the end location and cannot be advanced. * @throws IOException */ public boolean advance() throws IOException { if (atEnd()) { return false; } int curBid = currentLocation.getBlockIndex(); long curRid = currentLocation.getRecordIndex(); long entriesInBlock = reader.getBlockEntryCount(curBid); if (curRid + 1 >= entriesInBlock) { if (endLocation.compareTo(curBid + 1, 0) <= 0) { // last entry in TFile. parkCursorAtEnd(); } else { // last entry in Block. initBlock(curBid + 1); } } else { inBlockAdvance(1); } return true; }
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); }