vastdb 0.0.5.9__py3-none-any.whl → 0.0.5.10__py3-none-any.whl
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.
- vastdb/api.py +67 -17
- {vastdb-0.0.5.9.dist-info → vastdb-0.0.5.10.dist-info}/METADATA +5 -2
- {vastdb-0.0.5.9.dist-info → vastdb-0.0.5.10.dist-info}/RECORD +6 -6
- {vastdb-0.0.5.9.dist-info → vastdb-0.0.5.10.dist-info}/WHEEL +1 -1
- {vastdb-0.0.5.9.dist-info → vastdb-0.0.5.10.dist-info}/LICENSE +0 -0
- {vastdb-0.0.5.9.dist-info → vastdb-0.0.5.10.dist-info}/top_level.txt +0 -0
vastdb/api.py
CHANGED
|
@@ -92,6 +92,8 @@ TABULAR_QUERY_DATA_FAILED_STREAM_ID = 0xFFFFFFFF - 2
|
|
|
92
92
|
TABULAR_INVALID_ROW_ID = 0xFFFFFFFFFFFF # (1<<48)-1
|
|
93
93
|
ESTORE_INVALID_EHANDLE = UINT64_MAX
|
|
94
94
|
|
|
95
|
+
KAFKA_TOPICS_SCHEMA_NAME = 'kafka_topics'
|
|
96
|
+
|
|
95
97
|
"""
|
|
96
98
|
S3 Tabular API
|
|
97
99
|
"""
|
|
@@ -722,15 +724,14 @@ def _decode_table_props(s):
|
|
|
722
724
|
TableInfo = namedtuple('table_info', 'name properties handle num_rows size_in_bytes num_partitions')
|
|
723
725
|
|
|
724
726
|
|
|
725
|
-
def _parse_table_info(obj):
|
|
727
|
+
def _parse_table_info(obj, parse_properties):
|
|
726
728
|
name = obj.Name().decode()
|
|
727
729
|
properties = obj.Properties().decode()
|
|
728
730
|
handle = obj.Handle().decode()
|
|
729
731
|
num_rows = obj.NumRows()
|
|
730
732
|
used_bytes = obj.SizeInBytes()
|
|
731
733
|
num_partitions = obj.NumPartitions()
|
|
732
|
-
|
|
733
|
-
properties = _decode_table_props(properties)
|
|
734
|
+
properties = parse_properties(properties)
|
|
734
735
|
return TableInfo(name, properties, handle, num_rows, used_bytes, num_partitions)
|
|
735
736
|
|
|
736
737
|
def build_record_batch(column_info, column_values):
|
|
@@ -1016,8 +1017,27 @@ class VastdbApi:
|
|
|
1016
1017
|
return snapshots, is_truncated, marker
|
|
1017
1018
|
|
|
1018
1019
|
def create_table(self, bucket, schema, name, arrow_schema=None, txid=0, client_tags=[], expected_retvals=[],
|
|
1019
|
-
|
|
1020
|
-
|
|
1020
|
+
create_imports_table=False, use_external_row_ids_allocation=False):
|
|
1021
|
+
return self._create_table_internal(bucket=bucket, schema=schema, name=name, arrow_schema=arrow_schema,
|
|
1022
|
+
txid=txid, client_tags=client_tags, expected_retvals=expected_retvals,
|
|
1023
|
+
create_imports_table=create_imports_table,
|
|
1024
|
+
use_external_row_ids_allocation=use_external_row_ids_allocation)
|
|
1025
|
+
|
|
1026
|
+
def create_topic(self, bucket, name, topic_partitions, expected_retvals=[],
|
|
1027
|
+
message_timestamp_type=None, retention_ms=None,
|
|
1028
|
+
message_timestamp_after_max_ms=None, message_timestamp_before_max_ms=None):
|
|
1029
|
+
table_props = _encode_table_props(message_timestamp_type=message_timestamp_type,
|
|
1030
|
+
retention_ms=retention_ms,
|
|
1031
|
+
message_timestamp_after_max_ms=message_timestamp_after_max_ms,
|
|
1032
|
+
message_timestamp_before_max_ms=message_timestamp_before_max_ms)
|
|
1033
|
+
return self._create_table_internal(bucket=bucket, schema=KAFKA_TOPICS_SCHEMA_NAME, name=name, arrow_schema=None,
|
|
1034
|
+
expected_retvals=expected_retvals, topic_partitions=topic_partitions,
|
|
1035
|
+
table_props=table_props)
|
|
1036
|
+
|
|
1037
|
+
def _create_table_internal(self, bucket, schema, name, arrow_schema=None,
|
|
1038
|
+
txid=0, client_tags=[], expected_retvals=[], topic_partitions=0,
|
|
1039
|
+
create_imports_table=False, use_external_row_ids_allocation=False,
|
|
1040
|
+
table_props=None):
|
|
1021
1041
|
"""
|
|
1022
1042
|
Create a table, use the following request
|
|
1023
1043
|
POST /bucket/schema/table?table HTTP/1.1
|
|
@@ -1042,10 +1062,8 @@ class VastdbApi:
|
|
|
1042
1062
|
headers['Content-Length'] = str(len(serialized_schema))
|
|
1043
1063
|
url_params = {'topic_partitions': str(topic_partitions)} if topic_partitions else {}
|
|
1044
1064
|
|
|
1045
|
-
if
|
|
1046
|
-
|
|
1047
|
-
if table_props is not None:
|
|
1048
|
-
url_params['table-props'] = table_props
|
|
1065
|
+
if table_props is not None:
|
|
1066
|
+
url_params['table-props'] = table_props
|
|
1049
1067
|
|
|
1050
1068
|
res = self.session.post(self._api_prefix(bucket=bucket, schema=schema, table=name, command="table", url_params=url_params),
|
|
1051
1069
|
data=serialized_schema, headers=headers)
|
|
@@ -1097,9 +1115,22 @@ class VastdbApi:
|
|
|
1097
1115
|
return num_rows, size_in_bytes, is_external_rowid_alloc
|
|
1098
1116
|
return self._check_res(res, "get_table_stats", expected_retvals)
|
|
1099
1117
|
|
|
1100
|
-
def
|
|
1118
|
+
def alter_topic(self, bucket, name,
|
|
1101
1119
|
new_name="", expected_retvals=[],
|
|
1102
|
-
message_timestamp_type=None, retention_ms=None, message_timestamp_after_max_ms=None,
|
|
1120
|
+
message_timestamp_type=None, retention_ms=None, message_timestamp_after_max_ms=None,
|
|
1121
|
+
message_timestamp_before_max_ms=None):
|
|
1122
|
+
table_properties = _encode_table_props(message_timestamp_type=message_timestamp_type,
|
|
1123
|
+
retention_ms=retention_ms,
|
|
1124
|
+
message_timestamp_after_max_ms=message_timestamp_after_max_ms,
|
|
1125
|
+
message_timestamp_before_max_ms=message_timestamp_before_max_ms)
|
|
1126
|
+
if table_properties is None:
|
|
1127
|
+
table_properties = ""
|
|
1128
|
+
|
|
1129
|
+
return self.alter_table(bucket=bucket, schema=KAFKA_TOPICS_SCHEMA_NAME, name=name,
|
|
1130
|
+
table_properties=table_properties, expected_retvals=expected_retvals)
|
|
1131
|
+
|
|
1132
|
+
def alter_table(self, bucket, schema, name, txid=0, client_tags=[], table_properties="",
|
|
1133
|
+
new_name="", expected_retvals=[]):
|
|
1103
1134
|
"""
|
|
1104
1135
|
PUT /mybucket/myschema/mytable?table HTTP/1.1
|
|
1105
1136
|
Content-Length: ContentLength
|
|
@@ -1111,10 +1142,8 @@ class VastdbApi:
|
|
|
1111
1142
|
"""
|
|
1112
1143
|
builder = flatbuffers.Builder(1024)
|
|
1113
1144
|
|
|
1114
|
-
if
|
|
1115
|
-
table_properties =
|
|
1116
|
-
if table_properties is None:
|
|
1117
|
-
table_properties = ""
|
|
1145
|
+
if table_properties is None:
|
|
1146
|
+
table_properties = ""
|
|
1118
1147
|
|
|
1119
1148
|
properties = builder.CreateString(table_properties)
|
|
1120
1149
|
tabular_alter_table.Start(builder)
|
|
@@ -1134,6 +1163,10 @@ class VastdbApi:
|
|
|
1134
1163
|
|
|
1135
1164
|
return self._check_res(res, "alter_table", expected_retvals)
|
|
1136
1165
|
|
|
1166
|
+
def drop_topic(self, bucket, name, expected_retvals=[]):
|
|
1167
|
+
return self.drop_table(bucket=bucket, schema=KAFKA_TOPICS_SCHEMA_NAME, name=name,
|
|
1168
|
+
expected_retvals=expected_retvals)
|
|
1169
|
+
|
|
1137
1170
|
def drop_table(self, bucket, schema, name, txid=0, client_tags=[], expected_retvals=[]):
|
|
1138
1171
|
"""
|
|
1139
1172
|
DELETE /mybucket/schema_path/mytable?table HTTP/1.1
|
|
@@ -1145,8 +1178,25 @@ class VastdbApi:
|
|
|
1145
1178
|
res = self.session.delete(self._api_prefix(bucket=bucket, schema=schema, table=name, command="table"), headers=headers)
|
|
1146
1179
|
return self._check_res(res, "drop_table", expected_retvals)
|
|
1147
1180
|
|
|
1181
|
+
def list_topics(self, bucket, max_keys=1000, next_key=0, name_prefix="",
|
|
1182
|
+
exact_match=False, expected_retvals=[], include_list_stats=False, count_only=False):
|
|
1183
|
+
return self._list_tables_internal(bucket=bucket, schema=KAFKA_TOPICS_SCHEMA_NAME,
|
|
1184
|
+
parse_properties=_decode_table_props, max_keys=max_keys,
|
|
1185
|
+
next_key=next_key, name_prefix=name_prefix, exact_match=exact_match,
|
|
1186
|
+
expected_retvals=expected_retvals,
|
|
1187
|
+
include_list_stats=include_list_stats, count_only=count_only)
|
|
1188
|
+
|
|
1148
1189
|
def list_tables(self, bucket, schema, txid=0, client_tags=[], max_keys=1000, next_key=0, name_prefix="",
|
|
1149
1190
|
exact_match=False, expected_retvals=[], include_list_stats=False, count_only=False):
|
|
1191
|
+
parse_properties = lambda x: x
|
|
1192
|
+
return self._list_tables_internal(bucket=bucket, schema=schema, txid=txid, client_tags=client_tags,
|
|
1193
|
+
parse_properties=parse_properties, max_keys=max_keys, next_key=next_key,
|
|
1194
|
+
name_prefix=name_prefix, exact_match=exact_match,
|
|
1195
|
+
expected_retvals=expected_retvals,
|
|
1196
|
+
include_list_stats=include_list_stats, count_only=count_only)
|
|
1197
|
+
|
|
1198
|
+
def _list_tables_internal(self, bucket, schema, parse_properties, txid=0, client_tags=[], max_keys=1000, next_key=0, name_prefix="",
|
|
1199
|
+
exact_match=False, expected_retvals=[], include_list_stats=False, count_only=False):
|
|
1150
1200
|
"""
|
|
1151
1201
|
GET /mybucket/schema_path?table HTTP/1.1
|
|
1152
1202
|
tabular-txid: TransactionId
|
|
@@ -1182,7 +1232,7 @@ class VastdbApi:
|
|
|
1182
1232
|
tables_length = lists.TablesLength()
|
|
1183
1233
|
count = int(res_headers['tabular-list-count']) if 'tabular-list-count' in res_headers else tables_length
|
|
1184
1234
|
for i in range(tables_length):
|
|
1185
|
-
tables.append(_parse_table_info(lists.Tables(i)))
|
|
1235
|
+
tables.append(_parse_table_info(lists.Tables(i), parse_properties))
|
|
1186
1236
|
|
|
1187
1237
|
return bucket_name, schema_name, tables, next_key, is_truncated, count
|
|
1188
1238
|
|
|
@@ -2350,7 +2400,7 @@ class VastdbApi:
|
|
|
2350
2400
|
raise ValueError(f'bucket: {bucket} did not start from {bucket_name}')
|
|
2351
2401
|
projections_length = lists.ProjectionsLength()
|
|
2352
2402
|
for i in range(projections_length):
|
|
2353
|
-
projections.append(_parse_table_info(lists.Projections(i)))
|
|
2403
|
+
projections.append(_parse_table_info(lists.Projections(i), lambda x:x))
|
|
2354
2404
|
|
|
2355
2405
|
return bucket_name, schema_name, table_name, projections, next_key, is_truncated, count
|
|
2356
2406
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vastdb
|
|
3
|
-
Version: 0.0.5.
|
|
3
|
+
Version: 0.0.5.10
|
|
4
4
|
Summary: VAST Data SDK
|
|
5
5
|
Home-page: https://github.com/vast-data/vastdb_sdk
|
|
6
6
|
Author: VAST DATA
|
|
7
7
|
Author-email: hello@vastdata.com
|
|
8
8
|
License: Copyright (C) VAST Data Ltd.
|
|
9
|
+
Platform: UNKNOWN
|
|
9
10
|
Description-Content-Type: text/markdown
|
|
10
11
|
License-File: LICENSE
|
|
12
|
+
Requires-Dist: aws-requests-auth
|
|
11
13
|
Requires-Dist: flatbuffers
|
|
12
14
|
Requires-Dist: pyarrow
|
|
13
15
|
Requires-Dist: requests
|
|
14
|
-
Requires-Dist: aws-requests-auth
|
|
15
16
|
Requires-Dist: xmltodict
|
|
16
17
|
|
|
17
18
|
|
|
@@ -42,3 +43,5 @@ vastdb_session = create_vastdb_session(access_key, secret_key)
|
|
|
42
43
|
```
|
|
43
44
|
#### For the complete Guide for the SDK please go to VastData github: https://github.com/vast-data/vastdb_sdk
|
|
44
45
|
|
|
46
|
+
|
|
47
|
+
|
|
@@ -148,9 +148,9 @@ vast_flatbuf/tabular/ObjectDetails.py,sha256=5mMZ0iL_iC1cztyyjPeEeJv3ch6Nk1zyCOc
|
|
|
148
148
|
vast_flatbuf/tabular/S3File.py,sha256=KC9c2oS5-JXwTTriUVFdjOvRG0B54Cq9kviSDZY3NI0,4450
|
|
149
149
|
vast_flatbuf/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
150
150
|
vastdb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
151
|
-
vastdb/api.py,sha256=
|
|
152
|
-
vastdb-0.0.5.
|
|
153
|
-
vastdb-0.0.5.
|
|
154
|
-
vastdb-0.0.5.
|
|
155
|
-
vastdb-0.0.5.
|
|
156
|
-
vastdb-0.0.5.
|
|
151
|
+
vastdb/api.py,sha256=nqsUzGeEPWSuO402dUQp_-6BPdZI0EXjBxc48GifA1M,131408
|
|
152
|
+
vastdb-0.0.5.10.dist-info/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
|
|
153
|
+
vastdb-0.0.5.10.dist-info/METADATA,sha256=i1r5ba8-9wFSZhHtqAp2lcbhZAZd8CvMDucLdSDZr-c,1370
|
|
154
|
+
vastdb-0.0.5.10.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
155
|
+
vastdb-0.0.5.10.dist-info/top_level.txt,sha256=Vsj2MKtlhPg0J4so64slQtnwjhgoPmJgcG-6YcVAwVc,20
|
|
156
|
+
vastdb-0.0.5.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|