-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-16146 Add ZSTD compression format
- Loading branch information
Showing
7 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import sys | ||
sys.path.insert(1,"../../../") | ||
import h2o | ||
from tests import pyunit_utils | ||
from os import path | ||
import struct | ||
|
||
''' | ||
Export file with h2o.export_file compressed with 'zstd' | ||
''' | ||
|
||
|
||
def is_zstd_file(path): | ||
with open(path, 'rb') as f: | ||
magic_bytes = f.read(4) | ||
return struct.unpack('<I', magic_bytes)[0] == 0xFD2FB528 | ||
|
||
|
||
def export_zstd(): | ||
prostate = h2o.import_file(pyunit_utils.locate("smalldata/prostate/prostate.csv")) | ||
target = path.join(pyunit_utils.locate("results"), "prostate_export.csv.zst") | ||
h2o.export_file(prostate, target, compression="zstd") | ||
|
||
assert is_zstd_file(target) | ||
|
||
prostate_zstd = h2o.import_file(target) | ||
|
||
assert pyunit_utils.compare_frames(prostate, prostate_zstd, numElements=2) | ||
|
||
|
||
if __name__ == "__main__": | ||
pyunit_utils.standalone_test(export_zstd) | ||
else: | ||
export_zstd() | ||
|
||
|
||
|