You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "felipecrv (via GitHub)" <gi...@apache.org> on 2024/08/13 18:34:42 UTC
[PR] GH-43677: [C++][FlightRPC] Move the FlightTestServer to its own .cc and .h files [arrow]
felipecrv opened a new pull request, #43678:
URL: https://github.com/apache/arrow/pull/43678
### Rationale for this change
One way of learning about a codebase is reading the tests. As it is now, it's hard to see the minimal `FlightServerBase` sub-class in `flight/test_util.cc`, so I moved it to its own file.
### What changes are included in this PR?
- Renaming `FlightTestServer` to `TestFlightServer`
- Moving the class to `test_flight_server.{h,cc}`
### Are these changes tested?
By existing tests.
### Are there any user-facing changes?
`ExampleTestServer` is removed from the testing library in favor of `FlightTestServer::Make`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43677: [C++][FlightRPC] Move the FlightTestServer to its own .cc and .h files [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on PR #43678:
URL: https://github.com/apache/arrow/pull/43678#issuecomment-2287319639
Pushed a commit moving the auth handlers as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43677: [C++][FlightRPC] Move the FlightTestServer to its own .cc and .h files [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv merged PR #43678:
URL: https://github.com/apache/arrow/pull/43678
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43677: [C++][FlightRPC] Move the FlightTestServer to its own .cc and .h files [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #43678:
URL: https://github.com/apache/arrow/pull/43678#discussion_r1716128091
##########
cpp/src/arrow/flight/test_flight_server.cc:
##########
@@ -0,0 +1,417 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <memory>
+
+#include "arrow/flight/test_flight_server.h"
+
+#include "arrow/array/array_base.h"
+#include "arrow/array/array_primitive.h"
+#include "arrow/array/builder_primitive.h"
+#include "arrow/flight/server.h"
+#include "arrow/flight/test_util.h"
+#include "arrow/flight/type_fwd.h"
+#include "arrow/status.h"
+
+namespace arrow::flight {
+namespace {
+
+class ErrorRecordBatchReader : public RecordBatchReader {
+ public:
+ ErrorRecordBatchReader() : schema_(arrow::schema({})) {}
+
+ std::shared_ptr<Schema> schema() const override { return schema_; }
+
+ Status ReadNext(std::shared_ptr<RecordBatch>* out) override {
+ *out = nullptr;
+ return Status::OK();
+ }
+
+ Status Close() override {
+ // This should be propagated over DoGet to the client
+ return Status::IOError("Expected error");
+ }
+
+ private:
+ std::shared_ptr<Schema> schema_;
+};
+
+Status GetBatchForFlight(const Ticket& ticket, std::shared_ptr<RecordBatchReader>* out) {
+ if (ticket.ticket == "ticket-ints-1") {
+ RecordBatchVector batches;
+ RETURN_NOT_OK(ExampleIntBatches(&batches));
+ ARROW_ASSIGN_OR_RAISE(*out, RecordBatchReader::Make(batches));
+ return Status::OK();
+ } else if (ticket.ticket == "ticket-floats-1") {
+ RecordBatchVector batches;
+ RETURN_NOT_OK(ExampleFloatBatches(&batches));
+ ARROW_ASSIGN_OR_RAISE(*out, RecordBatchReader::Make(batches));
+ return Status::OK();
+ } else if (ticket.ticket == "ticket-dicts-1") {
+ RecordBatchVector batches;
+ RETURN_NOT_OK(ExampleDictBatches(&batches));
+ ARROW_ASSIGN_OR_RAISE(*out, RecordBatchReader::Make(batches));
+ return Status::OK();
+ } else if (ticket.ticket == "ticket-large-batch-1") {
+ RecordBatchVector batches;
+ RETURN_NOT_OK(ExampleLargeBatches(&batches));
+ ARROW_ASSIGN_OR_RAISE(*out, RecordBatchReader::Make(batches));
+ return Status::OK();
+ } else {
+ return Status::NotImplemented("no stream implemented for ticket: " + ticket.ticket);
+ }
+}
+
+} // namespace
+
+std::unique_ptr<FlightServerBase> TestFlightServer::Make() {
+ return std::make_unique<TestFlightServer>();
+}
Review Comment:
Do we need this factory method?
How about using `std::make_unique<TestFlightServer>()` directly in callers?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43677: [C++][FlightRPC] Move the FlightTestServer to its own .cc and .h files [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on code in PR #43678:
URL: https://github.com/apache/arrow/pull/43678#discussion_r1716141049
##########
cpp/src/arrow/flight/test_flight_server.cc:
##########
@@ -0,0 +1,417 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <memory>
+
+#include "arrow/flight/test_flight_server.h"
+
+#include "arrow/array/array_base.h"
+#include "arrow/array/array_primitive.h"
+#include "arrow/array/builder_primitive.h"
+#include "arrow/flight/server.h"
+#include "arrow/flight/test_util.h"
+#include "arrow/flight/type_fwd.h"
+#include "arrow/status.h"
+
+namespace arrow::flight {
+namespace {
+
+class ErrorRecordBatchReader : public RecordBatchReader {
+ public:
+ ErrorRecordBatchReader() : schema_(arrow::schema({})) {}
+
+ std::shared_ptr<Schema> schema() const override { return schema_; }
+
+ Status ReadNext(std::shared_ptr<RecordBatch>* out) override {
+ *out = nullptr;
+ return Status::OK();
+ }
+
+ Status Close() override {
+ // This should be propagated over DoGet to the client
+ return Status::IOError("Expected error");
+ }
+
+ private:
+ std::shared_ptr<Schema> schema_;
+};
+
+Status GetBatchForFlight(const Ticket& ticket, std::shared_ptr<RecordBatchReader>* out) {
+ if (ticket.ticket == "ticket-ints-1") {
+ RecordBatchVector batches;
+ RETURN_NOT_OK(ExampleIntBatches(&batches));
+ ARROW_ASSIGN_OR_RAISE(*out, RecordBatchReader::Make(batches));
+ return Status::OK();
+ } else if (ticket.ticket == "ticket-floats-1") {
+ RecordBatchVector batches;
+ RETURN_NOT_OK(ExampleFloatBatches(&batches));
+ ARROW_ASSIGN_OR_RAISE(*out, RecordBatchReader::Make(batches));
+ return Status::OK();
+ } else if (ticket.ticket == "ticket-dicts-1") {
+ RecordBatchVector batches;
+ RETURN_NOT_OK(ExampleDictBatches(&batches));
+ ARROW_ASSIGN_OR_RAISE(*out, RecordBatchReader::Make(batches));
+ return Status::OK();
+ } else if (ticket.ticket == "ticket-large-batch-1") {
+ RecordBatchVector batches;
+ RETURN_NOT_OK(ExampleLargeBatches(&batches));
+ ARROW_ASSIGN_OR_RAISE(*out, RecordBatchReader::Make(batches));
+ return Status::OK();
+ } else {
+ return Status::NotImplemented("no stream implemented for ticket: " + ticket.ticket);
+ }
+}
+
+} // namespace
+
+std::unique_ptr<FlightServerBase> TestFlightServer::Make() {
+ return std::make_unique<TestFlightServer>();
+}
Review Comment:
It's used quite a lot and is handy to not have to write the longer make_unique invocation. This is replacing the old free function called `ExampleTestServer`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-43677: [C++][FlightRPC] Move the FlightTestServer to its own .cc and .h files [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #43678:
URL: https://github.com/apache/arrow/pull/43678#issuecomment-2288437729
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 69bce8f0cd02297ecc31caef22db67e654c16e28.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/28757024543) has more details. It also includes information about 4 possible false positives for unstable benchmarks that are known to sometimes produce them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org