MCPcopy Create free account
hub / github.com/apache/arrow / ValidateEditScript

Function ValidateEditScript

cpp/src/arrow/array/diff_test.cc:50–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 struct_({field("insert", boolean()), field("run_length", int64())});
49
50Status ValidateEditScript(const Array& edits, const Array& base, const Array& target) {
51 // beginning (in base) of the run before the current hunk
52 int64_t base_run_begin = 0;
53 return VisitEditScript(edits, [&](int64_t delete_begin, int64_t delete_end,
54 int64_t insert_begin, int64_t insert_end) {
55 auto target_run_begin = insert_begin - (delete_begin - base_run_begin);
56 if (!base.RangeEquals(base_run_begin, delete_begin, target_run_begin, target)) {
57 return Status::Invalid("base and target were unequal in a run");
58 }
59
60 base_run_begin = delete_end;
61 for (int64_t i = insert_begin; i < insert_end; ++i) {
62 for (int64_t d = delete_begin; d < delete_end; ++d) {
63 if (target.RangeEquals(i, i + 1, d, base)) {
64 return Status::Invalid("a deleted element was simultaneously inserted");
65 }
66 }
67 }
68
69 return Status::OK();
70 });
71}
72
73class DiffTest : public ::testing::Test {
74 protected:

Callers 1

TEST_FFunction · 0.85

Calls 4

VisitEditScriptFunction · 0.85
RangeEqualsMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected