etl_lib.task.data_loading.ParallelJSONLoad2Neo4jTask module
- class ParallelJSONLoad2Neo4jTask(context, file, model=None, error_file=None, table_size=10, batch_size=5000, max_workers=None, prefetch=4)[source]
Bases:
TaskParallel JSON to Neo4j load using the mix-and-batch strategy.
Wires a
JSONBatchSource, optional Pydantic validation, a diagonal splitter (to avoid overlapping node locks), and a Cypher sink. Records are distributed into (row, col) partitions and processed in non-overlapping groups, exactly as inParallelCSVLoad2Neo4jTask.Unlike the CSV variant there are no reader kwargs to forward.
JSONBatchSourcedetects the JSON layout from the file content itself.- Parameters:
context (
ETLContext) – Shared ETL context.file (
Path) – JSON file to load, either JSON Lines or an array, optionally gzipped.model (
type[BaseModel] |None) – Optional Pydantic model for record validation. Invalid records go to error_file.error_file (
Path|None) – Output for invalid records. Required when model is set.table_size (
int) – Bucketing grid size for the splitter.batch_size (
int) – Per-cell target batch size from the splitter.prefetch (
int) – Number of waves to prefetch from the splitter.
Notes
_query() must return Cypher that starts with
UNWIND $batch AS row.Override _id_extractor() if your records do not expose
start/end. The default usesetl_lib.core.SplittingBatchProcessor.dict_id_extractor().Validation round-trips each record through the Pydantic model, so source-injected fields such as
_rowreach the query only when no model is given.
- __init__(context, file, model=None, error_file=None, table_size=10, batch_size=5000, max_workers=None, prefetch=4)[source]
Construct a Task object.
- Parameters:
context (
ETLContext) –ETLContextinstance. Will be available to subclasses.file (Path)
error_file (Path | None)
table_size (int)
batch_size (int)
max_workers (int | None)
prefetch (int)
- run_internal(**kwargs)[source]
Place to provide the logic to be performed.
This base class provides all the housekeeping and reporting, so that implementation must/should not need to care about them. Exceptions should not be captured by implementations. They are handled by this base class.
- Parameters:
kwargs – will be passed to run_internal
- Return type:
- Returns:
An instance of
TaskReturn.