Skip to content

Commit

Permalink
apacheGH-36326: [C++] Remove APIs deprecated in v9.0 or earlier (apac…
Browse files Browse the repository at this point in the history
…he#36675)

### Rationale for this change

General cleanup of C++ APIs deprecated for at least a year.

### What changes are included in this PR?

Removes any APIs annotated with `ARROW_DEPRECATED` and an included version `<=9.0`. In a few cases, tests needed to be removed or slightly altered.

### Are these changes tested?

Yes (covered by existing tests) when applicable.

### Are there any user-facing changes?

Yes

* Closes: apache#36326

Authored-by: benibus <[email protected]>
Signed-off-by: Gang Wu <[email protected]>
  • Loading branch information
benibus authored Jul 19, 2023
1 parent 7ad3003 commit a7958d9
Show file tree
Hide file tree
Showing 24 changed files with 11 additions and 598 deletions.
19 changes: 1 addition & 18 deletions cpp/src/arrow/array/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1727,21 +1727,6 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesStdBool) {
this->Check(this->builder_nn_, false);
}

TYPED_TEST(TestPrimitiveBuilder, TestAdvance) {
ARROW_SUPPRESS_DEPRECATION_WARNING
int64_t n = 1000;
ASSERT_OK(this->builder_->Reserve(n));

ASSERT_OK(this->builder_->Advance(100));
ASSERT_EQ(100, this->builder_->length());

ASSERT_OK(this->builder_->Advance(900));

int64_t too_many = this->builder_->capacity() - 1000 + 1;
ASSERT_RAISES(Invalid, this->builder_->Advance(too_many));
ARROW_UNSUPPRESS_DEPRECATION_WARNING
}

