Skip to content

Commit

Permalink
Refactor initialization of EngineSchemaVisitor object
Browse files Browse the repository at this point in the history
  • Loading branch information
samansmink committed May 14, 2024
1 parent ed500a8 commit 191943d
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/include/delta_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ class SchemaVisitor {

static unique_ptr<FieldList> VisitSnapshotSchema(const ffi::SnapshotHandle* snapshot) {
SchemaVisitor state;
ffi::EngineSchemaVisitor visitor = {
.data = &state,
.make_field_list = (uintptr_t (*)(void*, uintptr_t)) &MakeFieldList,
.visit_struct = (void (*)(void*, uintptr_t, ffi::KernelStringSlice, uintptr_t)) &VisitStruct,
.visit_string = VisitSimpleType<LogicalType::VARCHAR>(),
.visit_long = VisitSimpleType<LogicalType::BIGINT>(),
.visit_integer = VisitSimpleType<LogicalType::SMALLINT>(),
.visit_byte = VisitSimpleType<LogicalType::TINYINT>(),
.visit_float = VisitSimpleType<LogicalType::FLOAT>(),
.visit_double = VisitSimpleType<LogicalType::DOUBLE>(),
.visit_boolean = VisitSimpleType<LogicalType::BOOLEAN>(),
.visit_binary = VisitSimpleType<LogicalType::VARCHAR>(), // TODO: check
.visit_date = VisitSimpleType<LogicalType::DATE>(), // TODO: check
.visit_timestamp = VisitSimpleType<LogicalType::TIMESTAMP>(), // TODO: check
.visit_timestamp_ntz = VisitSimpleType<LogicalType::TIMESTAMP_TZ>() // TODO: check
};
ffi::EngineSchemaVisitor visitor;

visitor.data = &state;
visitor.make_field_list = (uintptr_t (*)(void*, uintptr_t)) &MakeFieldList;
visitor.visit_struct = (void (*)(void*, uintptr_t, ffi::KernelStringSlice, uintptr_t)) &VisitStruct;
visitor.visit_string = VisitSimpleType<LogicalType::VARCHAR>();
visitor.visit_long = VisitSimpleType<LogicalType::BIGINT>();
visitor.visit_integer = VisitSimpleType<LogicalType::SMALLINT>();
visitor.visit_byte = VisitSimpleType<LogicalType::TINYINT>();
visitor.visit_float = VisitSimpleType<LogicalType::FLOAT>();
visitor.visit_double = VisitSimpleType<LogicalType::DOUBLE>();
visitor.visit_boolean = VisitSimpleType<LogicalType::BOOLEAN>();
visitor.visit_binary = VisitSimpleType<LogicalType::VARCHAR>(); // TODO: check
visitor.visit_date = VisitSimpleType<LogicalType::DATE>(); // TODO: check
visitor.visit_timestamp = VisitSimpleType<LogicalType::TIMESTAMP>(); // TODO: check
visitor.visit_timestamp_ntz = VisitSimpleType<LogicalType::TIMESTAMP_TZ>(); // TODO: check

uintptr_t result = visit_schema(snapshot, &visitor);
return state.TakeFieldList(result);
}
Expand Down

0 comments on commit 191943d

Please sign in to comment.