Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-343: Add extern class template export for BooleanBuilder superclass #180

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions cpp/src/arrow/types/primitive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ bool PrimitiveArray::Equals(const std::shared_ptr<Array>& arr) const {
return EqualsExact(*static_cast<const PrimitiveArray*>(arr.get()));
}

template class NumericArray<UInt8Type>;
template class NumericArray<UInt16Type>;
template class NumericArray<UInt32Type>;
template class NumericArray<UInt64Type>;
template class NumericArray<Int8Type>;
template class NumericArray<Int16Type>;
template class NumericArray<Int32Type>;
template class NumericArray<Int64Type>;
template class NumericArray<TimestampType>;
template class NumericArray<FloatType>;
template class NumericArray<DoubleType>;
template class NumericArray<BooleanType>;

template <typename T>
Status PrimitiveBuilder<T>::Init(int32_t capacity) {
RETURN_NOT_OK(ArrayBuilder::Init(capacity));
Expand Down Expand Up @@ -168,19 +155,6 @@ Status PrimitiveBuilder<BooleanType>::Append(
return Status::OK();
}

template class PrimitiveBuilder<UInt8Type>;
template class PrimitiveBuilder<UInt16Type>;
template class PrimitiveBuilder<UInt32Type>;
template class PrimitiveBuilder<UInt64Type>;
template class PrimitiveBuilder<Int8Type>;
template class PrimitiveBuilder<Int16Type>;
template class PrimitiveBuilder<Int32Type>;
template class PrimitiveBuilder<Int64Type>;
template class PrimitiveBuilder<TimestampType>;
template class PrimitiveBuilder<FloatType>;
template class PrimitiveBuilder<DoubleType>;
template class PrimitiveBuilder<BooleanType>;

BooleanArray::BooleanArray(int32_t length, const std::shared_ptr<Buffer>& data,
int32_t null_count, const std::shared_ptr<Buffer>& null_bitmap)
: PrimitiveArray(
Expand Down Expand Up @@ -235,4 +209,29 @@ bool BooleanArray::RangeEquals(int32_t start_idx, int32_t end_idx,
return true;
}

// Instantiate templates
template class NumericArray<UInt8Type>;
template class NumericArray<UInt16Type>;
template class NumericArray<UInt32Type>;
template class NumericArray<UInt64Type>;
template class NumericArray<Int8Type>;
template class NumericArray<Int16Type>;
template class NumericArray<Int32Type>;
template class NumericArray<Int64Type>;
template class NumericArray<TimestampType>;
template class NumericArray<FloatType>;
template class NumericArray<DoubleType>;
template class PrimitiveBuilder<UInt8Type>;
template class PrimitiveBuilder<UInt16Type>;
template class PrimitiveBuilder<UInt32Type>;
template class PrimitiveBuilder<UInt64Type>;
template class PrimitiveBuilder<Int8Type>;
template class PrimitiveBuilder<Int16Type>;
template class PrimitiveBuilder<Int32Type>;
template class PrimitiveBuilder<Int64Type>;
template class PrimitiveBuilder<TimestampType>;
template class PrimitiveBuilder<FloatType>;
template class PrimitiveBuilder<DoubleType>;
template class PrimitiveBuilder<BooleanType>;

} // namespace arrow
55 changes: 23 additions & 32 deletions cpp/src/arrow/types/primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,6 @@ class ARROW_EXPORT NumericArray : public PrimitiveArray {
value_type Value(int i) const { return raw_data()[i]; }
};

#define NUMERIC_ARRAY_DECL(NAME, TypeClass) \
using NAME = NumericArray<TypeClass>; \
extern template class ARROW_EXPORT NumericArray<TypeClass>;

NUMERIC_ARRAY_DECL(UInt8Array, UInt8Type);
NUMERIC_ARRAY_DECL(Int8Array, Int8Type);
NUMERIC_ARRAY_DECL(UInt16Array, UInt16Type);
NUMERIC_ARRAY_DECL(Int16Array, Int16Type);
NUMERIC_ARRAY_DECL(UInt32Array, UInt32Type);
NUMERIC_ARRAY_DECL(Int32Array, Int32Type);
NUMERIC_ARRAY_DECL(UInt64Array, UInt64Type);
NUMERIC_ARRAY_DECL(Int64Array, Int64Type);
NUMERIC_ARRAY_DECL(TimestampArray, TimestampType);
NUMERIC_ARRAY_DECL(FloatArray, FloatType);
NUMERIC_ARRAY_DECL(DoubleArray, DoubleType);

template <typename Type>
class ARROW_EXPORT PrimitiveBuilder : public ArrayBuilder {
public:
Expand Down Expand Up @@ -260,22 +244,6 @@ struct TypeTraits<DoubleType> {
static inline int bytes_required(int elements) { return elements * sizeof(double); }
};

// Builders

typedef NumericBuilder<UInt8Type> UInt8Builder;
typedef NumericBuilder<UInt16Type> UInt16Builder;
typedef NumericBuilder<UInt32Type> UInt32Builder;
typedef NumericBuilder<UInt64Type> UInt64Builder;

typedef NumericBuilder<Int8Type> Int8Builder;
typedef NumericBuilder<Int16Type> Int16Builder;
typedef NumericBuilder<Int32Type> Int32Builder;
typedef NumericBuilder<Int64Type> Int64Builder;
typedef NumericBuilder<TimestampType> TimestampBuilder;

typedef NumericBuilder<FloatType> FloatBuilder;
typedef NumericBuilder<DoubleType> DoubleBuilder;

class ARROW_EXPORT BooleanArray : public PrimitiveArray {
public:
BooleanArray(int32_t length, const std::shared_ptr<Buffer>& data,
Expand Down Expand Up @@ -327,6 +295,29 @@ class ARROW_EXPORT BooleanBuilder : public PrimitiveBuilder<BooleanType> {
Status Append(uint8_t val) { return Append(static_cast<bool>(val)); }
};

// Builders

#define NUMERIC_ARRAY_DECL(NAME, TypeClass) \
using NAME##Array = NumericArray<NAME##Type>; \
using NAME##Builder = NumericBuilder<NAME##Type>; \
extern template class ARROW_EXPORT NumericArray<NAME##Type>; \
extern template class ARROW_EXPORT NumericBuilder<NAME##Type>;

NUMERIC_ARRAY_DECL(UInt8Array, UInt8Type);
NUMERIC_ARRAY_DECL(Int8Array, Int8Type);
NUMERIC_ARRAY_DECL(UInt16Array, UInt16Type);
NUMERIC_ARRAY_DECL(Int16Array, Int16Type);
NUMERIC_ARRAY_DECL(UInt32Array, UInt32Type);
NUMERIC_ARRAY_DECL(Int32Array, Int32Type);
NUMERIC_ARRAY_DECL(UInt64Array, UInt64Type);
NUMERIC_ARRAY_DECL(Int64Array, Int64Type);
NUMERIC_ARRAY_DECL(TimestampArray, TimestampType);
NUMERIC_ARRAY_DECL(FloatArray, FloatType);
NUMERIC_ARRAY_DECL(DoubleArray, DoubleType);

// Make these instantiated template symbols visible in Clang and devtoolset, etc.
extern template class ARROW_EXPORT PrimitiveBuilder<BooleanType>;

} // namespace arrow

#endif // ARROW_TYPES_PRIMITIVE_H