public void close() throws IOException { if (slr != null) { slr.close(); } } }
@Override public InputStream getInputStream() { return slr.getInputStream(); }
public String getLastLine(SeekableLineReader slr) throws IOException { int lastLineLenTest = 0; int lastLineLenInc = 400; String endLine = null; do { lastLineLenTest += lastLineLenInc; slr.seek(slr.getSize() - lastLineLenTest); // TODO: assume larger buffer slr.readLine(); // skip partial line String nextLine = null; endLine = null; while ((nextLine = slr.readLine()) != null) { endLine = nextLine; } } while (endLine == null); return endLine; }
public String next() { String line = null; try { if (startOffset + currSplit != 0) { slr.skipLine(); } line = slr.readLine(); currSplit++; long seekDiff = ((endOffset - startOffset) * currSplit) / numSplits; slr.seek(startOffset + seekDiff); } catch (IOException io) { io.printStackTrace(); } return line; }
public long binaryFindOffset(SeekableLineReader slr, final String key, Comparator<String> comparator) throws IOException long fileSize = slr.getSize(); long min = 0; long max = (long) fileSize / blockSize; slr.seek(mid * blockSize); if(mid > 0) slr.skipLine(); // probably a partial line line = slr.readLine();
public static void closeAllReaders() { for (Entry<String, SeekableLineReader> entry : slrMap.get().entrySet()) { try { SeekableLineReader reader = entry.getValue(); if (!reader.isClosed()) { LOGGER.warning("Unclosed reader for: " + entry.getKey()); reader.close(); } } catch (IOException io) { } } slrMap.get().clear(); }
currReader = createBlockReader(location); currReader.seekWithMaxRead(startOffset, decompress, totalLength); currReader.close(); } catch (IOException e) {
InputStream is = slr.getInputStream(); if (!success) { if (slr != null) { slr.close();
public StepSeekingIterator(SeekableLineReader slr, long startOffset, long endOffset, int numSplits) throws IOException { this.slr = slr; this.currSplit = 0; this.startOffset = startOffset; this.numSplits = numSplits; this.endOffset = endOffset; slr.seek(startOffset); }
@Override public String readLine() throws IOException { return slr.readLine(); }
@Override public void setBufferFully(boolean bufferFully) { slr.setBufferFully(bufferFully); }
@Override public long getSize() throws IOException { return slr.getSize(); }
@Override public void seekWithMaxRead(long offset, boolean gzip, int maxLength) throws IOException { slr.seekWithMaxRead(offset, gzip, maxLength); }
@Override public boolean isClosed() { return slr.isClosed(); }
@Override public void skipLine() throws IOException { slr.skipLine(); }
public String next() { String line = null; try { if (startOffset + currSplit != 0) { slr.skipLine(); } line = slr.readLine(); currSplit++; long seekDiff = ((endOffset - startOffset) * currSplit) / numSplits; slr.seek(startOffset + seekDiff); } catch (IOException io) { io.printStackTrace(); } return line; }