Simple pickle and small metadata parse speedups#549
Merged
martindurant merged 6 commits intodask:masterfrom Jan 25, 2021
Merged
Simple pickle and small metadata parse speedups#549martindurant merged 6 commits intodask:masterfrom
martindurant merged 6 commits intodask:masterfrom
Conversation
Member
Author
|
@rjzamora , the pickle methods here should simplify your life a little. |
Member
|
Thanks for working on this @martindurant ! Note that I am getting good performance with this PR, but I am getting some bad results for partitioned columns after I remove from fastparquet import ParquetFile
import pickle
import dask.dataframe as dd
import pandas as pd
import numpy as np
import copy
base_path = "mytest"
metadata_path = "/".join([base_path, "_metadata"])
peice_path = './mytest/b=2001/c=2/part.0.parquet'
df = pd.DataFrame(
{
"a": np.random.rand(50),
"b": np.random.choice([2001, 2002, 2003], size=50),
"c": np.random.choice([1, 2, 3], size=50),
}
)
df.index.name = "index"
dd.from_pandas(df, 2).to_parquet(base_path, partition_on=["b", "c"], engine="fastparquet")
# NO Pickle
pf = ParquetFile(metadata_path)
row_groups = [pf.row_groups[0]]
df = pf.read_row_group_file(pf.row_groups[0], ["a", "b", "c"], [])
print("\nGOOD - No Pickle\n", df)
# YES Pickle
pfc = pickle.loads(pickle.dumps(pf))
pfc.row_groups = row_groups
df = pfc.read_row_group_file(pfc.row_groups[0], ["a", "b", "c"], [])
print("\nGOOD - Yes Pickle\n", df)
# Strip `pf.fmd.row_groups` and Pickle
pf.fmd.row_groups = None # THIS LINE CAUSES THE PROBLEM
pfc = pickle.loads(pickle.dumps(pf))
pfc.row_groups = row_groups
df = pfc.read_row_group_file(pfc.row_groups[0], ["a", "b", "c"], [])
print("\nBAD - Yes Pickle\n", df) |
Member
Author
|
The following works: |
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.
A bigger parse improvement, not yet made, would be to call val_to_num only if the type is known from the metadata (no guessing, which is error prone) or when filtering, to the type of user-supplied comparison value.
This is complicated by the partitioning column metadata being in terms of the original column names, but these get lost when reading drill-style paths (could get reapplied, of course).