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 | #include "arrow/compute/context.h" |
19 | |
20 | #include <memory> |
21 | |
22 | #include "arrow/buffer.h" |
23 | #include "arrow/util/cpu-info.h" |
24 | |
25 | namespace arrow { |
26 | namespace compute { |
27 | |
28 | FunctionContext::FunctionContext(MemoryPool* pool) |
29 | : pool_(pool), cpu_info_(internal::CpuInfo::GetInstance()) {} |
30 | |
31 | MemoryPool* FunctionContext::memory_pool() const { return pool_; } |
32 | |
33 | Status FunctionContext::Allocate(const int64_t nbytes, std::shared_ptr<Buffer>* out) { |
34 | return AllocateBuffer(pool_, nbytes, out); |
35 | } |
36 | |
37 | void FunctionContext::SetStatus(const Status& status) { |
38 | if (ARROW_PREDICT_FALSE(!status_.ok())) { |
39 | return; |
40 | } |
41 | status_ = status; |
42 | } |
43 | |
44 | /// \brief Clear any error status |
45 | void FunctionContext::ResetStatus() { status_ = Status::OK(); } |
46 | |
47 | } // namespace compute |
48 | } // namespace arrow |
49 |