/************** tabcmg C++ Program Source Code File (.CPP) *************/ /* PROGRAM NAME: tabcmg Version 1.3 */ /* (C) Copyright to the author Olivier BERTRAND 2017 - 2021 */ /* This program are the C MongoDB class DB execution routines. */ /***********************************************************************/
/***********************************************************************/ /* Include relevant sections of the MariaDB header file. */ /***********************************************************************/ #include <my_global.h>
/***********************************************************************/ /* Include application header files: */ /* global.h is header containing all global declarations. */ /* plgdbsem.h is header containing the DB application declarations. */ /* tdbdos.h is header containing the TDBDOS declarations. */ /* json.h is header containing the JSON classes declarations. */ /***********************************************************************/ #include"global.h" #include"plgdbsem.h" #include"xtable.h" #include"maputil.h" #include"filamtxt.h" #include"tabext.h" #include"tabcmg.h" #include"tabmul.h" #include"filter.h"
/***********************************************************************/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/ /***********************************************************************/
PCOL TDBCMG::InsertSpecialColumn(PCOL colp)
{ if (!colp->IsSpecial()) return NULL;
colp->SetNext(Columns);
Columns = colp; return colp;
} // end of InsertSpecialColumn
/*********************************************************************/ /* Open an C connection for this table. */ /*********************************************************************/ if (!Cmgp)
Cmgp = new(g) CMgoConn(g, &Pcg); elseif (Cmgp->IsConnected())
Cmgp->Close();
if (Cmgp->Connect(g)) returntrue;
Done = true; returnfalse;
} // end of Init
/***********************************************************************/ /* MONGO Cardinality: returns table size in number of rows. */ /***********************************************************************/ int TDBCMG::Cardinality(PGLOBAL g)
{ if (!g) return1; elseif (Cardinal < 0)
Cardinal = (!Init(g)) ? Cmgp->CollSize(g) : 0;
/***********************************************************************/ /* OpenDB: Data Base open routine for MONGO access method. */ /***********************************************************************/ bool TDBCMG::OpenDB(PGLOBAL g)
{ if (Use == USE_OPEN) { /*******************************************************************/ /* Table already open replace it at its beginning. */ /*******************************************************************/
Cmgp->Rewind();
Fpos = -1; returnfalse;
} // endif Use
/*********************************************************************/ /* First opening. */ /*********************************************************************/ if (Pcg.Pipe && Mode != MODE_READ) {
strcpy(g->Message, "Pipeline tables are read only"); returntrue;
} // endif Pipe
Use = USE_OPEN; // Do it now in case we are recursively called
if (Init(g)) returntrue;
if (Mode == MODE_DELETE && !Next) // Delete all documents return Cmgp->DocDelete(g); elseif (Mode == MODE_INSERT)
Cmgp->MakeColumnGroups(g);
returnfalse;
} // end of OpenDB
/***********************************************************************/ /* Data Base indexed read routine for ODBC access method. */ /***********************************************************************/ bool TDBCMG::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
{
strcpy(g->Message, "MONGO tables are not indexable"); returntrue;
} // end of ReadKey
/***********************************************************************/ /* ReadDB: Get next document from a collection. */ /***********************************************************************/ int TDBCMG::ReadDB(PGLOBAL g)
{ return Cmgp->ReadNext(g);
} // end of ReadDB
/***********************************************************************/ /* WriteDB: Data Base write routine for MGO access method. */ /***********************************************************************/ int TDBCMG::WriteDB(PGLOBAL g)
{ return Cmgp->Write(g);
} // end of WriteDB
/***********************************************************************/ /* Data Base delete line routine for MGO access method. */ /***********************************************************************/ int TDBCMG::DeleteDB(PGLOBAL g, int irc)
{ return (irc == RC_OK) ? WriteDB(g) : RC_OK;
} // end of DeleteDB
/***********************************************************************/ /* Table close routine for MONGO tables. */ /***********************************************************************/ void TDBCMG::CloseDB(PGLOBAL g)
{
Cmgp->Close();
Done = false;
} // end of CloseDB
/***********************************************************************/ /* MGOCOL constructor used for copying columns. */ /* tdbp is the pointer to the new table descriptor. */ /***********************************************************************/
MGOCOL::MGOCOL(MGOCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
{
Tmgp = col1->Tmgp;
Jpath = col1->Jpath;
Sgfy = col1->Sgfy;
} // end of MGOCOL copy constructor
/***********************************************************************/ /* Get path when proj is false or projection path when proj is true. */ /***********************************************************************/
PSZ MGOCOL::GetJpath(PGLOBAL g, bool proj)
{ if (Jpath) { if (proj) { char *p1, *p2, *projpath = PlugDup(g, Jpath); int i = 0;
for (p1 = p2 = projpath; *p1; p1++) if (*p1 == '.') { if (!i)
*p2++ = *p1;
i = 1;
} elseif (i) { if (!isdigit(*p1)) {
*p2++ = *p1;
i = 0;
} // endif p1
} else
*p2++ = *p1;
if (*(p2 - 1) == '.')
p2--;
*p2 = 0; return projpath;
} else return Jpath;
} else return Name;
} // end of GetJpath
/***********************************************************************/ /* ReadColumn: */ /***********************************************************************/ void MGOCOL::ReadColumn(PGLOBAL g)
{
Tmgp->Cmgp->GetColumnValue(g, this);
} // end of ReadColumn
/***********************************************************************/ /* WriteColumn: */ /***********************************************************************/ void MGOCOL::WriteColumn(PGLOBAL g)
{ // Check whether this node must be written if (Value != To_Val)
Value->SetValue_pval(To_Val, FALSE); // Convert the updated value
} // end of WriteColumn
/* ---------------------------TDBGOL class --------------------------- */
/***********************************************************************/ /* TDBGOL class constructor. */ /***********************************************************************/
TDBGOL::TDBGOL(PMGODEF tdp) : TDBCAT(tdp)
{
Topt = tdp->GetTopt();
Uri = tdp->Uri;
Db = tdp->GetTabschema();
} // end of TDBJCL constructor
/***********************************************************************/ /* GetResult: Get the list the JSON file columns. */ /***********************************************************************/
PQRYRES TDBGOL::GetResult(PGLOBAL g)
{ return MGOColumns(g, Db, Uri, Topt, false);
} // end of GetResult
/* -------------------------- End of mongo --------------------------- */
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.