aboutsummaryrefslogtreecommitdiffstats
path: root/py_bindings/log_db.pyi
blob: 49c10f2f11f10d84ebe49c45bb953e6a3e77c624 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
WRITE_DURABILITY_FLUSH: int
WRITE_DURABILITY_FLUSH_SYNC: int
READ_CONSISTENCY_EVENTUAL: int
READ_CONSISTENCY_STRONG: int

VALUE_INT: int
VALUE_DECIMAL: int
VALUE_STRING: int
VALUE_BYTES: int
VALUE_NULL: int

Record = list["Value"]

class Config:
    def data_dir(self, data_dir: str) -> "Config": ...
    def segment_size(self, segment_size: int) -> "Config": ...
    def write_durability(self, write_durability: int) -> "Config": ...
    def read_consistency(self, read_consistency: int) -> "Config": ...
    def schema(self, schema: list[tuple[str, "Type"]]) -> "Config": ...
    def primary_key(self, primary_key: str) -> "Config": ...
    def secondary_keys(self, secondary_keys: list[str]) -> "Config": ...
    def initialize(self) -> "DB": ...

class DB:
    @staticmethod
    def configure() -> Config: ...
    def upsert(self, record: Record) -> None: ...
    def get(self, key: str) -> Record: ...
    def find_by(self, key: str, value: "Value") -> list[Record]: ...
    def batch_find_by(self, key: str, values: list["Value"]) -> list[tuple[int, Record]]: ...
    def delete(self, key: str) -> list[Record]: ...
    def delete_by(self, key: str, value: "Value") -> list[Record]: ...
    def range_by(self, key: str, start: "Bound", end: "Bound") -> list[Record]: ...
    def tx_begin(self) -> None: ...
    def tx_commit(self) -> None: ...
    def tx_rollback(self) -> None: ...

class Value:
    @staticmethod
    def int(v: int) -> "Value": ...
    @staticmethod
    def decimal(v: str) -> "Value": ...
    @staticmethod
    def string(v: str) -> "Value": ...
    @staticmethod
    def bytes(v: bytes) -> "Value": ...
    @staticmethod
    def null() -> "Value": ...

    def kind(self) -> int: ...

    def as_int(self) -> int: ...
    def as_decimal(self) -> str: ...
    def as_string(self) -> str: ...
    def as_bytes(self) -> bytes: ...
    def as_null(self) -> None: ...

class Type:
    @staticmethod
    def int() -> "Type": ...
    @staticmethod
    def decimal() -> "Type": ...
    @staticmethod
    def string() -> "Type": ...
    @staticmethod
    def bytes() -> "Type": ...

    def nullable(self) -> "Type": ...

class Bound:
    @staticmethod
    def unbounded() -> "Bound": ...
    @staticmethod
    def included(v: "Value") -> "Bound": ...
    @staticmethod
    def excluded(v: "Value") -> "Bound": ...