MCPcopy Create free account
hub / github.com/MariaDB/server / MakeDocument

Method MakeDocument

storage/connect/tabjson.cpp:2289–2437  ·  view source on GitHub ↗

/ Make the document tree from a file. */ /

Source from the content-addressed store, hash-verified

2287/* Make the document tree from a file. */
2288/***********************************************************************/
2289int TDBJSON::MakeDocument(PGLOBAL g)
2290{
2291 char *p, *p1, *p2, *memory, *objpath, *key = NULL;
2292 int i = 0;
2293 size_t len;
2294 my_bool a;
2295 MODE mode = Mode;
2296 PJSON jsp;
2297 PJOB objp = NULL;
2298 PJAR arp = NULL;
2299 PJVAL val = NULL;
2300
2301 if (Done)
2302 return RC_OK;
2303
2304 /*********************************************************************/
2305 /* Create the mapping file object in mode read. */
2306 /*********************************************************************/
2307 Mode = MODE_READ;
2308
2309 if (!Txfp->OpenTableFile(g)) {
2310 PFBLOCK fp = Txfp->GetTo_Fb();
2311
2312 if (fp) {
2313 len = fp->Length;
2314 memory = fp->Memory;
2315 } else {
2316 Mode = mode; // Restore saved Mode
2317 return MakeNewDoc(g);
2318 } // endif fp
2319
2320 } else
2321 return RC_FX;
2322
2323 /*********************************************************************/
2324 /* Parse the json file and allocate its tree structure. */
2325 /*********************************************************************/
2326 g->Message[0] = 0;
2327 jsp = Top = ParseJson(g, memory, len, &Pretty);
2328 Txfp->CloseTableFile(g, false);
2329 Mode = mode; // Restore saved Mode
2330
2331 if (!jsp && g->Message[0])
2332 return RC_FX;
2333
2334 if ((objpath = PlugDup(g, Objname))) {
2335 if (*objpath == '$') objpath++;
2336 if (*objpath == '.') objpath++;
2337 p1 = (*objpath == '[') ? objpath++ : NULL;
2338
2339 /*********************************************************************/
2340 /* Find the table in the tree structure. */
2341 /*********************************************************************/
2342 for (p = objpath; jsp && p; p = (p2 ? p2 : NULL)) {
2343 a = (p1 != NULL);
2344 p1 = strchr(p, '[');
2345 p2 = strchr(p, '.');
2346

Callers 3

mainMethod · 0.45
mainMethod · 0.45
GetColumnsMethod · 0.45

Calls 15

ParseJsonFunction · 0.85
PlugDupFunction · 0.85
IsNumFunction · 0.85
safe_strcpyFunction · 0.85
atoiFunction · 0.85
InitArrayMethod · 0.80
OpenTableFileMethod · 0.45
CloseTableFileMethod · 0.45
GetTypeMethod · 0.45
GetObjectMethod · 0.45
GetKeyValueMethod · 0.45
GetJsonMethod · 0.45

Tested by 2

mainMethod · 0.36
mainMethod · 0.36