PyStellarDB 0.13.2__tar.gz → 0.13.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pystellardb-0.13.2 → pystellardb-0.13.4}/PKG-INFO +1 -1
- {pystellardb-0.13.2 → pystellardb-0.13.4}/PyStellarDB.egg-info/PKG-INFO +1 -1
- {pystellardb-0.13.2 → pystellardb-0.13.4}/pystellardb/_version.py +3 -3
- {pystellardb-0.13.2 → pystellardb-0.13.4}/pystellardb/graph_types.py +32 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/pystellardb/stellar_hive.py +25 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/LICENSE +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/MANIFEST.in +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/PyStellarDB.egg-info/SOURCES.txt +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/PyStellarDB.egg-info/dependency_links.txt +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/PyStellarDB.egg-info/requires.txt +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/PyStellarDB.egg-info/top_level.txt +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/README.rst +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/pystellardb/__init__.py +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/pystellardb/stellar_rdd.py +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/setup.cfg +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/setup.py +0 -0
- {pystellardb-0.13.2 → pystellardb-0.13.4}/versioneer.py +0 -0
@@ -8,11 +8,11 @@ import json
|
|
8
8
|
|
9
9
|
version_json = '''
|
10
10
|
{
|
11
|
-
"date": "2024-
|
11
|
+
"date": "2024-10-30T09:30:52+0800",
|
12
12
|
"dirty": false,
|
13
13
|
"error": null,
|
14
|
-
"full-revisionid": "
|
15
|
-
"version": "0.13.
|
14
|
+
"full-revisionid": "88d8d41626e7131ffbf0e675bce34330a12fd953",
|
15
|
+
"version": "0.13.4"
|
16
16
|
}
|
17
17
|
''' # END VERSION_JSON
|
18
18
|
|
@@ -8,6 +8,7 @@ from future.utils import with_metaclass
|
|
8
8
|
import json
|
9
9
|
import logging
|
10
10
|
import binascii
|
11
|
+
from typing import cast
|
11
12
|
|
12
13
|
_logger = logging.getLogger(__name__)
|
13
14
|
|
@@ -46,6 +47,21 @@ class GraphElement(with_metaclass(abc.ABCMeta, object)):
|
|
46
47
|
|
47
48
|
def getRowKeyHexString(self):
|
48
49
|
return self._rowKeyHexString
|
50
|
+
|
51
|
+
def __hash__(self):
|
52
|
+
if self._rowKeyHexString:
|
53
|
+
return hash(self._rowKeyHexString)
|
54
|
+
else:
|
55
|
+
return hash(self._fields)
|
56
|
+
|
57
|
+
def __eq__(self, value):
|
58
|
+
if isinstance(value, GraphElement):
|
59
|
+
if self._rowKeyHexString:
|
60
|
+
return self._rowKeyHexString == value._rowKeyHexString
|
61
|
+
else:
|
62
|
+
return self._fields == value._fields
|
63
|
+
else:
|
64
|
+
return False
|
49
65
|
|
50
66
|
|
51
67
|
class Vertex(GraphElement):
|
@@ -292,6 +308,22 @@ class Path(object):
|
|
292
308
|
|
293
309
|
def __str__(self):
|
294
310
|
return str([str(entry) for entry in self._elems])
|
311
|
+
|
312
|
+
def __hash__(self):
|
313
|
+
rks = []
|
314
|
+
for elem in self._elems:
|
315
|
+
rks.append(cast(GraphElement, elem).getRowKeyHexString())
|
316
|
+
|
317
|
+
return hash(tuple(rks))
|
318
|
+
|
319
|
+
def __eq__(self, value):
|
320
|
+
if isinstance(value, Path):
|
321
|
+
if self.length() == value.length():
|
322
|
+
return self.getElements() == value.getElements()
|
323
|
+
else:
|
324
|
+
return False
|
325
|
+
else:
|
326
|
+
return False
|
295
327
|
|
296
328
|
@staticmethod
|
297
329
|
def parsePathFromJson(schema, json_str):
|
@@ -146,6 +146,7 @@ class StellarConnection(object):
|
|
146
146
|
protocol_version = ttypes.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6
|
147
147
|
|
148
148
|
self._graph_schema = None
|
149
|
+
self._graph_schema_from_data = None
|
149
150
|
|
150
151
|
try:
|
151
152
|
self._transport.open()
|
@@ -171,6 +172,11 @@ class StellarConnection(object):
|
|
171
172
|
|
172
173
|
self._graph_schema = graph_types.GraphSchema.parseSchemaFromJson(
|
173
174
|
schemaInJson)
|
175
|
+
|
176
|
+
# get schema from data
|
177
|
+
cursor.execute('manipulate graph {} get_schema_from_data'.format(graph_name))
|
178
|
+
self._graph_schema_from_data = cursor.fetchone()[0]
|
179
|
+
self._graph_schema_from_data = json.loads(self._graph_schema_from_data)
|
174
180
|
else:
|
175
181
|
assert response.serverProtocolVersion == protocol_version, \
|
176
182
|
"Unable to handle protocol version {}".format(response.serverProtocolVersion)
|
@@ -219,6 +225,25 @@ class StellarConnection(object):
|
|
219
225
|
def getGraphSchema(self):
|
220
226
|
return self._graph_schema
|
221
227
|
|
228
|
+
def getSchemaFromData(self) -> dict:
|
229
|
+
"""
|
230
|
+
Get schema from graph data.
|
231
|
+
The difference of getGraphSchema() and getSchemaFromData() is the latter one will return start node labels and end node labels of edges.
|
232
|
+
Result format is:
|
233
|
+
{
|
234
|
+
"vertices": [
|
235
|
+
{ "label": "label_a", "fields": ["prop1", "prop2", ...] }
|
236
|
+
],
|
237
|
+
"edges": [
|
238
|
+
"label": "label_b",
|
239
|
+
"fields": ["prop3", "prop4", ...],
|
240
|
+
"src_dst_labels": [
|
241
|
+
{"src": "label_x", "dst": "label_y"},
|
242
|
+
]
|
243
|
+
]
|
244
|
+
}
|
245
|
+
"""
|
246
|
+
return self._graph_schema_from_data
|
222
247
|
|
223
248
|
class StellarCursor(hive.Cursor):
|
224
249
|
"""These objects represent a database cursor, which is used to manage the context of a fetch
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|