graflo.db.tigergraph.loading_job¶
A typed loading job for a bulk load, and the delimited text it is fed.
Pure: nothing here opens a connection. :func:loading_job lays out one file
variable per vertex type and one per concrete edge (source, relation,
target), columns in the order the schema DDL declares the type's attributes;
:func:create_job_gsql renders it. :func:vertex_line and :func:edge_line
encode one folded row, :func:split_body packs lines into request bodies, and
:func:check_load_response refuses a load that skipped any line.
Rows are separated by :data:EOL and fields by :data:SEP, list items by
:data:LIST_SEP: control characters, so text holding commas, quotes or line
breaks loads unchanged without quoting, which loading jobs do not escape.
Attributes¶
ColumnKind = Literal['scalar', 'list', 'datetime']
module-attribute
¶
EOL = '\x1e'
module-attribute
¶
LIST_SEP = '\x1d'
module-attribute
¶
MAX_BODY_BYTES = 200 * 1024 * 1024
module-attribute
¶
SEP = '\x1f'
module-attribute
¶
Classes¶
EdgeLoad
¶
Bases: BaseModel
The file of one concrete edge: source id, target id, then the type's attributes.
Source code in graflo/db/tigergraph/loading_job.py
LoadColumn
¶
Bases: BaseModel
One attribute of a type, as a column of its file.
Source code in graflo/db/tigergraph/loading_job.py
LoadRejectedError
¶
LoadingJob
¶
Bases: BaseModel
A loading job with one file variable per vertex type and per concrete edge.
Source code in graflo/db/tigergraph/loading_job.py
Attributes¶
edges
instance-attribute
¶
graph
instance-attribute
¶
model_config = ConfigDict(frozen=True)
class-attribute
instance-attribute
¶
name
instance-attribute
¶
vertices
instance-attribute
¶
Methods:¶
edge(stored_id)
¶
The file of the concrete edge stored_id.
Raises:
| Type | Description |
|---|---|
KeyError
|
The schema declares no such edge. |
Source code in graflo/db/tigergraph/loading_job.py
vertex(vertex_type)
¶
The file of vertex_type.
Raises:
| Type | Description |
|---|---|
KeyError
|
The schema declares no such vertex type. |
Source code in graflo/db/tigergraph/loading_job.py
VertexLoad
¶
Bases: BaseModel
The file of one vertex type: its attributes, primary id first.
Source code in graflo/db/tigergraph/loading_job.py
Functions:¶
check_load_response(response, *, lines)
¶
Refuse a load response that reports an error or any skipped line.
A loading job skips a line it cannot parse and still answers success, so every rejection counter must be zero and every posted line valid.
Raises:
| Type | Description |
|---|---|
LoadRejectedError
|
The response reports an error, a rejected line or fewer valid lines than lines. |
Source code in graflo/db/tigergraph/loading_job.py
create_job_gsql(job)
¶
CREATE LOADING JOB for job: file variables with no path, fed by POST.
Vertices load with NEW_VERTEX_ONLY (the target is empty, so a vertex
already there was written by this load), edges with VERTEX_MUST_EXIST
and explicit endpoint types, one LOAD per file.
Source code in graflo/db/tigergraph/loading_job.py
edge_line(load, row, match_keys_source, match_keys_target)
¶
One edge row: the endpoints' primary ids as the upsert path builds them, then attributes.
Raises:
| Type | Description |
|---|---|
ValueError
|
An endpoint has no identity value. |
Source code in graflo/db/tigergraph/loading_job.py
encode_value(value, column)
¶
value as one field of column; None is an empty field.
Raises:
| Type | Description |
|---|---|
ValueError
|
The text holds a separator, or a number is not finite. |
TypeError
|
The value is not a scalar (or, for a list column, a list). |
Source code in graflo/db/tigergraph/loading_job.py
job_name(graph)
¶
loading_job(schema, graph)
¶
The loading job for schema, columns in its DDL's attribute order.
schema is the physical schema the DDL was applied from. Edge types shared by several endpoint pairs get one file per pair, each with every attribute of the type, so pairs never mix layouts in one file.
Raises:
| Type | Description |
|---|---|
ValueError
|
Two files would get the same variable name. |
Source code in graflo/db/tigergraph/loading_job.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
split_body(lines, max_bytes=MAX_BODY_BYTES)
¶
lines packed in order into bodies of at most max_bytes, with their line counts.
Raises:
| Type | Description |
|---|---|
ValueError
|
One line alone exceeds max_bytes. |
Source code in graflo/db/tigergraph/loading_job.py
vertex_line(load, doc)
¶
One vertex row; an attribute absent or null is an empty field.