Skip to content

Commit

Permalink
fix bugs in result set creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvpboss1004 committed Sep 17, 2022
1 parent edcb107 commit 5d5d0f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
12 changes: 5 additions & 7 deletions src/pyrocketmq/client/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Union
from typing import List, Optional

from java.util import ArrayList
from org.apache.rocketmq.client import ClientConfig as JClientConfig
Expand All @@ -11,18 +11,16 @@ class QueryResult(list):
def __init__(self,
query_result:Optional[JQueryResult] = None,
indexLastUpdateTimestamp:Optional[int] = None,
messageList:Union[ArrayList, List[MessageExt], None] = None,
messageList:Optional[List[MessageExt]] = None,
):
if query_result is not None == indexLastUpdateTimestamp is not None and messageList is not None:
raise Exception('Exactly one of query_result and indexLastUpdateTimestamp+messageList must be specified')
elif query_result is not None:
self.this = query_result
list.__init__(self, self.messageList)
else:
self.this = JQueryResult(
indexLastUpdateTimestamp,
messageList if isinstance(messageList,ArrayList) else ArrayList([msg.this for msg in messageList])
)
list.__init__(self, )
self.this = JQueryResult(indexLastUpdateTimestamp, ArrayList([msg.this for msg in messageList]))
list.__init__(self, messageList)

@property
def indexLastUpdateTimestamp(self) -> int:
Expand Down
9 changes: 4 additions & 5 deletions src/pyrocketmq/client/consumer/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@ def __init__(self,
nextBeginOffset:Optional[int] = None,
minOffset:Optional[int] = None,
maxOffset:Optional[int] = None,
msgFoundList:Union[ArrayList, List[MessageExt], None] = None,
msgFoundList:Optional[List[MessageExt]] = None,
):
if pull_result is None == (pullStatus is None or nextBeginOffset is None or minOffset is None or maxOffset is None or msgFoundList is None):
raise Exception('Exactly one of pull_result and nextBeginOffset+minOffset+maxOffset+msgFoundList must be specified')
elif pull_result is not None:
self.this = pull_result
list.__init__(self, self.msgFoundList)
else:
self.this = JPullResult(pullStatus.value, nextBeginOffset, minOffset, maxOffset,
msgFoundList if isinstance(msgFoundList,ArrayList) else ArrayList([m.this for m in msgFoundList])
)
list.__init__(self, msgFoundList)
self.this = JPullResult(pullStatus.value, nextBeginOffset, minOffset, maxOffset, ArrayList([m.this for m in msgFoundList]))
list.__init__(self, msgFoundList)

@property
def pullStatus(self) -> PullStatus:
Expand Down

0 comments on commit 5d5d0f3

Please sign in to comment.