Exemplo n.º 1
0
  @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;
  }
Exemplo n.º 2
0
    void close() throws IOException {
      reader.close();

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

      this.segmentLength = reader.getLength();
    }