2017-07-18 13:16:55 +02:00
|
|
|
/**************** tabcmg H Declares Source Code File (.H) **************/
|
2021-05-01 22:29:38 +02:00
|
|
|
/* Name: tabcmg.h Version 1.3 */
|
2017-05-23 19:35:50 +02:00
|
|
|
/* */
|
2021-05-01 22:29:38 +02:00
|
|
|
/* (C) Copyright to the author Olivier BERTRAND 2017 - 2021 */
|
2017-05-23 19:35:50 +02:00
|
|
|
/* */
|
|
|
|
/* This file contains the MongoDB classes declares. */
|
|
|
|
/***********************************************************************/
|
2017-07-02 22:29:31 +02:00
|
|
|
#include "mongo.h"
|
|
|
|
#include "cmgoconn.h"
|
2017-05-23 19:35:50 +02:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Class used to get the columns of a mongo collection. */
|
|
|
|
/***********************************************************************/
|
2017-07-18 13:16:55 +02:00
|
|
|
class CMGDISC : public MGODISC {
|
2017-05-23 19:35:50 +02:00
|
|
|
public:
|
|
|
|
// Constructor
|
2017-07-18 13:16:55 +02:00
|
|
|
CMGDISC(PGLOBAL g, int *lg) : MGODISC(g, lg) { drv = "C"; }
|
2017-05-23 19:35:50 +02:00
|
|
|
|
2017-07-18 13:16:55 +02:00
|
|
|
// Methods
|
|
|
|
virtual void GetDoc(void);
|
|
|
|
//virtual bool Find(PGLOBAL g, int i, int k, bool b);
|
|
|
|
virtual bool Find(PGLOBAL g);
|
|
|
|
|
|
|
|
// BSON Function
|
|
|
|
//bool FindInDoc(PGLOBAL g, bson_iter_t *iter, const bson_t *doc,
|
|
|
|
// char *pcn, char *pfmt, int i, int k, bool b);
|
2017-05-23 19:35:50 +02:00
|
|
|
bool FindInDoc(PGLOBAL g, bson_iter_t *iter, const bson_t *doc,
|
2017-07-18 13:16:55 +02:00
|
|
|
char *pcn, char *pfmt, int k, bool b);
|
2017-05-23 19:35:50 +02:00
|
|
|
|
|
|
|
// Members
|
2017-07-18 13:16:55 +02:00
|
|
|
bson_iter_t iter;
|
|
|
|
const bson_t *doc;
|
|
|
|
}; // end of CMGDISC
|
2017-05-23 19:35:50 +02:00
|
|
|
|
2017-07-18 13:16:55 +02:00
|
|
|
/* -------------------------- TDBCMG class --------------------------- */
|
2017-05-23 19:35:50 +02:00
|
|
|
|
|
|
|
/***********************************************************************/
|
2017-06-10 00:52:56 +02:00
|
|
|
/* This is the MongoDB Table Type class declaration. */
|
2017-05-23 19:35:50 +02:00
|
|
|
/* The table is a collection, each record being a document. */
|
|
|
|
/***********************************************************************/
|
2017-07-18 13:16:55 +02:00
|
|
|
class DllExport TDBCMG : public TDBEXT {
|
2017-05-23 19:35:50 +02:00
|
|
|
friend class MGOCOL;
|
|
|
|
friend class MGODEF;
|
2017-07-18 13:16:55 +02:00
|
|
|
friend class CMGDISC;
|
2017-07-02 22:29:31 +02:00
|
|
|
friend PQRYRES MGOColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool);
|
2017-05-23 19:35:50 +02:00
|
|
|
public:
|
|
|
|
// Constructor
|
2017-07-18 13:16:55 +02:00
|
|
|
TDBCMG(MGODEF *tdp);
|
|
|
|
TDBCMG(TDBCMG *tdbp);
|
2017-05-23 19:35:50 +02:00
|
|
|
|
|
|
|
// Implementation
|
|
|
|
virtual AMT GetAmType(void) {return TYPE_AM_MGO;}
|
2017-07-18 13:16:55 +02:00
|
|
|
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBCMG(this);}
|
2017-05-23 19:35:50 +02:00
|
|
|
|
|
|
|
// Methods
|
|
|
|
virtual PTDB Clone(PTABS t);
|
|
|
|
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
|
|
|
virtual PCOL InsertSpecialColumn(PCOL colp);
|
|
|
|
virtual int RowNumber(PGLOBAL g, bool b = FALSE) {return N;}
|
|
|
|
|
|
|
|
// Database routines
|
|
|
|
virtual int Cardinality(PGLOBAL g);
|
|
|
|
virtual int GetMaxSize(PGLOBAL g);
|
|
|
|
virtual bool OpenDB(PGLOBAL g);
|
|
|
|
virtual int ReadDB(PGLOBAL g);
|
|
|
|
virtual int WriteDB(PGLOBAL g);
|
|
|
|
virtual int DeleteDB(PGLOBAL g, int irc);
|
|
|
|
virtual void CloseDB(PGLOBAL g);
|
|
|
|
virtual bool ReadKey(PGLOBAL g, OPVAL op, const key_range *kr);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool Init(PGLOBAL g);
|
|
|
|
|
|
|
|
// Members
|
2017-07-02 22:29:31 +02:00
|
|
|
CMgoConn *Cmgp; // Points to a C Mongo connection class
|
|
|
|
CMGOPARM Pcg; // Parms passed to Cmgp
|
2017-05-23 19:35:50 +02:00
|
|
|
const Item *Cnd; // The first condition
|
2021-07-24 16:28:57 +02:00
|
|
|
PCSZ Strfy; // The stringified columns
|
2017-05-23 19:35:50 +02:00
|
|
|
int Fpos; // The current row index
|
|
|
|
int N; // The current Rownum
|
|
|
|
int B; // Array index base
|
|
|
|
bool Done; // Init done
|
2017-07-18 13:16:55 +02:00
|
|
|
}; // end of class TDBCMG
|
2017-05-23 19:35:50 +02:00
|
|
|
|
|
|
|
/* --------------------------- MGOCOL class -------------------------- */
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Class MGOCOL: MongoDB access method column descriptor. */
|
|
|
|
/***********************************************************************/
|
|
|
|
class DllExport MGOCOL : public EXTCOL {
|
2017-07-18 13:16:55 +02:00
|
|
|
friend class TDBCMG;
|
2017-05-23 19:35:50 +02:00
|
|
|
friend class FILTER;
|
|
|
|
public:
|
|
|
|
// Constructors
|
|
|
|
MGOCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
|
|
|
|
MGOCOL(MGOCOL *colp, PTDB tdbp); // Constructor used in copy process
|
|
|
|
|
|
|
|
// Implementation
|
2017-07-02 22:29:31 +02:00
|
|
|
virtual int GetAmType(void) { return Tmgp->GetAmType(); }
|
2021-05-01 22:29:38 +02:00
|
|
|
virtual bool Stringify(void) { return Sgfy; }
|
2017-05-23 19:35:50 +02:00
|
|
|
|
|
|
|
// Methods
|
2017-07-02 22:29:31 +02:00
|
|
|
virtual PSZ GetJpath(PGLOBAL g, bool proj);
|
|
|
|
virtual void ReadColumn(PGLOBAL g);
|
|
|
|
virtual void WriteColumn(PGLOBAL g);
|
2017-05-23 19:35:50 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Default constructor not to be used
|
|
|
|
MGOCOL(void) {}
|
|
|
|
|
|
|
|
// Members
|
2017-07-18 13:16:55 +02:00
|
|
|
TDBCMG *Tmgp; // To the MGO table block
|
2017-05-23 19:35:50 +02:00
|
|
|
char *Jpath; // The json path
|
2021-05-01 22:29:38 +02:00
|
|
|
bool Sgfy; // True if stringified
|
2017-05-23 19:35:50 +02:00
|
|
|
}; // end of class MGOCOL
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* This is the class declaration for the MONGO catalog table. */
|
|
|
|
/***********************************************************************/
|
|
|
|
class DllExport TDBGOL : public TDBCAT {
|
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
TDBGOL(PMGODEF tdp);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Specific routines
|
|
|
|
virtual PQRYRES GetResult(PGLOBAL g);
|
|
|
|
|
|
|
|
// Members
|
2017-07-02 22:29:31 +02:00
|
|
|
PTOS Topt;
|
|
|
|
PCSZ Uri;
|
|
|
|
PCSZ Db;
|
2017-05-23 19:35:50 +02:00
|
|
|
}; // end of class TDBGOL
|