/************** CMGFAM C++ Program Source Code File (.CPP) *************/ /* PROGRAM NAME: cmgfam.cpp */ /* ------------- */ /* Version 1.5 */ /* */ /* COPYRIGHT: */ /* ---------- */ /* (C) Copyright to the author Olivier BERTRAND 20017 - 2020 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ /* This program are the MongoDB access method classes. */ /* */ /***********************************************************************/
/***********************************************************************/ /* Include relevant sections of the System header files. */ /***********************************************************************/ #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. */ /* filamtxt.h is header containing the file AM classes declarations. */ /***********************************************************************/ #include"global.h" #include"plgdbsem.h" #include"reldef.h" #include"filamtxt.h" #include"tabdos.h" #ifdefined(BSON_SUPPORT) #include"tabbson.h" #else #include"tabjson.h" #endif// BSON_SUPPORT #include"cmgfam.h"
/***********************************************************************/ /* Reset: reset position values at the beginning of file. */ /***********************************************************************/ void CMGFAM::Reset(void)
{
TXTFAM::Reset();
Fpos = Tpos = Spos = 0;
} // end of Reset
/***********************************************************************/ /* MGO GetFileLength: returns file size in number of bytes. */ /***********************************************************************/ int CMGFAM::GetFileLength(PGLOBAL g)
{ return0;
} // end of GetFileLength
/***********************************************************************/ /* Cardinality: returns the number of documents in the collection. */ /* This function can be called with a null argument to test the */ /* availability of Cardinality implementation (1 yes, 0 no). */ /***********************************************************************/ int CMGFAM::Cardinality(PGLOBAL g)
{ if (!g) return1;
return (!Init(g)) ? Cmgp->CollSize(g) : 0;
} // end of Cardinality
/***********************************************************************/ /* Note: This function is not really implemented yet. */ /***********************************************************************/ int CMGFAM::MaxBlkSize(PGLOBAL, int s)
{ return s;
} // end of MaxBlkSize
/*********************************************************************/ /* Open an C connection for this table. */ /*********************************************************************/ if (!Cmgp) {
Pcg.Tdbp = Tdbp;
Cmgp = new(g) CMgoConn(g, &Pcg);
} elseif (Cmgp->IsConnected())
Cmgp->Close();
if (Cmgp->Connect(g)) returntrue;
Done = true; returnfalse;
} // end of Init
/***********************************************************************/ /* OpenTableFile: Open a MongoDB table. */ /***********************************************************************/ bool CMGFAM::OpenTableFile(PGLOBAL g)
{
Mode = Tdbp->GetMode();
if (Pcg.Pipe && Mode != MODE_READ) {
strcpy(g->Message, "Pipeline tables are read only"); returntrue;
} // endif Pipe
if (Init(g)) returntrue;
if (Mode == MODE_DELETE && !Tdbp->GetNext()) // Delete all documents return Cmgp->DocDelete(g); elseif (Mode == MODE_INSERT)
Cmgp->MakeColumnGroups(g);
returnfalse;
} // end of OpenTableFile
/***********************************************************************/ /* GetRowID: return the RowID of last read record. */ /***********************************************************************/ int CMGFAM::GetRowID(void)
{ return Rows;
} // end of GetRowID
/***********************************************************************/ /* GetPos: return the position of last read record. */ /***********************************************************************/ int CMGFAM::GetPos(void)
{ return Fpos;
} // end of GetPos
/***********************************************************************/ /* GetNextPos: return the position of next record. */ /***********************************************************************/ int CMGFAM::GetNextPos(void)
{ return Fpos; // TODO
} // end of GetNextPos
/***********************************************************************/ /* SetPos: Replace the table at the specified position. */ /***********************************************************************/ bool CMGFAM::SetPos(PGLOBAL g, int pos)
{
Fpos = pos;
Placed = true; returnfalse;
} // end of SetPos
/***********************************************************************/ /* Record file position in case of UPDATE or DELETE. */ /***********************************************************************/ bool CMGFAM::RecordPos(PGLOBAL g)
{
strcpy(g->Message, "CMGFAM::RecordPos NIY"); returntrue;
} // end of RecordPos
/***********************************************************************/ /* Initialize Fpos and the current position for indexed DELETE. */ /***********************************************************************/ int CMGFAM::InitDelete(PGLOBAL g, int fpos, int spos)
{
strcpy(g->Message, "CMGFAM::InitDelete NIY"); return RC_FX;
} // end of InitDelete
/***********************************************************************/ /* Skip one record in file. */ /***********************************************************************/ int CMGFAM::SkipRecord(PGLOBAL g, bool header)
{ return RC_OK; // Dummy
} // end of SkipRecord
/***********************************************************************/ /* ReadBuffer: Get next document from a collection. */ /***********************************************************************/ int CMGFAM::ReadBuffer(PGLOBAL g)
{ int rc = Cmgp->ReadNext(g);
if (rc != RC_OK) return rc;
strncpy(Tdbp->GetLine(), Cmgp->GetDocument(g), Lrecl); return RC_OK;
} // end of ReadBuffer
/***********************************************************************/ /* WriteBuffer: File write routine for MGO access method. */ /***********************************************************************/ int CMGFAM::WriteBuffer(PGLOBAL g)
{
Pcg.Line = Tdbp->GetLine(); return Cmgp->Write(g);
} // end of WriteBuffer
/***********************************************************************/ /* Data Base delete line routine for MGO and BLK access methods. */ /***********************************************************************/ int CMGFAM::DeleteRecords(PGLOBAL g, int irc)
{ return (irc == RC_OK) ? WriteBuffer(g) : RC_OK;
} // end of DeleteRecords
/***********************************************************************/ /* Table file close routine for MGO access method. */ /***********************************************************************/ void CMGFAM::CloseTableFile(PGLOBAL g, bool)
{
Cmgp->Close();
Done = false;
} // end of CloseTableFile
/***********************************************************************/ /* Rewind routine for MGO access method. */ /***********************************************************************/ void CMGFAM::Rewind(void)
{
Cmgp->Rewind();
} // end of Rewind
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.27 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.