1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#ifndef ARROW_COMPUTE_TEST_UTIL_H
19#define ARROW_COMPUTE_TEST_UTIL_H
20
21#include <memory>
22#include <vector>
23
24#include "arrow/array.h"
25#include "arrow/memory_pool.h"
26#include "arrow/type.h"
27
28#include "arrow/compute/context.h"
29
30namespace arrow {
31namespace compute {
32
33class ComputeFixture {
34 public:
35 ComputeFixture() : ctx_(default_memory_pool()) {}
36
37 protected:
38 FunctionContext ctx_;
39};
40
41template <typename Type, typename T>
42std::shared_ptr<Array> _MakeArray(const std::shared_ptr<DataType>& type,
43 const std::vector<T>& values,
44 const std::vector<bool>& is_valid) {
45 std::shared_ptr<Array> result;
46 if (is_valid.size() > 0) {
47 ArrayFromVector<Type, T>(type, is_valid, values, &result);
48 } else {
49 ArrayFromVector<Type, T>(type, values, &result);
50 }
51 return result;
52}
53
54} // namespace compute
55} // namespace arrow
56
57#endif
58