diff options
-rw-r--r-- | storage/connect/json.h | 100 | ||||
-rw-r--r-- | storage/connect/mysql-test/connect/r/json_java_3.result | 30 | ||||
-rw-r--r-- | storage/connect/tabjson.h | 2 |
3 files changed, 72 insertions, 60 deletions
diff --git a/storage/connect/json.h b/storage/connect/json.h index d04577f1734..9ebfbefdf6f 100644 --- a/storage/connect/json.h +++ b/storage/connect/json.h @@ -140,36 +140,36 @@ public: // Methods virtual int size(void) { return 1; } - virtual JTYP GetValType(void) { X return TYPE_JSON; } - virtual void InitArray(PGLOBAL g) { X } +// virtual JTYP GetValType(void) { X return TYPE_JSON; } +// virtual void InitArray(PGLOBAL g) { X } //virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;} - virtual PJPR AddPair(PGLOBAL g, PCSZ key) { X return NULL; } +// virtual PJPR AddPair(PGLOBAL g, PCSZ key) { X return NULL; } virtual void Clear(void) { X } - virtual PJAR GetKeyList(PGLOBAL g) { X return NULL; } - virtual PJAR GetValList(PGLOBAL g) { X return NULL; } - virtual PJVAL GetValue(const char* key) { X return NULL; } +// virtual PJAR GetKeyList(PGLOBAL g) { X return NULL; } +// virtual PJAR GetValList(PGLOBAL g) { X return NULL; } +// virtual PJVAL GetValue(const char* key) { X return NULL; } virtual PJOB GetObject(void) { return NULL; } virtual PJAR GetArray(void) { return NULL; } virtual PJVAL GetValue(int i) { X return NULL; } virtual int GetSize(bool b) { X return 0; } //virtual PVL GetVal(void) { X return NULL; } virtual PJSON GetJsp(void) { X return NULL; } - virtual PJSON GetJson(void) { X return NULL; } +// virtual PJSON GetJson(void) { X return NULL; } virtual PJPR GetFirst(void) { X return NULL; } - virtual int GetInteger(void) { X return 0; } - virtual double GetFloat() { X return 0.0; } - virtual PSZ GetString(PGLOBAL g, char *buff = NULL) { X return NULL; } +// virtual int GetInteger(void) { X return 0; } +// virtual double GetFloat() { X return 0.0; } +// virtual PSZ GetString(PGLOBAL g, char *buff = NULL) { X return NULL; } virtual PSZ GetText(PGLOBAL g, PSTRG text) { X return NULL; } virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; } - virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; } - virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key) { X } - virtual void SetVal(PVL vlp) { X } - virtual void SetValue(PGLOBAL g, PVAL valp) { X } +// virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; } +// virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key) { X } +// virtual void SetVal(PVL vlp) { X } +// virtual void SetValue(PGLOBAL g, PVAL valp) { X } virtual void SetValue(PJSON jsp) { X } - virtual void SetString(PGLOBAL g, PSZ s, short c) { X } - virtual void SetInteger(PGLOBAL g, int n) { X } - virtual void SetFloat(PGLOBAL g, double f) { X } - virtual void DeleteKey(PCSZ k) { X } +// virtual void SetString(PGLOBAL g, PSZ s, short c) { X } +// virtual void SetInteger(PGLOBAL g, int n) { X } +// virtual void SetFloat(PGLOBAL g, double f) { X } +// virtual void DeleteKey(PCSZ k) { X } virtual bool DeleteValue(int i) { X return true; } virtual bool IsNull(void) { X return true; } @@ -190,21 +190,25 @@ public: //using JSON::GetVal; //using JSON::SetVal; + + // Methods virtual void Clear(void) {First = Last = NULL;} //virtual JTYP GetValType(void) {return TYPE_JOB;} virtual PJPR GetFirst(void) {return First;} virtual int GetSize(bool b); - virtual PJPR AddPair(PGLOBAL g, PCSZ key); virtual PJOB GetObject(void) {return this;} - virtual PJVAL GetValue(const char* key); - virtual PJAR GetKeyList(PGLOBAL g); - virtual PJAR GetValList(PGLOBAL g); virtual PSZ GetText(PGLOBAL g, PSTRG text); virtual bool Merge(PGLOBAL g, PJSON jsp); - virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key); - virtual void DeleteKey(PCSZ k); virtual bool IsNull(void); + // Specific + PJPR AddPair(PGLOBAL g, PCSZ key); + PJVAL GetValue(const char* key); + PJAR GetKeyList(PGLOBAL g); + PJAR GetValList(PGLOBAL g); + void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key); + void DeleteKey(PCSZ k); + protected: PJPR First; PJPR Last; @@ -222,20 +226,24 @@ class JARRAY : public JSON { //using JSON::GetVal; //using JSON::SetVal; + + // Methods virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual int size(void) { return Size; } - virtual JTYP GetType(void) {return TYPE_JAR;} +//virtual JTYP GetType(void) {return TYPE_JAR;} virtual PJAR GetArray(void) {return this;} virtual int GetSize(bool b); - PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL); - virtual void InitArray(PGLOBAL g); virtual PJVAL GetValue(int i); virtual PSZ GetText(PGLOBAL g, PSTRG text); virtual bool Merge(PGLOBAL g, PJSON jsp); - virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i); virtual bool DeleteValue(int n); virtual bool IsNull(void); + // Specific + PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int* x = NULL); + bool SetValue(PGLOBAL g, PJVAL jvp, int i); + void InitArray(PGLOBAL g); + protected: // Members int Size; // The number of items in the array @@ -265,31 +273,35 @@ public: //using JSON::GetVal; //using JSON::SetVal; + + // Methods virtual void Clear(void) {Jsp = NULL; Val = NULL; Next = NULL; Del = false;} - virtual JTYP GetType(void) {return TYPE_JVAL;} +//virtual JTYP GetType(void) {return TYPE_JVAL;} virtual JTYP GetValType(void); virtual PJOB GetObject(void); virtual PJAR GetArray(void); - inline PVL GetVal(void) {return Val;} - PVAL GetValue(PGLOBAL g); virtual PJSON GetJsp(void) {return Jsp;} - virtual PJSON GetJson(void) { return (Jsp ? Jsp : this); } - virtual int GetInteger(void); - virtual long long GetBigint(void); - virtual double GetFloat(void); - virtual PSZ GetString(PGLOBAL g, char *buff = NULL); virtual PSZ GetText(PGLOBAL g, PSTRG text); - virtual void SetValue(PJSON jsp); - virtual void SetValue(PGLOBAL g, PVAL valp); - inline void SetVal(PVL vlp) { Val = vlp; } - virtual void SetString(PGLOBAL g, PSZ s, int ci = 0); - virtual void SetInteger(PGLOBAL g, int n); - virtual void SetBigint(PGLOBAL g, longlong ll); - virtual void SetFloat(PGLOBAL g, double f); - virtual void SetBool(PGLOBAL g, bool b); virtual bool IsNull(void); + // Specific + inline PVL GetVal(void) { return Val; } + inline void SetVal(PVL vlp) { Val = vlp; } + inline PJSON GetJson(void) { return (Jsp ? Jsp : this); } + PSZ GetString(PGLOBAL g, char* buff = NULL); + int GetInteger(void); + long long GetBigint(void); + double GetFloat(void); + PVAL GetValue(PGLOBAL g); + void SetValue(PJSON jsp); + void SetValue(PGLOBAL g, PVAL valp); + void SetString(PGLOBAL g, PSZ s, int ci = 0); + void SetInteger(PGLOBAL g, int n); + void SetBigint(PGLOBAL g, longlong ll); + void SetFloat(PGLOBAL g, double f); + void SetBool(PGLOBAL g, bool b); + protected: PJSON Jsp; // To the json value PVL Val; // To the string or numeric value diff --git a/storage/connect/mysql-test/connect/r/json_java_3.result b/storage/connect/mysql-test/connect/r/json_java_3.result index e7dd9468845..b9ba919507d 100644 --- a/storage/connect/mysql-test/connect/r/json_java_3.result +++ b/storage/connect/mysql-test/connect/r/json_java_3.result @@ -80,11 +80,11 @@ t1 CREATE TABLE `t1` ( ) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mongodb://localhost:27017' `TABLE_TYPE`='JSON' `TABNAME`='restaurants' `OPTION_LIST`='Depth=1,Driver=Java,Version=3' `DATA_CHARSET`='utf8' `LRECL`=4096 SELECT * FROM t1 LIMIT 5; _id address_building address_coord address_street address_zipcode borough cuisine grades_date grades_grade grades_score name restaurant_id -58ada47de5a51ddfcd5ed51c 1007 -73.856077 Morris Park Ave 10462 Bronx Bakery 1393804800 A 2 Morris Park Bake Shop 30075445 -58ada47de5a51ddfcd5ed51d 469 -73.961704 Flatbush Avenue 11225 Brooklyn Hamburgers 1419897600 A 8 Wendy'S 30112340 -58ada47de5a51ddfcd5ed51e 351 -73.98513559999999 West 57 Street 10019 Manhattan Irish 1409961600 A 2 Dj Reynolds Pub And Restaurant 30191841 -58ada47de5a51ddfcd5ed51f 2780 -73.98241999999999 Stillwell Avenue 11224 Brooklyn American 1402358400 A 5 Riviera Caterer 40356018 -58ada47de5a51ddfcd5ed520 97-22 -73.8601152 63 Road 11374 Queens Jewish/Kosher 1416787200 Z 20 Tov Kosher Kitchen 40356068 +58ada47de5a51ddfcd5ed51c 1007 -73.856077, 40.848447 Morris Park Ave 10462 Bronx Bakery 1393804800 A 2 Morris Park Bake Shop 30075445 +58ada47de5a51ddfcd5ed51d 469 -73.961704, 40.662942 Flatbush Avenue 11225 Brooklyn Hamburgers 1419897600 A 8 Wendy'S 30112340 +58ada47de5a51ddfcd5ed51e 351 -73.98513559999999, 40.7676919 West 57 Street 10019 Manhattan Irish 1409961600 A 2 Dj Reynolds Pub And Restaurant 30191841 +58ada47de5a51ddfcd5ed51f 2780 -73.98241999999999, 40.579505 Stillwell Avenue 11224 Brooklyn American 1402358400 A 5 Riviera Caterer 40356018 +58ada47de5a51ddfcd5ed520 97-22 -73.8601152, 40.7311739 63 Road 11374 Queens Jewish/Kosher 1416787200 Z 20 Tov Kosher Kitchen 40356068 DROP TABLE t1; # # Dropping a column @@ -93,16 +93,16 @@ CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JSON TABNAME=restaurants DATA_CHARSET= COLIST='{"grades":0}' OPTION_LIST='Driver=Java,Version=3,level=0' CONNECTION='mongodb://localhost:27017' LRECL=4096; SELECT * FROM t1 LIMIT 10; _id address borough cuisine name restaurant_id -58ada47de5a51ddfcd5ed51c 1007 -73.856077 40.848447 Morris Park Ave 10462 Bronx Bakery Morris Park Bake Shop 30075445 -58ada47de5a51ddfcd5ed51d 469 -73.961704 40.662942 Flatbush Avenue 11225 Brooklyn Hamburgers Wendy'S 30112340 -58ada47de5a51ddfcd5ed51e 351 -73.98513559999999 40.7676919 West 57 Street 10019 Manhattan Irish Dj Reynolds Pub And Restaurant 30191841 -58ada47de5a51ddfcd5ed51f 2780 -73.98241999999999 40.579505 Stillwell Avenue 11224 Brooklyn American Riviera Caterer 40356018 -58ada47de5a51ddfcd5ed520 97-22 -73.8601152 40.7311739 63 Road 11374 Queens Jewish/Kosher Tov Kosher Kitchen 40356068 -58ada47de5a51ddfcd5ed521 8825 -73.8803827 40.7643124 Astoria Boulevard 11369 Queens American Brunos On The Boulevard 40356151 -58ada47de5a51ddfcd5ed522 2206 -74.1377286 40.6119572 Victory Boulevard 10314 Staten Island Jewish/Kosher Kosher Island 40356442 -58ada47de5a51ddfcd5ed523 7114 -73.9068506 40.6199034 Avenue U 11234 Brooklyn Delicatessen Wilken'S Fine Food 40356483 -58ada47de5a51ddfcd5ed524 6409 -74.00528899999999 40.628886 11 Avenue 11219 Brooklyn American Regina Caterers 40356649 -58ada47de5a51ddfcd5ed525 1839 -73.9482609 40.6408271 Nostrand Avenue 11226 Brooklyn Ice Cream, Gelato, Yogurt, Ices Taste The Tropics Ice Cream 40356731 +58ada47de5a51ddfcd5ed51c 1007 (-73.856077, 40.848447) Morris Park Ave 10462 Bronx Bakery Morris Park Bake Shop 30075445 +58ada47de5a51ddfcd5ed51d 469 (-73.961704, 40.662942) Flatbush Avenue 11225 Brooklyn Hamburgers Wendy'S 30112340 +58ada47de5a51ddfcd5ed51e 351 (-73.98513559999999, 40.7676919) West 57 Street 10019 Manhattan Irish Dj Reynolds Pub And Restaurant 30191841 +58ada47de5a51ddfcd5ed51f 2780 (-73.98241999999999, 40.579505) Stillwell Avenue 11224 Brooklyn American Riviera Caterer 40356018 +58ada47de5a51ddfcd5ed520 97-22 (-73.8601152, 40.7311739) 63 Road 11374 Queens Jewish/Kosher Tov Kosher Kitchen 40356068 +58ada47de5a51ddfcd5ed521 8825 (-73.8803827, 40.7643124) Astoria Boulevard 11369 Queens American Brunos On The Boulevard 40356151 +58ada47de5a51ddfcd5ed522 2206 (-74.1377286, 40.6119572) Victory Boulevard 10314 Staten Island Jewish/Kosher Kosher Island 40356442 +58ada47de5a51ddfcd5ed523 7114 (-73.9068506, 40.6199034) Avenue U 11234 Brooklyn Delicatessen Wilken'S Fine Food 40356483 +58ada47de5a51ddfcd5ed524 6409 (-74.00528899999999, 40.628886) 11 Avenue 11219 Brooklyn American Regina Caterers 40356649 +58ada47de5a51ddfcd5ed525 1839 (-73.9482609, 40.6408271) Nostrand Avenue 11226 Brooklyn Ice Cream, Gelato, Yogurt, Ices Taste The Tropics Ice Cream 40356731 DROP TABLE t1; # # Specifying Jpath diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h index ef944021d7f..f5d7b3153b2 100644 --- a/storage/connect/tabjson.h +++ b/storage/connect/tabjson.h @@ -173,7 +173,7 @@ protected: PGLOBAL G; // Support of parse memory PJSON Top; // The top JSON tree PJSON Row; // The current row - PJSON Val; // The value of the current row + PJVAL Val; // The value of the current row PJCOL Colp; // The multiple column JMODE Jmode; // MODE_OBJECT by default PCSZ Objname; // The table object name |