quanghgx commented on code in PR #13986:
URL: https://github.com/apache/arrow/pull/13986#discussion_r964318174
##########
python/pyarrow/_flight.pyx:
##########
@@ -289,6 +289,33 @@ cdef class Action(_Weakrefable):
type(action)))
return (<Action> action).action
+ def serialize(self):
+ """Get the wire-format representation of this type.
+
+ Useful when interoperating with non-Flight systems (e.g. REST
+ services) that may want to return Flight types.
+
+ """
+ return GetResultValue(self.action.SerializeToString())
+
+ @classmethod
+ def deserialize(cls, serialized):
+ """Parse the wire-format representation of this type.
+
+ Useful when interoperating with non-Flight systems (e.g. REST
+ services) that may want to return Flight types.
+
+ """
+ cdef Action action = Action.__new__(Action)
+ action.action = GetResultValue(
+ CAction.Deserialize(tobytes(serialized)))
+ return action
+
+ def __eq__(self, Action other):
+ # TODO (qhoang): question for myself, do we need to push this down
Review Comment:
Thank you so much, @lidavidm
* Added Equals and operator== to C++ side.
Need your help on 3 queries:
1. For ActionType, currently, it is defined as a named-tuple, should we
change it to be backed by CActionType?
https://github.com/apache/arrow/blob/master/python/pyarrow/_flight.pyx#L293
2. Same with Criteria, it is not defined in _flight.pyx yet, should I add it
in this MR as well?
3. And the last one, mostly for your advice, David:
```python
# This one works
result = flight.Result(b"result1")
result2 = flight.Result.deserialize(result.serialize())
assert result.body == result2.body
# But it does not for this one:
assert result == result2
# Result::__eq__ is already defined in _flight.pyx. (I am getting myself
familiar with unique_ptr in Cython)
```
Appreciate your help. I have been learning a lot in last week.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]