sop4py 2.0.7__tar.gz → 2.0.9__tar.gz

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.

Potentially problematic release.


This version of sop4py might be problematic. Click here for more details.

Files changed (27) hide show
  1. {sop4py-2.0.7/sop4py.egg-info → sop4py-2.0.9}/PKG-INFO +120 -3
  2. {sop4py-2.0.7 → sop4py-2.0.9}/README.md +119 -2
  3. {sop4py-2.0.7 → sop4py-2.0.9}/pyproject.toml +1 -1
  4. {sop4py-2.0.7 → sop4py-2.0.9/sop4py.egg-info}/PKG-INFO +120 -3
  5. {sop4py-2.0.7 → sop4py-2.0.9}/MANIFEST.in +0 -0
  6. {sop4py-2.0.7 → sop4py-2.0.9}/setup.cfg +0 -0
  7. {sop4py-2.0.7 → sop4py-2.0.9}/sop/__init__.py +0 -0
  8. {sop4py-2.0.7 → sop4py-2.0.9}/sop/btree.py +0 -0
  9. {sop4py-2.0.7 → sop4py-2.0.9}/sop/call_go.py +0 -0
  10. {sop4py-2.0.7 → sop4py-2.0.9}/sop/context.py +0 -0
  11. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_amd64darwin.dylib +0 -0
  12. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_amd64darwin.h +0 -0
  13. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_amd64linux.h +0 -0
  14. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_amd64linux.so +0 -0
  15. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_amd64windows.dll +0 -0
  16. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_amd64windows.h +0 -0
  17. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_arm64darwin.dylib +0 -0
  18. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_arm64darwin.h +0 -0
  19. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_arm64linux.h +0 -0
  20. {sop4py-2.0.7 → sop4py-2.0.9}/sop/libjsondb_arm64linux.so +0 -0
  21. {sop4py-2.0.7 → sop4py-2.0.9}/sop/redis.py +0 -0
  22. {sop4py-2.0.7 → sop4py-2.0.9}/sop/test_btree.py +0 -0
  23. {sop4py-2.0.7 → sop4py-2.0.9}/sop/test_btree_idx.py +0 -0
  24. {sop4py-2.0.7 → sop4py-2.0.9}/sop/transaction.py +0 -0
  25. {sop4py-2.0.7 → sop4py-2.0.9}/sop4py.egg-info/SOURCES.txt +0 -0
  26. {sop4py-2.0.7 → sop4py-2.0.9}/sop4py.egg-info/dependency_links.txt +0 -0
  27. {sop4py-2.0.7 → sop4py-2.0.9}/sop4py.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sop4py
3
- Version: 2.0.7
3
+ Version: 2.0.9
4
4
  Summary: Scalable Objects Persistence for Python. Release Candidate 1 (RC1) Release
5
5
  Author-email: Gerardo Recinto <gerardorecinto@yahoo.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -47,7 +47,7 @@ Following steps outlines how to use the Scalable Objects Persistence code librar
47
47
  * Open the global Redis connection
48
48
  * Create a transaction
49
49
  * Begin a transaction
50
- * Create a new B-tree, or Open an existing B-tree
50
+ * Create new B-tree(s), or Open existing B-tree(s)
51
51
  * Manage data, do some CRUD operations
52
52
  * Commit the transaction
53
53
 
@@ -59,7 +59,9 @@ from sop import btree
59
59
  from sop import context
60
60
  from sop import redis
61
61
 
62
+ # Store info & Registry home base folders. Array of strings of two elements, one for Active & another, for passive folder.
62
63
  stores_folders = ("/disk1", "/disk2")