TYPED_TEST(TestPrimitiveBuilder, TestResize) {
int64_t cap = kMinBuilderCapacity * 2;

Expand All @@ -1757,9 +1742,7 @@ TYPED_TEST(TestPrimitiveBuilder, TestReserve) {
ASSERT_OK(this->builder_->Reserve(100));
ASSERT_EQ(0, this->builder_->length());
ASSERT_GE(100, this->builder_->capacity());
ARROW_SUPPRESS_DEPRECATION_WARNING
ASSERT_OK(this->builder_->Advance(100));
ARROW_UNSUPPRESS_DEPRECATION_WARNING
ASSERT_OK(this->builder_->AppendEmptyValues(100));
ASSERT_EQ(100, this->builder_->length());
ASSERT_GE(100, this->builder_->capacity());

Expand Down
2 changes: 0 additions & 2 deletions cpp/src/arrow/array/builder_adaptive.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class ARROW_EXPORT AdaptiveUIntBuilder : public internal::AdaptiveIntBuilderBase
explicit AdaptiveUIntBuilder(MemoryPool* pool = default_memory_pool())
: AdaptiveUIntBuilder(sizeof(uint8_t), pool) {}

using ArrayBuilder::Advance;
using internal::AdaptiveIntBuilderBase::Reset;

/// Scalar append
Expand Down Expand Up @@ -182,7 +181,6 @@ class ARROW_EXPORT AdaptiveIntBuilder : public internal::AdaptiveIntBuilderBase
int64_t alignment = kDefaultBufferAlignment)
: AdaptiveIntBuilder(sizeof(uint8_t), pool, alignment) {}

using ArrayBuilder::Advance;
using internal::AdaptiveIntBuilderBase::Reset;

/// Scalar append
Expand Down
8 changes: 0 additions & 8 deletions cpp/src/arrow/array/builder_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ Status ArrayBuilder::Resize(int64_t capacity) {
return null_bitmap_builder_.Resize(capacity);
}

Status ArrayBuilder::Advance(int64_t elements) {
if (length_ + elements > capacity_) {
return Status::Invalid("Builder must be expanded");
}
length_ += elements;
return null_bitmap_builder_.Advance(elements);
}

namespace {

template <typename ConstIterator>
Expand Down
9 changes: 0 additions & 9 deletions cpp/src/arrow/array/builder_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,6 @@ class ARROW_EXPORT ArrayBuilder {
return Status::NotImplemented("AppendArraySlice for builder for ", *type());
}

/// For cases where raw data was memcpy'd into the internal buffers, allows us
/// to advance the length of the builder. It is your responsibility to use
/// this function responsibly.
ARROW_DEPRECATED(
"Deprecated in 6.0.0. ArrayBuilder::Advance is poorly supported and mostly "
"untested.\nFor low-level control over buffer construction, use BufferBuilder "
"or TypedBufferBuilder directly.")
Status Advance(int64_t elements);

/// \brief Return result of builder as an internal generic ArrayData
/// object. Resets builder except for dictionary builder
///
Expand Down
28 changes: 0 additions & 28 deletions cpp/src/arrow/compute/api_scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -775,34 +775,6 @@ SCALAR_EAGER_BINARY(Or, "or")
SCALAR_EAGER_BINARY(Xor, "xor")
SCALAR_EAGER_UNARY(Invert, "invert")

// ----------------------------------------------------------------------

Result<Datum> Compare(const Datum& left, const Datum& right, CompareOptions options,
ExecContext* ctx) {
std::string func_name;
switch (options.op) {
case CompareOperator::EQUAL:
func_name = "equal";
break;
case CompareOperator::NOT_EQUAL:
func_name = "not_equal";
break;
case CompareOperator::GREATER:
func_name = "greater";
break;
case CompareOperator::GREATER_EQUAL:
func_name = "greater_equal";
break;
case CompareOperator::LESS:
func_name = "less";
break;
case CompareOperator::LESS_EQUAL:
func_name = "less_equal";
break;
}
return CallFunction(func_name, {left, right}, nullptr, ctx);
}

// ----------------------------------------------------------------------
// Validity functions

Expand Down
18 changes: 0 additions & 18 deletions cpp/src/arrow/compute/api_scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -970,24 +970,6 @@ Result<Datum> RoundTemporal(
const Datum& arg, RoundTemporalOptions options = RoundTemporalOptions::Defaults(),
ExecContext* ctx = NULLPTR);

/// \brief Compare a numeric array with a scalar.
///
/// \param[in] left datum to compare, must be an Array
/// \param[in] right datum to compare, must be a Scalar of the same type than
/// left Datum.
/// \param[in] options compare options
/// \param[in] ctx the function execution context, optional
/// \return resulting datum
///
/// Note on floating point arrays, this uses ieee-754 compare semantics.
///
/// \since 1.0.0
/// \note API not yet finalized
ARROW_DEPRECATED("Deprecated in 5.0.0. Use each compare function directly")
ARROW_EXPORT
Result<Datum> Compare(const Datum& left, const Datum& right, CompareOptions options,
ExecContext* ctx = NULLPTR);

/// \brief Invert the values of a boolean datum
/// \param[in] value datum to invert
/// \param[in] ctx the function execution context, optional
Expand Down
7 changes: 0 additions & 7 deletions cpp/src/arrow/compute/api_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,5 @@ Result<Datum> CumulativeMin(const Datum& values, const CumulativeOptions& option
return CallFunction("cumulative_min", {Datum(values)}, &options, ctx);
}

// ----------------------------------------------------------------------
// Deprecated functions

Result<std::shared_ptr<Array>> SortToIndices(const Array& values, ExecContext* ctx) {
return SortIndices(values, SortOrder::Ascending, ctx);
}

} // namespace compute
} // namespace arrow
8 changes: 0 additions & 8 deletions cpp/src/arrow/compute/api_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,5 @@ Result<std::shared_ptr<Array>> PairwiseDiff(const Array& array,
bool check_overflow = false,
ExecContext* ctx = NULLPTR);

// ----------------------------------------------------------------------
// Deprecated functions

ARROW_DEPRECATED("Deprecated in 3.0.0. Use SortIndices()")
ARROW_EXPORT
Result<std::shared_ptr<Array>> SortToIndices(const Array& values,
ExecContext* ctx = NULLPTR);

} // namespace compute
} // namespace arrow
21 changes: 0 additions & 21 deletions cpp/src/arrow/csv/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1246,27 +1246,6 @@ Result<std::shared_ptr<TableReader>> TableReader::Make(
parse_options, convert_options);
}

Result<std::shared_ptr<TableReader>> TableReader::Make(
MemoryPool* pool, io::IOContext io_context, std::shared_ptr<io::InputStream> input,
const ReadOptions& read_options, const ParseOptions& parse_options,
const ConvertOptions& convert_options) {
return MakeTableReader(pool, io_context, std::move(input), read_options, parse_options,
convert_options);
}

