graflo.architecture.backend.reader¶
Streaming reader for GraFlo file backend directories.
Attributes¶
Classes¶
GraFloBackendReader
¶
Read schema and chunked graph data from a GraFlo backend directory.
:meth:iter_vertex_batches and :meth:iter_edge_batches yield records as
written; :meth:vertex_records, :meth:edge_records and
:meth:load_graph_container fold them by identity
(:mod:~graflo.architecture.backend.fold), so a read sees one document per
entity, as a database would.
Source code in graflo/architecture/backend/reader.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
Methods:¶
__init__(input_dir)
¶
Source code in graflo/architecture/backend/reader.py
edge_id_of(edge_key)
¶
The logical edge stored under edge_key, if one is.
Source code in graflo/architecture/backend/reader.py
edge_records(edge_key)
¶
Every edge stored under edge_key, one folded record each.
Source code in graflo/architecture/backend/reader.py
iter_edge_batches(edge_key, *, batch_size=1000, limit=None)
¶
Source code in graflo/architecture/backend/reader.py
iter_vertex_batches(vertex_type, *, batch_size=1000, limit=None)
¶
Source code in graflo/architecture/backend/reader.py
load_graph_container(*, limit=None)
¶
The whole graph, keyed by the logical names of schema.yaml.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int | None
|
At most this many records per vertex type and per edge. |
None
|
Source code in graflo/architecture/backend/reader.py
read_index()
¶
read_schema()
¶
reload_index()
¶
Re-read INDEX.json, which any writer may have published since.
Returns:
| Type | Description |
|---|---|
bool
|
Whether it changed since the last read; on a change, the cached |
bool
|
schema is dropped too. |
Source code in graflo/architecture/backend/reader.py
vertex_records(collection)
¶
Every entity stored under collection, one folded record each.
Source code in graflo/architecture/backend/reader.py
vertex_type_of(collection)
¶
The logical vertex type stored under collection, if one is.
Functions:¶
edge_chunk_key(schema, edge_id)
¶
The key the chunks of the edge edge_id are stored under.
The storage names of both endpoints and the logical relation, which is what a writer passes the connection.
Source code in graflo/architecture/backend/reader.py
stored_schema(schema)
¶
schema with every stored name filled in, as the writer used them.
Source code in graflo/architecture/backend/reader.py
vertex_chunk_key(schema, vertex)
¶
The name the chunks of vertex are stored under: its storage name.
It is the name a writer passes the connection, so a directory written for a target that renames things is read back under the same name.