This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 7906e3cd60 GH-45512: [C++] Clean up undefined symbols in libarrow
without IPC (#45513)
7906e3cd60 is described below
commit 7906e3cd609f1b6c561426647f5129701e1b1aca
Author: William Ayd <[email protected]>
AuthorDate: Wed Feb 12 23:36:34 2025 -0500
GH-45512: [C++] Clean up undefined symbols in libarrow without IPC (#45513)
### Rationale for this change
When building the Arrow library without IPC, the library ends up with
undefined symbols to functions that are only available with ARROW_IPC=ON
### What changes are included in this PR?
Use the ARROW_IPC macro to detect if IPC is being used, and when not,
return a NotImplementedError
### Are these changes tested?
Compiles cleanly and no longer shows undefined IPC symbols
### Are there any user-facing changes?
No
* GitHub Issue: #45512
Authored-by: Will Ayd <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
cpp/src/arrow/compute/expression.cc | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/cpp/src/arrow/compute/expression.cc
b/cpp/src/arrow/compute/expression.cc
index e2f3195db5..e970cd3175 100644
--- a/cpp/src/arrow/compute/expression.cc
+++ b/cpp/src/arrow/compute/expression.cc
@@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.
+#include "arrow/util/config.h"
+
#include "arrow/compute/expression.h"
#include <algorithm>
@@ -30,8 +32,10 @@
#include "arrow/compute/function_internal.h"
#include "arrow/compute/util.h"
#include "arrow/io/memory.h"
-#include "arrow/ipc/reader.h"
-#include "arrow/ipc/writer.h"
+#ifdef ARROW_IPC
+# include "arrow/ipc/reader.h"
+# include "arrow/ipc/writer.h"
+#endif
#include "arrow/util/hash_util.h"
#include "arrow/util/key_value_metadata.h"
#include "arrow/util/logging.h"
@@ -1492,6 +1496,7 @@ Result<Expression> RemoveNamedRefs(Expression src) {
// this in the schema of a RecordBatch. Embedded arrays and scalars are stored
in its
// columns. Finally, the RecordBatch is written to an IPC file.
Result<std::shared_ptr<Buffer>> Serialize(const Expression& expr) {
+#ifdef ARROW_IPC
struct {
std::shared_ptr<KeyValueMetadata> metadata_ =
std::make_shared<KeyValueMetadata>();
ArrayVector columns_;
@@ -1567,9 +1572,13 @@ Result<std::shared_ptr<Buffer>> Serialize(const
Expression& expr) {
RETURN_NOT_OK(writer->WriteRecordBatch(*batch));
RETURN_NOT_OK(writer->Close());
return stream->Finish();
+#else
+ return Status::NotImplemented("IPC feature isn't enabled");
+#endif
}
Result<Expression> Deserialize(std::shared_ptr<Buffer> buffer) {
+#ifdef ARROW_IPC
io::BufferReader stream(std::move(buffer));
ARROW_ASSIGN_OR_RAISE(auto reader,
ipc::RecordBatchFileReader::Open(&stream));
ARROW_ASSIGN_OR_RAISE(auto batch, reader->ReadRecordBatch(0));
@@ -1670,6 +1679,9 @@ Result<Expression> Deserialize(std::shared_ptr<Buffer>
buffer) {
};
return FromRecordBatch{*batch, 0}.GetOne();
+#else
+ return Status::NotImplemented("IPC feature isn't enabled");
+#endif
}
Expression project(std::vector<Expression> values, std::vector<std::string>
names) {