Result<std::shared_ptr<StreamingReader>> StreamingReader::Make(
MemoryPool* pool, std::shared_ptr<io::InputStream> input,
const ReadOptions& read_options, const ParseOptions& parse_options,
const ConvertOptions& convert_options) {
auto io_context = io::IOContext(pool);
auto cpu_executor = arrow::internal::GetCpuThreadPool();
auto reader_fut = MakeStreamingReader(io_context, std::move(input), cpu_executor,
read_options, parse_options, convert_options);
auto reader_result = reader_fut.result();
ARROW_ASSIGN_OR_RAISE(auto reader, reader_result);
return reader;
}

Result<std::shared_ptr<StreamingReader>> StreamingReader::Make(
io::IOContext io_context, std::shared_ptr<io::InputStream> input,
const ReadOptions& read_options, const ParseOptions& parse_options,
Expand Down
13 changes: 0 additions & 13 deletions cpp/src/arrow/csv/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ class ARROW_EXPORT TableReader {
const ReadOptions&,
const ParseOptions&,
const ConvertOptions&);

ARROW_DEPRECATED(
"Deprecated in 4.0.0. "
"Use MemoryPool-less variant (the IOContext holds a pool already)")
static Result<std::shared_ptr<TableReader>> Make(
MemoryPool* pool, io::IOContext io_context, std::shared_ptr<io::InputStream> input,
const ReadOptions&, const ParseOptions&, const ConvertOptions&);
};

/// \brief A class that reads a CSV file incrementally
Expand Down Expand Up @@ -105,12 +98,6 @@ class ARROW_EXPORT StreamingReader : public RecordBatchReader {
static Result<std::shared_ptr<StreamingReader>> Make(
io::IOContext io_context, std::shared_ptr<io::InputStream> input,
const ReadOptions&, const ParseOptions&, const ConvertOptions&);

ARROW_DEPRECATED("Deprecated in 4.0.0. Use IOContext-based overload")
static Result<std::shared_ptr<StreamingReader>> Make(
MemoryPool* pool, std::shared_ptr<io::InputStream> input,
const ReadOptions& read_options, const ParseOptions& parse_options,
const ConvertOptions& convert_options);
};

/// \brief Count the logical rows of data in a CSV file (i.e. the
Expand Down
78 changes: 0 additions & 78 deletions cpp/src/arrow/flight/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ arrow::Result<std::shared_ptr<Table>> FlightStreamReader::ToTable(
return Table::FromRecordBatches(schema, std::move(batches));
}

Status FlightStreamReader::ReadAll(std::vector<std::shared_ptr<RecordBatch>>* batches,
const StopToken& stop_token) {
return ToRecordBatches(stop_token).Value(batches);
}

Status FlightStreamReader::ReadAll(std::shared_ptr<Table>* table,
const StopToken& stop_token) {
return ToTable(stop_token).Value(table);
}

/// \brief An ipc::MessageReader adapting the Flight ClientDataStream interface.
///
/// In order to support app_metadata and reuse the existing IPC
Expand Down Expand Up @@ -520,11 +510,6 @@ arrow::Result<std::unique_ptr<FlightClient>> FlightClient::Connect(
return Connect(location, FlightClientOptions::Defaults());
}

Status FlightClient::Connect(const Location& location,
std::unique_ptr<FlightClient>* client) {
return Connect(location, FlightClientOptions::Defaults()).Value(client);
}

