CorcRecordReader implements RecordReader<NullWritable, Corc> { @Override public boolean next(NullWritable key, Corc value) throws IOException { while (reader.next(key, value.getOrcStruct())) { if (filter.accept(value)) { if (transactional) { value.setRecordIdentifier(transactionalReader.getRecordIdentifier()); } return true; } } return false; } CorcRecordReader(StructTypeInfo typeInfo, RecordReader<NullWritable, OrcStruct> reader, ConverterFactory factory,
      Filter filter); @Override boolean next(NullWritable key, Corc value); @Override NullWritable createKey(); @Override Corc createValue(); @Override long getPos(); @Override void close(); @Override float getProgress();  }
@Test public void readerNext() throws IOException { @SuppressWarnings("unchecked") RecordReader<NullWritable, OrcStruct> recordReader = mock(RecordReader.class); CorcRecordReader reader = new CorcRecordReader(typeInfo, recordReader, factory, Filter.ACCEPT); Corc corc = mock(Corc.class); when(recordReader.next(any(NullWritable.class), any(OrcStruct.class))).thenReturn(true); boolean next = reader.next(NullWritable.get(), corc); assertTrue(next); verify(corc, never()).setRecordIdentifier(any(RecordIdentifier.class)); }
@Test public void readerNoNext() throws IOException { @SuppressWarnings("unchecked") RecordReader<NullWritable, OrcStruct> recordReader = mock(RecordReader.class); CorcRecordReader reader = new CorcRecordReader(typeInfo, recordReader, factory, Filter.ACCEPT); Corc corc = mock(Corc.class); when(recordReader.next(any(NullWritable.class), any(OrcStruct.class))).thenReturn(false); boolean next = reader.next(NullWritable.get(), corc); assertFalse(next); verify(corc, never()).setRecordIdentifier(any(RecordIdentifier.class)); }
@Test public void readerNoNextFilterNotAccept() throws IOException { @SuppressWarnings("unchecked") RecordReader<NullWritable, OrcStruct> recordReader = mock(RecordReader.class); Filter filter = mock(Filter.class); CorcRecordReader reader = new CorcRecordReader(typeInfo, recordReader, factory, filter); Corc corc = mock(Corc.class); when(recordReader.next(any(NullWritable.class), any(OrcStruct.class))).thenReturn(true).thenReturn(false); when(filter.accept(corc)).thenReturn(false); boolean next = reader.next(NullWritable.get(), corc); assertFalse(next); verify(corc, never()).setRecordIdentifier(any(RecordIdentifier.class)); }
@Test public void readerNextTransactional() throws IOException { @SuppressWarnings("unchecked") AcidRecordReader<NullWritable, OrcStruct> recordReader = mock(AcidRecordReader.class); CorcRecordReader reader = new CorcRecordReader(typeInfo, recordReader, factory, Filter.ACCEPT); Corc corc = mock(Corc.class); when(recordReader.next(any(NullWritable.class), any(OrcStruct.class))).thenReturn(true); boolean next = reader.next(NullWritable.get(), corc); assertTrue(next); verify(corc).setRecordIdentifier(any(RecordIdentifier.class)); }
@Test public void readerNoNextTransactional() throws IOException { @SuppressWarnings("unchecked") AcidRecordReader<NullWritable, OrcStruct> recordReader = mock(AcidRecordReader.class); CorcRecordReader reader = new CorcRecordReader(typeInfo, recordReader, factory, Filter.ACCEPT); Corc corc = mock(Corc.class); when(recordReader.next(any(NullWritable.class), any(OrcStruct.class))).thenReturn(false); boolean next = reader.next(NullWritable.get(), corc); assertFalse(next); verify(corc, never()).setRecordIdentifier(any(RecordIdentifier.class)); }