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

Function createMemTestFile

c++/test/TestPredicatePushdown.cc:29–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 static const int DEFAULT_MEM_STREAM_SIZE = 10 * 1024 * 1024; // 10M
28
29 void createMemTestFile(MemoryOutputStream& memStream, uint64_t rowIndexStride) {
30 MemoryPool* pool = getDefaultPool();
31 auto type =
32 std::unique_ptr<Type>(Type::buildTypeFromString("struct<int1:bigint,string1:string>"));
33 WriterOptions options;
34 options.setStripeSize(1024 * 1024)
35 .setCompressionBlockSize(1024)
36 .setMemoryBlockSize(64)
37 .setCompression(CompressionKind_NONE)
38 .setMemoryPool(pool)
39 .setRowIndexStride(rowIndexStride);
40
41 auto writer = createWriter(*type, &memStream, options);
42 auto batch = writer->createRowBatch(3500);
43 auto& structBatch = dynamic_cast<StructVectorBatch&>(*batch);
44 auto& longBatch = dynamic_cast<LongVectorBatch&>(*structBatch.fields[0]);
45 auto& strBatch = dynamic_cast<StringVectorBatch&>(*structBatch.fields[1]);
46
47 // row group stride is 1000, here 3500 rows of data constitute 4 row groups.
48 // the min/max pair of each row group is as below:
49 // int1: 0/299700, 300000/599700, 600000/899700, 900000/1049700
50 // string1: "0"/"9990", "10000"/"19990", "20000"/"29990", "30000"/"34990"
51 char buffer[3500 * 5];
52 uint64_t offset = 0;
53 for (uint64_t i = 0; i < 3500; ++i) {
54 longBatch.data[i] = static_cast<int64_t>(i * 300);
55
56 std::ostringstream ss;
57 ss << 10 * i;
58 std::string str = ss.str();
59 memcpy(buffer + offset, str.c_str(), str.size());
60 strBatch.data[i] = buffer + offset;
61 strBatch.length[i] = static_cast<int64_t>(str.size());
62 offset += str.size();
63 }
64 structBatch.numElements = 3500;
65 longBatch.numElements = 3500;
66 strBatch.numElements = 3500;
67 writer->add(*batch);
68 writer->close();
69 }
70
71 void TestRangePredicates(Reader* reader) {
72 // Build search argument (x >= 300000 AND x < 600000) for column 'int1'.

Callers 1

TESTFunction · 0.85

Calls 6

getDefaultPoolFunction · 0.85
createWriterFunction · 0.70
sizeMethod · 0.65
addMethod · 0.65
closeMethod · 0.65
createRowBatchMethod · 0.45

Tested by

no test coverage detected