diff options
Diffstat (limited to 'storage/connect/tabmgo.h')
-rw-r--r-- | storage/connect/tabmgo.h | 125 |
1 files changed, 11 insertions, 114 deletions
diff --git a/storage/connect/tabmgo.h b/storage/connect/tabmgo.h index 66676794e47..bc01df7cfc7 100644 --- a/storage/connect/tabmgo.h +++ b/storage/connect/tabmgo.h @@ -1,43 +1,12 @@ /**************** tabmgo H Declares Source Code File (.H) **************/ -/* Name: tabmgo.h Version 1.0 */ +/* Name: tabmgo.h Version 1.1 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2017 */ /* */ /* This file contains the MongoDB classes declares. */ /***********************************************************************/ -#include "osutil.h" -#include "block.h" -#include "colblk.h" - -/***********************************************************************/ -/* Include MongoDB library header files. */ -/***********************************************************************/ -#include <bson.h> -#include <bcon.h> -#include <mongoc.h> - -typedef class MGODEF *PMGODEF; -typedef class TDBMGO *PTDBMGO; -typedef class MGOCOL *PMGOCOL; -typedef class INCOL *PINCOL; - -typedef struct _bncol { - struct _bncol *Next; - char *Name; - char *Fmt; - int Type; - int Len; - int Scale; - bool Cbn; - bool Found; -} BCOL, *PBCOL; - -typedef struct KEYCOL { - KEYCOL *Next; - PINCOL Incolp; - PCOL Colp; - char *Key; -} *PKC; +#include "mongo.h" +#include "cmgoconn.h" /***********************************************************************/ /* Class used to get the columns of a mongo collection. */ @@ -62,52 +31,7 @@ public: bool all; }; // end of MGODISC -/***********************************************************************/ -/* MongoDB table. */ -/***********************************************************************/ -class DllExport MGODEF : public EXTDEF { /* Table description */ - friend class TDBMGO; - friend class MGOFAM; - friend class MGODISC; - friend PQRYRES MGOColumns(PGLOBAL, char *, PTOS, bool); -public: - // Constructor - MGODEF(void); - - // Implementation - virtual const char *GetType(void) { return "MONGO"; } - - // Methods - virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); - virtual PTDB GetTable(PGLOBAL g, MODE m); - -protected: - // Members - PCSZ Uri; /* MongoDB connection URI */ - PCSZ Colist; /* Options list */ - PCSZ Filter; /* Filtering query */ - int Level; /* Used for catalog table */ - int Base; /* The array index base */ - bool Pipe; /* True is Colist is a pipeline */ -}; // end of MGODEF - -/* ------------------------- TDBMGO classes -------------------------- */ - -/***********************************************************************/ -/* Used when inserting values in a MongoDB collection. */ -/***********************************************************************/ -class INCOL : public BLOCK { -public: - // Constructor - INCOL(void) { Klist = NULL; } - - // Methods - void AddCol(PGLOBAL g, PCOL colp, char *jp); - - //Members - bson_t Child; - PKC Klist; -}; // end of INCOL; +/* -------------------------- TDBMGO class --------------------------- */ /***********************************************************************/ /* This is the MongoDB Table Type class declaration. */ @@ -120,7 +44,7 @@ class DllExport TDBMGO : public TDBEXT { friend PQRYRES MGOColumns(PGLOBAL, char *, PTOS, bool); public: // Constructor - TDBMGO(PMGODEF tdp); + TDBMGO(MGODEF *tdp); TDBMGO(TDBMGO *tdbp); // Implementation @@ -131,7 +55,6 @@ public: virtual PTDB Clone(PTABS t); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL InsertSpecialColumn(PCOL colp); - virtual void SetFilter(PFIL fp); virtual int RowNumber(PGLOBAL g, bool b = FALSE) {return N;} // Database routines @@ -146,35 +69,15 @@ public: protected: bool Init(PGLOBAL g); - mongoc_cursor_t *MakeCursor(PGLOBAL g); - void ShowDocument(bson_iter_t *i, const bson_t *b, const char *k); - void MakeColumnGroups(PGLOBAL g); - bool DocWrite(PGLOBAL g, PINCOL icp); // Members - PGLOBAL G; // Needed by SetFilter - mongoc_uri_t *Uri; - mongoc_client_pool_t *Pool; // Thread safe client pool - mongoc_client_t *Client; // The MongoDB client - mongoc_database_t *Database; // The MongoDB database - mongoc_collection_t *Collection; // The MongoDB collection - mongoc_cursor_t *Cursor; - const bson_t *Document; - bson_t *Query; // MongoDB cursor filter - bson_t *Opts; // MongoDB cursor options - bson_error_t Error; - PINCOL Fpc; // To insert INCOL classes + CMgoConn *Cmgp; // Points to a C Mongo connection class + CMGOPARM Pcg; // Parms passed to Cmgp const Item *Cnd; // The first condition - const char *Uristr; - const char *Db_name; - const char *Coll_name; - const char *Options; // The MongoDB options - const char *Filter; // The filtering query int Fpos; // The current row index int N; // The current Rownum int B; // Array index base bool Done; // Init done - bool Pipe; // True for pipeline }; // end of class TDBMGO /* --------------------------- MGOCOL class -------------------------- */ @@ -191,26 +94,20 @@ public: MGOCOL(MGOCOL *colp, PTDB tdbp); // Constructor used in copy process // Implementation - virtual int GetAmType(void) { return Tmgp->GetAmType(); } + virtual int GetAmType(void) { return Tmgp->GetAmType(); } // Methods -//virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); - virtual void ReadColumn(PGLOBAL g); - virtual void WriteColumn(PGLOBAL g); - bool AddValue(PGLOBAL g, bson_t *doc, char *key, bool upd); + virtual PSZ GetJpath(PGLOBAL g, bool proj); + virtual void ReadColumn(PGLOBAL g); + virtual void WriteColumn(PGLOBAL g); protected: // Default constructor not to be used MGOCOL(void) {} - char *GetProjPath(PGLOBAL g); - char *Mini(PGLOBAL g, const bson_t *bson, bool b); // Members TDBMGO *Tmgp; // To the MGO table block - bson_iter_t Iter; // Used to retrieve column value - bson_iter_t Desc; // Descendant iter char *Jpath; // The json path - char *Mbuf; // The Mini buffer }; // end of class MGOCOL /***********************************************************************/ |