vastdb 1.3.4__py3-none-any.whl → 1.3.5__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/_internal.py CHANGED
@@ -119,6 +119,8 @@ TABULAR_INVALID_ROW_ID = 0xFFFFFFFFFFFF # (1<<48)-1
119
119
  ESTORE_INVALID_EHANDLE = UINT64_MAX
120
120
  IMPORTED_OBJECTS_TABLE_NAME = "vastdb-imported-objects"
121
121
 
122
+ KAFKA_TOPICS_SCHEMA_NAME = 'kafka_topics'
123
+
122
124
  """
123
125
  S3 Tabular API
124
126
  """
@@ -787,15 +789,14 @@ def _decode_table_props(s):
787
789
  TableInfo = namedtuple('TableInfo', 'name properties handle num_rows size_in_bytes num_partitions')
788
790
 
789
791
 
790
- def _parse_table_info(obj):
792
+ def _parse_table_info(obj, parse_properties):
791
793
  name = obj.Name().decode()
792
794
  properties = obj.Properties().decode()
793
795
  handle = obj.Handle().decode()
794
796
  num_rows = obj.NumRows()
795
797
  used_bytes = obj.SizeInBytes()
796
798
  num_partitions = obj.NumPartitions()
797
- if num_partitions != 0:
798
- properties = _decode_table_props(properties)
799
+ properties = parse_properties(properties)
799
800
  return TableInfo(name, properties, handle, num_rows, used_bytes, num_partitions)
800
801
 
801
802
 
@@ -1109,9 +1110,29 @@ class VastdbApi:
1109
1110
 
1110
1111
  return snapshots, is_truncated, marker
1111
1112
 
1112
- def create_table(self, bucket, schema, name, arrow_schema=None, txid=0, client_tags=[], expected_retvals=[],
1113
- topic_partitions=0, create_imports_table=False, use_external_row_ids_allocation=False,
1114
- message_timestamp_type=None, retention_ms=None, message_timestamp_after_max_ms=None, message_timestamp_before_max_ms=None):
1113
+ def create_table(self, bucket, schema, name, arrow_schema=None,
1114
+ txid=0, client_tags=[], expected_retvals=[],
1115
+ create_imports_table=False, use_external_row_ids_allocation=False, table_props=None):
1116
+ self._create_table_internal(bucket=bucket, schema=schema, name=name, arrow_schema=arrow_schema,
1117
+ txid=txid, client_tags=client_tags, expected_retvals=expected_retvals,
1118
+ create_imports_table=create_imports_table, use_external_row_ids_allocation=use_external_row_ids_allocation,
1119
+ table_props=table_props)
1120
+
1121
+ def create_topic(self, bucket, name, topic_partitions, expected_retvals=[],
1122
+ message_timestamp_type=None, retention_ms=None, message_timestamp_after_max_ms=None,
1123
+ message_timestamp_before_max_ms=None):
1124
+ table_props = _encode_table_props(message_timestamp_type=message_timestamp_type,
1125
+ retention_ms=retention_ms,
1126
+ message_timestamp_after_max_ms=message_timestamp_after_max_ms,
1127
+ message_timestamp_before_max_ms=message_timestamp_before_max_ms)
1128
+
1129
+ self._create_table_internal(bucket=bucket, schema=KAFKA_TOPICS_SCHEMA_NAME, name=name, arrow_schema=None,
1130
+ expected_retvals=expected_retvals, topic_partitions=topic_partitions,
1131
+ table_props=table_props)
1132
+
1133
+ def _create_table_internal(self, bucket, schema, name, arrow_schema=None,
1134
+ txid=0, client_tags=[], expected_retvals=[], topic_partitions=0,
1135
+ create_imports_table=False, use_external_row_ids_allocation=False, table_props=None):
1115
1136
  """
1116
1137
  Create a table, use the following request
1117
1138
  POST /bucket/schema/table?table HTTP/1.1
@@ -1142,10 +1163,8 @@ class VastdbApi:
1142
1163
  if create_imports_table:
1143
1164
  url_params['sub-table'] = IMPORTED_OBJECTS_TABLE_NAME
1144
1165
 
1145
- if topic_partitions > 0:
1146
- table_props = _encode_table_props(message_timestamp_type=message_timestamp_type, retention_ms=retention_ms, message_timestamp_after_max_ms=message_timestamp_after_max_ms, message_timestamp_before_max_ms=message_timestamp_before_max_ms)
1147
- if table_props is not None:
1148
- url_params['table-props'] = table_props
1166
+ if table_props is not None:
1167
+ url_params['table-props'] = table_props
1149
1168
 
1150
1169
  self._request(
1151
1170
  method="POST",
@@ -1174,9 +1193,22 @@ class VastdbApi:
1174
1193
  endpoints = [self.url] # we cannot replace the host by a VIP address in HTTPS-based URLs
1175
1194
  return TableStatsResult(num_rows, size_in_bytes, is_external_rowid_alloc, tuple(endpoints))
1176
1195
 
1177
- def alter_table(self, bucket, schema, name, txid=0, client_tags=[], table_properties="",
1196
+ def alter_topic(self, bucket, name,
1178
1197
  new_name="", expected_retvals=[],
1179
- message_timestamp_type=None, retention_ms=None, message_timestamp_after_max_ms=None, message_timestamp_before_max_ms=None):
1198
+ message_timestamp_type=None, retention_ms=None, message_timestamp_after_max_ms=None,
1199
+ message_timestamp_before_max_ms=None):
1200
+ table_properties = _encode_table_props(message_timestamp_type=message_timestamp_type,
1201
+ retention_ms=retention_ms,
1202
+ message_timestamp_after_max_ms=message_timestamp_after_max_ms,
1203
+ message_timestamp_before_max_ms=message_timestamp_before_max_ms)
1204
+ if table_properties is None:
1205
+ table_properties = ""
1206
+
1207
+ self.alter_table(bucket=bucket, schema=KAFKA_TOPICS_SCHEMA_NAME, name=name,
1208
+ table_properties=table_properties, expected_retvals=expected_retvals)
1209
+
1210
+ def alter_table(self, bucket, schema, name, txid=0, client_tags=[], table_properties="",
1211
+ new_name="", expected_retvals=[]):
1180
1212
  """
