Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
context.h
Go to the documentation of this file.
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_CONTEXT_H
19 #define ARROW_COMPUTE_CONTEXT_H
20 
21 #include <memory>
22 
23 #include "arrow/memory_pool.h"
24 #include "arrow/status.h"
25 #include "arrow/type_fwd.h"
26 #include "arrow/util/visibility.h"
27 
28 namespace arrow {
29 namespace compute {
30 
31 #define RETURN_IF_ERROR(ctx) \
32  if (ARROW_PREDICT_FALSE(ctx->HasError())) { \
33  Status s = ctx->status(); \
34  ctx->ResetStatus(); \
35  return s; \
36  }
37 
39 class ARROW_EXPORT FunctionContext {
40  public:
42  MemoryPool* memory_pool() const;
43 
45  Status Allocate(const int64_t nbytes, std::shared_ptr<Buffer>* out);
46 
52  void SetStatus(const Status& status);
53 
55  void ResetStatus();
56 
58  bool HasError() const { return !status_.ok(); }
59 
61  const Status& status() const { return status_; }
62 
63  private:
64  Status status_;
65  MemoryPool* pool_;
66 };
67 
68 } // namespace compute
69 } // namespace arrow
70 
71 #endif // ARROW_COMPUTE_CONTEXT_H
#define ARROW_MEMORY_POOL_DEFAULT
Definition: memory_pool.h:94
bool HasError() const
Return true if an error has occurred.
Definition: context.h:58
Container for variables and options used by function evaluation.
Definition: context.h:39
Definition: status.h:93
Top-level namespace for Apache Arrow C++ API.
Definition: adapter.h:32
const Status & status() const
Return the current status of the context.
Definition: context.h:61
Base class for memory allocation.
Definition: memory_pool.h:34