Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter parquet merging to avoid memory issues #106

Open
ikrommyd opened this issue Aug 18, 2024 · 0 comments
Open

Smarter parquet merging to avoid memory issues #106

ikrommyd opened this issue Aug 18, 2024 · 0 comments

Comments

@ikrommyd
Copy link

Hello,

Following Jim's instructions, I was able to do this to merge some parquet files that wouldn't normally by an ak.from_parquet -> ak.to_parquet sequence due to memory limitations:

In [8]: folder = "EGamma0_Run2024F-PromptEGMNano-v1_NANOAOD"

In [9]: files = [f"{folder}/{x}" for x in os.listdir(folder) if x.endswith(".parquet")][:3]

In [10]: files
Out[10]:
['EGamma0_Run2024F-PromptEGMNano-v1_NANOAOD/NTuples-part000.parquet',
 'EGamma0_Run2024F-PromptEGMNano-v1_NANOAOD/NTuples-part001.parquet',
 'EGamma0_Run2024F-PromptEGMNano-v1_NANOAOD/NTuples-part002.parquet']

In [11]: folder
Out[11]: 'EGamma0_Run2024F-PromptEGMNano-v1_NANOAOD'

In [12]: def generate():
    ...:     for f in files:
    ...:         array = ak.from_parquet(f)
    ...:         yield array
    ...:         del array
    ...:

In [13]: ak.to_parquet_row_groups(generate(), f"{folder}.parquet")
Out[13]:
<pyarrow._parquet.FileMetaData object at 0x7fe93ec623b0>
  created_by: parquet-cpp-arrow version 13.0.0
  num_columns: 272
  num_rows: 57038
  num_row_groups: 3
  format_version: 2.6
  serialized_size: 0

I'm just posting this here because perhaps something around this logic can be implemented in hepconvert to get a bit smarter parquet merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant