MCPcopy Create free account
hub / github.com/apache/orc / MockDataReader

Class MockDataReader

java/core/src/test/org/apache/orc/impl/MockDataReader.java:33–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31import java.util.Set;
32
33public class MockDataReader implements DataReader {
34 private final List<MockStripe> stripes = new ArrayList<>();
35 private final int numColumns;
36 private long offset = 3;
37 private MockStripe next;
38 private Set<ByteBuffer> outBuffers =
39 Collections.newSetFromMap(new IdentityHashMap<>());
40 private final InStream.StreamOptions options;
41
42 public MockDataReader(TypeDescription schema) {
43 this(schema, new InStream.StreamOptions());
44 }
45
46 public MockDataReader(TypeDescription schema,
47 InStream.StreamOptions options) {
48 numColumns = schema.getMaximumId() + 1;
49 next = new MockStripe(numColumns, stripes.size(), offset);
50 this.options = options;
51 }
52
53 public MockDataReader addStream(int column, OrcProto.Stream.Kind kind,
54 ByteBuffer bytes) {
55 next.addStream(column, kind, offset, bytes);
56 offset += bytes.remaining();
57 return this;
58 }
59
60 public MockDataReader addEncoding(OrcProto.ColumnEncoding.Kind kind) {
61 next.addEncoding(kind);
62 return this;
63 }
64
65 public MockDataReader addStripeFooter(int rows, String timezone) {
66 next.close(rows, timezone);
67 stripes.add(next);
68 offset += next.getFooterLength();
69 next = new MockStripe(numColumns, stripes.size(), offset);
70 return this;
71 }
72
73 @Override
74 public void open() { }
75
76 @Override
77 public OrcProto.StripeFooter readStripeFooter(StripeInformation stripe) {
78 return stripes.get((int) stripe.getStripeId()).getFooter();
79 }
80
81 @Override
82 public BufferChunkList readFileData(BufferChunkList list,
83 boolean doForceDirect) {
84 for(BufferChunk buffer = list.get(); buffer != null;
85 buffer = (BufferChunk) buffer.next) {
86 if (!buffer.hasData()) {
87 MockStripe stripe = getStripeByOffset(buffer.getOffset());
88 ByteBuffer data = stripe.getData(buffer.getOffset(), buffer.getLength());
89 outBuffers.add(data);
90 buffer.setChunk(data);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected