@SuppressWarnings("unchecked") private Reader<Text, Text> getReader(int i) throws IOException { Reader<Text, Text> readerMock = mock(Reader.class); when(readerMock.getPosition()).thenReturn(0l).thenReturn(10l).thenReturn(20l); when(readerMock.nextRawKey(any(DataInputBuffer.class))).thenAnswer(getKeyAnswer("Segment" + i)); doAnswer(getValueAnswer("Segment" + i)) .when(readerMock) .nextRawValue(any(DataInputBuffer.class)); return readerMock; }
void close() throws IOException { reader.close(); if (!preserve && fs != null) { fs.delete(file, false); } }
public long getPosition() throws IOException { return reader.getPosition(); }
boolean next() throws IOException { return reader.next(key, value); }
long getLength() { return (reader == null) ? segmentLength : reader.getLength(); }
public Segment(Reader<K, V> reader, boolean preserve) { this.reader = reader; this.preserve = preserve; this.segmentLength = reader.getLength(); }