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 "arrow/memory_pool.h"
22 #include "arrow/status.h"
23 #include "arrow/type_fwd.h"
24 #include "arrow/util/visibility.h"
25 
26 namespace arrow {
27 namespace compute {
28 
29 #define RETURN_IF_ERROR(ctx) \
30  if (ARROW_PREDICT_FALSE(ctx->HasError())) { \
31  Status s = ctx->status(); \
32  ctx->ResetStatus(); \
33  return s; \
34  }
35 
37 class ARROW_EXPORT FunctionContext {
38  public:
40  MemoryPool* memory_pool() const;
41 
43  Status Allocate(const int64_t nbytes, std::shared_ptr<Buffer>* out);
44 
50  void SetStatus(const Status& status);
51 
53  void ResetStatus();
54 
56  bool HasError() const { return !status_.ok(); }
57 
59  const Status& status() const { return status_; }
60 
61  private:
62  Status status_;
63  MemoryPool* pool_;
64 };
65 
66 } // namespace compute
67 } // namespace arrow
68 
69 #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:56
Container for variables and options used by function evaluation.
Definition: context.h:37
Definition: status.h:106
Top-level namespace for Apache Arrow C++ API.
Definition: allocator.h:29
const Status & status() const
Return the current status of the context.
Definition: context.h:59
Base class for memory allocation.
Definition: memory_pool.h:34