forked from rapidsai/cudf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start migrating I/O writers to pylibcudf (starting with JSON)
- Loading branch information
Showing
9 changed files
with
236 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
from . cimport avro, types | ||
from .types cimport SourceInfo, TableWithMetadata | ||
from . cimport avro, json, types | ||
from .types cimport SinkInfo, SourceInfo, TableWithMetadata |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
from . import avro, types | ||
from .types import SourceInfo, TableWithMetadata | ||
from . import avro, json, types | ||
from .types import SinkInfo, SourceInfo, TableWithMetadata |
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,19 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
from libcpp cimport bool | ||
from libcpp.string cimport string | ||
|
||
from cudf._lib.pylibcudf.io.types cimport SinkInfo, TableWithMetadata | ||
from cudf._lib.pylibcudf.libcudf.io.types cimport compression_type | ||
|
||
|
||
cpdef void write_json( | ||
SinkInfo sink_info, | ||
TableWithMetadata tbl, | ||
str na_rep = *, | ||
bool include_nulls = *, | ||
bool lines = *, | ||
int rows_per_chunk = *, | ||
str true_value = *, | ||
str false_value = * | ||
) |
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,47 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
from libcpp cimport bool | ||
from libcpp.limits cimport numeric_limits | ||
from libcpp.string cimport string | ||
from libcpp.utility cimport move | ||
|
||
from cudf._lib.pylibcudf.io.types cimport SinkInfo, TableWithMetadata | ||
from cudf._lib.pylibcudf.libcudf.io.json cimport ( | ||
json_writer_options, | ||
write_json as cpp_write_json, | ||
) | ||
from cudf._lib.pylibcudf.libcudf.io.types cimport table_metadata | ||
from cudf._lib.pylibcudf.types cimport size_type | ||
|
||
|
||
cpdef void write_json( | ||
SinkInfo sink_info, | ||
TableWithMetadata table_w_meta, | ||
str na_rep = "", | ||
bool include_nulls = False, | ||
bool lines = False, | ||
int rows_per_chunk = numeric_limits[size_type].max(), | ||
str true_value = "true", | ||
str false_value = "false" | ||
): | ||
""" | ||
""" | ||
cdef table_metadata tbl_meta = table_w_meta.metadata | ||
cdef string na_rep_c = na_rep.encode() | ||
cdef string true_value_c = true_value.encode() | ||
cdef string false_value_c = false_value.encode() | ||
|
||
cdef json_writer_options options = move( | ||
json_writer_options.builder(sink_info.c_obj, table_w_meta.tbl.view()) | ||
.metadata(tbl_meta) | ||
.na_rep(na_rep_c) | ||
.include_nulls(include_nulls) | ||
.lines(lines) | ||
.rows_per_chunk(rows_per_chunk) | ||
.true_value(true_value_c) | ||
.false_value(false_value_c) | ||
.build() | ||
) | ||
|
||
with nogil: | ||
cpp_write_json(options) |
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
Oops, something went wrong.