64
+
63
65
  ec = {
64
66
  # Erasure Config default entry(key="") will allow different B-tree (data store) to share same EC structure.
65
67
  # You can also specify a different one exclusive to a B-tree with the given name.
@@ -128,8 +130,123 @@ t.commit(ctx)
128
130
  print("ended.")
129
131
  ```
130
132
 
133
+ # Index Specification
134
+ You can specify a Key structure that can be complex like a class and cherry pick the fields you want to affect the indexing and data organization in the B-tree. Like pick two fields from the Key class as comprised your index. And optionally specify the sort order, like 1st field is descending order and the 2nd field ascending.
135
+
136
+ Here is a good example to illustrate this use-case.
137
+ ```
138
+ import unittest
139
+ from . import transaction
140
+ from . import btree
141
+ from . import context
142
+
143
+ from .redis import *
144
+ from .test_btree import to
145
+
146
+ from dataclasses import dataclass
147
+
148
+ # Define your Key data class with two fields.
149
+ @dataclass
150
+ class Key:
151
+ address1: str
152
+ address2: str
153
+
154
+ # Define your Value data class.
155
+ @dataclass
156
+ class Person:
157
+ first_name: str
158
+ last_name: str
159
+
160
+ # Create a context for use in Transaction & B-tree API calls.
161
+ ctx = context.Context()
162
+
163
+ class TestBtreeIndexSpecs(unittest.TestCase):
164
+ def setUpClass():
165
+ ro = RedisOptions()
166
+ Redis.open_connection(ro)
167
+
168
+ t = transaction.Transaction(ctx, to)
169
+ t.begin()
170
+
171
+ cache = btree.CacheConfig()
172
+ bo = btree.BtreeOptions("personidx", True, cache_config=cache)
173
+
174
+ # Specify Small size, meaning, both Key & Value object values will be stored in the B-tree node segment.
175
+ # This is very efficient/appropriate for small data structure sizes (of Key & Value pairs).
176
+ bo.set_value_data_size(btree.ValueDataSize.Small)
177
+
178
+ # Specify that the B-tree will host non-primitive Key data type, i.e. - it is a dataclass.
179
+ bo.is_primitive_key = False
180
+
181
+ btree.Btree.new(
182
+ ctx,
183
+ bo,
184
+ t,
185
+ # Specify the Index fields of the Key class. You control how many fields get included
186
+ # and each field's sort order (asc or desc).
187
+ btree.IndexSpecification(
188
+ index_fields=(
189
+ # 1st field is "address1" in descending order.
190
+ btree.IndexFieldSpecification(
191
+ "address1", ascending_sort_order=False
192
+ ),
193
+ # 2nd field is "address2" in ascending order (default).
194
+ btree.IndexFieldSpecification("address2"),
195
+ )
196
+ ),
197
+ )
198
+
199
+ # Commit the transaction to finalize it.
200
+ t.commit(ctx)
201
+
202
+ def test_add(self):
203
+ t = transaction.Transaction(ctx, to)
204
+ t.begin()
205
+
206
+ b3 = btree.Btree.open(ctx, "personidx", t)
207
+
208
+ pk = Key(address1="123 main st", address2="Fremont, CA")
209
+ l = [btree.Item(pk, Person(first_name="joe", last_name="petit"))]
210
+
211
+ # Populate with some sample Key & Value pairs of data set.
212
+ for i in range(20):
213
+ pk = Key(address1=f"{i}123 main st", address2="Fremont, CA")
214
+ l.append(btree.Item(pk, Person(first_name=f"joe{i}", last_name="petit")))
215
+
216
+ # Submit the entire generated batch to be added to B-tree in one call.
217
+ b3.add_if_not_exists(ctx, l)
218
+
219
+ # Commit the changes.
220
+ t.commit(ctx)
221
+
222
+ def test_get_items_batch(self):
223
+ t = transaction.Transaction(ctx, to)
224
+ t.begin()
225
+
226
+ b3 = btree.Btree.open(ctx, "personidx", t)
227
+
228
+ # Fetch the data starting with 1st record up to 10th.
229
+ # Paging info is:
230
+ # 0 page offset means the current record where the cursor is located, 0 skipped items, 10 items to fetch.
231
+ # In forward direction.
232
+ items = b3.get_items(
233
+ ctx,
234
+ btree.PagingInfo(0, 0, 10, direction=btree.PagingDirection.Forward.value),
235
+ )
236
+
237
+ print(f"read items from indexed keyed b-tree {items}")
238
+
239
+ # End the transaction by calling commit. Commit in this case will also double check that the fetched items
240
+ # did not change while in the transaction. If there is then it will return an error to denote this and
241
+ # thus, your code can treat it as failure if it needs to, like in a financial transaction.
242
+ t.commit(ctx)
243
+
244
+ ```
245
+
246
+ ** Above is the same code of "sop/test_btree_idx.py" unit test file.
247
+
131
248
  # SOP in Github
132
249
  SOP open source project (MIT license) is in github. You can checkout the "...sop/jsondb/" package which contains the Go code enabling general purpose JSON data management & the Python wrapper, coding guideline of which, was described above.
133
250
 
134
251
  Please feel free to join the SOP project if you have the bandwidth and participate/co-own/lead! the project engineering.
135
- SOP project link: https://github.com/sharedcode/sop
252
+ SOP project links: https://github.com/sharedcode/sop & https://pypi.org/project/sop4py
@@ -36,7 +36,7 @@ Following steps outlines how to use the Scalable Objects Persistence code librar
36
36
  * Open the global Redis connection
37
37
  * Create a transaction
38
38
  * Begin a transaction
39
- * Create a new B-tree, or Open an existing B-tree
39
+ * Create new B-tree(s), or Open existing B-tree(s)
40
40
  * Manage data, do some CRUD operations
41
41
  * Commit the transaction
42
42
 
@@ -48,7 +48,9 @@ from sop import btree
48
48
  from sop import context
49
49
  from sop import redis
50
50
 
51
+ # Store info & Registry home base folders. Array of strings of two elements, one for Active & another, for passive folder.
51
52
  stores_folders = ("/disk1", "/disk2")
53
+
52
54
  ec = {
53
55
  # Erasure Config default entry(key="") will allow different B-tree (data store) to share same EC structure.
54
56
  # You can also specify a different one exclusive to a B-tree with the given name.
@@ -117,8 +119,123 @@ t.commit(ctx)
117
119
  print("ended.")
118
120
  ```
119
121
 
122
+ # Index Specification
123
+ You can specify a Key structure that can be complex like a class and cherry pick the fields you want to affect the indexing and data organization in the B-tree. Like pick two fields from the Key class as comprised your index. And optionally specify the sort order, like 1st field is descending order and the 2nd field ascending.
124
+
125
+ Here is a good example to illustrate this use-case.
126
+ ```
127
+ import unittest
128
+ from . import transaction
129
+ from . import btree
130
+ from . import context
131
+
132
+ from .redis import *
133
+ from .test_btree import to
134
+
135
+ from dataclasses import dataclass
136
+
137
+ # Define your Key data class with two fields.
138
+ @dataclass
139
+ class Key:
140
+ address1: str
141
+ address2: str
142
+
143
+ # Define your Value data class.
144
+ @dataclass
145
+ class Person:
146
+ first_name: str
147
+ last_name: str
148
+
149
+ # Create a context for use in Transaction & B-tree API calls.
150
+ ctx = context.Context()
151
+
152
+ class TestBtreeIndexSpecs(unittest.TestCase):
153
+ def setUpClass():
154
+ ro = RedisOptions()
155
+ Redis.open_connection(ro)
156
+
157
+ t = transaction.Transaction(ctx, to)
158
+ t.begin()
159
+
160
+ cache = btree.CacheConfig()
161
+ bo = btree.BtreeOptions("personidx", True, cache_config=cache)
162
+
163
+ # Specify Small size, meaning, both Key & Value object values will be stored in the B-tree node segment.
164
+ # This is very efficient/appropriate for small data structure sizes (of Key & Value pairs).
165
+ bo.set_value_data_size(btree.ValueDataSize.Small)
166
+
167
+ # Specify that the B-tree will host non-primitive Key data type, i.e. - it is a dataclass.
168
+ bo.is_primitive_key = False
169
+
170
+ btree.Btree.new(
171
+ ctx,
172
+ bo,
173
+ t,
174
+ # Specify the Index fields of the Key class. You control how many fields get included
175
+ # and each field's sort order (asc or desc).
176
+ btree.IndexSpecification(
177
+ index_fields=(
178
+ # 1st field is "address1" in descending order.
179
+ btree.IndexFieldSpecification(
180
+ "address1", ascending_sort_order=False
181
+ ),
182
+ # 2nd field is "address2" in ascending order (default).
183
+ btree.IndexFieldSpecification("address2"),
184
+ )
185
+ ),
186
+ )
187
+
188
+ # Commit the transaction to finalize it.
189
+ t.commit(ctx)
190
+
191
+ def test_add(self):
192
+ t = transaction.Transaction(ctx, to)
193
+ t.begin()
194
+
195
+ b3 = btree.Btree.open(ctx, "personidx", t)
196
+
197
+ pk = Key(address1="123 main st", address2="Fremont, CA")
198
+ l = [btree.Item(pk, Person(first_name="joe", last_name="petit"))]
199
+
200
+ # Populate with some sample Key & Value pairs of data set.
201
+ for i in range(20):
202
+ pk = Key(address1=f"{i}123 main st", address2="Fremont, CA")
203
+ l.append(btree.Item(pk, Person(first_name=f"joe{i}", last_name="petit")))
204
+
205
+ # Submit the entire generated batch to be added to B-tree in one call.
206
+ b3.add_if_not_exists(ctx, l)
207
+
208
+ # Commit the changes.
209
+ t.commit(ctx)
210
+
211
+ def test_get_items_batch(self):
212
+ t = transaction.Transaction(ctx, to)
213
+ t.begin()
214
+
215
+ b3 = btree.Btree.open(ctx, "personidx", t)
216
+
217
+ # Fetch the data starting with 1st record up to 10th.
218
+ # Paging info is:
219
+ # 0 page offset means the current record where the cursor is located, 0 skipped items, 10 items to fetch.
220
+ # In forward direction.
221
+ items = b3.get_items(
222
+ ctx,
223
+ btree.PagingInfo(0, 0, 10, direction=btree.PagingDirection.Forward.value),
224
+ )
225
+
226
+ print(f"read items from indexed keyed b-tree {items}")
227
+
228
+ # End the transaction by calling commit. Commit in this case will also double check that the fetched items
229
+ # did not change while in the transaction. If there is then it will return an error to denote this and
230
+ # thus, your code can treat it as failure if it needs to, like in a financial transaction.
231
+ t.commit(ctx)
232
+
233
+ ```
234
+
235
+ ** Above is the same code of "sop/test_btree_idx.py" unit test file.
236
+
120
237
  # SOP in Github
121
238
  SOP open source project (MIT license) is in github. You can checkout the "...sop/jsondb/" package which contains the Go code enabling general purpose JSON data management & the Python wrapper, coding guideline of which, was described above.
122
239
 
123
240
  Please feel free to join the SOP project if you have the bandwidth and participate/co-own/lead! the project engineering.
124
- SOP project link: https://github.com/sharedcode/sop
241
+ SOP project links: https://github.com/sharedcode/sop & https://pypi.org/project/sop4py
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "sop4py"
10
- version = "2.0.7"
10
+ version = "2.0.9"
11
11
  authors = [
12
12
  { name="Gerardo Recinto", email="gerardorecinto@yahoo.com" },
13
13
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sop4py
3
- Version: 2.0.7
3
+ Version: 2.0.9
4
4
  Summary: Scalable Objects Persistence for Python. Release Candidate 1 (RC1) Release
5
5
  Author-email: Gerardo Recinto <gerardorecinto@yahoo.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -47,7 +47,7 @@ Following steps outlines how to use the Scalable Objects Persistence code librar
47
47
  * Open the global Redis connection
48
48
  * Create a transaction
49
49
  * Begin a transaction
50
- * Create a new B-tree, or Open an existing B-tree
50
+ * Create new B-tree(s), or Open existing B-tree(s)
51
51
  * Manage data, do some CRUD operations
52
52
  * Commit the transaction
53
53
 
@@ -59,7 +59,9 @@ from sop import btree
59
59
  from sop import context
60
60
  from sop import redis
61
61
 
62
+ # Store info & Registry home base folders. Array of strings of two elements, one for Active & another, for passive folder.
62
63
  stores_folders = ("/disk1", "/disk2")
64
+
63
65
  ec = {
64
66
  # Erasure Config default entry(key="") will allow different B-tree (data store) to share same EC structure.
65
67
  # You can also specify a different one exclusive to a B-tree with the given name.
@@ -128,8 +130,123 @@ t.commit(ctx)
128
130
  print("ended.")
129
131
  ```
130
132
 
133
+ # Index Specification
134
+ You can specify a Key structure that can be complex like a class and cherry pick the fields you want to affect the indexing and data organization in the B-tree. Like pick two fields from the Key class as comprised your index. And optionally specify the sort order, like 1st field is descending order and the 2nd field ascending.
135
+
136
+ Here is a good example to illustrate this use-case.
137
+ ```
138
+ import unittest
139
+ from . import transaction
140
+ from . import btree
141
+ from . import context
142
+
143
+ from .redis import *
144
+ from .test_btree import to
145
+
146
+ from dataclasses import dataclass
147
+
148
+ # Define your Key data class with two fields.
149
+ @dataclass
150
+ class Key:
151
+ address1: str
152
+ address2: str
153
+
154
+ # Define your Value data class.
155
+ @dataclass
156
+ class Person:
157
+ first_name: str
158
+ last_name: str
159
+
160
+ # Create a context for use in Transaction & B-tree API calls.
161
+ ctx = context.Context()
162
+
163
+ class TestBtreeIndexSpecs(unittest.TestCase):
164
+ def setUpClass():
165
+ ro = RedisOptions()
166
+ Redis.open_connection(ro)
167
+
168
+ t = transaction.Transaction(ctx, to)
169
+ t.begin()
170
+
171
+ cache = btree.CacheConfig()
172
+ bo = btree.BtreeOptions("personidx", True, cache_config=cache)
173
+
174
+ # Specify Small size, meaning, both Key & Value object values will be stored in the B-tree node segment.
175
+ # This is very efficient/appropriate for small data structure sizes (of Key & Value pairs).
176
+ bo.set_value_data_size(btree.ValueDataSize.Small)
177
+
178
+ # Specify that the B-tree will host non-primitive Key data type, i.e. - it is a dataclass.
179
+ bo.is_primitive_key = False
180
+
181
+ btree.Btree.new(
182
+ ctx,
183
+ bo,
184
+ t,
185
+ # Specify the Index fields of the Key class. You control how many fields get included
186
+ # and each field's sort order (asc or desc).
187
+ btree.IndexSpecification(
188
+ index_fields=(
189
+ # 1st field is "address1" in descending order.
190
+ btree.IndexFieldSpecification(
191
+ "address1", ascending_sort_order=False
192
+ ),
193
+ # 2nd field is "address2" in ascending order (default).
194
+ btree.IndexFieldSpecification("address2"),
195
+ )
196
+ ),
197
+ )
198
+
199
+ # Commit the transaction to finalize it.
200
+ t.commit(ctx)
201
+
202
+ def test_add(self):
203
+ t = transaction.Transaction(ctx, to)
204
+ t.begin()
205
+
206
+ b3 = btree.Btree.open(ctx, "personidx", t)
207
+
208
+ pk = Key(address1="123 main st", address2="Fremont, CA")
209
+ l = [btree.Item(pk, Person(first_name="joe", last_name="petit"))]
210
+
211
+ # Populate with some sample Key & Value pairs of data set.
212
+ for i in range(20):
213
+ pk = Key(address1=f"{i}123 main st", address2="Fremont, CA")
214
+ l.append(btree.Item(pk, Person(first_name=f"joe{i}", last_name="petit")))
215
+
216
+ # Submit the entire generated batch to be added to B-tree in one call.
217
+ b3.add_if_not_exists(ctx, l)
218
+
219
+ # Commit the changes.
220
+ t.commit(ctx)
221
+
222
+ def test_get_items_batch(self):
223
+ t = transaction.Transaction(ctx, to)
224
+ t.begin()
225
+
226
+ b3 = btree.Btree.open(ctx, "personidx", t)
227
+
228
+ # Fetch the data starting with 1st record up to 10th.
229
+ # Paging info is:
230
+ # 0 page offset means the current record where the cursor is located, 0 skipped items, 10 items to fetch.
231
+ # In forward direction.
232
+ items = b3.get_items(
233
+ ctx,
234
+ btree.PagingInfo(0, 0, 10, direction=btree.PagingDirection.Forward.value),
235
+ )
236
+
237
+ print(f"read items from indexed keyed b-tree {items}")
238
+
239
+ # End the transaction by calling commit. Commit in this case will also double check that the fetched items
240
+ # did not change while in the transaction. If there is then it will return an error to denote this and
241
+ # thus, your code can treat it as failure if it needs to, like in a financial transaction.
242
+ t.commit(ctx)
243
+
244
+ ```
245
+
246
+ ** Above is the same code of "sop/test_btree_idx.py" unit test file.
247
+
131
248
  # SOP in Github
132
249
  SOP open source project (MIT license) is in github. You can checkout the "...sop/jsondb/" package which contains the Go code enabling general purpose JSON data management & the Python wrapper, coding guideline of which, was described above.
133
250
 
134
251
  Please feel free to join the SOP project if you have the bandwidth and participate/co-own/lead! the project engineering.
135
- SOP project link: https://github.com/sharedcode/sop
252
+ SOP project links: https://github.com/sharedcode/sop & https://pypi.org/project/sop4py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes