This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new 8c4e869c fix: Linking to nanoarrow-testing-shared on Windows (#778)
8c4e869c is described below
commit 8c4e869cc8e4920737a513bc3012780050016bc5
Author: Dewey Dunnington <[email protected]>
AuthorDate: Wed Jun 11 09:14:32 2025 -0500
fix: Linking to nanoarrow-testing-shared on Windows (#778)
We missed one issue in the last PR for this to work out of the box. I
imagine people put std::string in headers all the time and there's
another workaround here (or maybe people just ignore this warning all
the time)...perhaps a better long-term solution would be to just expose
a C interface here.
---
src/nanoarrow/nanoarrow_testing.hpp | 17 ++++-------
src/nanoarrow/testing/testing.cc | 60 +++++++++++++++++++++++++++----------
2 files changed, 49 insertions(+), 28 deletions(-)
diff --git a/src/nanoarrow/nanoarrow_testing.hpp
b/src/nanoarrow/nanoarrow_testing.hpp
index bcc3f4fa..945e19ea 100644
--- a/src/nanoarrow/nanoarrow_testing.hpp
+++ b/src/nanoarrow/nanoarrow_testing.hpp
@@ -34,7 +34,8 @@ namespace testing {
// Forward-declaration of internal types
namespace internal {
class DictionaryContext;
-}
+struct Differences;
+} // namespace internal
/// \defgroup nanoarrow_testing-json Integration test helpers
///
@@ -190,14 +191,6 @@ class NANOARROW_DLL TestingJSONReader {
/// "key", and "value".
/// - Float32 and Float64 values are compared according to their JSON
serialization.
class NANOARROW_DLL TestingJSONComparison {
- private:
- // Internal representation of a human-readable inequality
- struct NANOARROW_DLL Difference {
- std::string path;
- std::string actual;
- std::string expected;
- };
-
public:
TestingJSONComparison();
virtual ~TestingJSONComparison();
@@ -226,13 +219,13 @@ class NANOARROW_DLL TestingJSONComparison {
}
/// \brief Returns the number of differences found by the previous call
- int64_t num_differences() const { return differences_.size(); }
+ int64_t num_differences() const;
/// \brief Dump a human-readable summary of differences to out
void WriteDifferences(std::ostream& out);
/// \brief Clear any existing differences
- void ClearDifferences() { differences_.clear(); }
+ void ClearDifferences();
/// \brief Compare a stream of record batches
///
@@ -267,7 +260,7 @@ class NANOARROW_DLL TestingJSONComparison {
private:
TestingJSONWriter writer_actual_;
TestingJSONWriter writer_expected_;
- std::vector<Difference> differences_;
+ internal::Differences* differences_;
struct ArrowSchema schema_;
struct ArrowArrayView actual_;
struct ArrowArrayView expected_;
diff --git a/src/nanoarrow/testing/testing.cc b/src/nanoarrow/testing/testing.cc
index 70a06017..597f42ef 100644
--- a/src/nanoarrow/testing/testing.cc
+++ b/src/nanoarrow/testing/testing.cc
@@ -2503,14 +2503,32 @@ ArrowErrorCode ForceMapNamesCanonical(ArrowSchema*
schema) {
} // namespace
+// Internal representation of a human-readable inequality
+struct Difference {
+ std::string path;
+ std::string actual;
+ std::string expected;
+};
+
+namespace internal {
+// A wrapper to keep std::string out of the header, which Windows complains
+// about in a dynamic linking scenario.
+struct Differences {
+ std::vector<Difference> inner;
+};
+} // namespace internal
+
TestingJSONComparison::TestingJSONComparison()
- : compare_batch_flags_(true), compare_metadata_order_(true) {
+ : differences_(new internal::Differences()),
+ compare_batch_flags_(true),
+ compare_metadata_order_(true) {
// We do our own metadata comparison
writer_actual_.set_include_metadata(false);
writer_expected_.set_include_metadata(false);
- // We can't use nanoarrow::UniqueXXX in the public header because it doesn't
export
- // a DLL interface, so we initialize and delete them here as part of the
class.
+ // We can't use nanoarrow::UniqueXXX or std::vector<Difference> in the public
+ // header because it doesn't export a DLL interface, so we initialize and
+ // delete them here as part of the class.
nanoarrow::internal::init_pointer(&schema_);
nanoarrow::internal::init_pointer(&actual_);
nanoarrow::internal::init_pointer(&expected_);
@@ -2520,10 +2538,17 @@ TestingJSONComparison::~TestingJSONComparison() {
nanoarrow::internal::release_pointer(&schema_);
nanoarrow::internal::release_pointer(&actual_);
nanoarrow::internal::release_pointer(&expected_);
+ delete differences_;
+}
+
+void TestingJSONComparison::ClearDifferences() { differences_->inner.clear(); }
+
+int64_t TestingJSONComparison::num_differences() const {
+ return differences_->inner.size();
}
void TestingJSONComparison::WriteDifferences(std::ostream& out) {
- for (const auto& difference : differences_) {
+ for (const auto& difference : differences_->inner) {
out << "Path: " << difference.path << "\n";
out << "- " << difference.actual << "\n";
out << "+ " << difference.expected << "\n";
@@ -2567,12 +2592,14 @@ ArrowErrorCode
TestingJSONComparison::CompareArrayStream(ArrowArrayStream* actua
// Check the finished/unfinished status of both streams
if (actual_array->release == nullptr && expected_array->release !=
nullptr) {
- differences_.push_back({batch_label, "finished stream", "unfinished
stream"});
+ differences_->inner.push_back(
+ {batch_label, "finished stream", "unfinished stream"});
return NANOARROW_OK;
}
if (actual_array->release != nullptr && expected_array->release ==
nullptr) {
- differences_.push_back({batch_label, "unfinished stream", "finished
stream"});
+ differences_->inner.push_back(
+ {batch_label, "unfinished stream", "finished stream"});
return NANOARROW_OK;
}
@@ -2617,13 +2644,14 @@ ArrowErrorCode
TestingJSONComparison::CompareSchema(const ArrowSchema* actual,
// Compare flags
if (compare_batch_flags_ && actual->flags != expected->flags) {
- differences_.push_back({path, std::string(".flags: ") +
std::to_string(actual->flags),
- std::string(".flags: ") +
std::to_string(expected->flags)});
+ differences_->inner.push_back(
+ {path, std::string(".flags: ") + std::to_string(actual->flags),
+ std::string(".flags: ") + std::to_string(expected->flags)});
}
// Compare children
if (actual->n_children != expected->n_children) {
- differences_.push_back(
+ differences_->inner.push_back(
{path, std::string(".n_children: ") +
std::to_string(actual->n_children),
std::string(".n_children: ") + std::to_string(expected->n_children)});
} else {
@@ -2675,13 +2703,13 @@ ArrowErrorCode
TestingJSONComparison::CompareBatch(const ArrowArray* actual,
NANOARROW_RETURN_NOT_OK(ArrowArrayViewSetArray(&actual_, actual, error));
if (actual->offset != expected->offset) {
- differences_.push_back({path, ".offset: " + std::to_string(actual->offset),
- ".offset: " + std::to_string(expected->offset)});
+ differences_->inner.push_back({path, ".offset: " +
std::to_string(actual->offset),
+ ".offset: " +
std::to_string(expected->offset)});
}
if (actual->length != expected->length) {
- differences_.push_back({path, ".length: " + std::to_string(actual->length),
- ".length: " + std::to_string(expected->length)});
+ differences_->inner.push_back({path, ".length: " +
std::to_string(actual->length),
+ ".length: " +
std::to_string(expected->length)});
}
// ArrowArrayViewSetArray() ensured that number of children of both match
schema
@@ -2725,7 +2753,7 @@ ArrowErrorCode
TestingJSONComparison::CompareFieldBase(ArrowSchema* actual,
std::string actual_json = ss.str();
if (actual_json != expected_json) {
- differences_.push_back({path, actual_json, expected_json});
+ differences_->inner.push_back({path, actual_json, expected_json});
}
NANOARROW_RETURN_NOT_OK(CompareMetadata(actual->metadata,
expected->metadata, error,
@@ -2757,7 +2785,7 @@ ArrowErrorCode
TestingJSONComparison::CompareMetadata(const char* actual,
// If we still have an inequality, add a difference.
if (!metadata_equal) {
- differences_.push_back({path, actual_json, expected_json});
+ differences_->inner.push_back({path, actual_json, expected_json});
}
return NANOARROW_OK;
@@ -2796,7 +2824,7 @@ ArrowErrorCode
TestingJSONComparison::CompareColumn(ArrowSchema* schema,
std::string actual_json = ss.str();
if (actual_json != expected_json) {
- differences_.push_back({path, actual_json, expected_json});
+ differences_->inner.push_back({path, actual_json, expected_json});
}
return NANOARROW_OK;