| 939 | namespace { |
| 940 | |
| 941 | uint64_t writeSampleData(MemoryOutputStream& memStream, uint64_t stripeSize = 1024, |
| 942 | uint64_t rowsPerStripe = 1000) { |
| 943 | auto type = Type::buildTypeFromString("struct<id:int,name:string,value:double>"); |
| 944 | WriterOptions options; |
| 945 | options.setStripeSize(stripeSize) |
| 946 | .setCompressionBlockSize(1024) |
| 947 | .setMemoryBlockSize(64) |
| 948 | .setCompression(CompressionKind_NONE) |
| 949 | .setRowIndexStride(100); |
| 950 | auto writer = createWriter(*type, &memStream, options); |
| 951 | |
| 952 | uint64_t totalRows = rowsPerStripe * 3; |
| 953 | uint64_t batchSize = 100; |
| 954 | std::vector<std::string> names(totalRows, ""); |
| 955 | |
| 956 | for (uint64_t startRow = 0; startRow < totalRows; startRow += batchSize) { |
| 957 | uint64_t currentBatchSize = std::min(batchSize, totalRows - startRow); |
| 958 | auto batch = writer->createRowBatch(currentBatchSize); |
| 959 | auto& structBatch = static_cast<StructVectorBatch&>(*batch); |
| 960 | auto& idBatch = static_cast<LongVectorBatch&>(*structBatch.fields[0]); |
| 961 | auto& nameBatch = static_cast<StringVectorBatch&>(*structBatch.fields[1]); |
| 962 | auto& valueBatch = static_cast<DoubleVectorBatch&>(*structBatch.fields[2]); |
| 963 | |
| 964 | for (uint64_t i = 0; i < currentBatchSize; ++i) { |
| 965 | idBatch.data[i] = static_cast<int64_t>(startRow + i); |
| 966 | names[startRow + i] = "name_" + std::to_string(startRow + i); |
| 967 | nameBatch.data[i] = const_cast<char*>(names[startRow + i].c_str()); |
| 968 | nameBatch.length[i] = static_cast<int64_t>(names[startRow + i].length()); |
| 969 | valueBatch.data[i] = static_cast<double>(startRow + i) * 1.5; |
| 970 | } |
| 971 | |
| 972 | structBatch.numElements = currentBatchSize; |
| 973 | writer->add(*batch); |
| 974 | } |
| 975 | |
| 976 | writer->close(); |
| 977 | return totalRows; |
| 978 | } |
| 979 | |
| 980 | uint64_t readAllRows(RowReader& rowReader, uint64_t batchSize = 1000) { |
| 981 | auto batch = rowReader.createRowBatch(batchSize); |
no test coverage detected