/** * Read from the InputStream into the given Text. * @param str the object to store the given line * @return the number of bytes read including the newline * @throws IOException if the underlying stream throws */ public int readLine(Text str) throws IOException { return readLine(str, Integer.MAX_VALUE, Integer.MAX_VALUE); }
/** * Read from the InputStream into the given Text. * @param str the object to store the given line * @param maxLineLength the maximum number of bytes to store into str. * @return the number of bytes read including the newline * @throws IOException if the underlying stream throws */ public int readLine(Text str, int maxLineLength) throws IOException { return readLine(str, maxLineLength, Integer.MAX_VALUE); }
/** * Read from the InputStream into the given Text. * @param str the object to store the given line * @return the number of bytes read including the newline * @throws IOException if the underlying stream throws */ public int readLine(Text str) throws IOException { return readLine(str, Integer.MAX_VALUE, Integer.MAX_VALUE); }
/** * Read from the InputStream into the given Text. * @param str the object to store the given line * @return the number of bytes read including the newline * @throws IOException if the underlying stream throws */ public int readLine(Text str) throws IOException { return readLine(str, Integer.MAX_VALUE, Integer.MAX_VALUE); }
/** * Read from the InputStream into the given Text. * @param str the object to store the given line * @param maxLineLength the maximum number of bytes to store into str. * @return the number of bytes read including the newline * @throws IOException if the underlying stream throws */ public int readLine(Text str, int maxLineLength) throws IOException { return readLine(str, maxLineLength, Integer.MAX_VALUE); }
/** * Read from the InputStream into the given Text. * @param str the object to store the given line * @param maxLineLength the maximum number of bytes to store into str. * @return the number of bytes read including the newline * @throws IOException if the underlying stream throws */ public int readLine(Text str, int maxLineLength) throws IOException { return readLine(str, maxLineLength, Integer.MAX_VALUE); }
private int readLineInto(Text dest) throws EOFException, IOException { int bytesRead = lineReader.readLine(dest, MAX_LINE_LENGTH); if (bytesRead <= 0) throw new EOFException(); pos += bytesRead; return bytesRead; } }
private int readLineInto(Text dest) throws EOFException, IOException { int bytesRead = lineReader.readLine(dest, MAX_LINE_LENGTH); if (bytesRead <= 0) throw new EOFException(); pos += bytesRead; return bytesRead; } }
private int readLineInto(Text dest) throws EOFException, IOException { int bytesRead = lineReader.readLine(dest, MAX_LINE_LENGTH); if (bytesRead <= 0) throw new EOFException(); pos += bytesRead; return bytesRead; } }
private int readLineInto(Text dest) throws IOException { int bytesRead = lineReader.readLine(dest, MAX_LINE_LENGTH); if (bytesRead <= 0) { throw new EOFException(); } pos += bytesRead; return bytesRead; } }
private void positionAtFirstRecord(FSDataInputStream stream) throws IOException { if (start > 0) { // Advance to the start of the first line in our slice. // We use a temporary LineReader to read a partial line and find the // start of the first one on or after our starting position. // In case our slice starts right at the beginning of a line, we need to back // up by one position and then discard the first line. start -= 1; stream.seek(start); LineReader reader = new LineReader(stream); int bytesRead = reader.readLine(buffer, (int)Math.min(MAX_LINE_LENGTH, end - start)); start = start + bytesRead; stream.seek(start); } // else // if start == 0 we're starting at the beginning of a line pos = start; }
private void positionAtFirstRecord(FSDataInputStream stream) throws IOException { if (start > 0) { stream.seek(start); } // we are now in a new chromosome/fragment, so read its name/index sequence // and reset position counter // index sequence LineReader reader = new LineReader(stream); int bytesRead = reader.readLine(buffer, (int)Math.min(MAX_LINE_LENGTH, end - start)); current_split_indexseq = buffer.toString(); // now get rid of '>' character current_split_indexseq = current_split_indexseq.substring(1,current_split_indexseq.length()); // initialize position counter current_split_pos = 1; logger.debug("read index sequence: {}"); start = start + bytesRead; stream.seek(start); pos = start; }
private int lowLevelQseqRead(Text key, SequencedFragment value) throws IOException { int bytesRead = lineReader.readLine(buffer, MAX_LINE_LENGTH); pos += bytesRead; if (bytesRead >= MAX_LINE_LENGTH) { String line; try { line = Text.decode(buffer.getBytes(), 0, 500); } catch (java.nio.charset.CharacterCodingException e) { line = "(line not convertible to printable format)"; } throw new RuntimeException("found abnormally large line (length " + bytesRead + ") at " + makePositionMessage(pos - bytesRead) + ": " + line); } else if (bytesRead > 0) scanQseqLine(buffer, key, value); return bytesRead; }
/** * Reads the next key/value pair from the input for processing. */ public boolean next(Text key, ReferenceFragment value) throws IOException { if (pos >= end) return false; // past end of slice int bytesRead = lineReader.readLine(buffer, MAX_LINE_LENGTH); pos += bytesRead; if (bytesRead >= MAX_LINE_LENGTH) throw new RuntimeException("found abnormally large line (length " + bytesRead + ") at " + makePositionMessage(pos - bytesRead) + ": " + Text.decode(buffer.getBytes(), 0, 500)); else if (bytesRead <= 0) return false; // EOF else { scanFastaLine(buffer, key, value); current_split_pos += bytesRead; return true; } }
/** * Reads the next key/value pair from the input for processing. */ public boolean next(Text key, ReferenceFragment value) throws IOException { if (pos >= end) return false; // past end of slice int bytesRead = lineReader.readLine(buffer, MAX_LINE_LENGTH); pos += bytesRead; if (bytesRead >= MAX_LINE_LENGTH) throw new RuntimeException("found abnormally large line (length " + bytesRead + ") at " + makePositionMessage(pos - bytesRead) + ": " + Text.decode(buffer.getBytes(), 0, 500)); else if (bytesRead <= 0) return false; // EOF else { scanFastaLine(buffer, key, value); current_split_pos += bytesRead; return true; } }
private int lowLevelQseqRead(Text key, SequencedFragment value) throws IOException { int bytesRead = lineReader.readLine(buffer, MAX_LINE_LENGTH); pos += bytesRead; if (bytesRead >= MAX_LINE_LENGTH) { String line; try { line = Text.decode(buffer.getBytes(), 0, 500); } catch (java.nio.charset.CharacterCodingException e) { line = "(line not convertible to printable format)"; } throw new RuntimeException("found abnormally large line (length " + bytesRead + ") at " + makePositionMessage(pos - bytesRead) + ": " + line); } else if (bytesRead > 0) scanQseqLine(buffer, key, value); return bytesRead; }
@Test public void testReadBufferedLine() throws IOException { reader = new LineReader(new ByteArrayInputStream(input22.getBytes()), 22); reader.readLine(dest); assertEquals("0123456789", dest.toString()); }
@Test public void testReadBeyondBuffer() throws IOException { reader = new LineReader(new ByteArrayInputStream(input22.getBytes()), 5); reader.readLine(dest); assertEquals("0123456789", dest.toString()); }
@Test public void testSkipOnBufferedLine() throws IOException { reader = new LineReader(new ByteArrayInputStream(input22.getBytes()), 22); long skipped = reader.skip(1); assertEquals(1, skipped); reader.readLine(dest); assertEquals("123456789", dest.toString()); }
@Test public void testSkipBeyondBuffer() throws IOException { reader = new LineReader(new ByteArrayInputStream(input22.getBytes()), 5); long skipped = reader.skip(11); assertEquals(11, skipped); reader.readLine(dest); assertEquals("0987654321", dest.toString()); }