@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;
  }
Example #2
0
    void close() throws IOException {
      reader.close();

      if (!preserve && fs != null) {
        fs.delete(file, false);
      }
    }
Example #3
0
 public long getPosition() throws IOException {
   return reader.getPosition();
 }
Example #4
0
 boolean next() throws IOException {
   return reader.next(key, value);
 }
Example #5
0
 long getLength() {
   return (reader == null) ? segmentLength : reader.getLength();
 }
Example #6
0
    public Segment(Reader<K, V> reader, boolean preserve) {
      this.reader = reader;
      this.preserve = preserve;

      this.segmentLength = reader.getLength();
    }