-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit-dispatch-duplicate-timestampnumber.cpp
152 lines (124 loc) · 5.24 KB
/
unit-dispatch-duplicate-timestampnumber.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "catch.hpp"
#include "stryke/dispatch.hpp"
#include "utils_for_test.hpp"
#include "stryke/core.hpp"
#include "stryke/options.hpp"
#include <filesystem>
#include <vector>
namespace fs = std::filesystem;
TEST_CASE("OrcWriterDispatchDuplicate<TimestampNumber, ...> Split", "[Dispatch][Duplicate]") {
stryke::WriterOptions options;
options.set_batch_size(1000);
options.set_batch_max(0);
options.set_stripe_size(500);
std::string root_folder = "data_test";
fs::remove_all(root_folder);
SECTION("Split by date") {
uint64_t nbr_rows = 10000;
SECTION("0 split") {
{
stryke::OrcWriterDispatchDuplicate<stryke::TimestampNumber, stryke::Int> writer({"date", "col1"}, root_folder, "test", options);
for (uint64_t i = 0; i < nbr_rows; ++i) {
writer.write(1544400000 + 86400 * i / (nbr_rows), i);
}
}
stryke::BasicStats tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-0.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == nbr_rows);
}
SECTION("1 split") {
stryke::BasicStats tmp_b;
{
stryke::OrcWriterDispatchDuplicate<stryke::TimestampNumber, stryke::Int> writer({"date", "col1"}, root_folder, "test", options);
for (uint64_t i = 0; i < nbr_rows; ++i) {
writer.write(1544400000 + 86400 * i / (nbr_rows / 2.), i);
}
}
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-0.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == nbr_rows / 2.);
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=11/" + "test-2018-12-11-0.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == nbr_rows / 2.);
}
}
SECTION("Split by number of batch") {
uint64_t nbr_rows = 10000;
SECTION("0 split") {
{
stryke::OrcWriterDispatchDuplicate<stryke::TimestampNumber, stryke::Int> writer({"date", "col1"}, root_folder, "test", options);
for (uint64_t i = 0; i < nbr_rows; ++i) {
writer.write(1544400000 + 86400 * i / (nbr_rows), i);
}
}
stryke::BasicStats tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-0.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == nbr_rows);
}
SECTION("1 split") {
stryke::BasicStats tmp_b;
{
options.set_batch_max(5);
stryke::OrcWriterDispatchDuplicate<stryke::TimestampNumber, stryke::Int> writer({"date", "col1"}, root_folder, "test", options);
for (uint64_t i = 0; i < nbr_rows; ++i) {
writer.write(1544400000 + 86400 * i / (nbr_rows), i);
}
}
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-0.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == nbr_rows / 2.);
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-1.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == nbr_rows / 2.);
}
}
SECTION("Split by force") {
uint64_t nbr_rows = 10000;
SECTION("1 split") {
uint64_t check_point = 10;
stryke::BasicStats tmp_b;
{
stryke::OrcWriterDispatchDuplicate<stryke::TimestampNumber, stryke::Int> writer({"date", "col1"}, root_folder, "test", options);
for (uint64_t i = 0; i < nbr_rows; ++i) {
writer.write(1544400000 + 86400 * i / (nbr_rows), i);
if (i == check_point - 1) {
writer.close();
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-0.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == check_point);
}
}
}
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-1.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == nbr_rows - check_point);
}
SECTION("2 split") {
uint64_t check_point1 = 10;
uint64_t check_point2 = 100;
stryke::BasicStats tmp_b;
{
stryke::OrcWriterDispatchDuplicate<stryke::TimestampNumber, stryke::Int> writer({"date", "col1"}, root_folder, "test", options);
for (uint64_t i = 0; i < nbr_rows; ++i) {
writer.write(1544400000 + 86400 * i / (nbr_rows), i);
if (i == check_point1 - 1) {
writer.close();
}
if (i == check_point2 - 1) {
writer.close();
}
}
}
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-0.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == check_point1);
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-1.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == check_point2 - check_point1);
tmp_b = stryke::get_basic_stats(root_folder + "/year=2018/month=12/day=10/" + "test-2018-12-10-2.orc");
REQUIRE(tmp_b.nbr_columns == 3);
REQUIRE(tmp_b.nbr_rows == nbr_rows - check_point2);
}
}
fs::remove_all(root_folder);
}