1181
1213
  PUT /mybucket/myschema/mytable?table HTTP/1.1
1182
1214
  Content-Length: ContentLength
@@ -1188,10 +1220,8 @@ class VastdbApi:
1188
1220
  """
1189
1221
  builder = flatbuffers.Builder(1024)
1190
1222
 
1191
- if message_timestamp_type is not None or retention_ms is not None or message_timestamp_after_max_ms is not None or message_timestamp_before_max_ms is not None:
1192
- table_properties = _encode_table_props(message_timestamp_type=message_timestamp_type, retention_ms=retention_ms, message_timestamp_after_max_ms=message_timestamp_after_max_ms, message_timestamp_before_max_ms=message_timestamp_before_max_ms)
1193
- if table_properties is None:
1194
- table_properties = ""
1223
+ if table_properties is None:
1224
+ table_properties = ""
1195
1225
 
1196
1226
  properties = builder.CreateString(table_properties)
1197
1227
  tabular_alter_table.Start(builder)
@@ -1211,6 +1241,10 @@ class VastdbApi:
1211
1241
  url=self._url(bucket=bucket, schema=schema, table=name, command="table", url_params=url_params),
1212
1242
  data=alter_table_req, headers=headers)
1213
1243
 
1244
+ def drop_topic(self, bucket, name, expected_retvals=[]):
1245
+ self.drop_table(bucket=bucket, schema=KAFKA_TOPICS_SCHEMA_NAME, name=name,
1246
+ expected_retvals=expected_retvals)
1247
+
1214
1248
  def drop_table(self, bucket, schema, name, txid=0, client_tags=[], expected_retvals=[], remove_imports_table=False):
1215
1249
  """
1216
1250
  DELETE /mybucket/schema_path/mytable?table HTTP/1.1
@@ -1227,8 +1261,26 @@ class VastdbApi:
1227
1261
  url=self._url(bucket=bucket, schema=schema, table=name, command="table", url_params=url_params),
1228
1262
  headers=headers)
1229
1263
 
1264
+ def list_topics(self, bucket, max_keys=1000, next_key=0, name_prefix="",
1265
+ exact_match=False, expected_retvals=[], include_list_stats=False, count_only=False):
1266
+ return self._list_tables_internal(bucket=bucket, schema=KAFKA_TOPICS_SCHEMA_NAME,
1267
+ parse_properties=_decode_table_props, max_keys=max_keys,
1268
+ next_key=next_key, name_prefix=name_prefix, exact_match=exact_match,
1269
+ expected_retvals=expected_retvals,
1270
+ include_list_stats=include_list_stats, count_only=count_only)
1271
+
1230
1272
  def list_tables(self, bucket, schema, txid=0, client_tags=[], max_keys=1000, next_key=0, name_prefix="",
1231
1273
  exact_match=False, expected_retvals=[], include_list_stats=False, count_only=False):
