Improve peformances put/get rows using pandas.DataFrame#19
Merged
knonomura merged 2 commits intogriddb:masterfrom Sep 21, 2020
dangtrungtin:master
Merged
Improve peformances put/get rows using pandas.DataFrame#19knonomura merged 2 commits intogriddb:masterfrom dangtrungtin:master
knonomura merged 2 commits intogriddb:masterfrom
dangtrungtin:master
Conversation
- Add function: void Container.put_rows(input: pandas.DataFrame) - Add function: pandas.DataFrame RowSet.fetch_rows() - Reduce call function to check NULL field
Member
|
Oh, that's great ! I have a question. Thanks. |
Contributor
Author
|
With long type, I put 1000 rows x 10000 fields. With string type, I use 1000 rows x 7552 fields. |
Member
|
Thank you for your information. |
Member
|
I have a request. |
- PutRowsWithDataFrame.py : sample for put rows. - FetchRowsWithDataFrame.py : sample for fetch rows.
Contributor
Author
|
I added 2 samples:
|
Member
|
Thank you for your samples. |
Member
|
I guess this pull request is very useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add function : void Container.put_rows(pandas.DataFrame input). In python layer, I convert input from pandas.DataFrame to numpy.array because NumPy support C-API. In C++ layer, I use API from NumPy to put data into GridDB. Compare with using Container.multi_puts(input : list[list]) to put large data with LONG type, the time to run reduce about 11% and memory using reduce 20%. With String type, the time to run reduce about 10% and memory using reduce about 8%.
Add function : pandas.DataFrame RowSet.fetch_rows(). In C++ layer, it uses Iterable object (RowList.h/cpp) to wrap output data. In python layer, I convert data from Iterable object to pandas.DataFrame. Compare with using RowSet.next() to query large data with LONG type, the time to run reduce 17% and memory using are the same. When query large data with STRING type, the time to run reduce 11%.
Reduce call function to check NULL field: when get data, for each row field, Python Client is using gsGetRowFieldNull() then gsGetRowFieldAsXXX(). I change to use gsGetRowFieldAsXXX(), then if data is empty or null then I use gsGetRowFieldNull() to check whether field is null.
There is a note for Container.put_rows(). To create DataFrame, we use: "frame = pandas.DataFrame(data)" with "data" is list. However, when list has None value, Pandas library will automatic change value, for example None value to NaN value. To prevent this, in python code should use "frame = pandas.DataFrame(data, dtype=object)".