Commit 1d468ee0 authored by Olivier Bertrand's avatar Olivier Bertrand

Fix slow processing of pretty json files by BSON tables

parent fc98a6d5
...@@ -376,7 +376,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) ...@@ -376,7 +376,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
} // endswitch ReadDB } // endswitch ReadDB
} else } else
jsp = bp->GetArrayValue(bdp, i); jsp = bp->GetNext(jsp);
if (!(row = (jsp) ? bp->GetObject(jsp) : NULL)) if (!(row = (jsp) ? bp->GetObject(jsp) : NULL))
break; break;
...@@ -2185,7 +2185,9 @@ void BSONCOL::WriteColumn(PGLOBAL g) ...@@ -2185,7 +2185,9 @@ void BSONCOL::WriteColumn(PGLOBAL g)
TDBBSON::TDBBSON(PGLOBAL g, PBDEF tdp, PTXF txfp) : TDBBSN(g, tdp, txfp) TDBBSON::TDBBSON(PGLOBAL g, PBDEF tdp, PTXF txfp) : TDBBSN(g, tdp, txfp)
{ {
Docp = NULL; Docp = NULL;
Docrow = NULL;
Multiple = tdp->Multiple; Multiple = tdp->Multiple;
Docsize = 0;
Done = Changed = false; Done = Changed = false;
Bp->SetPretty(2); Bp->SetPretty(2);
} // end of TDBBSON standard constructor } // end of TDBBSON standard constructor
...@@ -2193,7 +2195,9 @@ TDBBSON::TDBBSON(PGLOBAL g, PBDEF tdp, PTXF txfp) : TDBBSN(g, tdp, txfp) ...@@ -2193,7 +2195,9 @@ TDBBSON::TDBBSON(PGLOBAL g, PBDEF tdp, PTXF txfp) : TDBBSN(g, tdp, txfp)
TDBBSON::TDBBSON(PBTDB tdbp) : TDBBSN(tdbp) TDBBSON::TDBBSON(PBTDB tdbp) : TDBBSN(tdbp)
{ {
Docp = tdbp->Docp; Docp = tdbp->Docp;
Docrow = tdbp->Docrow;
Multiple = tdbp->Multiple; Multiple = tdbp->Multiple;
Docsize = tdbp->Docsize;
Done = tdbp->Done; Done = tdbp->Done;
Changed = tdbp->Changed; Changed = tdbp->Changed;
} // end of TDBBSON copy constructor } // end of TDBBSON copy constructor
...@@ -2374,6 +2378,7 @@ int TDBBSON::MakeDocument(PGLOBAL g) ...@@ -2374,6 +2378,7 @@ int TDBBSON::MakeDocument(PGLOBAL g)
} // endif jsp } // endif jsp
Docsize = Bp->GetSize(Docp);
Done = true; Done = true;
return RC_OK; return RC_OK;
} // end of MakeDocument } // end of MakeDocument
...@@ -2388,7 +2393,7 @@ int TDBBSON::Cardinality(PGLOBAL g) ...@@ -2388,7 +2393,7 @@ int TDBBSON::Cardinality(PGLOBAL g)
else if (Cardinal < 0) { else if (Cardinal < 0) {
if (!Multiple) { if (!Multiple) {
if (MakeDocument(g) == RC_OK) if (MakeDocument(g) == RC_OK)
Cardinal = Bp->GetSize(Docp); Cardinal = Docsize;
} else } else
return 10; return 10;
...@@ -2530,12 +2535,9 @@ int TDBBSON::ReadDB(PGLOBAL) ...@@ -2530,12 +2535,9 @@ int TDBBSON::ReadDB(PGLOBAL)
NextSame = false; NextSame = false;
M++; M++;
rc = RC_OK; rc = RC_OK;
} else if (++Fpos < (signed)Bp->GetSize(Docp)) { } else if (++Fpos < Docsize) {
Row = Bp->GetArrayValue(Docp, Fpos); Docrow = (Docrow) ? Bp->GetNext(Docrow) : Bp->GetArrayValue(Docp, Fpos);
Row = (Docrow->Type == TYPE_JVAL) ? Bp->GetBson(Docrow) : Docrow;
if (Row->Type == TYPE_JVAL)
Row = Bp->GetBson(Row);
SameRow = 0; SameRow = 0;
M = 1; M = 1;
rc = RC_OK; rc = RC_OK;
......
...@@ -318,7 +318,9 @@ class DllExport TDBBSON : public TDBBSN { ...@@ -318,7 +318,9 @@ class DllExport TDBBSON : public TDBBSN {
// Members // Members
PBVAL Docp; // The document array PBVAL Docp; // The document array
PBVAL Docrow; // Document row
int Multiple; // 0: No 1: DIR 2: Section 3: filelist int Multiple; // 0: No 1: DIR 2: Section 3: filelist
int Docsize; // The document size
bool Done; // True when document parsing is done bool Done; // True when document parsing is done
bool Changed; // After Update, Insert or Delete bool Changed; // After Update, Insert or Delete
}; // end of class TDBBSON }; // end of class TDBBSON
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment