JSON? ??? ?? ?? ?? ??? ??? ?? ??? ?? ???? ????, ?? ? ?????? ? ?? ?? ??(LLM)? ?? ?????. JSON ??? ??? ?? ? ???, ??? ???? ? ??? ????? ??? ?????? ?????.
JSON ???? ??? ??? ?? ???? ???? ?? ? ???? ??? JSON Lines(NDJSON???? ?)? ??? ??? ??? ????. JSON Lines ???? DataFrame?? ?? ??? ?? ??? ???? ?? ? ? ?? ? ?????.
? ?????? ?? ?????? ???? JSON Lines ???? DataFrame?? ???? Python API? ??? ??? ?????.
- pandas
- DuckDB
- pyarrow
- RAPIDS cuDF pandas ??? ??
?? ??? ???? ?? ???? ?? cudf.pandas? JSON ??? ???? ??? ???? ?? ??? ???? ?????. ?? Apache Spark? ???? ???, Python ???? ??? ???, ??? ???, ??? ?? ? ?? JSON ?? ??? ??? ? ??? ???? cuDF? ?? JSON ?? ?? ??? ?? ?????.
JSON ?? vs JSON ??
JSON ??? ??? ???? ??(parsing)? ??(reading)? ???? ?? ?????.
JSON parser
simdjson? ?? JSON parser? ?? ???? ??? ??? ??? ?????. ??? ??? ?? ??, ?, ?? ??/?, ? ??/? ?? ???? JSON ???? ??? ?? ??? ?????. ??? JSON ????? ??? ???? ? ?? ?? ????, ?? ?? ???? ???? ?? ??? ??? ???? ????.
??? ?? ??????? JSON Lines? ??? ????? ??? Dataframe ?? Apache Arrow? ?? ? ???? ???? ?? ??? ????.
JSON readers
pandas.read_json? ?? JSON ??? ?? ?? ???? ?? ??? ??? Dataframe?? ?????. ?? ????? ?? ??? ???? ??? ??? ????, ??? ?? ??? ??? ?? ??? ?? ?? ????, ?? ??? null ??? ????, ??? ??? ???? ?? ??? ?????.
JSON ??? ??? ?? ???? ???? Dataframe?? ????, JSON ???? ????? ??????? ????? ???.
JSON Lines reader ????
JSON Lines? ???? ???? ?? ??? ?????. JSON ???? ? ?? ??? ??? ??? ????.
- ??? ??? ?
- ??? ? ??
- ? ?? ??? ?? ??? ??? ??
- ?? ??? ??
- ??? ?? ??
- ??? ? ??(Fraction)
? ????? ??? ?? 200K?? ????, ? ?? 2??? 200?? ??? ????? ??? ???? ???????. ???? 4?? ??? ??? ??? ????.
- ? ?? ?? ??? ??
list<int>
?list<str>
- ?? ?? ??? ??
struct<int>
?struct<str>
? 1? list<int>
, list<str>
, struct<int>
, struct<str>
?? ??? ??? ?? ?? ? ?? ??? ?, ? ? ?? ?????.
??? ?? | ??? ?? |
list<int> | {"c0":[848377,848377],"c1":[164802,164802],...\n{"c0":[732888,732888],"c1":[817331,817331],... |
list<str> | {"c0":["FJéBCCBJD","FJéBCCBJD"],"c1":["CHJGGGGBé","CHJGGGGBé"],...\n{"c0":["DFéGHFéFD","DFéGHFéFD"],"c1":["FDFJJCJCD","FDFJJCJCD"],... |
struct<int> | {"c0":{"c0":361398},"c1":{"c0":772836},...\n{"c0":{"c0":57414},"c1":{"c0":619350},... |
struct<str> | {"c0":{"c0":"FBJGGCFGF"},"c1":{"c0":"?aFFéaJéJ"},...\n{"c0":{"c0":"éJFHDHGGC"},"c1":{"c0":"FDaBBCCBJ"},... |
? 1? list<int>
, list<str>
, struct<int>
, struct<str>
?? ??? ??? ?? ?? ? ?? ??? ?, ? ? ?? ?????.
?? ??? cuDF? 25.02 ???? ?? ????? ??? pandas 2.2.3, duckdb 1.1.3, pyarrow 17.0.0?? ???????. ?? ????? NVIDIA H100 Tensor ?? 80GB HBM3 GPU? 2TiB RAM? ??? Intel Xeon Platinum 8480CL CPU? ??????. ??? ????? ???? ?? ?? ???? OS ??? ??? ????? ?? ?? 3? ?? ? 3???? ???? ???????.
?? ??? ?? cudf.pandas ???, libcudf CUDA C++ ?? ??? ?? Python API? pylibcudf? ?? ???? ??????. pylibcudf ??? RAPIDS Memory Manager(RMM)? ?? CUDA ??? ??? ???? ??????. ??? ?? JSONL ?? ?? ??? ? ?? ??? ?? ???? ???? ???????.
JSON Lines ??? ???? ?? ?? Python ?????? ? ?? ??? ????.
# pandas and cudf.pandas import pandas as pd df = pd.read_json(file_path, lines=True) # DuckDB import duckdb df = duckdb.read_json(file_path, format='newline_delimited') # pyarrow import pyarrow.json as paj table = paj.read_json(file_path) # pylibcudf import pylibcudf as plc s = plc.io.types.SourceInfo([file_path]) opt = plc.io.json.JsonReaderOptions.builder(s).lines(True).build() df = plc.io.json.read_json(opt)
JSON Lines ?? ??
????? Python?? ??? ? ?? JSON ??? ?? ??? ??????, ?? ???? 1.5??? ? 5??? ?????.
? 2? ? ?? ?? 8.2GB? 28? ?? ??? ??? ? 7?? JSON ?? ??? ??? ???? ??? ?????.
- JSON ??? cudf.pandas? ???? ?? ??? ???? pandas? ?? ? 133?, pyarrow ??? ???? pandas? ?? 60? ??? ?????.
- DuckDB ? pyarrow? ??? ??? ????, DuckDB? ?? ? 60? ??, ?? ?? ??? ?? pyarrow? ?? 6.9?? ????.
- ?? ?? ??? 1.5?? pylibcudf?, block_size ??? ???? pyarrow ?? ? 4.6? ?? ??? ????.
?? ?? | ???? ??? (?) | ??? |
cudf.pandas | 2.1 | Using -m cudf.pandas from the command line |
pylibcudf | 1.5 | |
pandas | 281 | |
pandas-pa | 130 | Using the pyarrow engine |
DuckDB | 62.9 | |
pyarrow | 15.2 | |
pyarrow-20MB | 6.9 | Using a 20 MB block_size value |
? 2?? ?? ? ? 2, 5, 10, 20, 50, 100, 200? ??? ?? list<int>
, list<str>
, struct<int>
, struct<str>
? ???? ????.
??? ??? ? ??? ???? ??? ??, JSON ?? ??? ?? ??? ?? ??? ??? ?? ?????? ?? ????? ???? ?? ? ? ????. CPU ?? ?????? ?? 40MB/s?? 3GB/s??, GPU ?? cuDF? ?? 2~6GB/s?? ??? ??? ?????.
?? 1? 200K ?? 2~200? ?? ?? ??? ???? ? ??? ?? ???? ?????. ?? ??? ??? ? 10MB?? 1.5GB?? ?????.

?? 1? ? ?? ??? ?? ?? ??? ??? ?????. ?? ?? ??? x?? ?????.
cudf.pandas read_json? 2–5GB/s? ???? ??????, ? ?? ?? ??? ??? ????? ??????. ?? ? ??? ??? ???? ? ??? ??? ?? ?? ???????. pylibcudf ?????? Python ? pandas ??? ????? ?? cuDF-python?? ? 1~2GB/s ?? ???? ?????.
pandas read_json? ?? ?? UltraJSON ??(“pandas-uj”? ???? ???)? ?? ? 40~50MB/s ???? ??????. pyarrow ??(engine="pyarrow"
)? ???? ? ?? ??(pandas-pa)?? ?? ?? 70–100MB/s?? ???? ??????. pandas JSON ??? ??? ?? ? ??? ?? Python ???? ???? ??? ???? ??? ??? ??? ??? ????.
DuckDB read_json? ?? list<str>
? struct<str>
??? ?? ? 0.5~1GB/s? ???? ????, list<int>
? struct<int>
??? ? ?? 0.2GB/s ??? ???? ??????. ??? ???? ? ?? ?? ??? ???? ???????.
pyarrow read_json? ??, 5~20?? ?? ?? ?? 2–3GB/s? ??? ???? ?????, ? ?? 50? ???? ???? ??? ?? ??????. ??? ??? ? ??? ?? ??? ??? ?? ?? ??? ??? ??? ????? ?????. ? ?? 200??? ??? ??? ?? ?? 5KB? ??, ???? ? 0.6GB/s? ??????.
pyarrow block_size ?? ??? 20MB(pyarrow-20MB)? ??? ? ?? 100? ??? ?? ???? ?????, ? ?? 50? ??? ?? ???? ???????.
????? ????, DuckDB? ?? ??? ??? ?? ??? ???? ??? ?? cuDF ? pyarrow? ?? ? ?? ?? ??? ??? ?? ??? ???? ?????. GPU ?? cudf.pandas ? pylibcudf? ??? ??? ? ??? ???, ?? 50MB ??? ?? ??? ??? ?? ?? ?? ??? ?? ???? ?????.
JSON Lines ?? ??
JSON ??? ??? ?? ??? ??? ?, JSON ????? ???? ?? JSON ???? ????? dataframe? ? ???? ?? ?? ??? ???? ??? ????. ?????? ?? ??, ???? ??? ???, ???? ??? ??? ?? ?? ??? JSON ?? ??? ?????. ???? ??? ??? ???? ?????? JSON ?? ??? ??? ? ????.
??? JSON ?? ??? ? ?? ??? ????.
# 'Single quotes'
# field name "a" uses single quotes instead of double quotes
s = '{"a":0}\n{\'a\':0}\n{"a":0}\n'
# ‘Invalid records'
# the second record is invalid
s = '{"a":0}\n{"a"\n{"a":0}\n'
# 'Mixed types'
# column "a" switches between list and map
s = '{"a":[0]}\n{"a":[0]}\n{"a":{"b":0}}\n'
cuDF? ?? JSON ?? ??? ????? cuDF-Python(import cudf
) ? pylibcudf? ?????? ???? ?? ????. ?????? ?? ?? ???? ??? ?? ???? ???? cuDF? ?????? ????? ???? ? ?? ?? ??? ?????. cuDF? Apache Spark?? ????? ???? allowSingleQuotes ??? ????? ? ??? ?????.
???? ???? ?? ???? ??? cuDF ? DuckDB ?? ??? ???? null? ???? ?? ?? ??? ?????. ?? ??? ????? ??? ?? ? ??? ??? ??, ?? ?? ?? ?? null? ?????.
??? ???? ??? ?? ???? ??? ?? ??? ???? ?? ??, cuDF? ??? ??? ???? ?? ???? dtype ??? ??? ??? ?????. DuckDB? JSON ??? ??? ?????? ??? ?? ??? ?????.
??? ??? ??, pandas ?????? Python ??? ? ???? ??? ???? ?? ???? ?? ???? ???? ?? ??? ????.
??? ? ?? “a”? ?? dtype ??? ???? ???? ?? ??? ???? cuDF-Python ? pylibcudf? ?????. ??? ??? cudf.read_json ? pylibcudf.io.json.read_json? ?????.
pylibcudf? ?? JsonReaderOptions ??? build ?? ??? ?? ??? ? ????.
# cuDF-python
import cudf
df = cudf.read_json(
file_path,
dtype={"a":str},
on_bad_lines='recover',
lines=True,
normalize_single_quotes=True
)
# pylibcudf
import pylibcudf as plc
s = plc.io.types.SourceInfo([file_path])
opt = (
plc.io.json.JsonReaderOptions.builder(s)
.lines(True)
.dtypes([("a",plc.types.DataType(plc.types.TypeId.STRING), [])])
.recovery_mode(plc.io.types.JSONRecoveryMode.RECOVER_WITH_NULL)
.normalize_single_quotes(True)
.build()
)
df = plc.io.json.read_json(opt)
? 3? ? ?? ???? JSON ?? ??? ?? Python API? ???? ?? JSON ??? ??? ?????. X ??? ?? ??? ??? ?????? ????, ?? ??? ?????? Dataframe? ????? ????? ?????. ?????? ?? ???? ??? ??? ??? ? ????.
????? | ???? ?? ??? | ??? ?? | |
cuDF-Python, pylibcudf | ?? ????? ??? | ?? null? ?? | ?? ???? ?? |
pandas | ? ?? | ? ?? | ?? Python ??? ?? |
pandas (engine=”pyarrow“) | ? ?? | ? ?? | ? ?? |
DuckDB | ? ?? | ?? null? ?? | ?? JSON ??? ?? ???? ?? |
pyarrow | ? ?? | ? ?? | ? ?? |
cuDF? Apache Spark ??? ???? ? ??? ? ?? ?? JSON ?? ??? ????, ?? Python ???? ??? ? ????. ??? ?? ? ??? ??? ????.
- ?? ? ???? ?? ??? ?? ??
- ??? ?? ??? ???
- dtype? ??? ???? ?? ? ??
- NaN ? ??? ??
??? ??? json_reader_options? ?? libcudf C++ API ??? ?????.
?? ?? ?? JSON Lines ??? ????? ???? ?? ?? ?? ?? ?? ??? JSON Lines ??? ???? ?? ??? ?? ??? ?? ??? ??? RAPIDS? ??? GPU ?? JSON ??? ??? ?????.
??
RAPIDS cuDF? Python?? JSON ???? ???? ?? ???? ???? ???? ??? ?????.
24.12 ????? RAPIDS Accelerator For Apache Spark?? GPU ??? JSON ??? ??? ??? ? ????. ??? ??? GPU? Apache Spark JSON ?? ???? ?????.
??? ??? ?? ???? ????? ????.
- cuDF ??
- /rapidsai/cudf GitHub ???
- RAPIDS Docker ???? (??? ? ?? ??? ?? ??)
- ?? ?? ?? ??? ???? ????? ??? DLI ??
- GPU ???? ?? cudf.pandas ????? ???
?? ???
- DLI ??: RAPIDS cuDF? DataFrame ?? ?? ??
- GTC ??: Python?? CUDA ??? ???? 1,001?? ??
- GTC ??: ??? ??? ??? ?? ???
- SDK: DGL ????
- SDK: PyTorch Geometric(PyG) ????
- SDK: RAPIDS