Skip to content

Commit

Permalink
Update fbthrift lib (#98)
Browse files Browse the repository at this point in the history
* fix meta leader change

* update fbthrift lib and generate code

* add whole_latency

* fix test failed
  • Loading branch information
laura-ding authored Apr 21, 2021
1 parent 3c1769a commit 016d781
Show file tree
Hide file tree
Showing 81 changed files with 3,104 additions and 6,493 deletions.
2 changes: 1 addition & 1 deletion example/ScanVertexEdgeExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def prepare_data():
# init connection pool
connection_pool = ConnectionPool()
# the graphd server's address
assert connection_pool.init([('172.28.3.1', 9669)], config)
assert connection_pool.init([('127.0.0.1', 9671)], config)
client = connection_pool.get_session('root', 'nebula')
client.execute('CREATE SPACE IF NOT EXISTS ScanSpace('
'PARTITION_NUM=10,'
Expand Down
5 changes: 3 additions & 2 deletions nebula2/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

from __future__ import absolute_import
import six
import sys
from nebula2.fbthrift.util.Recursive import fix_spec
from nebula2.fbthrift.Thrift import *
from nebula2.fbthrift.Thrift import TType, TMessageType, TPriority, TRequestContext, TProcessorEventHandler, TServerInterface, TProcessor, TException, TApplicationException, UnimplementedTypedef
from nebula2.fbthrift.protocol.TProtocol import TProtocolException



from .ttypes import *
from .ttypes import UTF8STRINGS, NullType, Date, Time, DateTime, Value, NList, NMap, NSet, Row, DataSet, Tag, Vertex, Edge, Step, Path, HostAddr, KeyValue, LogInfo, PartitionBackupInfo, GraphSpaceID, PartitionID, TagID, EdgeType, EdgeRanking, LogID, TermID, Timestamp, IndexID, Port, SessionID

162 changes: 29 additions & 133 deletions nebula2/common/ttypes.py

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions nebula2/data/ResultSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@


class ResultSet(object):
def __init__(self, resp, decode_type='utf-8'):
def __init__(self, resp, _all_latency, decode_type='utf-8'):
"""
get data from ResultSet
"""
self._decode_type = decode_type
self._resp = resp
self._data_set_wrapper = None
self._all_latency = _all_latency;
if self._resp.data is not None:
self._data_set_wrapper = DataSetWrapper(resp.data, self._decode_type)

Expand All @@ -45,10 +46,16 @@ def comment(self):

def latency(self):
"""
unit us
the server's latency, unit us
"""
return self._resp.latency_in_us

def whole_latency(self):
"""
the whole latency of the query
"""
return self._all_latency

def plan_desc(self):
return self._resp.plan_desc

Expand Down
27 changes: 12 additions & 15 deletions nebula2/fbthrift/TMultiplexedProcessor.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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
# Licensed 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.
# 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.

# pyre-unsafe

from __future__ import absolute_import
from __future__ import division
Expand Down
25 changes: 10 additions & 15 deletions nebula2/fbthrift/TSCons.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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
# Licensed 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.
# 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.

from __future__ import absolute_import
from __future__ import division
Expand Down
29 changes: 13 additions & 16 deletions nebula2/fbthrift/Thrift.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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
# Licensed 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.
# 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.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging
import six
import sys
import threading
Expand Down Expand Up @@ -111,7 +107,8 @@ def handlerError(self, handler_context, fn_name, exception):
Note that this method is NOT called if the handler threw an
exception that is declared in the thrift service specification"""
pass

logging.exception("Unexpected error in service handler " + fn_name + ":")


class TServerInterface:
Expand Down
26 changes: 10 additions & 16 deletions nebula2/fbthrift/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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
# Licensed 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.
# 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.

__all__ = ['Thrift', 'TSCons']
trollius = False
29 changes: 13 additions & 16 deletions nebula2/fbthrift/protocol/TBinaryProtocol.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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
# Licensed 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.
# 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.

# pyre-unsafe

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from .TProtocol import *
from nebula2.fbthrift.protocol.TProtocol import *
from struct import pack, unpack

class TBinaryProtocol(TProtocolBase):
Expand Down
20 changes: 18 additions & 2 deletions nebula2/fbthrift/protocol/TCompactProtocol.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed 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.

# pyre-unsafe

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import sys
from .TProtocol import *
from nebula2.fbthrift.protocol.TProtocol import *
from struct import pack, unpack

__all__ = [
Expand Down Expand Up @@ -324,7 +340,7 @@ def readMessageBegin(self):
if not (self.__version <= self.VERSION and
self.__version >= self.VERSION_LOW):
raise TProtocolException(TProtocolException.BAD_VERSION,
'Bad version: %d (expect %d)' % (version, self.VERSION))
'Bad version: %d (expect %d)' % (self.__version, self.VERSION))
seqid = self.__readVarint()
name = self.__readString()
return (name, type, seqid)
Expand Down
33 changes: 15 additions & 18 deletions nebula2/fbthrift/protocol/THeaderProtocol.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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
# Licensed 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.
# 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.

# pyre-unsafe

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from .TProtocol import TProtocolBase, TProtocolException
from nebula2.fbthrift.protocol.TProtocol import TProtocolBase, TProtocolException
from nebula2.fbthrift.Thrift import TApplicationException, TMessageType
from .TBinaryProtocol import TBinaryProtocolAccelerated
from .TCompactProtocol import TCompactProtocolAccelerated
from nebula2.fbthrift.protocol.TBinaryProtocol import TBinaryProtocolAccelerated
from nebula2.fbthrift.protocol.TCompactProtocol import TCompactProtocolAccelerated
from nebula2.fbthrift.transport.THeaderTransport import THeaderTransport, CLIENT_TYPE


Expand Down
Loading

0 comments on commit 016d781

Please sign in to comment.