Skip to content

Commit

Permalink
v1.1.0 - expanded to automatic map_size and default 1 TB allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayaan Hossain committed Nov 3, 2024
1 parent 0563548 commit c2432d7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ A `ShareDB` instance may be opened simultaneously in children, for reading in pa
```python
>>> from ShareDB import ShareDB # Easy import
>>> print(ShareDB.__version__) # Check version
1.0.5
1.1.0
>>> myDB = ShareDB(path='./test.ShareDB') # Store ShareDB locally
>>> myDB['Name'] = ['Ayaan Hossain'] # Insert information
>>> myDB.get(key='Name') # Retrieve values
Expand Down
13 changes: 9 additions & 4 deletions ShareDB/ShareDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ShareDB(object):
and Python 3.6 and above.
'''

__version__ = '1.0.7'
__version__ = '1.1.0'

__author__ = 'Ayaan Hossain'

Expand All @@ -73,11 +73,12 @@ def __init__(self,
(default=False)
readers - integer, max no. of processes that may read data in
parallel
(default=40 processes)
(default=100 processes)
buffer_size - integer, max no. of commits after which a sync is triggered
(default=100,000)
map_size - integer, max amount of bytes to allocate for storage
(default=1TB)
map_size - integer, max amount of bytes to allocate for storage,
if None, then the entire disk is marked for use (safe)
(default=10**12, or 1 TB)
Returns: self to ShareDB object.
Expand Down Expand Up @@ -175,6 +176,10 @@ def __init__(self,
if not os.path.isdir(path):
os.makedirs(path)

# Determine map_size
if map_size is None:
map_size, _, __ = shutil.disk_usage(path)

# Create configuration if absent
if not os.path.exists(path + 'ShareDB.config'):
config = ShareDB._store_config(
Expand Down
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
| `compress` | `string` | if `True` - will compress the values using `zlib` | `False` |
| `readers` | `integer` | max no. of processes that may read data in parallel | `100` |
| `buffer_size` | `integer` | max no. of commits after which a sync is triggered | `100,000` |
| `map_size` | `integer` | max amount of bytes to allocate for storage | `10**12` (1 TB) |
| `map_size` | `integer` | max amount of bytes to allocate for storage, if `None`, then the entire disk is marked for use (safe) | `10**12` (1 TB) |

**_Returns_**: `self` to `ShareDB` object.

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
name='ShareDB',

# Link: https://www.python.org/dev/peps/pep-0440/#version-scheme
version='1.0.7',
version='1.1.0',

description="An on-disk pythonic embedded key-value store for compressed data storage and distributed data analysis.",

Expand Down
2 changes: 1 addition & 1 deletion tests/test_ShareDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def get_myDB_resources(total):
compress=random.choice([True, False]),
readers=40,
buffer_size=100,
map_size=10**7)
map_size=random.choice([None, 10**7]))

# Populate myDB with random items and record keys
key_val_dict = {}
Expand Down

0 comments on commit c2432d7

Please sign in to comment.