vastdb 0.0.5.8__py3-none-any.whl → 0.0.5.9__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 +36 -9
- {vastdb-0.0.5.8.dist-info → vastdb-0.0.5.9.dist-info}/METADATA +1 -1
- {vastdb-0.0.5.8.dist-info → vastdb-0.0.5.9.dist-info}/RECORD +6 -6
- {vastdb-0.0.5.8.dist-info → vastdb-0.0.5.9.dist-info}/WHEEL +1 -1
- {vastdb-0.0.5.8.dist-info → vastdb-0.0.5.9.dist-info}/LICENSE +0 -0
- {vastdb-0.0.5.8.dist-info → vastdb-0.0.5.9.dist-info}/top_level.txt +0 -0
vastdb/api.py
CHANGED
|
@@ -681,18 +681,42 @@ def _iter_nested_arrays(column: pa.Array) -> Iterator[pa.Array]:
|
|
|
681
681
|
elif isinstance(column.type, pa.ListType):
|
|
682
682
|
yield from _iter_nested_arrays(column.values) # Note: Map is serialized in VAST as a List<Struct<K, V>>
|
|
683
683
|
|
|
684
|
+
class ValidateInList:
|
|
685
|
+
def __init__(self, *args):
|
|
686
|
+
self.candidates = [x.strip() for x in args]
|
|
687
|
+
|
|
688
|
+
def __call__(self, x):
|
|
689
|
+
x = x.strip()
|
|
690
|
+
if x not in self.candidates:
|
|
691
|
+
raise Exception(f'{x} is not in {self.candidates}')
|
|
692
|
+
return x
|
|
693
|
+
|
|
694
|
+
def __getitem__(self, x):
|
|
695
|
+
return self
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
_int_coding = (lambda x: str(int(x)), lambda x: int(x))
|
|
699
|
+
_prop_coding = {
|
|
700
|
+
"message.timestamp.type": ValidateInList('CreateTime', 'LogAppendTime'),
|
|
701
|
+
"retention.ms": _int_coding,
|
|
702
|
+
"message.timestamp.after.max.ms": _int_coding,
|
|
703
|
+
"message.timestamp.before.max.ms": _int_coding
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
|
|
684
707
|
def _encode_table_props(**kwargs):
|
|
685
708
|
if all([v is None for v in kwargs.values()]):
|
|
686
709
|
return None
|
|
687
710
|
else:
|
|
688
|
-
|
|
711
|
+
pairs = [(k.replace("_", ".").strip(), v) for k, v in kwargs.items() if v is not None]
|
|
712
|
+
return "$".join([f"{k}={_prop_coding[k][0](v)}" for k, v in pairs])
|
|
689
713
|
|
|
690
714
|
|
|
691
715
|
def _decode_table_props(s):
|
|
692
716
|
if s.strip() == '':
|
|
693
717
|
return {}
|
|
694
|
-
|
|
695
|
-
|
|
718
|
+
triplets = [(x.strip(), x.strip().replace(".", "_"), y.strip()) for x, y in [z.split('=') for z in s.strip().split("$")]]
|
|
719
|
+
return {y: _prop_coding[x][1](z) for x, y, z in triplets if z != ''}
|
|
696
720
|
|
|
697
721
|
|
|
698
722
|
TableInfo = namedtuple('table_info', 'name properties handle num_rows size_in_bytes num_partitions')
|
|
@@ -991,9 +1015,9 @@ class VastdbApi:
|
|
|
991
1015
|
|
|
992
1016
|
return snapshots, is_truncated, marker
|
|
993
1017
|
|
|
994
|
-
def create_table(self, bucket, schema, name, arrow_schema, txid=0, client_tags=[], expected_retvals=[],
|
|
1018
|
+
def create_table(self, bucket, schema, name, arrow_schema=None, txid=0, client_tags=[], expected_retvals=[],
|
|
995
1019
|
topic_partitions=0, create_imports_table=False, use_external_row_ids_allocation=False,
|
|
996
|
-
|
|
1020
|
+
message_timestamp_type=None, retention_ms=None, message_timestamp_after_max_ms=None, message_timestamp_before_max_ms=None):
|
|
997
1021
|
"""
|
|
998
1022
|
Create a table, use the following request
|
|
999
1023
|
POST /bucket/schema/table?table HTTP/1.1
|
|
@@ -1011,12 +1035,15 @@ class VastdbApi:
|
|
|
1011
1035
|
"""
|
|
1012
1036
|
headers = self._fill_common_headers(txid=txid, client_tags=client_tags)
|
|
1013
1037
|
|
|
1038
|
+
if arrow_schema is None:
|
|
1039
|
+
arrow_schema = pa.schema([])
|
|
1040
|
+
|
|
1014
1041
|
serialized_schema = arrow_schema.serialize()
|
|
1015
1042
|
headers['Content-Length'] = str(len(serialized_schema))
|
|
1016
1043
|
url_params = {'topic_partitions': str(topic_partitions)} if topic_partitions else {}
|
|
1017
1044
|
|
|
1018
1045
|
if topic_partitions > 0:
|
|
1019
|
-
table_props = _encode_table_props(
|
|
1046
|
+
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)
|
|
1020
1047
|
if table_props is not None:
|
|
1021
1048
|
url_params['table-props'] = table_props
|
|
1022
1049
|
|
|
@@ -1072,7 +1099,7 @@ class VastdbApi:
|
|
|
1072
1099
|
|
|
1073
1100
|
def alter_table(self, bucket, schema, name, txid=0, client_tags=[], table_properties="",
|
|
1074
1101
|
new_name="", expected_retvals=[],
|
|
1075
|
-
|
|
1102
|
+
message_timestamp_type=None, retention_ms=None, message_timestamp_after_max_ms=None, message_timestamp_before_max_ms=None):
|
|
1076
1103
|
"""
|
|
1077
1104
|
PUT /mybucket/myschema/mytable?table HTTP/1.1
|
|
1078
1105
|
Content-Length: ContentLength
|
|
@@ -1084,8 +1111,8 @@ class VastdbApi:
|
|
|
1084
1111
|
"""
|
|
1085
1112
|
builder = flatbuffers.Builder(1024)
|
|
1086
1113
|
|
|
1087
|
-
if
|
|
1088
|
-
table_properties = _encode_table_props(
|
|
1114
|
+
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:
|
|
1115
|
+
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)
|
|
1089
1116
|
if table_properties is None:
|
|
1090
1117
|
table_properties = ""
|
|
1091
1118
|
|
|
@@ -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=LVNRk-JDupQ0sse81NDYUcLmZnCNgvbPPViFOqYiT24,128132
|
|
152
|
+
vastdb-0.0.5.9.dist-info/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
|
|
153
|
+
vastdb-0.0.5.9.dist-info/METADATA,sha256=uFA7pciywuqrIZhun9u6OQdlm1gSy5rLYc6dzU5ra_E,1349
|
|
154
|
+
vastdb-0.0.5.9.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
155
|
+
vastdb-0.0.5.9.dist-info/top_level.txt,sha256=Vsj2MKtlhPg0J4so64slQtnwjhgoPmJgcG-6YcVAwVc,20
|
|
156
|
+
vastdb-0.0.5.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|