Name | parquetdb JSON |
Version |
0.9.0
JSON |
| download |
home_page | None |
Summary | ParquetDB is a lightweight database-like system built on top of Apache Parquet files using PyArrow. |
upload_time | 2024-12-18 19:57:56 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT License Copyright (c) 2023 lllangWV Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
parquet
pyarrow
data
storage
schema evolution
nested and complex data types
scalable
database
python
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ParquetDB
ParquetDB is a lightweight database-like system built on top of Apache Parquet files using PyArrow. It offers a simple and efficient way to store, manage, and retrieve complex data types without the overhead of serialization, which is often a bottleneck in machine learning pipelines. By leveraging Parquet's columnar storage format and PyArrow's computational capabilities, ParquetDB provides high performance for data-intensive applications.
![Benchmark Create and Read Times for Different Databases](benchmarks/benchmark_create_read_times.png)
## Table of Contents
- [Features](#features)
- [Why ParquetDB?](#why-parquetdb)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Creating a Database](#creating-a-database)
- [Adding Data](#adding-data)
- [Reading Data](#reading-data)
- [Updating Data](#updating-data)
- [Deleting Data](#deleting-data)
- [Benchmark Overview](#benchmark-overview)
- [Contributing](#contributing)
- [License](#license)
## Features
- **Simple Interface**: Easy-to-use methods for creating, reading, updating, and deleting data.
- **High Performance**: Utilizes Apache Parquet and PyArrow for efficient data storage and retrieval.
- **Supports Complex Data Types**: Handles nested and complex data types without serialization overhead.
- **Scalable**: Designed to handle large datasets efficiently.
- **Schema Evolution**: Supports adding new fields and updating schemas seamlessly.
## Roadmap
- Support foriegn keys use
- Multiprocessing for reading and writing
## Why ParquetDB?
### The Challenge of Serialization and Deserialization
In many data processing and machine learning workflows, a significant performance bottleneck occurs during the serialization and deserialization of data. Serialization is the process of converting complex data structures or objects into a format that can be easily stored or transmitted, while deserialization is the reverse process of reconstructing these objects from the serialized format.
The need for serialization arises when:
1. Storing data on disk
2. Transmitting data over a network
3. Caching data in memory
However, serialization and deserialization can be computationally expensive, especially when dealing with large datasets or complex object structures. This process can lead to:
- Increased I/O operations
- Higher CPU usage
- Increased memory consumption
- Longer processing times
These issues become particularly problematic in machine learning pipelines, where data needs to be frequently loaded, processed, and saved. The overhead of constantly serializing and deserializing data can significantly slow down the entire workflow, affecting both development iteration speed and production performance.
### How Parquet Files Address the Serialization Challenge
Apache Parquet files offer a solution to the serialization/deserialization problem by providing:
1. **Columnar Storage Format**: Parquet stores data in a columnar format, which allows for efficient compression and encoding schemes. This format is particularly beneficial for analytical queries that typically involve a subset of columns.
2. **Schema Preservation**: Parquet files store the schema of the data along with the data itself. This eliminates the need for separate schema definitions and reduces the risk of schema mismatch errors.
3. **Efficient Encoding**: Parquet uses advanced encoding techniques like dictionary encoding, bit packing, and run length encoding, which can significantly reduce file sizes and improve read performance.
4. **Predicate Pushdown**: Parquet supports predicate pushdown, allowing queries to skip irrelevant data blocks entirely, further improving query performance.
5. **Compatibility**: Parquet files are compatible with various big data processing frameworks, making it easier to integrate into existing data pipelines.
By leveraging these features, ParquetDB eliminates the need for explicit serialization and deserialization of complex data types. Data can be read directly from and written directly to Parquet files, maintaining its structure and allowing for efficient querying and processing.
### The ParquetDB Advantage
ParquetDB builds upon the benefits of Parquet files by providing:
1. A simple, database-like interface for working with Parquet files
2. Efficient storage and retrieval of complex data types
3. High-performance data operations leveraging PyArrow's computational capabilities
4. Seamless integration with machine learning pipelines and data processing workflows
By using ParquetDB, developers and data scientists can focus on their core tasks without worrying about the intricacies of data serialization or the performance implications of frequent I/O operations. This results in faster development cycles, improved system performance, and more efficient use of computational resources.
## Installation
Install ParquetDB using pip:
```bash
pip install parquetdb
```
## Quick Start
```python
from parquetdb import ParquetDB
# Initialize the database
db = ParquetDB(dataset_name='parquetdb')
# Create data
data = [
{'name': 'Alice', 'age': 30, 'occupation': 'Engineer'},
{'name': 'Bob', 'age': 25, 'occupation': 'Data Scientist'}
]
# Add data to the database
db.create(data)
# Read data from the database
employees = db.read()
print(employees.to_pandas())
```
## Usage
### Creating a Database
Initialize a ParquetDB instance by specifying the path the name of the dataset
```python
from parquetdb import ParquetDB
db = ParquetDB(dataset_name='parquetdb')
```
### Adding Data
Add data to the database using the `create` method. Data can be a dictionary, a list of dictionaries, or a Pandas DataFrame.
```python
data = [
{'name': 'Charlie', 'age': 28, 'occupation': 'Designer'},
{'name': 'Diana', 'age': 32, 'occupation': 'Product Manager'}
]
db.create(data)
```
### Normalizing
Normalization is a crucial process for ensuring the optimal performance and efficient management of data. In the context of file-based databases, like the ones used in ParquetDB, normalization helps balance the distribution of data across multiple files. Without proper normalization, files can end up with uneven row counts, leading to performance bottlenecks during operations like queries, inserts, updates, or deletions.
This method does not return anything but modifies the dataset directory in place, ensuring a more consistent and efficient structure for future operations.
```python
db.normalize(
normalize_config=NormalizeConfig(
load_format='batches', # Uses the batch generator to normalize
batch_readahead=10, # Controls the number of batches to load in memory a head of time.
fragment_readahead=2, # Controls the number of files to load in memory ahead of time.
batch_size = 100000, # Controls the batchsize when to use when normalizing. This will have impacts on amount of RAM consumed
max_rows_per_file=500000, # Controls the max number of rows per parquet file
max_rows_per_group=500000) # Controls the max number of rows per group parquet file
)
```
### Reading Data
Read data from the database using the `read` method. You can filter data by IDs, specify columns, and apply filters.
```python
# Read all data
all_employees = db.read()
# Read specific columns
names = db.read( columns=['name'])
# Read data with filters
from pyarrow import compute as pc
age_filter = pc.field('age') > 30
older_employees = db.read(filters=[age_filter])
```
### Updating Data
Update existing records in the database using the `update` method. Each record must include the `id` field.
```python
update_data = [
{'id': 1, 'occupation': 'Senior Engineer'},
{'id': 3, 'age': 29}
]
db.update(update_data)
```
### Deleting Data
Delete records from the database by specifying their IDs.
```python
db.delete(ids=[2, 4])
```
## Benchmark Overview
A benchmark was conducted to evaluate the performance of ParquetDB, SQLite, and MongoDB. The benchmark measures the read and write times for datasets consisting of 100 integer columns across varying record sizes.
#### Write Performance
For write operations, we tested the time required to insert records into each database and close the connections. Bulk inserts were used for SQLite and MongoDB, but only serial inserts were tested. Specifically for SQLite, `PRAGMA synchronous = OFF` and `PRAGMA journal_mode = MEMORY` were applied to optimize write performance.
#### Read Performance
For read operations, we measured the time taken to load the entire dataset into an array-like structure. Leaving the data in a cursor was not counted as a completed read.
#### Test Environment
The benchmark was executed on the following system:
- **Processor**: AMD Ryzen 7 3700X 8-Core, 3600 MHz
- **Logical Processors**: 16
- **Memory**: 32 GB RAM
The scripts used to generate these benchmark results can be found in the `benchmarks` directory.
### Results Summary
- **Read Times**: ParquetDB is the fastest for large datasets, followed by SQLite, with MongoDB trailing.
- **Write Times**: For large datasets, SQLite achieves the fastest write times, followed by ParquetDB and MongoDB.
## Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
---
*Note: This project is in its initial stages. Features and APIs are subject to change. Please refer to the latest documentation and release notes for updates.*
Raw data
{
"_id": null,
"home_page": null,
"name": "parquetdb",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "parquet, pyarrow, data, storage, schema evolution, nested and complex data types, scalable, database, python",
"author": null,
"author_email": "Logan Lang <lllang@mix.wvu.edu>, Aldo Romero <Aldo.Romero@mail.wvu.edu>, Kamal Choudhary <kamal.choudhary@nist.gov>, Eduardo Hernandez <Eduardo.Hernandez@csic.es>",
"download_url": "https://files.pythonhosted.org/packages/2a/26/ec9006f39903c92a995f031ed44ffceb29031122632561c0a00587eaa122/parquetdb-0.9.0.tar.gz",
"platform": null,
"description": "# ParquetDB\n\nParquetDB is a lightweight database-like system built on top of Apache Parquet files using PyArrow. It offers a simple and efficient way to store, manage, and retrieve complex data types without the overhead of serialization, which is often a bottleneck in machine learning pipelines. By leveraging Parquet's columnar storage format and PyArrow's computational capabilities, ParquetDB provides high performance for data-intensive applications. \n\n\n![Benchmark Create and Read Times for Different Databases](benchmarks/benchmark_create_read_times.png)\n\n## Table of Contents\n\n- [Features](#features)\n- [Why ParquetDB?](#why-parquetdb)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n - [Creating a Database](#creating-a-database)\n - [Adding Data](#adding-data)\n - [Reading Data](#reading-data)\n - [Updating Data](#updating-data)\n - [Deleting Data](#deleting-data)\n- [Benchmark Overview](#benchmark-overview)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Simple Interface**: Easy-to-use methods for creating, reading, updating, and deleting data.\n- **High Performance**: Utilizes Apache Parquet and PyArrow for efficient data storage and retrieval.\n- **Supports Complex Data Types**: Handles nested and complex data types without serialization overhead.\n- **Scalable**: Designed to handle large datasets efficiently.\n- **Schema Evolution**: Supports adding new fields and updating schemas seamlessly.\n\n## Roadmap\n\n- Support foriegn keys use\n- Multiprocessing for reading and writing\n\n## Why ParquetDB?\n\n### The Challenge of Serialization and Deserialization\n\nIn many data processing and machine learning workflows, a significant performance bottleneck occurs during the serialization and deserialization of data. Serialization is the process of converting complex data structures or objects into a format that can be easily stored or transmitted, while deserialization is the reverse process of reconstructing these objects from the serialized format.\n\nThe need for serialization arises when:\n1. Storing data on disk\n2. Transmitting data over a network\n3. Caching data in memory\n\nHowever, serialization and deserialization can be computationally expensive, especially when dealing with large datasets or complex object structures. This process can lead to:\n\n- Increased I/O operations\n- Higher CPU usage\n- Increased memory consumption\n- Longer processing times\n\nThese issues become particularly problematic in machine learning pipelines, where data needs to be frequently loaded, processed, and saved. The overhead of constantly serializing and deserializing data can significantly slow down the entire workflow, affecting both development iteration speed and production performance.\n\n### How Parquet Files Address the Serialization Challenge\n\nApache Parquet files offer a solution to the serialization/deserialization problem by providing:\n\n1. **Columnar Storage Format**: Parquet stores data in a columnar format, which allows for efficient compression and encoding schemes. This format is particularly beneficial for analytical queries that typically involve a subset of columns.\n2. **Schema Preservation**: Parquet files store the schema of the data along with the data itself. This eliminates the need for separate schema definitions and reduces the risk of schema mismatch errors.\n3. **Efficient Encoding**: Parquet uses advanced encoding techniques like dictionary encoding, bit packing, and run length encoding, which can significantly reduce file sizes and improve read performance.\n4. **Predicate Pushdown**: Parquet supports predicate pushdown, allowing queries to skip irrelevant data blocks entirely, further improving query performance.\n5. **Compatibility**: Parquet files are compatible with various big data processing frameworks, making it easier to integrate into existing data pipelines.\n\nBy leveraging these features, ParquetDB eliminates the need for explicit serialization and deserialization of complex data types. Data can be read directly from and written directly to Parquet files, maintaining its structure and allowing for efficient querying and processing.\n\n### The ParquetDB Advantage\n\nParquetDB builds upon the benefits of Parquet files by providing:\n\n1. A simple, database-like interface for working with Parquet files\n2. Efficient storage and retrieval of complex data types\n3. High-performance data operations leveraging PyArrow's computational capabilities\n4. Seamless integration with machine learning pipelines and data processing workflows\n\nBy using ParquetDB, developers and data scientists can focus on their core tasks without worrying about the intricacies of data serialization or the performance implications of frequent I/O operations. This results in faster development cycles, improved system performance, and more efficient use of computational resources.\n\n\n## Installation\n\nInstall ParquetDB using pip:\n\n```bash\npip install parquetdb\n```\n\n## Quick Start\n\n```python\nfrom parquetdb import ParquetDB\n\n# Initialize the database\ndb = ParquetDB(dataset_name='parquetdb')\n\n# Create data\ndata = [\n {'name': 'Alice', 'age': 30, 'occupation': 'Engineer'},\n {'name': 'Bob', 'age': 25, 'occupation': 'Data Scientist'}\n]\n\n# Add data to the database\ndb.create(data)\n\n# Read data from the database\nemployees = db.read()\nprint(employees.to_pandas())\n```\n\n## Usage\n\n### Creating a Database\n\nInitialize a ParquetDB instance by specifying the path the name of the dataset\n\n```python\nfrom parquetdb import ParquetDB\n\ndb = ParquetDB(dataset_name='parquetdb')\n```\n\n### Adding Data\n\nAdd data to the database using the `create` method. Data can be a dictionary, a list of dictionaries, or a Pandas DataFrame.\n\n```python\ndata = [\n {'name': 'Charlie', 'age': 28, 'occupation': 'Designer'},\n {'name': 'Diana', 'age': 32, 'occupation': 'Product Manager'}\n]\n\ndb.create(data)\n```\n\n### Normalizing\n\nNormalization is a crucial process for ensuring the optimal performance and efficient management of data. In the context of file-based databases, like the ones used in ParquetDB, normalization helps balance the distribution of data across multiple files. Without proper normalization, files can end up with uneven row counts, leading to performance bottlenecks during operations like queries, inserts, updates, or deletions.\n\nThis method does not return anything but modifies the dataset directory in place, ensuring a more consistent and efficient structure for future operations.\n\n```python\ndb.normalize(\n normalize_config=NormalizeConfig(\n load_format='batches', # Uses the batch generator to normalize\n batch_readahead=10, # Controls the number of batches to load in memory a head of time.\n fragment_readahead=2, # Controls the number of files to load in memory ahead of time.\n batch_size = 100000, # Controls the batchsize when to use when normalizing. This will have impacts on amount of RAM consumed\n max_rows_per_file=500000, # Controls the max number of rows per parquet file\n max_rows_per_group=500000) # Controls the max number of rows per group parquet file\n)\n```\n\n### Reading Data\n\nRead data from the database using the `read` method. You can filter data by IDs, specify columns, and apply filters.\n\n```python\n# Read all data\nall_employees = db.read()\n\n# Read specific columns\nnames = db.read( columns=['name'])\n\n# Read data with filters\nfrom pyarrow import compute as pc\n\nage_filter = pc.field('age') > 30\nolder_employees = db.read(filters=[age_filter])\n```\n\n### Updating Data\n\nUpdate existing records in the database using the `update` method. Each record must include the `id` field.\n\n```python\nupdate_data = [\n {'id': 1, 'occupation': 'Senior Engineer'},\n {'id': 3, 'age': 29}\n]\n\ndb.update(update_data)\n```\n\n### Deleting Data\n\nDelete records from the database by specifying their IDs.\n\n```python\ndb.delete(ids=[2, 4])\n```\n\n\n## Benchmark Overview\n\nA benchmark was conducted to evaluate the performance of ParquetDB, SQLite, and MongoDB. The benchmark measures the read and write times for datasets consisting of 100 integer columns across varying record sizes.\n\n#### Write Performance\nFor write operations, we tested the time required to insert records into each database and close the connections. Bulk inserts were used for SQLite and MongoDB, but only serial inserts were tested. Specifically for SQLite, `PRAGMA synchronous = OFF` and `PRAGMA journal_mode = MEMORY` were applied to optimize write performance.\n\n#### Read Performance\nFor read operations, we measured the time taken to load the entire dataset into an array-like structure. Leaving the data in a cursor was not counted as a completed read.\n\n#### Test Environment\nThe benchmark was executed on the following system:\n- **Processor**: AMD Ryzen 7 3700X 8-Core, 3600 MHz\n- **Logical Processors**: 16\n- **Memory**: 32 GB RAM\n\nThe scripts used to generate these benchmark results can be found in the `benchmarks` directory.\n\n### Results Summary\n- **Read Times**: ParquetDB is the fastest for large datasets, followed by SQLite, with MongoDB trailing.\n- **Write Times**: For large datasets, SQLite achieves the fastest write times, followed by ParquetDB and MongoDB.\n\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n*Note: This project is in its initial stages. Features and APIs are subject to change. Please refer to the latest documentation and release notes for updates.*\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 lllangWV Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "ParquetDB is a lightweight database-like system built on top of Apache Parquet files using PyArrow.",
"version": "0.9.0",
"project_urls": {
"Changelog": "https://github.com/romerogroup/ParquetDB/CHANGELOG.md",
"Issues": "https://github.com/romerogroup/ParquetDB/issues",
"Repository": "https://github.com/romerogroup/ParquetDB"
},
"split_keywords": [
"parquet",
" pyarrow",
" data",
" storage",
" schema evolution",
" nested and complex data types",
" scalable",
" database",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4e453f30ebb91a83ca23bf379563b5caadfbb388f823a0ebf6da2e9b8f199592",
"md5": "2da3d1c434a547e941b1d9535349b878",
"sha256": "4c1e5ccd72e802000b1bcaefcd1ef7868522abfd60f19bbcbb0d2f0977de2383"
},
"downloads": -1,
"filename": "parquetdb-0.9.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2da3d1c434a547e941b1d9535349b878",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 37788,
"upload_time": "2024-12-18T19:57:52",
"upload_time_iso_8601": "2024-12-18T19:57:52.518164Z",
"url": "https://files.pythonhosted.org/packages/4e/45/3f30ebb91a83ca23bf379563b5caadfbb388f823a0ebf6da2e9b8f199592/parquetdb-0.9.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2a26ec9006f39903c92a995f031ed44ffceb29031122632561c0a00587eaa122",
"md5": "5626a89098408c259b7275a0003f7f54",
"sha256": "2f7c347296ee506d90f7dad31f591254e65f4bfcc05604dff422108ecdd1747c"
},
"downloads": -1,
"filename": "parquetdb-0.9.0.tar.gz",
"has_sig": false,
"md5_digest": "5626a89098408c259b7275a0003f7f54",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 320034,
"upload_time": "2024-12-18T19:57:56",
"upload_time_iso_8601": "2024-12-18T19:57:56.783119Z",
"url": "https://files.pythonhosted.org/packages/2a/26/ec9006f39903c92a995f031ed44ffceb29031122632561c0a00587eaa122/parquetdb-0.9.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-18 19:57:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "romerogroup",
"github_project": "ParquetDB",
"github_not_found": true,
"lcname": "parquetdb"
}