forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstruct.cc
More file actions
88 lines (70 loc) · 2.81 KB
/
Copy pathconstruct.cc
File metadata and controls
88 lines (70 loc) · 2.81 KB
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
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "arrow/types/construct.h"
#include <memory>
#include "arrow/types/floating.h"
#include "arrow/types/integer.h"
#include "arrow/types/list.h"
#include "arrow/types/string.h"
#include "arrow/util/status.h"
namespace arrow {
class ArrayBuilder;
// Initially looked at doing this with vtables, but shared pointers makes it
// difficult
#define BUILDER_CASE(ENUM, BuilderType) \
case LogicalType::ENUM: \
out->reset(new BuilderType(pool, type)); \
return Status::OK();
Status MakeBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& type,
std::shared_ptr<ArrayBuilder>* out) {
switch (type->type) {
BUILDER_CASE(UINT8, UInt8Builder);
BUILDER_CASE(INT8, Int8Builder);
BUILDER_CASE(UINT16, UInt16Builder);
BUILDER_CASE(INT16, Int16Builder);
BUILDER_CASE(UINT32, UInt32Builder);
BUILDER_CASE(INT32, Int32Builder);
BUILDER_CASE(UINT64, UInt64Builder);
BUILDER_CASE(INT64, Int64Builder);
// BUILDER_CASE(BOOL, BooleanBuilder);
BUILDER_CASE(FLOAT, FloatBuilder);
BUILDER_CASE(DOUBLE, DoubleBuilder);
BUILDER_CASE(STRING, StringBuilder);
case LogicalType::LIST:
{
std::shared_ptr<ArrayBuilder> value_builder;
const std::shared_ptr<DataType>& value_type = static_cast<ListType*>(
type.get())->value_type;
RETURN_NOT_OK(MakeBuilder(pool, value_type, &value_builder));
out->reset(new ListBuilder(pool, type, value_builder));
return Status::OK();
}
// BUILDER_CASE(CHAR, CharBuilder);
// BUILDER_CASE(VARCHAR, VarcharBuilder);
// BUILDER_CASE(BINARY, BinaryBuilder);
// BUILDER_CASE(DATE, DateBuilder);
// BUILDER_CASE(TIMESTAMP, TimestampBuilder);
// BUILDER_CASE(TIME, TimeBuilder);
// BUILDER_CASE(LIST, ListBuilder);
// BUILDER_CASE(STRUCT, StructBuilder);
// BUILDER_CASE(DENSE_UNION, DenseUnionBuilder);
// BUILDER_CASE(SPARSE_UNION, SparseUnionBuilder);
default:
return Status::NotImplemented(type->ToString());
}
}
} // namespace arrow