1274
+ def parse_properties(x):
1275
+ return x
1276
+ return self._list_tables_internal(bucket=bucket, schema=schema, txid=txid, client_tags=client_tags,
1277
+ parse_properties=parse_properties, max_keys=max_keys, next_key=next_key,
1278
+ name_prefix=name_prefix, exact_match=exact_match,
1279
+ expected_retvals=expected_retvals,
1280
+ include_list_stats=include_list_stats, count_only=count_only)
1281
+
1282
+ def _list_tables_internal(self, bucket, schema, parse_properties, txid=0, client_tags=[], max_keys=1000, next_key=0, name_prefix="",
1283
+ exact_match=False, expected_retvals=[], include_list_stats=False, count_only=False):
1232
1284
  """
1233
1285
  GET /mybucket/schema_path?table HTTP/1.1
1234
1286
  tabular-txid: TransactionId
@@ -1265,7 +1317,7 @@ class VastdbApi:
1265
1317
  tables_length = lists.TablesLength()
1266
1318
  count = int(res_headers['tabular-list-count']) if 'tabular-list-count' in res_headers else tables_length
1267
1319
  for i in range(tables_length):
1268
- tables.append(_parse_table_info(lists.Tables(i)))
1320
+ tables.append(_parse_table_info(lists.Tables(i), parse_properties))
1269
1321
 
1270
1322
  return bucket_name, schema_name, tables, next_key, is_truncated, count
1271
1323
 
@@ -1837,7 +1889,7 @@ class VastdbApi:
1837
1889
  raise ValueError(f'bucket: {bucket} did not start from {bucket_name}')
1838
1890
  projections_length = lists.ProjectionsLength()
1839
1891
  for i in range(projections_length):
1840
- projections.append(_parse_table_info(lists.Projections(i)))
1892
+ projections.append(_parse_table_info(lists.Projections(i), lambda x: x))
1841
1893
 
1842
1894
  return bucket_name, schema_name, table_name, projections, next_key, is_truncated, count
1843
1895
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vastdb
3
- Version: 1.3.4
3
+ Version: 1.3.5
4
4
  Summary: VAST Data SDK
5
5
  Home-page: https://github.com/vast-data/vastdb_sdk
6
6
  Author: VAST DATA
@@ -151,7 +151,7 @@ vast_flatbuf/tabular/S3File.py,sha256=KC9c2oS5-JXwTTriUVFdjOvRG0B54Cq9kviSDZY3NI
151
151
  vast_flatbuf/tabular/VipRange.py,sha256=_BJd1RRZAcK76T9vlsHzXKYVsPVaz6WTEAqStMQCAUQ,2069
152
152
  vast_flatbuf/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
153
153
  vastdb/__init__.py,sha256=J1JjKiFkKC95BHowfh9kJfQFTjRce-QMsc6zF_FfxC0,432
154
- vastdb/_internal.py,sha256=asBizp21nQvYo1cE4Vs4OSH01s-5NyWZO2lb7_nP9oc,96538
154
+ vastdb/_internal.py,sha256=N3Z5uQ9aYj-UlzJTtBBXpht2JV685emtiVhawm1zlKQ,99787
155
155
  vastdb/bucket.py,sha256=5KuKhPjZOevznZqWHDVVocejvAy7dcwobPuV6BJCfPc,2544
156
156
  vastdb/config.py,sha256=1tMYtzKXerGcIUjH4tIGEvZNWvO4fviCEdcNCnELJZo,2269
157
157
  vastdb/conftest.py,sha256=X2kVveySPQYZlVBXUMoo7Oea5IsvmJzjdqq3fpH2kVw,3469
@@ -204,8 +204,8 @@ vastdb/tests/util.py,sha256=dpRJYbboDnlqL4qIdvScpp8--5fxRUBIcIYitrfcj9o,555
204
204
  vastdb/vast_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
205
205
  vastdb/vast_tests/test_ha.py,sha256=744P4G6VJ09RIkHhMQL4wlipCBJWQVMhyvUrSc4k1HQ,975
206
206
  vastdb/vast_tests/test_scale.py,sha256=5jGwOdZH6Tv5tPdZYPWoqcxOceI2jA5i2D1zNKZHER4,3958
207
- vastdb-1.3.4.dist-info/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
208
- vastdb-1.3.4.dist-info/METADATA,sha256=r-TcsDB09WBgIgLC-asWybRhn4pj0geXjD2zFVzveq0,1340
209
- vastdb-1.3.4.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
210
- vastdb-1.3.4.dist-info/top_level.txt,sha256=Vsj2MKtlhPg0J4so64slQtnwjhgoPmJgcG-6YcVAwVc,20
211
- vastdb-1.3.4.dist-info/RECORD,,
207
+ vastdb-1.3.5.dist-info/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
208
+ vastdb-1.3.5.dist-info/METADATA,sha256=Vsfa6X_4snlbZNOVzNZ5x_HKEDzZozAn1Q3i9rCpRv4,1340
209
+ vastdb-1.3.5.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
210
+ vastdb-1.3.5.dist-info/top_level.txt,sha256=Vsj2MKtlhPg0J4so64slQtnwjhgoPmJgcG-6YcVAwVc,20
211
+ vastdb-1.3.5.dist-info/RECORD,,
File without changes