summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2021-07-30 10:45:26 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2021-07-30 10:45:26 +0200
commit1d468ee0401576e5646cef5d4e4ced9dc5a51a2b (patch)
tree5e221898d9705423c578b37911f4d8fe51811cdc
parentfc98a6d54a7d72865f8f3e580af588bb6ac5fd57 (diff)
downloadmariadb-git-1d468ee0401576e5646cef5d4e4ced9dc5a51a2b.tar.gz
Fix slow processing of pretty json files by BSON tables
-rw-r--r--storage/connect/tabbson.cpp18
-rw-r--r--storage/connect/tabbson.h2
2 files changed, 12 insertions, 8 deletions
diff --git a/storage/connect/tabbson.cpp b/storage/connect/tabbson.cpp
index 3b1f1c84d1a..e372dd662cf 100644
--- a/storage/connect/tabbson.cpp
+++ b/storage/connect/tabbson.cpp
@@ -376,7 +376,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
} // endswitch ReadDB
} else
- jsp = bp->GetArrayValue(bdp, i);
+ jsp = bp->GetNext(jsp);
if (!(row = (jsp) ? bp->GetObject(jsp) : NULL))
break;
@@ -2185,7 +2185,9 @@ void BSONCOL::WriteColumn(PGLOBAL g)
TDBBSON::TDBBSON(PGLOBAL g, PBDEF tdp, PTXF txfp) : TDBBSN(g, tdp, txfp)
{
Docp = NULL;
+ Docrow = NULL;
Multiple = tdp->Multiple;
+ Docsize = 0;
Done = Changed = false;
Bp->SetPretty(2);
} // end of TDBBSON standard constructor
@@ -2193,7 +2195,9 @@ TDBBSON::TDBBSON(PGLOBAL g, PBDEF tdp, PTXF txfp) : TDBBSN(g, tdp, txfp)
TDBBSON::TDBBSON(PBTDB tdbp) : TDBBSN(tdbp)
{
Docp = tdbp->Docp;
+ Docrow = tdbp->Docrow;
Multiple = tdbp->Multiple;
+ Docsize = tdbp->Docsize;
Done = tdbp->Done;
Changed = tdbp->Changed;
} // end of TDBBSON copy constructor
@@ -2374,6 +2378,7 @@ int TDBBSON::MakeDocument(PGLOBAL g)
} // endif jsp
+ Docsize = Bp->GetSize(Docp);
Done = true;
return RC_OK;
} // end of MakeDocument
@@ -2388,7 +2393,7 @@ int TDBBSON::Cardinality(PGLOBAL g)
else if (Cardinal < 0) {
if (!Multiple) {
if (MakeDocument(g) == RC_OK)
- Cardinal = Bp->GetSize(Docp);
+ Cardinal = Docsize;
} else
return 10;
@@ -2530,12 +2535,9 @@ int TDBBSON::ReadDB(PGLOBAL)
NextSame = false;
M++;
rc = RC_OK;
- } else if (++Fpos < (signed)Bp->GetSize(Docp)) {
- Row = Bp->GetArrayValue(Docp, Fpos);
-
- if (Row->Type == TYPE_JVAL)
- Row = Bp->GetBson(Row);
-
+ } else if (++Fpos < Docsize) {
+ Docrow = (Docrow) ? Bp->GetNext(Docrow) : Bp->GetArrayValue(Docp, Fpos);
+ Row = (Docrow->Type == TYPE_JVAL) ? Bp->GetBson(Docrow) : Docrow;
SameRow = 0;
M = 1;
rc = RC_OK;
diff --git a/storage/connect/tabbson.h b/storage/connect/tabbson.h
index 7f41bba6bd9..1696f4dfdbc 100644
--- a/storage/connect/tabbson.h
+++ b/storage/connect/tabbson.h
@@ -318,7 +318,9 @@ protected:
// Members
PBVAL Docp; // The document array
+ PBVAL Docrow; // Document row
int Multiple; // 0: No 1: DIR 2: Section 3: filelist
+ int Docsize; // The document size
bool Done; // True when document parsing is done
bool Changed; // After Update, Insert or Delete
}; // end of class TDBBSON