diff options
Diffstat (limited to 'storage/connect/tabjson.h')
-rw-r--r-- | storage/connect/tabjson.h | 91 |
1 files changed, 62 insertions, 29 deletions
diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h index 68f79a1526a..4505d30a21c 100644 --- a/storage/connect/tabjson.h +++ b/storage/connect/tabjson.h @@ -1,5 +1,5 @@ /*************** tabjson H Declares Source Code File (.H) **************/ -/* Name: tabjson.h Version 1.0 */ +/* Name: tabjson.h Version 1.1 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* */ @@ -16,8 +16,6 @@ typedef class JSONDEF *PJDEF; typedef class TDBJSON *PJTDB; typedef class JSONCOL *PJCOL; -class TDBJSN; - /***********************************************************************/ /* The JSON tree node. Can be an Object or an Array. */ /***********************************************************************/ @@ -25,7 +23,10 @@ typedef struct _jnode { PSZ Key; // The key used for object OPVAL Op; // Operator used for this node PVAL CncVal; // To cont value used for OP_CNC + PVAL Valp; // The internal array VALUE int Rank; // The rank in array + int Rx; // Read row number + int Nx; // Next to read row number } JNODE, *PJNODE; /***********************************************************************/ @@ -34,6 +35,8 @@ typedef struct _jnode { class JSONDEF : public DOSDEF { /* Table description */ friend class TDBJSON; friend class TDBJSN; + friend class TDBJCL; + friend PQRYRES JSONColumns(PGLOBAL, char*, PTOS, bool); public: // Constructor JSONDEF(void); @@ -52,6 +55,8 @@ class JSONDEF : public DOSDEF { /* Table description */ char *Xcol; /* Name of expandable column */ int Limit; /* Limit of multiple values */ int Pretty; /* Depends on file structure */ + int Level; /* Used for catalog table */ + int Base; /* Tne array index base */ bool Strict; /* Strict syntax checking */ }; // end of JSONDEF @@ -69,40 +74,48 @@ class TDBJSN : public TDBDOS { TDBJSN(TDBJSN *tdbp); // Implementation - virtual AMT GetAmType(void) {return TYPE_AM_JSN;} - virtual bool SkipHeader(PGLOBAL g); - virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);} + virtual AMT GetAmType(void) {return TYPE_AM_JSN;} + virtual bool SkipHeader(PGLOBAL g); + virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSN(this);} + PJSON GetRow(void) {return Row;} // Methods - virtual PTDB CopyOne(PTABS t); - virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); - virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); - virtual int RowNumber(PGLOBAL g, BOOL b = FALSE) - {return (b) ? N : Fpos + 1;} + virtual PTDB CopyOne(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 (b) ? M : N;} // Database routines - virtual int Cardinality(PGLOBAL g); - virtual int GetMaxSize(PGLOBAL g); - virtual bool OpenDB(PGLOBAL g); - virtual bool PrepareWriting(PGLOBAL g); - virtual int ReadDB(PGLOBAL g); + virtual int Cardinality(PGLOBAL g); + virtual int GetMaxSize(PGLOBAL g); + virtual bool OpenDB(PGLOBAL g); + virtual bool PrepareWriting(PGLOBAL g); + virtual int ReadDB(PGLOBAL g); protected: + PJSON FindRow(PGLOBAL g); + int MakeTopTree(PGLOBAL g, PJSON jsp); + // Members + PJSON Top; // The top JSON tree PJSON Row; // The current row + PJSON Val; // The value of the current row PJCOL Colp; // The multiple column JMODE Jmode; // MODE_OBJECT by default + char *Objname; // The table object name char *Xcol; // Name of expandable column int Fpos; // The current row index - int Spos; // DELETE start index int N; // The current Rownum + int M; // Index of multiple value int Limit; // Limit of multiple values int Pretty; // Depends on file structure - bool Strict; // Strict syntax checking - bool NextSame; // Same next row - bool Comma; // Row has final comma + int NextSame; // Same next row int SameRow; // Same row nb int Xval; // Index of expandable array + int B; // Array index base + bool Strict; // Strict syntax checking + bool Comma; // Row has final comma }; // end of class TDBJSN /* -------------------------- JSONCOL class -------------------------- */ @@ -130,8 +143,12 @@ class JSONCOL : public DOSCOL { protected: bool CheckExpand(PGLOBAL g, int i, PSZ nm, bool b); bool SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm); - PJSON GetRow(PGLOBAL g, int mode); + PVAL GetColumnValue(PGLOBAL g, PJSON row, int i); + PVAL ExpandArray(PGLOBAL g, PJAR arp, int n); + PVAL CalculateArray(PGLOBAL g, PJAR arp, int n); + PVAL MakeJson(PGLOBAL g, PJSON jsp); void SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n); + PJSON GetRow(PGLOBAL g); // Default constructor not to be used JSONCOL(void) {} @@ -139,12 +156,10 @@ class JSONCOL : public DOSCOL { // Members TDBJSN *Tjp; // To the JSN table block PVAL MulVal; // To value used by multiple column - PJAR Arp; // The intermediate array char *Jpath; // The json path - JNODE *Nodes ; // The intermediate objects + JNODE *Nodes; // The intermediate objects int Nod; // The number of intermediate objects - int Ival; // Index of multiple values - int Nx; // The last read sub-row + int Xnod; // Index of multiple values bool Xpd; // True for expandable column bool Parsed; // True when parsed }; // end of class JSONCOL @@ -164,6 +179,7 @@ class TDBJSON : public TDBJSN { // Implementation virtual AMT GetAmType(void) {return TYPE_AM_JSON;} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBJSON(this);} + PJAR GetDoc(void) {return Doc;} // Methods virtual PTDB CopyOne(PTABS t); @@ -172,26 +188,43 @@ class TDBJSON : public TDBJSN { virtual int Cardinality(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g); virtual void ResetSize(void); - virtual int GetRecpos(void) {return Fpos;} + virtual int GetProgCur(void) {return N;} + virtual int GetRecpos(void); + virtual bool SetRecpos(PGLOBAL g, int recpos); virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g); virtual bool PrepareWriting(PGLOBAL g) {return false;} virtual int WriteDB(PGLOBAL g); virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g); + int MakeDocument(PGLOBAL g); // Optimization routines virtual int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add); protected: int MakeNewDoc(PGLOBAL g); - int MakeDocument(PGLOBAL g); // Members - PJSON Top; // The file JSON tree PJAR Doc; // The document array - char *Objname; // The table object name int Multiple; // 0: No 1: DIR 2: Section 3: filelist bool Done; // True when document parsing is done bool Changed; // After Update, Insert or Delete }; // end of class TDBJSON + +/***********************************************************************/ +/* This is the class declaration for the JSON catalog table. */ +/***********************************************************************/ +class TDBJCL : public TDBCAT { + public: + // Constructor + TDBJCL(PJDEF tdp); + + protected: + // Specific routines + virtual PQRYRES GetResult(PGLOBAL g); + + // Members + PTOS Topt; + char *Db; + }; // end of class TDBJCL |