PyStellarDB 0.13.1__tar.gz → 0.13.3__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.1 → pystellardb-0.13.3}/PKG-INFO +1 -1
- {pystellardb-0.13.1 → pystellardb-0.13.3}/PyStellarDB.egg-info/PKG-INFO +1 -1
- {pystellardb-0.13.1 → pystellardb-0.13.3}/pystellardb/_version.py +3 -3
- {pystellardb-0.13.1 → pystellardb-0.13.3}/pystellardb/graph_types.py +22 -3
- {pystellardb-0.13.1 → pystellardb-0.13.3}/pystellardb/stellar_hive.py +25 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/LICENSE +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/MANIFEST.in +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/PyStellarDB.egg-info/SOURCES.txt +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/PyStellarDB.egg-info/dependency_links.txt +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/PyStellarDB.egg-info/requires.txt +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/PyStellarDB.egg-info/top_level.txt +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/README.rst +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/pystellardb/__init__.py +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/pystellardb/stellar_rdd.py +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/setup.cfg +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/setup.py +0 -0
- {pystellardb-0.13.1 → pystellardb-0.13.3}/versioneer.py +0 -0
@@ -8,11 +8,11 @@ import json
|
|
8
8
|
|
9
9
|
version_json = '''
|
10
10
|
{
|
11
|
-
"date": "2024-
|
11
|
+
"date": "2024-09-11T10:31:56+0800",
|
12
12
|
"dirty": false,
|
13
13
|
"error": null,
|
14
|
-
"full-revisionid": "
|
15
|
-
"version": "0.13.
|
14
|
+
"full-revisionid": "7b244e0a10d56e002a7a10d9cf7fb5f7049c55b5",
|
15
|
+
"version": "0.13.3"
|
16
16
|
}
|
17
17
|
''' # END VERSION_JSON
|
18
18
|
|
@@ -18,6 +18,7 @@ class GraphElement(with_metaclass(abc.ABCMeta, object)):
|
|
18
18
|
self._label = label
|
19
19
|
self._fields = {}
|
20
20
|
self._tags = []
|
21
|
+
self._rowKeyHexString = None
|
21
22
|
|
22
23
|
def getLabel(self):
|
23
24
|
return self._label
|
@@ -40,6 +41,12 @@ class GraphElement(with_metaclass(abc.ABCMeta, object)):
|
|
40
41
|
def setTags(self, newTags):
|
41
42
|
self._tags = newTags
|
42
43
|
|
44
|
+
def setRowKeyHexString(self, rowkey):
|
45
|
+
self._rowKeyHexString = rowkey
|
46
|
+
|
47
|
+
def getRowKeyHexString(self):
|
48
|
+
return self._rowKeyHexString
|
49
|
+
|
43
50
|
|
44
51
|
class Vertex(GraphElement):
|
45
52
|
"""
|
@@ -58,6 +65,7 @@ class Vertex(GraphElement):
|
|
58
65
|
'type': 'vertex',
|
59
66
|
'label': self._label,
|
60
67
|
'uid': self._uid,
|
68
|
+
'RowKeyHexString': self._rowKeyHexString,
|
61
69
|
}
|
62
70
|
|
63
71
|
if self._tags is not None and len(self._tags) > 0:
|
@@ -98,6 +106,9 @@ class Vertex(GraphElement):
|
|
98
106
|
if '__tags' in prop_dict:
|
99
107
|
vertex.setTags(prop_dict['__tags'])
|
100
108
|
|
109
|
+
rk = " ".join(map(lambda x: str(x), m['entityKey']))
|
110
|
+
vertex.setRowKeyHexString(rk)
|
111
|
+
|
101
112
|
return vertex
|
102
113
|
|
103
114
|
@staticmethod
|
@@ -176,6 +187,7 @@ class Edge(GraphElement):
|
|
176
187
|
'euid': self._uid,
|
177
188
|
'startNode': self._startNode.toJSON(),
|
178
189
|
'endNode': self._endNode.toJSON(),
|
190
|
+
'RowKeyHexString': self._rowKeyHexString,
|
179
191
|
}
|
180
192
|
|
181
193
|
if self._tags is not None and len(self._tags) > 0:
|
@@ -204,6 +216,9 @@ class Edge(GraphElement):
|
|
204
216
|
|
205
217
|
edge = Edge(m['labels'][0])
|
206
218
|
|
219
|
+
rk = " ".join(map(lambda x: str(x), m['entityKey']))
|
220
|
+
edge.setRowKeyHexString(rk)
|
221
|
+
|
207
222
|
prop_dict = m['properties']
|
208
223
|
|
209
224
|
# parse start node
|
@@ -222,8 +237,10 @@ class Edge(GraphElement):
|
|
222
237
|
raise ValueError(
|
223
238
|
'Could not find start node label with label index `{}`'.format(
|
224
239
|
startLabelIdx))
|
225
|
-
|
226
|
-
|
240
|
+
|
241
|
+
start_node = Vertex(startUid, startLabel)
|
242
|
+
start_node.setRowKeyHexString(" ".join(map(lambda x: str(x), m['entityKey'][:8])))
|
243
|
+
edge.setStartNode(start_node)
|
227
244
|
|
228
245
|
# parse end node
|
229
246
|
if 'endKey' not in m:
|
@@ -242,7 +259,9 @@ class Edge(GraphElement):
|
|
242
259
|
'Could not find end node label with label index `{}`'.format(
|
243
260
|
endLabelIdx))
|
244
261
|
|
245
|
-
|
262
|
+
end_node = Vertex(endUid, endLabel)
|
263
|
+
end_node.setRowKeyHexString(" ".join(map(lambda x: str(x), m['entityKey'][8:16])))
|
264
|
+
edge.setEndNode(end_node)
|
246
265
|
|
247
266
|
# parse extra edge id
|
248
267
|
if '__uid' in prop_dict:
|
@@ -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
|