-
Notifications
You must be signed in to change notification settings - Fork 409
Expand file tree
/
Copy path__init__.py
More file actions
255 lines (243 loc) · 5.96 KB
/
__init__.py
File metadata and controls
255 lines (243 loc) · 5.96 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from pyfory.lib import mmh3
from pyfory._fory import (
Fory,
ThreadSafeFory,
)
try:
from pyfory.serialization import ENABLE_FORY_CYTHON_SERIALIZATION
except ImportError:
ENABLE_FORY_CYTHON_SERIALIZATION = False
from pyfory.registry import TypeInfo
if ENABLE_FORY_CYTHON_SERIALIZATION:
from pyfory.serialization import Fory, TypeInfo # noqa: F401,F811
from pyfory.serializer import ( # noqa: F401 # pylint: disable=unused-import
Serializer,
BooleanSerializer,
ByteSerializer,
Int16Serializer,
Int32Serializer,
Int64Serializer,
Varint32Serializer,
Varint64Serializer,
TaggedInt64Serializer,
Uint8Serializer,
Uint16Serializer,
Uint32Serializer,
VarUint32Serializer,
Uint64Serializer,
VarUint64Serializer,
TaggedUint64Serializer,
Float32Serializer,
Float64Serializer,
BFloat16Serializer,
StringSerializer,
DateSerializer,
TimestampSerializer,
CollectionSerializer,
ListSerializer,
TupleSerializer,
StringArraySerializer,
SetSerializer,
MapSerializer,
EnumSerializer,
SliceSerializer,
FunctionSerializer,
TypeSerializer,
MethodSerializer,
ReduceSerializer,
StatefulSerializer,
)
from pyfory.struct import DataClassSerializer
from pyfory.field import dataclass, field # noqa: F401 # pylint: disable=unused-import
from pyfory.types import ( # noqa: F401 # pylint: disable=unused-import
TypeId,
Ref,
int8,
int16,
int32,
int64,
fixed_int32,
fixed_int64,
tagged_int64,
uint8,
uint16,
uint32,
fixed_uint32,
uint64,
fixed_uint64,
tagged_uint64,
float32,
float64,
bfloat16 as bfloat16_type,
bfloat16_array,
int8_array,
uint8_array,
int16_array,
int32_array,
int64_array,
uint16_array,
uint32_array,
uint64_array,
float32_array,
float64_array,
bool_ndarray,
int8_ndarray,
uint8_ndarray,
int16_ndarray,
int32_ndarray,
int64_ndarray,
uint16_ndarray,
uint32_ndarray,
uint64_ndarray,
float32_ndarray,
float64_ndarray,
)
from pyfory.type_util import ( # noqa: F401 # pylint: disable=unused-import
record_class_factory,
get_qualified_classname,
dataslots,
)
from pyfory.policy import DeserializationPolicy # noqa: F401 # pylint: disable=unused-import
from pyfory.buffer import Buffer # noqa: F401 # pylint: disable=unused-import
# BFloat16 support
from pyfory.bfloat16 import bfloat16 # noqa: F401
from pyfory.bfloat16_array import BFloat16Array # noqa: F401
# Keep compatibility with existing API naming.
BFloat16 = bfloat16
__version__ = "0.16.0.dev0"
__all__ = [
# Core classes
"Fory",
"ThreadSafeFory",
"TypeInfo",
"Buffer",
"DeserializationPolicy",
# Field metadata
"field",
"dataclass",
# Type utilities
"record_class_factory",
"get_qualified_classname",
"TypeId",
"Ref",
"int8",
"int16",
"int32",
"int64",
"fixed_int32",
"fixed_int64",
"tagged_int64",
"uint8",
"uint16",
"uint32",
"fixed_uint32",
"uint64",
"fixed_uint64",
"tagged_uint64",
"float32",
"float64",
"BFloat16",
"BFloat16Array",
"bfloat16",
"bfloat16_array",
"int8_array",
"uint8_array",
"int16_array",
"int32_array",
"int64_array",
"uint16_array",
"uint32_array",
"uint64_array",
"float32_array",
"float64_array",
"bool_ndarray",
"int8_ndarray",
"uint8_ndarray",
"int16_ndarray",
"int32_ndarray",
"int64_ndarray",
"uint16_ndarray",
"uint32_ndarray",
"uint64_ndarray",
"float32_ndarray",
"float64_ndarray",
"dataslots",
# Serializers
"Serializer",
"BooleanSerializer",
"ByteSerializer",
"Int16Serializer",
"Int32Serializer",
"Int64Serializer",
"Varint32Serializer",
"Varint64Serializer",
"TaggedInt64Serializer",
"Uint8Serializer",
"Uint16Serializer",
"Uint32Serializer",
"VarUint32Serializer",
"Uint64Serializer",
"VarUint64Serializer",
"TaggedUint64Serializer",
"Float32Serializer",
"Float64Serializer",
"BFloat16Serializer",
"StringSerializer",
"DateSerializer",
"TimestampSerializer",
"CollectionSerializer",
"ListSerializer",
"TupleSerializer",
"StringArraySerializer",
"SetSerializer",
"MapSerializer",
"EnumSerializer",
"SliceSerializer",
"DataClassSerializer",
"FunctionSerializer",
"TypeSerializer",
"MethodSerializer",
"ReduceSerializer",
"StatefulSerializer",
"mmh3",
# Version
"__version__",
]
# Try to import format utilities (requires pyarrow)
import warnings
try:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=RuntimeWarning)
from pyfory.format import ( # noqa: F401 # pylint: disable=unused-import
create_row_encoder,
RowData,
encoder,
Encoder,
)
__all__.extend(
[
"format",
"create_row_encoder",
"RowData",
"encoder",
"Encoder",
]
)
except (AttributeError, ImportError):
pass