arrow::Result<std::unique_ptr<FlightClient>> FlightClient::Connect(
const Location& location, const FlightClientOptions& options) {
flight::transport::grpc::InitializeFlightGrpcClient();
Expand All @@ -538,11 +523,6 @@ arrow::Result<std::unique_ptr<FlightClient>> FlightClient::Connect(
return client;
}

Status FlightClient::Connect(const Location& location, const FlightClientOptions& options,
std::unique_ptr<FlightClient>* client) {
return Connect(location, options).Value(client);
}

Status FlightClient::Authenticate(const FlightCallOptions& options,
std::unique_ptr<ClientAuthHandler> auth_handler) {
RETURN_NOT_OK(CheckOpen());
Expand All @@ -564,11 +544,6 @@ arrow::Result<std::unique_ptr<ResultStream>> FlightClient::DoAction(
return results;
}

Status FlightClient::DoAction(const FlightCallOptions& options, const Action& action,
std::unique_ptr<ResultStream>* results) {
return DoAction(options, action).Value(results);
}

arrow::Result<CancelFlightInfoResult> FlightClient::CancelFlightInfo(
const FlightCallOptions& options, const CancelFlightInfoRequest& request) {
ARROW_ASSIGN_OR_RAISE(auto body, request.SerializeToString());
Expand Down Expand Up @@ -601,11 +576,6 @@ arrow::Result<std::vector<ActionType>> FlightClient::ListActions(
return actions;
}

Status FlightClient::ListActions(const FlightCallOptions& options,
std::vector<ActionType>* actions) {
return ListActions(options).Value(actions);
}

arrow::Result<std::unique_ptr<FlightInfo>> FlightClient::GetFlightInfo(
const FlightCallOptions& options, const FlightDescriptor& descriptor) {
std::unique_ptr<FlightInfo> info;
Expand All @@ -614,32 +584,16 @@ arrow::Result<std::unique_ptr<FlightInfo>> FlightClient::GetFlightInfo(
return info;
}

Status FlightClient::GetFlightInfo(const FlightCallOptions& options,
const FlightDescriptor& descriptor,
std::unique_ptr<FlightInfo>* info) {
return GetFlightInfo(options, descriptor).Value(info);
}

arrow::Result<std::unique_ptr<SchemaResult>> FlightClient::GetSchema(
const FlightCallOptions& options, const FlightDescriptor& descriptor) {
RETURN_NOT_OK(CheckOpen());
return transport_->GetSchema(options, descriptor);
}

Status FlightClient::GetSchema(const FlightCallOptions& options,
const FlightDescriptor& descriptor,
std::unique_ptr<SchemaResult>* schema_result) {
return GetSchema(options, descriptor).Value(schema_result);
}

arrow::Result<std::unique_ptr<FlightListing>> FlightClient::ListFlights() {
return ListFlights({}, {});
}

Status FlightClient::ListFlights(std::unique_ptr<FlightListing>* listing) {
return ListFlights({}, {}).Value(listing);
}

arrow::Result<std::unique_ptr<FlightListing>> FlightClient::ListFlights(
const FlightCallOptions& options, const Criteria& criteria) {
std::unique_ptr<FlightListing> listing;
Expand All @@ -648,12 +602,6 @@ arrow::Result<std::unique_ptr<FlightListing>> FlightClient::ListFlights(
return listing;
}

Status FlightClient::ListFlights(const FlightCallOptions& options,
const Criteria& criteria,
std::unique_ptr<FlightListing>* listing) {
return ListFlights(options, criteria).Value(listing);
}

arrow::Result<std::unique_ptr<FlightStreamReader>> FlightClient::DoGet(
const FlightCallOptions& options, const Ticket& ticket) {
RETURN_NOT_OK(CheckOpen());
Expand All @@ -668,11 +616,6 @@ arrow::Result<std::unique_ptr<FlightStreamReader>> FlightClient::DoGet(
return stream_reader;
}

Status FlightClient::DoGet(const FlightCallOptions& options, const Ticket& ticket,
std::unique_ptr<FlightStreamReader>* stream) {
return DoGet(options, ticket).Value(stream);
}

arrow::Result<FlightClient::DoPutResult> FlightClient::DoPut(
const FlightCallOptions& options, const FlightDescriptor& descriptor,
const std::shared_ptr<Schema>& schema) {
Expand All @@ -689,17 +632,6 @@ arrow::Result<FlightClient::DoPutResult> FlightClient::DoPut(
return result;
}

Status FlightClient::DoPut(const FlightCallOptions& options,
const FlightDescriptor& descriptor,
const std::shared_ptr<Schema>& schema,
std::unique_ptr<FlightStreamWriter>* writer,
std::unique_ptr<FlightMetadataReader>* reader) {
ARROW_ASSIGN_OR_RAISE(auto result, DoPut(options, descriptor, schema));
*writer = std::move(result.writer);
*reader = std::move(result.reader);
return Status::OK();
}

arrow::Result<FlightClient::DoExchangeResult> FlightClient::DoExchange(
const FlightCallOptions& options, const FlightDescriptor& descriptor) {
RETURN_NOT_OK(CheckOpen());
Expand All @@ -717,16 +649,6 @@ arrow::Result<FlightClient::DoExchangeResult> FlightClient::DoExchange(
return result;
}

Status FlightClient::DoExchange(const FlightCallOptions& options,
const FlightDescriptor& descriptor,
std::unique_ptr<FlightStreamWriter>* writer,
std::unique_ptr<FlightStreamReader>* reader) {
ARROW_ASSIGN_OR_RAISE(auto result, DoExchange(options, descriptor));
*writer = std::move(result.writer);
*reader = std::move(result.reader);
return Status::OK();
}

Status FlightClient::Close() {
if (!closed_) {
closed_ = true;
Expand Down
Loading

0 comments on commit a7958d9

Please sign in to comment.