%global _empty_manifest_terminate_build 0 Name: python-kvfile Version: 0.0.13 Release: 1 Summary: Simple File-based KV-Store License: MIT URL: https://github.com/akariv/kvstore Source0: https://mirrors.nju.edu.cn/pypi/web/packages/4d/69/a9a649494b76b859d21bad41f6976c9d7ead98194ed207af20ea3a3f10f5/kvfile-0.0.13.tar.gz BuildArch: noarch Requires: python3-isodate Requires: python3-cachetools Requires: python3-pylama Requires: python3-tox Requires: python3-plyvel %description # kvfile [![Travis](https://img.shields.io/travis/akariv/kvfile/master.svg)](https://travis-ci.org/akariv/kvfile) [![Coveralls](http://img.shields.io/coveralls/akariv/kvfile.svg?branch=master)](https://coveralls.io/r/akariv/kvfile?branch=master) A simple Key-Value store that's file based - so can accommodate large data sets with a small memory footprint. Internally will use the faster `leveldb` as a storage backend or `sqlite3` as fallback if `leveldb` is not available. ## The Basics The API should feel familiar to anyone working with Python. It exposes `get`, `keys` and `items` for reading from the DB, and `set` for setting a value in the DB. ### Initializing ```python import datetime import decimal from kvfile import KVFile kv = KVFile() ``` ### Setting values ```python kv.set('s', 'value') kv.set('i', 123) kv.set('d', datetime.datetime.fromtimestamp(12325)) kv.set('n', decimal.Decimal('1234.56')) kv.set('ss', set(range(10))) kv.set('o', dict(d=decimal.Decimal('1234.58'), n=datetime.datetime.fromtimestamp(12325))) ``` ### Getting values ```python assert kv.get('s') == 'value' assert kv.get('i') == 123 assert kv.get('d') == datetime.datetime.fromtimestamp(12325) assert kv.get('n') == decimal.Decimal('1234.56') assert kv.get('ss') == set(range(10)) assert kv.get('o') == dict(d=decimal.Decimal('1234.58'), n=datetime.datetime.fromtimestamp(12325)) ``` ### Listing values `keys()` and `items()` methods return a generator yielding the values for efficient stream processing. The returned data is sorted ascending (by default) based on the keys ```python assert list(kv.keys()) == ['d', 'i', 'n', 'o', 's', 'ss'] assert list(kv.items()) == [ ('d', datetime.datetime.fromtimestamp(12325)), ('i', 123), ('n', decimal.Decimal('1234.56')), ('o', {'d': decimal.Decimal('1234.58'), 'n': datetime.datetime.fromtimestamp(12325)}), ('s', 'value'), ('ss', {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) ] ``` Set the `reverse` argument to True for the `keys()` and `items()` methods to sort in descending order. ### Bulk inserting data The SQLite DB backend can be very slow when bulk inserting data. You can use the insert method to insert efficiently in bulk. ```python kv.insert(((str(i), ':{}'.format(i)) for i in range(50000))) ``` The batch size is 1000 by default, you should modify it depending on the size of your data and available memory. ```python kv.insert(((str(i), ':{}'.format(i)) for i in range(50000)), batch_size=40000) ``` If you are inserting data from a generator and need to use the inserted data, use `insert_generator` method: ```python for key, value in kv.insert_generator(((str(i), ':{}'.format(i)) for i in range(50)), batch_size=10): print(key, value) ``` ## Installing leveldb On Debian based Linux: ```bash $ apt-get install libleveldb-dev libleveldb1 ``` On Alpine based Linux: ```bash $ apk --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --update add leveldb leveldb-dev ``` On OS X: ```bash $ brew install leveldb ``` %package -n python3-kvfile Summary: Simple File-based KV-Store Provides: python-kvfile BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-kvfile # kvfile [![Travis](https://img.shields.io/travis/akariv/kvfile/master.svg)](https://travis-ci.org/akariv/kvfile) [![Coveralls](http://img.shields.io/coveralls/akariv/kvfile.svg?branch=master)](https://coveralls.io/r/akariv/kvfile?branch=master) A simple Key-Value store that's file based - so can accommodate large data sets with a small memory footprint. Internally will use the faster `leveldb` as a storage backend or `sqlite3` as fallback if `leveldb` is not available. ## The Basics The API should feel familiar to anyone working with Python. It exposes `get`, `keys` and `items` for reading from the DB, and `set` for setting a value in the DB. ### Initializing ```python import datetime import decimal from kvfile import KVFile kv = KVFile() ``` ### Setting values ```python kv.set('s', 'value') kv.set('i', 123) kv.set('d', datetime.datetime.fromtimestamp(12325)) kv.set('n', decimal.Decimal('1234.56')) kv.set('ss', set(range(10))) kv.set('o', dict(d=decimal.Decimal('1234.58'), n=datetime.datetime.fromtimestamp(12325))) ``` ### Getting values ```python assert kv.get('s') == 'value' assert kv.get('i') == 123 assert kv.get('d') == datetime.datetime.fromtimestamp(12325) assert kv.get('n') == decimal.Decimal('1234.56') assert kv.get('ss') == set(range(10)) assert kv.get('o') == dict(d=decimal.Decimal('1234.58'), n=datetime.datetime.fromtimestamp(12325)) ``` ### Listing values `keys()` and `items()` methods return a generator yielding the values for efficient stream processing. The returned data is sorted ascending (by default) based on the keys ```python assert list(kv.keys()) == ['d', 'i', 'n', 'o', 's', 'ss'] assert list(kv.items()) == [ ('d', datetime.datetime.fromtimestamp(12325)), ('i', 123), ('n', decimal.Decimal('1234.56')), ('o', {'d': decimal.Decimal('1234.58'), 'n': datetime.datetime.fromtimestamp(12325)}), ('s', 'value'), ('ss', {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) ] ``` Set the `reverse` argument to True for the `keys()` and `items()` methods to sort in descending order. ### Bulk inserting data The SQLite DB backend can be very slow when bulk inserting data. You can use the insert method to insert efficiently in bulk. ```python kv.insert(((str(i), ':{}'.format(i)) for i in range(50000))) ``` The batch size is 1000 by default, you should modify it depending on the size of your data and available memory. ```python kv.insert(((str(i), ':{}'.format(i)) for i in range(50000)), batch_size=40000) ``` If you are inserting data from a generator and need to use the inserted data, use `insert_generator` method: ```python for key, value in kv.insert_generator(((str(i), ':{}'.format(i)) for i in range(50)), batch_size=10): print(key, value) ``` ## Installing leveldb On Debian based Linux: ```bash $ apt-get install libleveldb-dev libleveldb1 ``` On Alpine based Linux: ```bash $ apk --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --update add leveldb leveldb-dev ``` On OS X: ```bash $ brew install leveldb ``` %package help Summary: Development documents and examples for kvfile Provides: python3-kvfile-doc %description help # kvfile [![Travis](https://img.shields.io/travis/akariv/kvfile/master.svg)](https://travis-ci.org/akariv/kvfile) [![Coveralls](http://img.shields.io/coveralls/akariv/kvfile.svg?branch=master)](https://coveralls.io/r/akariv/kvfile?branch=master) A simple Key-Value store that's file based - so can accommodate large data sets with a small memory footprint. Internally will use the faster `leveldb` as a storage backend or `sqlite3` as fallback if `leveldb` is not available. ## The Basics The API should feel familiar to anyone working with Python. It exposes `get`, `keys` and `items` for reading from the DB, and `set` for setting a value in the DB. ### Initializing ```python import datetime import decimal from kvfile import KVFile kv = KVFile() ``` ### Setting values ```python kv.set('s', 'value') kv.set('i', 123) kv.set('d', datetime.datetime.fromtimestamp(12325)) kv.set('n', decimal.Decimal('1234.56')) kv.set('ss', set(range(10))) kv.set('o', dict(d=decimal.Decimal('1234.58'), n=datetime.datetime.fromtimestamp(12325))) ``` ### Getting values ```python assert kv.get('s') == 'value' assert kv.get('i') == 123 assert kv.get('d') == datetime.datetime.fromtimestamp(12325) assert kv.get('n') == decimal.Decimal('1234.56') assert kv.get('ss') == set(range(10)) assert kv.get('o') == dict(d=decimal.Decimal('1234.58'), n=datetime.datetime.fromtimestamp(12325)) ``` ### Listing values `keys()` and `items()` methods return a generator yielding the values for efficient stream processing. The returned data is sorted ascending (by default) based on the keys ```python assert list(kv.keys()) == ['d', 'i', 'n', 'o', 's', 'ss'] assert list(kv.items()) == [ ('d', datetime.datetime.fromtimestamp(12325)), ('i', 123), ('n', decimal.Decimal('1234.56')), ('o', {'d': decimal.Decimal('1234.58'), 'n': datetime.datetime.fromtimestamp(12325)}), ('s', 'value'), ('ss', {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) ] ``` Set the `reverse` argument to True for the `keys()` and `items()` methods to sort in descending order. ### Bulk inserting data The SQLite DB backend can be very slow when bulk inserting data. You can use the insert method to insert efficiently in bulk. ```python kv.insert(((str(i), ':{}'.format(i)) for i in range(50000))) ``` The batch size is 1000 by default, you should modify it depending on the size of your data and available memory. ```python kv.insert(((str(i), ':{}'.format(i)) for i in range(50000)), batch_size=40000) ``` If you are inserting data from a generator and need to use the inserted data, use `insert_generator` method: ```python for key, value in kv.insert_generator(((str(i), ':{}'.format(i)) for i in range(50)), batch_size=10): print(key, value) ``` ## Installing leveldb On Debian based Linux: ```bash $ apt-get install libleveldb-dev libleveldb1 ``` On Alpine based Linux: ```bash $ apk --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --update add leveldb leveldb-dev ``` On OS X: ```bash $ brew install leveldb ``` %prep %autosetup -n kvfile-0.0.13 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-kvfile -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Thu May 18 2023 Python_Bot - 0.0.13-1 - Package Spec generated