├── CLA_rev1.1.pdf ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── docs ├── NodejsAPIReference.files │ ├── filelist.xml │ ├── sheet001.htm │ ├── sheet002.htm │ ├── sheet003.htm │ ├── sheet004.htm │ ├── stylesheet.css │ └── tabstrip.htm └── NodejsAPIReference.htm ├── griddb_node.js ├── include └── gridstore.h ├── sample ├── BlobData.js ├── Connect.js ├── ContainerInformation.js ├── ContainerNames.js ├── CreateCollection.js ├── CreateIndex.js ├── CreateTimeSeries.js ├── FetchAll.js ├── GetRow.js ├── MultiGet.js ├── MultiPut.js ├── PutRow.js ├── PutRows.js ├── RemoveRowByRowkey.js ├── TQLAggregation.js ├── TQLSelect.js ├── TQLTimeseries.js ├── TimeSeriesRowExpiration.js ├── sample1.js ├── sample2.js └── sample3.js └── src ├── AggregationResult.cpp ├── AggregationResult.h ├── Container.cpp ├── Container.h ├── ContainerInfo.cpp ├── ContainerInfo.h ├── EnumValue.h ├── ExpirationInfo.h ├── Field.cpp ├── Field.h ├── GSException.h ├── PartitionController.cpp ├── PartitionController.h ├── Query.cpp ├── Query.h ├── QueryAnalysisEntry.cpp ├── QueryAnalysisEntry.h ├── RowKeyPredicate.cpp ├── RowKeyPredicate.h ├── RowSet.cpp ├── RowSet.h ├── Store.cpp ├── Store.h ├── StoreFactory.cpp ├── StoreFactory.h ├── TimeSeriesProperties.cpp ├── TimeSeriesProperties.h ├── Util.cpp ├── Util.h ├── griddb.i ├── gstype.i └── gstype_js_v8.i /CLA_rev1.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/griddb/nodejs_client/43c04a1d7335af89be003fddb805785619521ae1/CLA_rev1.1.pdf -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(griddb_client) 4 | 5 | set(C_LIB C:/Users/User/Downloads/griddb_c_lib) 6 | set(SWIG_RESOURCE C:/Users/User/Downloads/swigwin-4.0.0) 7 | set(SOURCE_HEADER src) 8 | set(C_HEADER include) 9 | set(NAN_HEADER node_modules/nan) 10 | 11 | set(SWIG_DIR ${SWIG_RESOURCE}/Lib) 12 | set(SWIG_EXECUTABLE ${SWIG_RESOURCE}/swig.exe) 13 | find_package(SWIG REQUIRED) 14 | include(${SWIG_USE_FILE}) 15 | set(CMAKE_SWIG_FLAGS -c++ -javascript -node) 16 | set(CMAKE_CXX_FLAGS "/DLL /LD /D_USRDLL /D_WINDLL /DBUILDING_NODE_EXTENSION /MT /MD") 17 | 18 | include_directories(${CMAKE_JS_INC} ${NAN_HEADER} ${C_HEADER} ${SOURCE_HEADER}) 19 | 20 | link_directories(${C_LIB}) 21 | 22 | file(GLOB SOURCE_FILES ${SOURCE_HEADER}/*.cpp) 23 | 24 | set_property(SOURCE ${SOURCE_HEADER}/griddb.i PROPERTY CPLUSPLUS ON) 25 | swig_add_library(${PROJECT_NAME} TYPE SHARED LANGUAGE javascript SOURCES ${SOURCE_HEADER}/griddb.i ${SOURCE_FILES}) 26 | set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") 27 | 28 | target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} gridstore_c) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | SWIG = swig -DSWIGWORDSIZE64 3 | CXX = g++ 4 | 5 | JS_ENGINE ?= node 6 | 7 | JS_OPTION = v8 8 | 9 | ARCH = $(shell arch) 10 | 11 | LDFLAGS = -Llibs -lpthread -lrt -lgridstore 12 | LDFLAGS_JS = -rdynamic -pthread 13 | 14 | CPPFLAGS = -fPIC -std=c++0x -g -O2 15 | INCLUDES = -Iinclude -Isrc 16 | 17 | INCLUDES_JS = $(INCLUDES) 18 | INCLUDES_JS += -I/usr/include/node 19 | INCLUDES_JS += -Inode_modules/nan 20 | 21 | CPPFLAGS_JS = $(CPPFLAGS) $(INCLUDES_JS) \ 22 | -DNODE_GYP_MODULE_NAME=griddb \ 23 | -DV8_DEPRECATION_WARNINGS=1 \ 24 | -DBUILDING_NODE_EXTENSION 25 | 26 | PROGRAM = griddb_client.node 27 | EXTRA = 28 | 29 | SOURCES = src/TimeSeriesProperties.cpp \ 30 | src/ContainerInfo.cpp \ 31 | src/AggregationResult.cpp \ 32 | src/Container.cpp \ 33 | src/Store.cpp \ 34 | src/StoreFactory.cpp \ 35 | src/PartitionController.cpp \ 36 | src/Query.cpp \ 37 | src/QueryAnalysisEntry.cpp \ 38 | src/RowKeyPredicate.cpp \ 39 | src/RowSet.cpp \ 40 | src/Field.cpp \ 41 | src/Util.cpp \ 42 | 43 | all: $(PROGRAM) 44 | 45 | SWIG_DEF = src/griddb.i 46 | 47 | SWIG_JS_SOURCES = src/griddb_js.cxx 48 | 49 | OBJS = $(SOURCES:.cpp=.o) 50 | SWIG_JS_OBJS = $(SWIG_JS_SOURCES:.cxx=.o) 51 | 52 | $(SWIG_JS_SOURCES) : $(SWIG_DEF) 53 | $(SWIG) -Ilibs/js/$(JS_OPTION) -outdir . -o $@ -c++ -javascript -$(JS_ENGINE) $< 54 | 55 | .cpp.o: 56 | $(CXX) $(CPPFLAGS) -c -o $@ $(INCLUDES) $< 57 | 58 | $(SWIG_JS_OBJS): $(SWIG_JS_SOURCES) 59 | $(CXX) $(CPPFLAGS_JS) -c -o $@ $< 60 | 61 | $(PROGRAM): $(OBJS) $(SWIG_JS_OBJS) 62 | $(CXX) -shared -o $@ $(OBJS) $(SWIG_JS_OBJS) $(LDFLAGS) $(LDFLAGS_JS) 63 | 64 | clean: 65 | rm -rf $(OBJS) $(SWIG_JS_OBJS) 66 | rm -rf $(SWIG_JS_SOURCES) 67 | rm -rf $(PROGRAM) $(EXTRA) 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GridDB Node.JS Client 2 | 3 | ## Overview 4 | 5 | GridDB Node.JS Client is developed using GridDB C Client and [SWIG](http://www.swig.org/) (Simplified Wrapper and Interface Generator). 6 | 7 | ## Operating environment 8 | 9 | Building of the library and execution of the sample programs have been checked in the following environment. 10 | 11 | OS: CentOS 7.6(x64) (GCC 4.8.5) 12 | SWIG: The development (master) version (commit ID 113d78a083aa897ffdca4ff6bd9b42e630d16d27(2020/4/7)) 13 | Node.js: v12 14 | GridDB C client: V4.6 CE(Community Edition) 15 | GridDB server: V4.6 CE, CentOS 7.9 (GCC 4.8.5) 16 | 17 | OS: Ubuntu 20.04(x64) (gcc 10.2.0) 18 | SWIG: The development (master) version (commit ID 113d78a083aa897ffdca4ff6bd9b42e630d16d27(2020/4/7)) 19 | Node.js: v12 20 | GridDB C client: V4.6 CE(Community Edition) 21 | GridDB server: V4.6 CE, CentOS 7.9 (GCC 4.8.5) 22 | 23 | OS: Windows 10(x64) (VS2017) 24 | SWIG: The development (master) version (commit ID 27f29aef2cf00735172c28d331536d0069b0f1f4(2021/3/2)) 25 | Node.js: v12 26 | GridDB C client: V4.6 CE(Community Edition) 27 | GridDB server: V4.6 CE, CentOS 7.9 (GCC 4.8.5) 28 | 29 | Note: We can build and run Node.JS Client with SWIG 4.0.2 for Node.js v10. 30 | 31 | ## QuickStart (CentOS, Ubuntu) 32 | ### Preparations 33 | 34 | Install SWIG: 35 | - Checkout SWIG with the upper commit ID at https://github.com/swig/swig 36 | - Run commands below in command line at SWIG folder: 37 | ``` 38 | ./autogen.sh 39 | ./configure 40 | make 41 | sudo make install 42 | ``` 43 | 44 | Install [GridDB Server](https://github.com/griddb/griddb) and [C Client](https://github.com/griddb/c_client). (Note: If you build them from source code, please use GCC 4.8.5.) 45 | 46 | Install Node.js(v12). 47 | 48 | If required, change INCLUDES_JS path in Makefile. 49 | 50 | Set LIBRARY_PATH. 51 | 52 | export LIBRARY_PATH=$LIBRARY_PATH: 53 | 54 | ### Build and Run 55 | 56 | 1. Execute the command on project directory. 57 | 58 | $ npm install nan 59 | $ make 60 | 61 | 2. Set the NODE_PATH variable for griddb Node.js module files. 62 | 63 | $ export NODE_PATH= 64 | 65 | 3. Write require("griddb_node") in Node.js. 66 | 67 | ### How to run sample 68 | 69 | GridDB Server need to be started in advance. 70 | 71 | 1. Set LD_LIBRARY_PATH 72 | 73 | export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}: 74 | 75 | 2. The command to run sample 76 | 77 | $ node sample/sample1.js 78 | 79 | -->[ 'name01', false, 1, ] 80 | 81 | ## QuickStart (Windows) 82 | ### Preparations 83 | 84 | Install CMake 85 | - Download and install package from https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2-win64-x64.msi 86 | 87 | Install Nuget 88 | - Download and install package from https://www.nuget.org/downloads (installed to C:\Tools) 89 | 90 | Install Bison using the following command: 91 | 92 | C:\Tools\nuget install bison-win32 -Version 2.4.1.1 -OutputDirectory C:\Tools\bison 93 | 94 | Install PCRE using Nuget using the following command: 95 | 96 | C:\Tools\nuget install pcre -Version 8.33.0.1 -OutputDirectory C:\Tools\pcre 97 | 98 | Install SWIG as below. 99 | - Checkout SWIG with the upper commit ID at https://github.com/swig/swig 100 | - Run commands below in cmd at SWIG folder: 101 | ``` 102 | SET PATH=C:\Tools\bison\bison-win32.2.4.1.1\tools\native\bin;%PATH% 103 | SET PCRE_ROOT=C:\Tools\pcre\pcre.8.33.0.1\build\native 104 | SET PCRE_PLATFORM=x64 105 | cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC /MT" -DCMAKE_CXX_FLAGS="/DPCRE_STATIC /MT" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib . 106 | cmake --build . --config Release 107 | ``` 108 | 109 | - Set path for SWIG_RESOURCE in CmakeList.txt. 110 | ``` 111 | set(SWIG_RESOURCE /PATH/TO/SWIG/FOLDER) 112 | ``` 113 | 114 | Install Node.js(v12) 115 | - Download and install package from https://nodejs.org/dist/v12.13.0/node-v12.13.0-x64.msi 116 | 117 | Install [GridDB Server](https://github.com/griddb/griddb) on CentOS. (Note: If you build them from source code, please use GCC 4.8.5.) 118 | 119 | Install GridDB C Client. 120 | - Please refer to https://github.com/griddb/c_client to install GridDB C client. 121 | - After installing GridDB C client, set path for C_LIB (path for gridstore_c.lib) in CmakeList.txt. 122 | ``` 123 | set(C_LIB C:/Users/User/Downloads/griddb_c_lib) 124 | ``` 125 | 126 | Install Cmake-js 127 | - Use command line: 128 | ``` 129 | npm install cmake-js 130 | ``` 131 | 132 | ### Build and Run in cmd 133 | 134 | 1. Execute the command on project directory. 135 | 136 | ``` 137 | $ npm install nan 138 | $ node .\node_modules\cmake-js\bin\cmake-js compile -G "Visual Studio 15 2017 Win64" 139 | ``` 140 | 141 | 2. Set the NODE_PATH variable for griddb Node.js module files. 142 | ``` 143 | $ set NODE_PATH= 144 | ``` 145 | 146 | 3. Set PATH variable for C Client library folder. 147 | 148 | ``` 149 | $ set PATH=%PATH%; 150 | ``` 151 | 152 | 4. Write require("griddb_node") in Node.js source code. 153 | 154 | 5. Copy build file to project directory. 155 | 156 | ``` 157 | $ copy build\Release\griddb_client.node . 158 | ``` 159 | 160 | ### How to run sample 161 | 162 | GridDB Server need to be started in advance. 163 | 164 | 1. The command to run sample 165 | 166 | ``` 167 | $ node sample/sample1.js 168 | 169 | -->[ 'name01', false, 1, ] 170 | ``` 171 | 172 | ## Function 173 | 174 | (available) 175 | - STRING, BOOL, BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, TIMESTAMP, BLOB type for GridDB 176 | - put single row, get row with key 177 | - normal query, aggregation with TQL 178 | - Multi-Put/Get/Query (batch processing) 179 | 180 | (not available) 181 | - GEOMETRY, Array type for GridDB 182 | - timeseries compression 183 | - timeseries-specific function like gsAggregateTimeSeries, gsQueryByTimeSeriesSampling in C client 184 | - trigger, affinity 185 | 186 | Please refer to the following files for more detailed information. 187 | - [Node.JS Client API Reference](https://griddb.github.io/nodejs_client/NodejsAPIReference.htm) 188 | 189 | Note: 190 | 1. The current API might be changed in the next version. e.g. ContainerInfo() 191 | 2. There is [Node.JS Client (0.8.4) Package for CentOS and Ubuntu on npm](https://www.npmjs.com/package/griddb_node) . 192 | 193 | ## Community 194 | 195 | * Issues 196 | Use the GitHub issue function if you have any requests, questions, or bug reports. 197 | * PullRequest 198 | Use the GitHub pull request function if you want to contribute code. 199 | You'll need to agree GridDB Contributor License Agreement(CLA_rev1.1.pdf). 200 | By using the GitHub pull request function, you shall be deemed to have agreed to GridDB Contributor License Agreement. 201 | 202 | ## License 203 | 204 | GridDB Node.JS Client source license is Apache License, version 2.0. 205 | -------------------------------------------------------------------------------- /docs/NodejsAPIReference.files/filelist.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/NodejsAPIReference.files/sheet001.htm: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 35 | 54 | 55 | 56 | 57 | 58 | 59 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 |
class
AggregationResult
Container
QueryAnalysisEntry
GSException
PartitionController
Query
RowKeyPredicate
RowSet
Store
StoreFactory
ContainerInfo
ExpirationInfo
107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /docs/NodejsAPIReference.files/sheet004.htm: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 35 | 54 | 55 | 56 | 57 | 58 | 59 | 61 | 62 | 63 | 64 | 65 | 67 | 68 | 70 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
 exampleConverted 69 | data-type
BOOLBYTESHORTINTEGERLONGFLOATDOUBLESTRINGTIMESTAMPBLOB
Input data-typenumber3  
string"yamada"        
booleantrue         
dateDate.now()         
BufferBuffer.from('yamada')         
178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /docs/NodejsAPIReference.files/stylesheet.css: -------------------------------------------------------------------------------- 1 | tr 2 | {mso-height-source:auto; 3 | mso-ruby-visibility:none;} 4 | col 5 | {mso-width-source:auto; 6 | mso-ruby-visibility:none;} 7 | br 8 | {mso-data-placement:same-cell;} 9 | ruby 10 | {ruby-align:left;} 11 | .style16 12 | {mso-number-format:General; 13 | text-align:general; 14 | vertical-align:middle; 15 | white-space:nowrap; 16 | mso-rotate:0; 17 | mso-background-source:auto; 18 | mso-pattern:auto; 19 | color:black; 20 | font-size:11.0pt; 21 | font-weight:400; 22 | font-style:normal; 23 | text-decoration:none; 24 | font-family:Calibri, sans-serif; 25 | mso-font-charset:0; 26 | border:none; 27 | mso-protection:locked visible; 28 | mso-style-name:TableStyleLight1;} 29 | .style0 30 | {mso-number-format:General; 31 | text-align:general; 32 | vertical-align:middle; 33 | white-space:nowrap; 34 | mso-rotate:0; 35 | mso-background-source:auto; 36 | mso-pattern:auto; 37 | color:black; 38 | font-size:11.0pt; 39 | font-weight:400; 40 | font-style:normal; 41 | text-decoration:none; 42 | font-family:"MS Pゴシック", monospace; 43 | mso-font-charset:128; 44 | border:none; 45 | mso-protection:locked visible; 46 | mso-style-name:標準; 47 | mso-style-id:0;} 48 | .font17 49 | {color:windowtext; 50 | font-size:6.0pt; 51 | font-weight:400; 52 | font-style:normal; 53 | text-decoration:none; 54 | font-family:"MS Pゴシック", monospace; 55 | mso-font-charset:128;} 56 | td 57 | {mso-style-parent:style0; 58 | padding-top:1px; 59 | padding-right:1px; 60 | padding-left:1px; 61 | mso-ignore:padding; 62 | color:black; 63 | font-size:11.0pt; 64 | font-weight:400; 65 | font-style:normal; 66 | text-decoration:none; 67 | font-family:"MS Pゴシック", monospace; 68 | mso-font-charset:128; 69 | mso-number-format:General; 70 | text-align:general; 71 | vertical-align:middle; 72 | border:none; 73 | mso-background-source:auto; 74 | mso-pattern:auto; 75 | mso-protection:locked visible; 76 | white-space:nowrap; 77 | mso-rotate:0;} 78 | .xl66 79 | {mso-style-parent:style0; 80 | border:.5pt solid windowtext; 81 | background:#DEEBF7; 82 | mso-pattern:#CCFFFF none;} 83 | .xl67 84 | {mso-style-parent:style0; 85 | border:.5pt solid windowtext;} 86 | .xl68 87 | {mso-style-parent:style0; 88 | color:windowtext; 89 | font-size:8.0pt; 90 | white-space:normal;} 91 | .xl69 92 | {mso-style-parent:style0; 93 | color:windowtext; 94 | font-size:8.0pt; 95 | white-space:normal;} 96 | .xl70 97 | {mso-style-parent:style0; 98 | color:windowtext; 99 | font-size:8.0pt; 100 | vertical-align:top; 101 | white-space:normal;} 102 | .xl71 103 | {mso-style-parent:style0; 104 | color:windowtext; 105 | font-size:8.0pt; 106 | vertical-align:top; 107 | border:.5pt solid windowtext; 108 | background:#BDD7EE; 109 | mso-pattern:#B9CDE5 none; 110 | white-space:normal;} 111 | .xl72 112 | {mso-style-parent:style0; 113 | color:windowtext; 114 | font-size:8.0pt; 115 | vertical-align:top; 116 | border:.5pt solid windowtext; 117 | background:#BDD7EE; 118 | mso-pattern:#B9CDE5 none; 119 | white-space:normal;} 120 | .xl73 121 | {mso-style-parent:style0; 122 | color:windowtext; 123 | font-size:8.0pt; 124 | border-top:.5pt solid windowtext; 125 | border-right:.5pt solid windowtext; 126 | border-bottom:none; 127 | border-left:.5pt solid windowtext; 128 | white-space:normal;} 129 | .xl74 130 | {mso-style-parent:style0; 131 | color:windowtext; 132 | font-size:8.0pt; 133 | border:.5pt solid windowtext; 134 | white-space:normal;} 135 | .xl75 136 | {mso-style-parent:style0; 137 | color:windowtext; 138 | font-size:8.0pt; 139 | vertical-align:top; 140 | border-top:.5pt solid windowtext; 141 | border-right:.5pt solid windowtext; 142 | border-bottom:none; 143 | border-left:.5pt solid windowtext; 144 | white-space:normal;} 145 | .xl76 146 | {mso-style-parent:style0; 147 | color:windowtext; 148 | font-size:8.0pt; 149 | vertical-align:top; 150 | border:.5pt solid windowtext; 151 | white-space:normal;} 152 | .xl77 153 | {mso-style-parent:style16; 154 | color:windowtext; 155 | font-size:8.0pt; 156 | font-family:Calibri, sans-serif; 157 | mso-font-charset:0; 158 | vertical-align:top; 159 | border-top:none; 160 | border-right:.5pt solid windowtext; 161 | border-bottom:none; 162 | border-left:.5pt solid windowtext; 163 | white-space:normal;} 164 | .xl78 165 | {mso-style-parent:style16; 166 | color:windowtext; 167 | font-size:8.0pt; 168 | font-family:Calibri, sans-serif; 169 | mso-font-charset:0; 170 | vertical-align:top; 171 | border:.5pt solid windowtext; 172 | white-space:normal;} 173 | .xl79 174 | {mso-style-parent:style16; 175 | color:windowtext; 176 | font-size:8.0pt; 177 | font-family:Calibri, sans-serif; 178 | mso-font-charset:0; 179 | text-align:left; 180 | border:.5pt solid windowtext; 181 | white-space:normal;} 182 | .xl80 183 | {mso-style-parent:style0; 184 | color:windowtext; 185 | font-size:8.0pt; 186 | vertical-align:top; 187 | border:.5pt solid windowtext; 188 | white-space:normal;} 189 | .xl81 190 | {mso-style-parent:style0; 191 | color:windowtext; 192 | font-size:8.0pt; 193 | border-top:.5pt solid windowtext; 194 | border-right:.5pt solid windowtext; 195 | border-bottom:none; 196 | border-left:.5pt solid windowtext; 197 | white-space:normal;} 198 | .xl82 199 | {mso-style-parent:style0; 200 | color:windowtext; 201 | font-size:8.0pt; 202 | text-align:left; 203 | white-space:normal;} 204 | .xl83 205 | {mso-style-parent:style0; 206 | color:windowtext; 207 | font-size:8.0pt; 208 | text-align:left;} 209 | .xl84 210 | {mso-style-parent:style0; 211 | color:windowtext;} 212 | .xl85 213 | {mso-style-parent:style0; 214 | color:windowtext; 215 | font-family:Calibri, sans-serif; 216 | mso-font-charset:0; 217 | border:.5pt solid windowtext;} 218 | .xl86 219 | {mso-style-parent:style0; 220 | color:#5B9BD5; 221 | font-family:Calibri, sans-serif; 222 | mso-font-charset:0; 223 | border:.5pt solid windowtext;} 224 | .xl87 225 | {mso-style-parent:style0; 226 | text-align:right;} 227 | .xl88 228 | {mso-style-parent:style0; 229 | border:.5pt solid windowtext; 230 | white-space:normal;} 231 | .xl89 232 | {mso-style-parent:style0; 233 | font-size:9.0pt; 234 | border:.5pt solid windowtext; 235 | white-space:normal;} 236 | .xl90 237 | {mso-style-parent:style0; 238 | text-align:right; 239 | border:.5pt solid windowtext;} 240 | .xl91 241 | {mso-style-parent:style0; 242 | color:red; 243 | border:.5pt solid windowtext;} 244 | .xl92 245 | {mso-style-parent:style0; 246 | color:red; 247 | text-align:right; 248 | border:.5pt solid windowtext;} 249 | .xl93 250 | {mso-style-parent:style0; 251 | color:red; 252 | border:.5pt solid windowtext; 253 | white-space:normal;} 254 | .xl94 255 | {mso-style-parent:style0; 256 | mso-number-format:"\@"; 257 | text-align:right; 258 | border:.5pt solid windowtext;} 259 | .xl95 260 | {mso-style-parent:style0; 261 | color:red; 262 | font-size:8.0pt; 263 | border:.5pt solid windowtext; 264 | white-space:normal;} 265 | .xl96 266 | {mso-style-parent:style0; 267 | color:red; 268 | font-size:8.0pt; 269 | border:.5pt solid windowtext; 270 | white-space:normal;} 271 | .xl97 272 | {mso-style-parent:style0; 273 | color:#00B050; 274 | font-size:8.0pt; 275 | border:.5pt solid windowtext; 276 | white-space:normal;} 277 | .xl98 278 | {mso-style-parent:style0; 279 | color:#00B050; 280 | font-size:8.0pt; 281 | vertical-align:top; 282 | border:.5pt solid windowtext; 283 | white-space:normal;} 284 | .xl99 285 | {mso-style-parent:style0; 286 | color:windowtext; 287 | font-size:8.0pt; 288 | text-align:left; 289 | border:.5pt solid windowtext; 290 | white-space:normal;} 291 | .xl100 292 | {mso-style-parent:style0; 293 | color:red; 294 | font-size:8.0pt; 295 | text-align:left; 296 | border:.5pt solid windowtext; 297 | white-space:normal;} 298 | .xl101 299 | {mso-style-parent:style0; 300 | color:windowtext; 301 | font-family:Calibri, sans-serif; 302 | mso-font-charset:0; 303 | text-align:left; 304 | border:.5pt solid windowtext; 305 | background:#DEEBF7; 306 | mso-pattern:#CCFFFF none;} 307 | .xl102 308 | {mso-style-parent:style0; 309 | color:windowtext; 310 | font-family:Calibri, sans-serif; 311 | mso-font-charset:0; 312 | border:.5pt solid windowtext; 313 | background:#DEEBF7; 314 | mso-pattern:#CCFFFF none; 315 | white-space:normal;} 316 | .xl103 317 | {mso-style-parent:style0; 318 | text-align:center; 319 | border-top:none; 320 | border-right:.5pt solid windowtext; 321 | border-bottom:.5pt solid windowtext; 322 | border-left:none;} 323 | .xl104 324 | {mso-style-parent:style0; 325 | text-align:center; 326 | border-top:none; 327 | border-right:.5pt solid windowtext; 328 | border-bottom:.5pt solid windowtext; 329 | border-left:.5pt solid windowtext;} 330 | .xl105 331 | {mso-style-parent:style0; 332 | text-align:center; 333 | border-top:none; 334 | border-right:none; 335 | border-bottom:.5pt solid windowtext; 336 | border-left:.5pt solid windowtext; 337 | white-space:normal;} 338 | .xl106 339 | {mso-style-parent:style0; 340 | text-align:center; 341 | border:.5pt solid windowtext; 342 | white-space:normal;} 343 | -------------------------------------------------------------------------------- /docs/NodejsAPIReference.files/tabstrip.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
 Class List  NodeJS Client API  Data Type List  Data-Type Mapping 
34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/NodejsAPIReference.htm: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 302 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | <body> 340 | <p>このページで使用するフレームは、お使いのブラウザーではサポートされていません。</p> 341 | </body> 342 | 343 | 344 | 345 | -------------------------------------------------------------------------------- /sample/BlobData.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_BlobData'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["blob", griddb.Type.BLOB] 18 | ], 19 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 20 | }); 21 | var file = './sample/BlobData.js'; 22 | var container; 23 | 24 | store.dropContainer(containerName) 25 | .then(() => { 26 | console.log('Connect to Cluster'); 27 | return store.putContainer(conInfo); 28 | }) 29 | .then(cont => { 30 | console.log("Create Collection name=%s", containerName); 31 | container = cont; 32 | var contents; 33 | try { 34 | contents = fs.readFileSync(file); 35 | } catch (err) { 36 | console.log('File not found'); 37 | throw err; 38 | } 39 | return container.put([0, contents]); 40 | }) 41 | .then(() => { 42 | console.log('Put Row (Blob)'); 43 | return container.get(0); 44 | }) 45 | .then(row => { 46 | console.log("Get Row (Blob size=%d)",row[1].length); 47 | console.log('Success!'); 48 | return true; 49 | }) 50 | .catch(err => { 51 | if (err.constructor.name == 'GSException') { 52 | for (var i = 0; i < err.getErrorStackSize(); i++) { 53 | console.log("[%d]", i); 54 | console.log(err.getErrorCode(i)); 55 | console.log(err.getMessage(i)); 56 | } 57 | } else { 58 | console.log(err); 59 | } 60 | }); 61 | -------------------------------------------------------------------------------- /sample/Connect.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | try { 6 | //Multicast method 7 | var store = factory.getStore({ 8 | "host": process.argv[2], 9 | "port": parseInt(process.argv[3]), 10 | "clusterName": process.argv[4], 11 | "username": process.argv[5], 12 | "password": process.argv[6] 13 | }); 14 | 15 | //Fixed list method 16 | //var store = factory.getStore({ 17 | // "notificationMember": process.argv[2], 18 | // "clusterName": process.argv[3], 19 | // "username": process.argv[4], 20 | // "password": process.argv[5] 21 | //}); 22 | 23 | //Provider method 24 | //var store = factory.getStore({ 25 | // "notificationProvider": process.argv[2], 26 | // "clusterName": process.argv[3], 27 | // "username": process.argv[4], 28 | // "password": process.argv[5] 29 | //}); 30 | } catch(err) { 31 | console.log(err); 32 | return false; 33 | } 34 | 35 | var containerName = 'containerName'; 36 | 37 | store.getContainer(containerName) 38 | .then((cont) => { 39 | if (!cont) { 40 | console.log('getContainer error'); 41 | } 42 | console.log('Connect to Cluster'); 43 | console.log('Success'); 44 | return true; 45 | }) 46 | .catch(err => { 47 | if (err.constructor.name == 'GSException') { 48 | for (var i = 0; i < err.getErrorStackSize(); i++) { 49 | console.log("[%d]", i); 50 | console.log(err.getErrorCode(i)); 51 | console.log(err.getMessage(i)); 52 | } 53 | } else { 54 | console.log(err); 55 | } 56 | }); 57 | -------------------------------------------------------------------------------- /sample/ContainerInformation.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_Info'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["productName", griddb.Type.STRING], 18 | ["count", griddb.Type.INTEGER] 19 | ], 20 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 21 | }); 22 | 23 | store.dropContainer(containerName) 24 | .then(() => { 25 | console.log('Connect to Cluster'); 26 | return store.putContainer(conInfo); 27 | }) 28 | .then(() => { 29 | console.log("Sample data generation: Create Collection name=%s", containerName); 30 | return store.getContainerInfo(containerName); 31 | }) 32 | .then((info) => { 33 | console.log("Get ContainerInfo: \n name=%s", info.name); 34 | if ( info.type == griddb.ContainerType.COLLECTION ){ 35 | console.log(' type=Collection'); 36 | } else { 37 | console.log(' type=TimeSeries'); 38 | } 39 | console.log(" rowKeyAssigned=%s", info.rowKey.toString()); 40 | console.log(" columnCount=%d", info.columnInfoList.length); 41 | info.columnInfoList.forEach( 42 | element => console.log(" column (%s, %d)", 43 | element[0], element[1]) 44 | ); 45 | console.log('Success!'); 46 | return true; 47 | }) 48 | .catch(err => { 49 | if (err.constructor.name == 'GSException') { 50 | for (var i = 0; i < err.getErrorStackSize(); i++) { 51 | console.log("[%d]", i); 52 | console.log(err.getErrorCode(i)); 53 | console.log(err.getMessage(i)); 54 | } 55 | } else { 56 | console.log(err); 57 | } 58 | }); 59 | -------------------------------------------------------------------------------- /sample/ContainerNames.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | 13 | for (var index = 0; index < store.partitionController.partitionCount; index++) { 14 | store.partitionController.getContainerNames(index, 0, -1) 15 | .then(nameList =>{ 16 | nameList.forEach(element => console.log(element)); 17 | return true; 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /sample/CreateCollection.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_collection1'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["productName", griddb.Type.STRING], 18 | ["count", griddb.Type.INTEGER] 19 | ], 20 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 21 | }); 22 | 23 | store.dropContainer(containerName) 24 | .then(() => { 25 | return store.putContainer(conInfo); 26 | }) 27 | .then(() => { 28 | console.log("Create Collection name=%s", containerName); 29 | console.log('Success!') 30 | return true; 31 | }) 32 | .catch(err => { 33 | if (err.constructor.name == 'GSException') { 34 | for (var i = 0; i < err.getErrorStackSize(); i++) { 35 | console.log("[%d]", i); 36 | console.log(err.getErrorCode(i)); 37 | console.log(err.getMessage(i)); 38 | } 39 | } else { 40 | console.log(err); 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /sample/CreateIndex.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_Index'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["productName", griddb.Type.STRING], 18 | ["count", griddb.Type.INTEGER] 19 | ], 20 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 21 | }); 22 | var container; 23 | 24 | store.dropContainer(containerName) 25 | .then(() => { 26 | return store.putContainer(conInfo); 27 | }) 28 | .then(cont => { 29 | console.log("Create Collection name=%s", containerName); 30 | container = cont; 31 | return container.createIndex({columnName: 'count',indexType: griddb.IndexType.HASH, name: 'hash_index'}); 32 | }) 33 | .then(() => { 34 | console.log("Create Index"); 35 | console.log("Success!"); 36 | return true; 37 | }) 38 | .catch(err => { 39 | if (err.constructor.name == 'GSException') { 40 | for (var i = 0; i < err.getErrorStackSize(); i++) { 41 | console.log("[%d]", i); 42 | console.log(err.getErrorCode(i)); 43 | console.log(err.getMessage(i)); 44 | } 45 | } else { 46 | console.log(err); 47 | } 48 | }); 49 | -------------------------------------------------------------------------------- /sample/CreateTimeSeries.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_timeseries1'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["date", griddb.Type.TIMESTAMP], 17 | ["value", griddb.Type.DOUBLE] 18 | ], 19 | 'type': griddb.ContainerType.TIME_SERIES 20 | }); 21 | 22 | store.dropContainer(containerName) 23 | .then(() => { 24 | return store.putContainer(conInfo); 25 | }) 26 | .then(() => { 27 | console.log("Create TimeSeries name=%s", containerName); 28 | console.log('Success!') 29 | return true; 30 | }) 31 | .catch(err => { 32 | if (err.constructor.name == 'GSException') { 33 | for (var i = 0; i < err.getErrorStackSize(); i++) { 34 | console.log("[%d]", i); 35 | console.log(err.getErrorCode(i)); 36 | console.log(err.getMessage(i)); 37 | } 38 | } else { 39 | console.log(err); 40 | } 41 | }); 42 | -------------------------------------------------------------------------------- /sample/FetchAll.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | 13 | var containerNameList = ["Sample_FetchAll1", "Sample_FetchAll2"]; 14 | var tqlList = ["select * where count > 60", "select * where count > 100"]; 15 | var rowCount = 5; 16 | var nameList = ["notebook PC", "desktop PC", "keyboard", "mouse", "printer"]; 17 | var numberList = [[108, 72, 25, 45, 62], [50, 11, 208, 23, 153]]; 18 | var queryList = []; 19 | var container; 20 | 21 | var promise = new Promise(function(resolve, reject) { 22 | resolve(true); 23 | }); 24 | 25 | //Create container, rows, query 26 | var createContainerRowsQuery = function(containerName, count){ 27 | return store.dropContainer(containerName) 28 | .then(() => { 29 | var conInfo = new griddb.ContainerInfo({ 30 | 'name': containerName, 31 | 'columnInfoList': [ 32 | ["id", griddb.Type.INTEGER], 33 | ["productName", griddb.Type.STRING], 34 | ["count", griddb.Type.INTEGER] 35 | ], 36 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 37 | }); 38 | return store.putContainer(conInfo); 39 | }) 40 | .then(cont => { 41 | console.log("Sample data generation: Create Collection name=%s", 42 | containerName); 43 | container = cont; 44 | var rows = []; 45 | for (var i=0;i < rowCount;i++) { 46 | var row = []; 47 | row[0] = i; 48 | row[1] = nameList[i]; 49 | row[2] = numberList[count][i]; 50 | rows.push(row); 51 | } 52 | return container.multiPut(rows); 53 | }) 54 | .then(() => { 55 | console.log("Sample data generation: Put Rows count=%d", rowCount); 56 | return container.query(tqlList[count]); 57 | }) 58 | .then((query)=> { 59 | console.log("FetchAll query : container=%s, tql=%s", containerName, tqlList[count]); 60 | queryList.push(query); 61 | return true; 62 | }) 63 | } 64 | 65 | //Get data and print to output. 66 | var getRowSet = function(query, containerName){ 67 | rs = query.getRowSet(); 68 | while (rs.hasNext()) { 69 | row = rs.next(); 70 | console.log("FetchAll result: container=%s, row=(%d, \"%s\", %d)", 71 | containerName, row[0], row[1], row[2]); 72 | } 73 | return true; 74 | } 75 | 76 | containerNameList.forEach(function(item, i) { 77 | promise = promise 78 | .then(() => { 79 | return createContainerRowsQuery(item, i);}) 80 | }); 81 | 82 | promise = promise 83 | .then(() => { 84 | return store.fetchAll(queryList); 85 | }) 86 | .then(() => { 87 | queryList.forEach(function(query, i) { 88 | return getRowSet(query, containerNameList[i]); 89 | }); 90 | }); 91 | 92 | promise = promise. 93 | catch(err => { 94 | if (err.constructor.name == 'GSException') { 95 | for (var i = 0; i < err.getErrorStackSize(); i++) { 96 | console.log("[%d]", i); 97 | console.log(err.getErrorCode(i)); 98 | console.log(err.getMessage(i)); 99 | } 100 | } else { 101 | console.log(err); 102 | } 103 | }); 104 | -------------------------------------------------------------------------------- /sample/GetRow.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_GetRow'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["productName", griddb.Type.STRING], 18 | ["count", griddb.Type.INTEGER] 19 | ], 20 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 21 | }); 22 | var rowCount = 5; 23 | var nameList = ["notebook PC", "desktop PC", "keyboard", "mouse", "printer"]; 24 | var numberList = [108, 72, 25, 45, 62]; 25 | var container; 26 | var rowId = 0; 27 | 28 | store.dropContainer(containerName) 29 | .then(() => { 30 | return store.putContainer(conInfo); 31 | }) 32 | .then(cont => { 33 | console.log("Sample data generation: Create Collection name=%s", containerName); 34 | container = cont; 35 | var rows = []; 36 | for (var i = 0;i < rowCount; i++) { 37 | rows.push([i, nameList[i], numberList[i]]); 38 | } 39 | return container.multiPut(rows); 40 | }) 41 | .then(() => { 42 | console.log("Sample data generation: Put Rows count=%d", rowCount); 43 | return container.get(rowId); 44 | }) 45 | .then((row) => { 46 | console.log("Get Row (id=%d, productName=%s, count=%d)", 47 | row[0], row[1], row[2]); 48 | console.log("Success!"); 49 | return true; 50 | }) 51 | .catch(err => { 52 | if (err.constructor.name == 'GSException') { 53 | for (var i = 0; i < err.getErrorStackSize(); i++) { 54 | console.log("[%d]", i); 55 | console.log(err.getErrorCode(i)); 56 | console.log(err.getMessage(i)); 57 | } 58 | } else { 59 | console.log(err); 60 | } 61 | }); 62 | -------------------------------------------------------------------------------- /sample/MultiGet.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | 13 | var containerNameList = ["Sample_MultiGet1", "Sample_MultiGet2"]; 14 | var rowCount = 5; 15 | var nameList = ["notebook PC", "desktop PC", "keyboard", "mouse", "printer"]; 16 | var numberList = [[108, 72, 25, 45, 62], [50, 11, 208, 23, 153]]; 17 | var predicateList = []; 18 | var container; 19 | 20 | var promise = new Promise(function(resolve, reject) { 21 | resolve(true); 22 | }); 23 | 24 | //Create container, rows, rowkey predicate 25 | var createContainerRowsPredicate = function(containerName, count){ 26 | return store.dropContainer(containerName) 27 | .then(() => { 28 | var conInfo = new griddb.ContainerInfo({ 29 | 'name': containerName, 30 | 'columnInfoList': [ 31 | ["id", griddb.Type.INTEGER], 32 | ["productName", griddb.Type.STRING], 33 | ["count", griddb.Type.INTEGER] 34 | ], 35 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 36 | }); 37 | return store.putContainer(conInfo); 38 | }) 39 | .then(cont => { 40 | console.log("Sample data generation: Create Collection name=%s", 41 | containerName); 42 | container = cont; 43 | var rows = []; 44 | for (var i=0;i < rowCount;i++) { 45 | var row = []; 46 | row[0] = i; 47 | row[1] = nameList[i]; 48 | row[2] = numberList[count][i]; 49 | rows.push(row); 50 | } 51 | return container.multiPut(rows); 52 | }) 53 | .then(() => { 54 | console.log("Sample data generation: Put Rows count=%d", rowCount); 55 | var predicate = store.createRowKeyPredicate(griddb.Type.INTEGER); 56 | predicate.setRange(0, 2); 57 | predicateList.push(predicate); 58 | return true; 59 | }) 60 | } 61 | 62 | //Get data and print to output. 63 | var getRowSet = function(query, containerName){ 64 | rs = query.getRowSet(); 65 | while (rs.hasNext()) { 66 | row = rs.next(); 67 | console.log("FetchAll result: container=%s, row=(%d, \"%s\", %d)", 68 | containerName, row[0], row[1], row[2]); 69 | } 70 | return true; 71 | } 72 | 73 | containerNameList.forEach(function(item, i) { 74 | promise = promise 75 | .then(() => { 76 | return createContainerRowsPredicate(item, i);}) 77 | }); 78 | 79 | promise = promise 80 | .then(() => { 81 | var param = {}; 82 | param[containerNameList[0]] = predicateList[0]; 83 | param[containerNameList[1]] = predicateList[1]; 84 | return store.multiGet(param); 85 | }) 86 | .then((ret) => { 87 | for (var key in ret) { 88 | for (i = 0; i< ret[key].length; i++) { 89 | console.log("MultiGet: container=%s, id=%d, productName=%s, count=%d", key, ret[key][i][0], ret[key][i][1], 90 | ret[key][i][2]); 91 | } 92 | } 93 | console.log("Success!"); 94 | return true; 95 | }); 96 | 97 | promise = promise. 98 | catch(err => { 99 | if (err.constructor.name == 'GSException') { 100 | for (var i = 0; i < err.getErrorStackSize(); i++) { 101 | console.log("[%d]", i); 102 | console.log(err.getErrorCode(i)); 103 | console.log(err.getMessage(i)); 104 | } 105 | } else { 106 | console.log(err); 107 | } 108 | }); 109 | -------------------------------------------------------------------------------- /sample/MultiPut.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | 13 | var containerNameList = ["Sample_MultiPut1", "Sample_MultiPut2"]; 14 | var rowCount = 5; 15 | var nameList = ["notebook PC", "desktop PC", "keyboard", "mouse", "printer"]; 16 | var numberList = [[108, 72, 25, 45, 62], [50, 11, 208, 23, 153]]; 17 | 18 | var promise = new Promise(function(resolve, reject) { 19 | resolve(true); 20 | }); 21 | 22 | //Create container 23 | var createContainer = function(containerName, count){ 24 | return store.dropContainer(containerName) 25 | .then(() => { 26 | var conInfo = new griddb.ContainerInfo({ 27 | 'name': containerName, 28 | 'columnInfoList': [ 29 | ["id", griddb.Type.INTEGER], 30 | ["productName", griddb.Type.STRING], 31 | ["count", griddb.Type.INTEGER] 32 | ], 33 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 34 | }); 35 | return store.putContainer(conInfo); 36 | }) 37 | .then(() => { 38 | console.log("Create Collection name=%s", containerName); 39 | return true; 40 | }) 41 | } 42 | 43 | 44 | containerNameList.forEach(function(item, i) { 45 | promise = promise 46 | .then(() => { 47 | return createContainer(item, i);}) 48 | }); 49 | 50 | promise = promise 51 | .then(() => { 52 | var rows = []; 53 | for (var count=0; count < containerNameList.length; count++) { 54 | var arr = []; 55 | for (var i=0;i < rowCount;i++) { 56 | var row = []; 57 | row[0] = i; 58 | row[1] = nameList[i]; 59 | row[2] = numberList[count][i]; 60 | arr.push(row); 61 | } 62 | rows.push(arr); 63 | } 64 | var param = {}; 65 | param[containerNameList[0]] = rows[0]; 66 | param[containerNameList[1]] = rows[1]; 67 | return store.multiPut(param); 68 | }) 69 | .then((ret) => { 70 | console.log("Multi Put"); 71 | console.log("Success!"); 72 | return true; 73 | }); 74 | 75 | promise = promise. 76 | catch(err => { 77 | if (err.constructor.name == 'GSException') { 78 | for (var i = 0; i < err.getErrorStackSize(); i++) { 79 | console.log("[%d]", i); 80 | console.log(err.getErrorCode(i)); 81 | console.log(err.getMessage(i)); 82 | } 83 | } else { 84 | console.log(err); 85 | } 86 | }); 87 | -------------------------------------------------------------------------------- /sample/PutRow.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_PutRow'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["productName", griddb.Type.STRING], 18 | ["count", griddb.Type.INTEGER] 19 | ], 20 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 21 | }); 22 | 23 | store.dropContainer(containerName) 24 | .then(() => { 25 | return store.putContainer(conInfo); 26 | }) 27 | .then(container => { 28 | console.log("Create Collection name=%s", containerName); 29 | var row = [0, "display", 150]; 30 | return container.put(row); 31 | }) 32 | .then(() => { 33 | console.log("Put Row"); 34 | console.log("Success!"); 35 | return true; 36 | }) 37 | .catch(err => { 38 | if (err.constructor.name == 'GSException') { 39 | for (var i = 0; i < err.getErrorStackSize(); i++) { 40 | console.log("[%d]", i); 41 | console.log(err.getErrorCode(i)); 42 | console.log(err.getMessage(i)); 43 | } 44 | } else { 45 | console.log(err); 46 | } 47 | }); 48 | -------------------------------------------------------------------------------- /sample/PutRows.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_PutRows'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["productName", griddb.Type.STRING], 18 | ["count", griddb.Type.INTEGER] 19 | ], 20 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 21 | }); 22 | 23 | store.dropContainer(containerName) 24 | .then(() => { 25 | return store.putContainer(conInfo); 26 | }) 27 | .then(container => { 28 | console.log("Create Collection name=%s", containerName); 29 | var rows = []; 30 | var rowCount = 5; 31 | for (var i = 0;i < rowCount; i++) { 32 | rows.push([i, "dvd", i * 10]); 33 | } 34 | return container.multiPut(rows); 35 | }) 36 | .then(() => { 37 | console.log("Put Rows"); 38 | console.log("Success!"); 39 | return true; 40 | }) 41 | .catch(err => { 42 | if (err.constructor.name == 'GSException') { 43 | for (var i = 0; i < err.getErrorStackSize(); i++) { 44 | console.log("[%d]", i); 45 | console.log(err.getErrorCode(i)); 46 | console.log(err.getMessage(i)); 47 | } 48 | } else { 49 | console.log(err); 50 | } 51 | }); 52 | -------------------------------------------------------------------------------- /sample/RemoveRowByRowkey.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_RemoveRowByRowkey'; 13 | var rowCount = 5; 14 | var nameList = ["notebook PC", "desktop PC", "keyboard", "mouse", "printer"]; 15 | var numberList = [108, 72, 25, 45, 62]; 16 | var conInfo = new griddb.ContainerInfo({ 17 | 'name': containerName, 18 | 'columnInfoList': [ 19 | ["id", griddb.Type.INTEGER], 20 | ["productName", griddb.Type.STRING], 21 | ["count", griddb.Type.INTEGER] 22 | ], 23 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 24 | }); 25 | var container; 26 | 27 | store.dropContainer(containerName) 28 | .then(() => { 29 | return store.putContainer(conInfo); 30 | }) 31 | .then(cont => { 32 | console.log("Sample data generation: Create Collection name=%s", containerName); 33 | var rows = []; 34 | container = cont; 35 | for (var i = 0;i < rowCount; i++) { 36 | rows.push([i, nameList[i], numberList[i]]); 37 | } 38 | return container.multiPut(rows); 39 | }) 40 | .then(() => { 41 | console.log("Sample data generation: Put Rows count=%d", rowCount); 42 | var rowKey = 3; 43 | console.log("Delete Row rowkey=%d", rowKey); 44 | return container.remove(rowKey); 45 | }) 46 | .then((ret) => { 47 | console.log("Success!"); 48 | return true; 49 | }) 50 | .catch(err => { 51 | if (err.constructor.name == 'GSException') { 52 | for (var i = 0; i < err.getErrorStackSize(); i++) { 53 | console.log("[%d]", i); 54 | console.log(err.getErrorCode(i)); 55 | console.log(err.getMessage(i)); 56 | } 57 | } else { 58 | console.log(err); 59 | } 60 | }); 61 | -------------------------------------------------------------------------------- /sample/TQLAggregation.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_TQLAggregation'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["productName", griddb.Type.STRING], 18 | ["count", griddb.Type.INTEGER] 19 | ], 20 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 21 | }); 22 | var rowCount = 5; 23 | var nameList = ["notebook PC", "desktop PC", "keyboard", "mouse", "printer"]; 24 | var numberList = [108, 72, 25, 45, 62]; 25 | var container; 26 | var queryStr = "SELECT MAX(count)"; 27 | 28 | store.dropContainer(containerName) 29 | .then(() => { 30 | return store.putContainer(conInfo); 31 | }) 32 | .then(cont => { 33 | console.log("Sample data generation: Create Collection name=%s", containerName); 34 | container = cont; 35 | var rows = []; 36 | for (var i = 0;i < rowCount; i++) { 37 | rows.push([i, nameList[i], numberList[i]]); 38 | console.log("Sample data generation: row=(%d, %s, %d)", i, nameList[i], numberList[i]); 39 | } 40 | return container.multiPut(rows); 41 | }) 42 | .then(() => { 43 | console.log("Sample data generation: Put Rows count=%d", rowCount); 44 | return container.query(queryStr); 45 | }) 46 | .then((query) => { 47 | console.log("TQL query : %s", queryStr); 48 | return query.fetch(); 49 | }) 50 | .then((rs) => { 51 | while(rs.hasNext()) { 52 | aggregation = rs.next(); 53 | max = aggregation.get(griddb.Type.LONG); 54 | console.log("TQL result: max=%d", max); 55 | } 56 | console.log('Success!'); 57 | return true; 58 | }) 59 | .catch(err => { 60 | if (err.constructor.name == 'GSException') { 61 | for (var i = 0; i < err.getErrorStackSize(); i++) { 62 | console.log("[%d]", i); 63 | console.log(err.getErrorCode(i)); 64 | console.log(err.getMessage(i)); 65 | } 66 | } else { 67 | console.log(err); 68 | } 69 | }); 70 | -------------------------------------------------------------------------------- /sample/TQLSelect.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_TQLSelect'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["id", griddb.Type.INTEGER], 17 | ["productName", griddb.Type.STRING], 18 | ["count", griddb.Type.INTEGER] 19 | ], 20 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 21 | }); 22 | var rowCount = 5; 23 | var nameList = ["notebook PC", "desktop PC", "keyboard", "mouse", "printer"]; 24 | var numberList = [108, 72, 25, 45, 62]; 25 | var container; 26 | var queryStr = "SELECT * WHERE count >= 50 ORDER BY id"; 27 | 28 | store.dropContainer(containerName) 29 | .then(() => { 30 | return store.putContainer(conInfo); 31 | }) 32 | .then(cont => { 33 | console.log("Sample data generation: Create Collection name=%s", containerName); 34 | container = cont; 35 | var rows = []; 36 | for (var i = 0;i < rowCount; i++) { 37 | rows.push([i, nameList[i], numberList[i]]); 38 | } 39 | return container.multiPut(rows); 40 | }) 41 | .then(() => { 42 | console.log("Sample data generation: Put Rows count=%d", rowCount); 43 | return container.query(queryStr); 44 | }) 45 | .then((query) => { 46 | console.log("TQL query : %s", queryStr); 47 | return query.fetch(); 48 | }) 49 | .then((rs) => { 50 | var row; 51 | while(rs.hasNext()) { 52 | row = rs.next(); 53 | console.log("TQL result: id=%d, productName=%s, count=%d" 54 | , row[0], row[1], row[2]); 55 | } 56 | console.log('Success!') 57 | return true; 58 | }) 59 | .catch(err => { 60 | if (err.constructor.name == 'GSException') { 61 | for (var i = 0; i < err.getErrorStackSize(); i++) { 62 | console.log("[%d]", i); 63 | console.log(err.getErrorCode(i)); 64 | console.log(err.getMessage(i)); 65 | } 66 | } else { 67 | console.log(err); 68 | } 69 | }); 70 | -------------------------------------------------------------------------------- /sample/TQLTimeseries.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_TQLTimeseries'; 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': containerName, 15 | 'columnInfoList': [ 16 | ["date", griddb.Type.TIMESTAMP], 17 | ["value1", griddb.Type.INTEGER], 18 | ["value2", griddb.Type.DOUBLE] 19 | ], 20 | 'type': griddb.ContainerType.TIME_SERIES 21 | }); 22 | var rowCount = 4; 23 | var dateList = ["2018-12-01T10:00:00.000Z", 24 | "2018-12-01T10:10:00.000Z", 25 | "2018-12-01T10:20:00.000Z", 26 | "2018-12-01T10:40:00.000Z"]; 27 | var value1List = [1, 3, 2, 4]; 28 | var value2List = [10.3, 5.7, 8.2, 4.5]; 29 | var container; 30 | var queryAvgStr = "SELECT TIME_AVG(value1)"; 31 | var queryTimeNextStr = "SELECT TIME_NEXT(*, TIMESTAMP('2018-12-01T10:10:00.000Z'))"; 32 | var queryTimeInter = "SELECT TIME_INTERPOLATED(value1, TIMESTAMP('2018-12-01T10:30:00.000Z'))"; 33 | 34 | store.dropContainer(containerName) 35 | .then(() => { 36 | return store.putContainer(conInfo); 37 | }) 38 | .then(cont => { 39 | console.log("Sample data generation: Create Collection name=%s", containerName); 40 | console.log("Sample data generation: column=(%s, %s, %s)", conInfo.columnInfoList[0][0], conInfo.columnInfoList[1][0], conInfo.columnInfoList[2][0]); 41 | container = cont; 42 | var rows = []; 43 | var row; 44 | for (var i = 0;i < rowCount; i++) { 45 | row = [new Date(dateList[i]), value1List[i], value2List[i]]; 46 | rows.push(row); 47 | console.log("Sample data generation: row=(%s, %d, %f)", row[0].toISOString(), row[1], row[2]); 48 | } 49 | return container.multiPut(rows); 50 | }) 51 | .then(() => { 52 | console.log("Sample data generation: Put Rows count=%d", rowCount); 53 | return container.query(queryAvgStr); 54 | }) 55 | .then((query) => { 56 | console.log("TQL query : %s", queryAvgStr); 57 | return query.fetch(); 58 | }) 59 | .then((rs) => { 60 | while(rs.hasNext()) { 61 | aggregation = rs.next(); 62 | var value = aggregation.get(griddb.Type.DOUBLE); 63 | console.log("TQL result: %f", value); 64 | } 65 | return true; 66 | }) 67 | .then(() => { 68 | return container.query(queryTimeNextStr); 69 | }) 70 | .then((query) => { 71 | console.log("TQL query : %s", queryTimeNextStr); 72 | return query.fetch(); 73 | }) 74 | .then((rs) => { 75 | var row; 76 | while(rs.hasNext()) { 77 | row = rs.next(); 78 | console.log("TQL result: row=(%s, %d, %f)", row[0].toISOString(), row[1], row[2]); 79 | } 80 | return container.query(queryTimeInter); 81 | }) 82 | .then((query) => { 83 | console.log("TQL query : %s", queryTimeInter); 84 | return query.fetch(); 85 | }) 86 | .then((rs) => { 87 | var row; 88 | while(rs.hasNext()) { 89 | row = rs.next(); 90 | console.log("TQL result: row=(%s, %d, %f)", row[0].toISOString(), row[1], row[2]); 91 | } 92 | console.log('Success!'); 93 | return true; 94 | }) 95 | .catch(err => { 96 | if (err.constructor.name == 'GSException') { 97 | for (var i = 0; i < err.getErrorStackSize(); i++) { 98 | console.log("[%d]", i); 99 | console.log(err.getErrorCode(i)); 100 | console.log(err.getMessage(i)); 101 | } 102 | } else { 103 | console.log(err); 104 | } 105 | }); 106 | -------------------------------------------------------------------------------- /sample/TimeSeriesRowExpiration.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | var containerName = 'Sample_RowExpiration'; 13 | var expirationInfo = new griddb.ExpirationInfo(100, griddb.GS_TIME_UNIT_DAY, 5); 14 | var conInfo = new griddb.ContainerInfo({ 15 | 'name': containerName, 16 | 'columnInfoList': [ 17 | ["date", griddb.Type.TIMESTAMP], 18 | ["value", griddb.Type.DOUBLE] 19 | ], 20 | 'type': griddb.ContainerType.TIME_SERIES, 'expiration' : expirationInfo 21 | }); 22 | 23 | store.dropContainer(containerName) 24 | .then(() => { 25 | return store.putContainer(conInfo); 26 | }) 27 | .then(() => { 28 | console.log("Create TimeSeries & Set Row Expiration name=%s", containerName); 29 | console.log('Success!') 30 | return true; 31 | }) 32 | .catch(err => { 33 | if (err.constructor.name == 'GSException') { 34 | for (var i = 0; i < err.getErrorStackSize(); i++) { 35 | console.log("[%d]", i); 36 | console.log(err.getErrorCode(i)); 37 | console.log(err.getMessage(i)); 38 | } 39 | } else { 40 | console.log(err); 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /sample/sample1.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': "col01", 15 | 'columnInfoList': [ 16 | ["name", griddb.Type.STRING], 17 | ["status", griddb.Type.BOOL], 18 | ["count", griddb.Type.LONG], 19 | ["lob", griddb.Type.BLOB] 20 | ], 21 | 'type': griddb.ContainerType.COLLECTION, 'rowKey': true 22 | }); 23 | 24 | var container; 25 | store.putContainer(conInfo, false) 26 | .then(cont => { 27 | container = cont; 28 | return container.createIndex({ 'columnName': 'count', 'indexType': griddb.IndexType.DEFAULT }); 29 | }) 30 | .then(() => { 31 | container.setAutoCommit(false); 32 | return container.put(["name01", false, 1, Buffer.from([65, 66, 67, 68, 69, 70, 71, 72, 73, 74])]); 33 | }) 34 | .then(() => { 35 | return container.commit(); 36 | }) 37 | .then(() => { 38 | query = container.query("select *") 39 | return query.fetch(); 40 | }) 41 | .then(rs => { 42 | while (rs.hasNext()) { 43 | console.log(rs.next()); 44 | } 45 | return container.commit(); 46 | }) 47 | .catch(err => { 48 | if (err.constructor.name == "GSException") { 49 | for (var i = 0; i < err.getErrorStackSize(); i++) { 50 | console.log("[", i, "]"); 51 | console.log(err.getErrorCode(i)); 52 | console.log(err.getMessage(i)); 53 | } 54 | } else { 55 | console.log(err); 56 | } 57 | }); 58 | -------------------------------------------------------------------------------- /sample/sample2.js: -------------------------------------------------------------------------------- 1 | var griddb = require('griddb_node'); 2 | var fs = require('fs'); 3 | 4 | var factory = griddb.StoreFactory.getInstance(); 5 | var store = factory.getStore({ 6 | "host": process.argv[2], 7 | "port": parseInt(process.argv[3]), 8 | "clusterName": process.argv[4], 9 | "username": process.argv[5], 10 | "password": process.argv[6] 11 | }); 12 | 13 | var conInfo = new griddb.ContainerInfo({ 14 | 'name': "point01", 15 | 'columnInfoList': [ 16 | ["timestamp", griddb.Type.TIMESTAMP], 17 | ["active", griddb.Type.BOOL], 18 | ["voltage", griddb.Type.DOUBLE] 19 | ], 20 | 'type': griddb.ContainerType.TIME_SERIES, 'rowKey': true 21 | }); 22 | 23 | var time_series; 24 | store.putContainer(conInfo, false) 25 | .then(ts => { 26 | time_series = ts; 27 | return ts.put([new Date(), false, 100]); 28 | }) 29 | .then(() => { 30 | query = time_series.query("select * where timestamp > TIMESTAMPADD(HOUR, NOW(), -6)"); 31 | return query.fetch(); 32 | }) 33 | .then(rowset => { 34 | while (rowset.hasNext()) { 35 | var row = rowset.next(); 36 | console.log("Time =", row[0], "Active =", row[1].toString(), "Voltage =", row[2]); 37 | } 38 | }) 39 | .catch(err => { 40 | if (err.constructor.name == "GSException") { 41 | for (var i = 0; i < err.getErrorStackSize(); i++) { 42 | console.log("[", i, "]"); 43 | console.log(err.getErrorCode(i)); 44 | console.log(err.getMessage(i)); 45 | } 46 | } else { 47 | console.log(err); 48 | } 49 | }); 50 | -------------------------------------------------------------------------------- /sample/sample3.js: -------------------------------------------------------------------------------- 1 | 2 | var griddb = require('griddb_node'); 3 | var fs = require('fs'); 4 | 5 | var factory = griddb.StoreFactory.getInstance(); 6 | var store = factory.getStore({ 7 | "host": process.argv[2], 8 | "port": parseInt(process.argv[3]), 9 | "clusterName": process.argv[4], 10 | "username": process.argv[5], 11 | "password": process.argv[6] 12 | }); 13 | 14 | var timeseries; 15 | store.getContainer("point01") 16 | .then(ts => { 17 | timeseries = ts; 18 | query = ts.query("select * from point01 where not active and voltage > 50"); 19 | return query.fetch(); 20 | }) 21 | .then(rowset => { 22 | var row; 23 | while (rowset.hasNext()) { 24 | row = rowset.next(); 25 | var timestamp = Date.parse(row[0]); 26 | aggCommand = "select AVG(voltage) from point01 where timestamp > TIMESTAMPADD(MINUTE, TO_TIMESTAMP_MS(" + timestamp + "), -10) AND timestamp < TIMESTAMPADD(MINUTE, TO_TIMESTAMP_MS(" + timestamp + "), 10)"; 27 | aggQuery = timeseries.query(aggCommand); 28 | 29 | aggQuery.fetch() 30 | .then(aggRs => { 31 | while (aggRs.hasNext()) { 32 | aggResult = aggRs.next(); 33 | console.log("[Timestamp = " + timestamp + "] Average voltage = " + aggResult.get(griddb.GS_TYPE_DOUBLE)); 34 | } 35 | }); 36 | } 37 | }) 38 | .catch(err => { 39 | if (err.constructor.name == "GSException") { 40 | for (var i = 0; i < err.getErrorStackSize(); i++) { 41 | console.log("[", i, "]"); 42 | console.log(err.getErrorCode(i)); 43 | console.log(err.getMessage(i)); 44 | } 45 | } else { 46 | console.log(err); 47 | } 48 | }); 49 | -------------------------------------------------------------------------------- /src/AggregationResult.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "AggregationResult.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Constructor a new Aggregation Result:: Aggregation Result object 23 | * @param aggResult Stores the result of an aggregation operation 24 | */ 25 | AggregationResult::AggregationResult(GSAggregationResult* aggResult) : 26 | mAggResult(aggResult), timestamp_output_with_float(false) { 27 | } 28 | 29 | AggregationResult::~AggregationResult() { 30 | close(); 31 | } 32 | 33 | /** 34 | * @brief Release AggregationResult resource 35 | */ 36 | void AggregationResult::close() { 37 | if (mAggResult != NULL) { 38 | gsCloseAggregationResult(&mAggResult); 39 | } 40 | mAggResult = NULL; 41 | } 42 | 43 | /** 44 | * @brief Obtains the result of aggregating numeric-type values. 45 | * @param type Column type 46 | * @param *agValue aggregation result 47 | */ 48 | void AggregationResult::get(GSType type, griddb::Field *agValue) { 49 | assert(agValue != NULL); 50 | void *value; 51 | agValue->type = type; 52 | switch (type) { 53 | case GS_TYPE_DOUBLE: 54 | value = &agValue->value.asDouble; 55 | break; 56 | case GS_TYPE_LONG: 57 | value = &agValue->value.asLong; 58 | break; 59 | case GS_TYPE_TIMESTAMP: 60 | value = &agValue->value.asTimestamp; 61 | break; 62 | default: 63 | throw GSException(mAggResult, "Not support type from Aggregation result"); 64 | break; 65 | } 66 | GSBool ret = gsGetAggregationValue(mAggResult, value, type); 67 | if (ret == GS_FALSE) { 68 | throw GSException(mAggResult, 69 | "Value cannot be retrieved from Aggregation result"); 70 | } 71 | } 72 | 73 | } /* namespace griddb */ 74 | -------------------------------------------------------------------------------- /src/AggregationResult.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _AGGREGATIONRESULT_H_ 18 | #define _AGGREGATIONRESULT_H_ 19 | 20 | #include 21 | 22 | #include "GSException.h" 23 | #include "Field.h" 24 | #include "gridstore.h" 25 | 26 | using namespace std; 27 | 28 | namespace griddb { 29 | 30 | class AggregationResult { 31 | 32 | GSAggregationResult* mAggResult; 33 | 34 | friend class RowSet; 35 | 36 | public: 37 | bool timestamp_output_with_float; 38 | ~AggregationResult(); 39 | void close(); 40 | void get(GSType type, griddb::Field *agValue); 41 | AggregationResult(GSAggregationResult* aggResult); 42 | 43 | }; 44 | 45 | } /* namespace griddb */ 46 | 47 | #endif /* _AGGREGATIONRESULT_H_ */ 48 | -------------------------------------------------------------------------------- /src/Container.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _CONTAINER_H_ 18 | #define _CONTAINER_H_ 19 | 20 | #include 21 | 22 | #include "Field.h" 23 | #include "Query.h" 24 | #include "GSException.h" 25 | #include "Util.h" 26 | 27 | using namespace std; 28 | 29 | namespace griddb { 30 | 31 | class Container { 32 | 33 | GSContainerInfo* mContainerInfo; 34 | GSContainer *mContainer; 35 | 36 | friend class Store; 37 | 38 | GSRow* mRow; 39 | GSType* mTypeList; 40 | 41 | public: 42 | bool timestamp_output_with_float; 43 | ~Container(); 44 | void close(GSBool allRelated = GS_FALSE); 45 | GSContainerType get_type(); 46 | void create_index(const char* column_name, GSIndexTypeFlags index_type = GS_INDEX_FLAG_DEFAULT, const char* name=NULL); 47 | void drop_index(const char* column_name, GSIndexTypeFlags index_type = GS_INDEX_FLAG_DEFAULT, const char* name=NULL); 48 | bool put(GSRow *row); 49 | Query* query(const char *query); 50 | void abort(); 51 | void flush(); 52 | void set_auto_commit(bool enabled); 53 | void commit(); 54 | GSBool get(Field* keyFields, GSRow *rowdata); 55 | bool remove(Field* keyFields); 56 | void multi_put(GSRow** listRowdata, int rowCount); 57 | GSContainer* getGSContainerPtr(); 58 | GSType* getGSTypeList(); 59 | int getColumnCount(); 60 | GSRow* getGSRowPtr(); 61 | 62 | private: 63 | Container(GSContainer *container, GSContainerInfo* containerInfo); 64 | void freeMemoryContainer(); 65 | }; 66 | 67 | } /* namespace griddb */ 68 | 69 | #endif /* _CONTAINER_H_ */ 70 | -------------------------------------------------------------------------------- /src/ContainerInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _CONTAINERINFO_H_ 18 | #define _CONTAINERINFO_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "TimeSeriesProperties.h" 26 | #include "ExpirationInfo.h" 27 | #include "GSException.h" 28 | #include "Util.h" 29 | 30 | //Support column_info_list attribute 31 | struct ColumnInfoList { 32 | GSColumnInfo* columnInfo; 33 | size_t size; 34 | }; 35 | 36 | using namespace std; 37 | 38 | namespace griddb { 39 | 40 | class ContainerInfo { 41 | /** 42 | * Contains information about a specific container 43 | */ 44 | private: 45 | GSContainerInfo mContainerInfo; 46 | 47 | //tmp attribute to get column info list 48 | ColumnInfoList mColumnInfoList; 49 | 50 | //tmp attribute support get expiration attribute 51 | ExpirationInfo* mExpInfo; 52 | 53 | public: 54 | ContainerInfo(GSContainerInfo *containerInfo); 55 | ContainerInfo(const GSChar* name, const GSColumnInfo* props, 56 | int propsCount, GSContainerType type = GS_CONTAINER_COLLECTION, 57 | bool row_key = true, ExpirationInfo* expiration = NULL); 58 | ~ContainerInfo(); 59 | 60 | void set_name(GSChar* containerName); 61 | void set_type(GSContainerType containerType); 62 | void set_row_key_assigned(bool rowKeyAssigned); 63 | const GSChar* get_name(); 64 | GSContainerType get_type(); 65 | GSColumnInfo get_column_info(size_t column); 66 | ColumnInfoList get_column_info_list(); 67 | void set_column_info_list(ColumnInfoList columnInfoList); 68 | ExpirationInfo* get_expiration_info(); 69 | void set_expiration_info(ExpirationInfo* expirationInfo); 70 | bool get_row_key_assigned(); 71 | GSContainerInfo* gs_info(); 72 | 73 | private: 74 | void init(const GSChar* name, GSContainerType type, const GSColumnInfo* props, 75 | int propsCount, bool rowKeyAssigned, ExpirationInfo* expiration); 76 | }; 77 | 78 | } /* namespace griddb */ 79 | 80 | #endif /* Define _CONTAINERINFO_H_ */ 81 | -------------------------------------------------------------------------------- /src/EnumValue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _ENUM_VALUE_H_ 18 | #define _ENUM_VALUE_H_ 19 | 20 | using namespace std; 21 | 22 | namespace griddb { 23 | // Represents the type(s) of a Container. 24 | class ContainerType { 25 | public: 26 | static const int COLLECTION = 0; 27 | static const int TIME_SERIES = 1; 28 | }; 29 | // Represents the type(s) of indexes set on a Container. 30 | class IndexType { 31 | public: 32 | static const int DEFAULT = -1; 33 | static const int TREE = 1 << 0; 34 | static const int HASH = 1 << 1; 35 | static const int SPATIAL = 1 << 2; 36 | }; 37 | // The type of content that can be extracted from GSRowSet. 38 | class RowSetType { 39 | public: 40 | static const int CONTAINER_ROWS = 0; 41 | static const int AGGREGATION_RESULT = 1; 42 | static const int QUERY_ANALYSIS = 2; 43 | }; 44 | // The options for fetching the result of a query. 45 | class FetchOption { 46 | public: 47 | static const int LIMIT = 0; 48 | 49 | #if GS_INTERNAL_DEFINITION_VISIBLE 50 | #if !GS_COMPATIBILITY_DEPRECATE_FETCH_OPTION_SIZE 51 | static const int SIZE = (LIMIT + 1); 52 | #endif 53 | #endif 54 | 55 | #if GS_COMPATIBILITY_SUPPORT_4_0 56 | static const int PARTIAL_EXECUTION = (LIMIT + 2); 57 | #endif 58 | }; 59 | // Represents the time unit(s) used in TimeSeries data operation. 60 | class TimeUnit { 61 | public: 62 | static const int YEAR = 0; 63 | static const int MONTH = 1; 64 | static const int DAY = 2; 65 | static const int HOUR = 3; 66 | static const int MINUTE = 4; 67 | static const int SECOND = 5; 68 | static const int MILLISECOND = 6; 69 | }; 70 | // Represents the type(s) of field values in GridDB. 71 | class Type { 72 | public: 73 | static const int STRING = 0; 74 | static const int BOOL = 1; 75 | static const int BYTE = 2; 76 | static const int SHORT = 3; 77 | static const int INTEGER = 4; 78 | static const int LONG = 5; 79 | static const int FLOAT = 6; 80 | static const int DOUBLE = 7; 81 | static const int TIMESTAMP = 8; 82 | static const int GEOMETRY = 9; 83 | static const int BLOB = 10; 84 | static const int STRING_ARRAY = 11; 85 | static const int BOOL_ARRAY = 12; 86 | static const int BYTE_ARRAY = 13; 87 | static const int SHORT_ARRAY = 14; 88 | static const int INTEGER_ARRAY = 15; 89 | static const int LONG_ARRAY = 16; 90 | static const int FLOAT_ARRAY = 17; 91 | static const int DOUBLE_ARRAY = 18; 92 | static const int TIMESTAMP_ARRAY = 19; 93 | 94 | // Can't use NULL because it is keyword of C language 95 | static const int NULL_TYPE = -1; 96 | }; 97 | // Sum of bits of value of the flag indicating the option setting for Column. 98 | class TypeOption { 99 | public: 100 | static const int NULLABLE = 1 << 1; 101 | static const int NOT_NULL = 1 << 2; 102 | }; 103 | } 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/ExpirationInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _EXPIRATIONINFO_H_ 18 | #define _EXPIRATIONINFO_H_ 19 | 20 | #include 21 | #include 22 | 23 | using namespace std; 24 | 25 | namespace griddb { 26 | class ExpirationInfo { 27 | /* 28 | * Contains information about expiration configuration 29 | */ 30 | GSTimeSeriesProperties mTimeSeriesProps; 31 | 32 | public: 33 | ExpirationInfo(const GSTimeSeriesProperties* timeSeriesProps) { 34 | mTimeSeriesProps.rowExpirationTime = timeSeriesProps->rowExpirationTime; 35 | mTimeSeriesProps.rowExpirationTimeUnit = timeSeriesProps->rowExpirationTimeUnit; 36 | mTimeSeriesProps.expirationDivisionCount = timeSeriesProps->expirationDivisionCount; 37 | mTimeSeriesProps.compressionList = NULL; 38 | mTimeSeriesProps.compressionListSize = 0; 39 | mTimeSeriesProps.compressionMethod = GS_COMPRESSION_NO; 40 | mTimeSeriesProps.compressionWindowSize = 0; 41 | mTimeSeriesProps.compressionWindowSizeUnit = GS_TIME_UNIT_YEAR; 42 | }; 43 | ExpirationInfo(int time, GSTimeUnit unit, int division_count) { 44 | mTimeSeriesProps.rowExpirationTime = time; 45 | mTimeSeriesProps.rowExpirationTimeUnit = unit; 46 | mTimeSeriesProps.expirationDivisionCount = division_count; 47 | mTimeSeriesProps.compressionList = NULL; 48 | mTimeSeriesProps.compressionListSize = 0; 49 | mTimeSeriesProps.compressionMethod = GS_COMPRESSION_NO; 50 | mTimeSeriesProps.compressionWindowSize = 0; 51 | mTimeSeriesProps.compressionWindowSizeUnit = GS_TIME_UNIT_YEAR; 52 | }; 53 | ~ExpirationInfo() { 54 | //nothing to do 55 | }; 56 | int get_time() { 57 | return mTimeSeriesProps.rowExpirationTime; 58 | }; 59 | void set_time(int time) { 60 | mTimeSeriesProps.rowExpirationTime = time; 61 | }; 62 | GSTimeUnit get_time_unit() { 63 | return mTimeSeriesProps.rowExpirationTimeUnit; 64 | }; 65 | void set_time_unit(GSTimeUnit unit) { 66 | mTimeSeriesProps.rowExpirationTimeUnit = unit; 67 | }; 68 | int get_division_count() { 69 | return mTimeSeriesProps.expirationDivisionCount; 70 | }; 71 | void set_division_count(int division_count) { 72 | mTimeSeriesProps.expirationDivisionCount = division_count; 73 | }; 74 | GSTimeSeriesProperties* gs_ts() { 75 | return &mTimeSeriesProps; 76 | }; 77 | }; 78 | 79 | } /* namespace griddb */ 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/Field.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "Field.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Constructor a new Field:: Field object 23 | */ 24 | Field::Field() : type(GS_TYPE_STRING) { 25 | memset(&value, 0, sizeof(GSValue)); 26 | }; 27 | 28 | Field::~Field() { 29 | switch (type) { 30 | case GS_TYPE_STRING: 31 | if (value.asString) { 32 | delete [] value.asString; 33 | value.asString = NULL; 34 | } 35 | break; 36 | case GS_TYPE_BLOB: 37 | if (value.asBlob.data) { 38 | delete [] (char*)value.asBlob.data; 39 | value.asBlob.data = NULL; 40 | } 41 | break; 42 | case GS_TYPE_INTEGER_ARRAY: 43 | if (value.asArray.elements.asInteger) { 44 | delete [] value.asArray.elements.asInteger; 45 | value.asArray.elements.asInteger = NULL; 46 | } 47 | break; 48 | case GS_TYPE_STRING_ARRAY: 49 | if (value.asArray.elements.asString) { 50 | for (int j = 0; j < value.asArray.length; j++) { 51 | if (value.asArray.elements.asString[j]) { 52 | delete [] value.asArray.elements.asString[j]; 53 | } 54 | } 55 | delete [] value.asArray.elements.asString; 56 | value.asArray.elements.asString = NULL; 57 | } 58 | break; 59 | case GS_TYPE_BOOL_ARRAY: 60 | if (value.asArray.elements.asBool) { 61 | delete [] value.asArray.elements.asBool; 62 | value.asArray.elements.asBool = NULL; 63 | } 64 | break; 65 | case GS_TYPE_BYTE_ARRAY: 66 | if (value.asArray.elements.asByte) { 67 | delete [] value.asArray.elements.asByte; 68 | value.asArray.elements.asByte = NULL; 69 | } 70 | break; 71 | case GS_TYPE_SHORT_ARRAY: 72 | if (value.asArray.elements.asShort) { 73 | delete [] value.asArray.elements.asShort; 74 | value.asArray.elements.asShort = NULL; 75 | } 76 | break; 77 | case GS_TYPE_LONG_ARRAY: 78 | if (value.asArray.elements.asLong) { 79 | delete [] value.asArray.elements.asLong; 80 | value.asArray.elements.asLong = NULL; 81 | } 82 | break; 83 | case GS_TYPE_FLOAT_ARRAY: 84 | if (value.asArray.elements.asFloat) { 85 | delete [] value.asArray.elements.asFloat; 86 | value.asArray.elements.asFloat = NULL; 87 | } 88 | break; 89 | case GS_TYPE_DOUBLE_ARRAY: 90 | if (value.asArray.elements.asDouble) { 91 | delete [] value.asArray.elements.asDouble; 92 | value.asArray.elements.asDouble = NULL; 93 | } 94 | break; 95 | case GS_TYPE_TIMESTAMP_ARRAY: 96 | if (value.asArray.elements.asTimestamp) { 97 | delete [] value.asArray.elements.asTimestamp; 98 | value.asArray.elements.asTimestamp = NULL; 99 | } 100 | break; 101 | default: 102 | //not need to free allocation 103 | break; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/Field.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _FIELD_H_ 18 | #define _FIELD_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include "gridstore.h" 24 | 25 | using namespace std; 26 | 27 | namespace griddb { 28 | 29 | class Field { 30 | public: 31 | GSType type; 32 | GSValue value; 33 | Field(); 34 | ~Field(); 35 | }; 36 | 37 | } 38 | 39 | #endif /* _FIELD_H_ */ 40 | -------------------------------------------------------------------------------- /src/GSException.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _GS_EXXCEPTION_H_ 18 | #define _GS_EXXCEPTION_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include "gridstore.h" 24 | 25 | using namespace std; 26 | 27 | #define DEFAULT_ERROR_CODE -1 28 | #define DEFAULT_ERROR_STACK_SIZE 1 29 | 30 | namespace griddb { 31 | 32 | /** 33 | * This class creates exception corresponding to error code 34 | */ 35 | class GSException : public exception { 36 | private: 37 | bool mIsTimeout; 38 | int32_t mCode; 39 | string mMessage; 40 | void *mResource; 41 | 42 | bool hasInnerError; 43 | size_t mInnerErrStackSize; 44 | GSResult* mInnerErrCodeStack; 45 | string* mInnerMessagesStack; 46 | string* mInnerErrorLocationStack; 47 | 48 | public: 49 | GSException(const char* message) : exception(), 50 | mCode(DEFAULT_ERROR_CODE), mMessage(message), mResource(NULL) { 51 | hasInnerError = false; 52 | mInnerErrStackSize = 0; 53 | mInnerErrCodeStack = NULL; 54 | mInnerMessagesStack = NULL; 55 | mInnerErrorLocationStack = NULL; 56 | mIsTimeout = false; 57 | } 58 | GSException(void *resource, const char* message) : exception(), 59 | mCode(DEFAULT_ERROR_CODE), mMessage(message), mResource(resource) { 60 | hasInnerError = false; 61 | mInnerErrStackSize = 0; 62 | mInnerErrCodeStack = NULL; 63 | mInnerMessagesStack = NULL; 64 | mInnerErrorLocationStack = NULL; 65 | mIsTimeout = false; 66 | } 67 | GSException(void *resource, int32_t code) : exception(), 68 | mCode(code), mResource(resource) { 69 | mMessage = "Error with number " + to_string((long long int)mCode); 70 | if (mCode != DEFAULT_ERROR_CODE && mResource != NULL) { 71 | //Case exception with error code from c layer 72 | mIsTimeout = gsIsTimeoutError(mCode); 73 | // Store error stack 74 | hasInnerError = true; 75 | mInnerErrStackSize = get_error_stack_size_from_lower_layer(); 76 | mInnerErrCodeStack = new GSResult[mInnerErrStackSize](); 77 | mInnerMessagesStack = new string[mInnerErrStackSize](); 78 | mInnerErrorLocationStack = new string[mInnerErrStackSize](); 79 | for (int i = 0; i < mInnerErrStackSize; i++) { 80 | mInnerErrCodeStack[i] = get_error_code_from_lower_layer(i); 81 | mInnerMessagesStack[i] = get_message_from_lower_layer(i); 82 | mInnerErrorLocationStack[i] = get_location_from_lower_layer(i); 83 | } 84 | } else { 85 | hasInnerError = false; 86 | mInnerErrStackSize = 0; 87 | mInnerErrCodeStack = NULL; 88 | mInnerMessagesStack = NULL; 89 | mInnerErrorLocationStack = NULL; 90 | mIsTimeout = false; 91 | } 92 | } 93 | GSException(const GSException* exception) { 94 | mCode = exception->mCode; 95 | mIsTimeout = exception->mIsTimeout; 96 | mMessage = exception->mMessage; 97 | mResource = exception->mResource; 98 | hasInnerError = exception->hasInnerError; 99 | if (hasInnerError == true) { 100 | mInnerErrStackSize = exception->mInnerErrStackSize; 101 | mInnerErrCodeStack = new GSResult[mInnerErrStackSize](); 102 | mInnerMessagesStack = new string[mInnerErrStackSize](); 103 | mInnerErrorLocationStack = new string[mInnerErrStackSize](); 104 | for (int i = 0; i < mInnerErrStackSize; i++) { 105 | mInnerErrCodeStack[i] = exception->mInnerErrCodeStack[i]; 106 | mInnerMessagesStack[i] = exception->mInnerMessagesStack[i]; 107 | mInnerErrorLocationStack[i] = exception->mInnerErrorLocationStack[i]; 108 | } 109 | } else { 110 | mInnerErrStackSize = 0; 111 | mInnerErrCodeStack = NULL; 112 | mInnerMessagesStack = NULL; 113 | mInnerErrorLocationStack = NULL; 114 | } 115 | } 116 | ~GSException() throw() { 117 | close(); 118 | } 119 | 120 | void close() { 121 | if (mInnerErrCodeStack != NULL) { 122 | delete[] mInnerErrCodeStack; 123 | mInnerErrCodeStack = NULL; 124 | } 125 | if (mInnerMessagesStack != NULL) { 126 | delete[] mInnerMessagesStack; 127 | mInnerMessagesStack = NULL; 128 | } 129 | if (mInnerErrorLocationStack != NULL) { 130 | delete[] mInnerErrorLocationStack; 131 | mInnerErrorLocationStack = NULL; 132 | } 133 | } 134 | int32_t get_code() { 135 | return mCode; 136 | } 137 | virtual const char* what() const throw() { 138 | return mMessage.c_str(); 139 | } 140 | /* 141 | * Check timeout. Convert from C-API: gsIsTimeoutError 142 | */ 143 | bool is_timeout() { 144 | return mIsTimeout; 145 | } 146 | /** 147 | * Get error stack size. Convert from C-API: gsGetErrorStackSize. 148 | */ 149 | size_t get_error_stack_size() { 150 | if (hasInnerError == false) { 151 | return DEFAULT_ERROR_STACK_SIZE; 152 | } 153 | return mInnerErrStackSize; 154 | } 155 | /** 156 | * Get error code. Convert from C-API: gsGetErrorCode. 157 | */ 158 | GSResult get_error_code(size_t stack_index) { 159 | if (hasInnerError == false) { 160 | if (stack_index == 0) return mCode; 161 | return 0; 162 | } else { 163 | if (stack_index >= mInnerErrStackSize) return 0; 164 | return mInnerErrCodeStack[stack_index]; 165 | } 166 | } 167 | /** 168 | * Get error message. Convert from C-API: gsFormatErrorMessage. 169 | */ 170 | string get_message(size_t stack_index, size_t buf_size = 1024) { 171 | if (hasInnerError == false) { 172 | if (stack_index == 0) return mMessage; 173 | return ""; 174 | } else { 175 | if (stack_index >= mInnerErrStackSize) return ""; 176 | return mInnerMessagesStack[stack_index]; 177 | } 178 | } 179 | /** 180 | * Get error location. Convert from C-API: gsFormatErrorLocation. 181 | */ 182 | string get_location(size_t stack_index, size_t buf_size = 1024) { 183 | if (hasInnerError == false) { 184 | return ""; 185 | } else { 186 | if (stack_index >= mInnerErrStackSize) return ""; 187 | return mInnerErrorLocationStack[stack_index]; 188 | } 189 | } 190 | private: 191 | /** 192 | * Get error stack size. Convert from C-API: gsGetErrorStackSize. 193 | */ 194 | size_t get_error_stack_size_from_lower_layer() { 195 | return gsGetErrorStackSize(mResource); 196 | } 197 | /** 198 | * Get error code. Convert from C-API: gsGetErrorCode. 199 | */ 200 | GSResult get_error_code_from_lower_layer(size_t stack_index) { 201 | return gsGetErrorCode(mResource, stack_index); 202 | } 203 | /** 204 | * Get error message. Convert from C-API: gsFormatErrorMessage. 205 | */ 206 | string get_message_from_lower_layer(size_t stack_index, size_t buf_size = 1024) { 207 | char* strBuf = new char[buf_size]; 208 | size_t stringSize = gsFormatErrorMessage(mResource, stack_index, strBuf, buf_size); 209 | string ret(strBuf, stringSize); 210 | delete [] strBuf; 211 | return ret; 212 | } 213 | /** 214 | * Get error location. Convert from C-API: gsFormatErrorLocation. 215 | */ 216 | string get_location_from_lower_layer(size_t stack_index, size_t buf_size = 1024) { 217 | char* strBuf = new char[buf_size]; 218 | size_t stringSize = gsFormatErrorLocation(mResource, stack_index, strBuf, buf_size); 219 | string ret(strBuf, stringSize); 220 | delete [] strBuf; 221 | return ret; 222 | } 223 | }; 224 | 225 | } /* namespace griddb */ 226 | 227 | #endif 228 | -------------------------------------------------------------------------------- /src/PartitionController.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "PartitionController.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Constructor a new PartitionController::PartitionController object 23 | * @param *controller A pointer for acquiring and processing the partition status 24 | */ 25 | PartitionController::PartitionController(GSPartitionController *controller) : 26 | mController(controller) { 27 | } 28 | 29 | /** 30 | * @brief Destructor to free resources for a PartitionController object 31 | */ 32 | PartitionController::~PartitionController() { 33 | close(); 34 | } 35 | 36 | /** 37 | * @brief Release PartitionController resource 38 | */ 39 | void PartitionController::close() { 40 | if (mController != NULL) { 41 | gsClosePartitionController(&mController); 42 | mController = NULL; 43 | } 44 | } 45 | 46 | /** 47 | * @brief Get partition count 48 | * @return The number of partitions in the target GridDB cluster 49 | */ 50 | int32_t PartitionController::get_partition_count() { 51 | int32_t value; 52 | GSResult ret = gsGetPartitionCount(mController, &value); 53 | 54 | // Check ret, if error, throw exception 55 | if (!GS_SUCCEEDED(ret)) { 56 | throw GSException(mController, ret); 57 | } 58 | return value; 59 | } 60 | 61 | /** 62 | * @brief Get container partition count 63 | * @param partition_index The partition index, from 0 to the number of partitions minus one 64 | * @return The number of Container 65 | */ 66 | int64_t PartitionController::get_container_count(int32_t partition_index) { 67 | int64_t value; 68 | GSResult ret = gsGetPartitionContainerCount(mController, partition_index, &value); 69 | 70 | // Check ret, if error, throw exception 71 | if (!GS_SUCCEEDED(ret)) { 72 | throw GSException(mController, ret); 73 | } 74 | return value; 75 | } 76 | 77 | /** 78 | * @brief Get a list of the Container names belonging to a specified partition. 79 | * @param partition_index The partition index, from 0 to the number of partitions minus one 80 | * @param start The start position of the acquisition range. A value must be greater than or equal to 0 81 | * @param ***stringList The pointer to a pointer variable to store the array list of Container name 82 | * @param *size The pointer to a variable to store the number of array elements of the Container name list 83 | * @param limit The upper limit of the number of cases acquired 84 | */ 85 | void PartitionController::get_container_names(int32_t partition_index, int64_t start, 86 | const GSChar * const ** stringList, size_t *size, int64_t limit) { 87 | int64_t* limitPtr; 88 | if (limit >= 0) { 89 | limitPtr = &limit; 90 | } else { 91 | limitPtr = NULL; 92 | } 93 | GSResult ret = gsGetPartitionContainerNames(mController, partition_index, start, limitPtr, stringList, size); 94 | 95 | if (!GS_SUCCEEDED(ret)) { 96 | throw GSException(mController, ret); 97 | } 98 | } 99 | 100 | /** 101 | * @brief Get the partition index corresponding to the specified Container name. 102 | * @param *container_name Container name 103 | * @return The partition index 104 | */ 105 | int32_t PartitionController::get_partition_index_of_container(const GSChar* container_name) { 106 | int32_t value; 107 | GSResult ret = gsGetPartitionIndexOfContainer(mController, container_name, &value); 108 | 109 | // Check ret, if error, throw exception 110 | if (!GS_SUCCEEDED(ret)) { 111 | throw GSException(mController, ret); 112 | } 113 | return value; 114 | } 115 | 116 | } /* namespace griddb */ 117 | -------------------------------------------------------------------------------- /src/PartitionController.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _PARTITIONCONTROLLER_H_ 18 | #define _PARTITIONCONTROLLER_H_ 19 | 20 | #include "gridstore.h" 21 | #include "GSException.h" 22 | 23 | namespace griddb { 24 | 25 | class PartitionController { 26 | friend class Store; 27 | 28 | private: 29 | GSPartitionController *mController; 30 | 31 | public: 32 | ~PartitionController(); 33 | void close(); 34 | int32_t get_partition_count(); 35 | int64_t get_container_count(int32_t partition_index); 36 | void get_container_names(int32_t partition_index, int64_t start, 37 | const GSChar * const ** stringList, size_t *size, int64_t limit = -1); 38 | int32_t get_partition_index_of_container(const GSChar *container_name); 39 | 40 | private: 41 | PartitionController(GSPartitionController *controller); 42 | }; 43 | 44 | } /* namespace griddb */ 45 | 46 | #endif /* _PARTITIONCONTROLLER_H_ */ 47 | -------------------------------------------------------------------------------- /src/Query.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "Query.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Constructor a new Query::Query object 23 | * @param *query A pointer holding the information about a query related to a specific GSContainer 24 | * @param *containerInfo A pointer holding the information about a specific GSContainer 25 | * @param *gsRow A pointer holding the information about a row related to a specific GSContainer 26 | */ 27 | Query::Query(GSQuery *query, GSContainerInfo *containerInfo, GSRow *gsRow) : mQuery(query), 28 | mContainerInfo(containerInfo), mRow(gsRow) { 29 | } 30 | 31 | Query::~Query() { 32 | close(); 33 | } 34 | 35 | /** 36 | * @brief Release Query resource 37 | */ 38 | void Query::close() { 39 | if (mQuery) { 40 | gsCloseQuery(&mQuery); 41 | mQuery = NULL; 42 | } 43 | } 44 | 45 | /** 46 | * @brief Fetch data from query result. 47 | * @param for_update Indicates whether it requests a lock for update or not 48 | * @return The pointer to a pointer variable to store GSRowSet instance 49 | */ 50 | RowSet* Query::fetch(bool for_update) { 51 | GSRowSet *gsRowSet; 52 | // Call method from C-Api. 53 | GSBool gsForUpdate = (for_update == true ? GS_TRUE:GS_FALSE); 54 | GSResult ret = gsFetch(mQuery, gsForUpdate, &gsRowSet); 55 | 56 | // Check ret, if error, throw exception 57 | if (!GS_SUCCEEDED(ret)) { 58 | throw GSException(mQuery, ret); 59 | } 60 | 61 | try { 62 | RowSet* rowset = new RowSet(gsRowSet, mContainerInfo, mRow); 63 | return rowset; 64 | } catch (bad_alloc& ba) { 65 | gsCloseRowSet(&gsRowSet); 66 | throw GSException(mQuery, "Memory allocation error"); 67 | } 68 | } 69 | 70 | /** 71 | * @brief Get row set. 72 | * @return The pointer to a pointer variable to store GSRowSet instance 73 | */ 74 | RowSet* Query::get_row_set() { 75 | GSRowSet *gsRowSet; 76 | GSResult ret = gsGetRowSet(mQuery, &gsRowSet); 77 | 78 | // Check ret, if error, throw exception 79 | if (!GS_SUCCEEDED(ret)) { 80 | throw GSException(mQuery, ret); 81 | } 82 | 83 | try { 84 | RowSet* rowset = new RowSet(gsRowSet, mContainerInfo, mRow); 85 | return rowset; 86 | } catch (bad_alloc& ba) { 87 | gsCloseRowSet(&gsRowSet); 88 | throw GSException(mQuery, "Memory allocation error"); 89 | } 90 | } 91 | 92 | /** 93 | * @brief Get raw pointer of GSQuery 94 | * @return A pointer store raw pointer of GSQuery 95 | */ 96 | GSQuery* Query::gs_ptr() { 97 | return mQuery; 98 | } 99 | 100 | /** 101 | * @brief Set fetch limit option for a result acquisition. 102 | * @param limit The maximum number of Rows to be fetched. 103 | * @param partial The option value for GSFetchOption 104 | */ 105 | void Query::set_fetch_options(int limit, bool partial){ 106 | GSResult ret; 107 | ret = gsSetFetchOption(mQuery, GS_FETCH_LIMIT, &limit, GS_TYPE_INTEGER); 108 | if (!GS_SUCCEEDED(ret)) { 109 | throw GSException(mQuery, ret); 110 | } 111 | #if GS_COMPATIBILITY_SUPPORT_4_0 112 | //Need to call gsSetFetchOption as many as the number of options 113 | ret = gsSetFetchOption(mQuery, GS_FETCH_PARTIAL_EXECUTION, &partial, GS_TYPE_BOOL); 114 | if (!GS_SUCCEEDED(ret)) { 115 | throw GSException(mQuery, ret); 116 | } 117 | #endif 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/Query.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _QUERY_H_ 18 | #define _QUERY_H_ 19 | 20 | #include 21 | 22 | #include "gridstore.h" 23 | #include "RowSet.h" 24 | #include "GSException.h" 25 | using namespace std; 26 | 27 | namespace griddb { 28 | 29 | /** 30 | * Convert from GSQuery 31 | */ 32 | 33 | class Query { 34 | friend class Container; 35 | private: 36 | GSQuery *mQuery; 37 | GSContainerInfo *mContainerInfo; 38 | GSRow* mRow; 39 | 40 | public: 41 | ~Query(); 42 | void close(); 43 | RowSet* fetch(bool for_update = false); 44 | void set_fetch_options(int limit = -1, bool partial = false); 45 | RowSet* get_row_set(); 46 | GSQuery* gs_ptr(); 47 | 48 | private: 49 | Query(GSQuery *query, GSContainerInfo *containerInfo, GSRow *gsRow); 50 | 51 | }; 52 | 53 | } 54 | 55 | #endif /* _QUERY_H_ */ 56 | -------------------------------------------------------------------------------- /src/QueryAnalysisEntry.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "QueryAnalysisEntry.h" 18 | 19 | #include 20 | 21 | namespace griddb { 22 | 23 | /** 24 | * @brief Constructor a new QueryAnalysisEntry::QueryAnalysisEntry object 25 | * @param *queryAnalysis Represents one of information entries composing a query plan and the results of analyzing a query operation. 26 | */ 27 | QueryAnalysisEntry::QueryAnalysisEntry(GSQueryAnalysisEntry* queryAnalysis) : mQueryAnalysis(NULL) { 28 | if (!queryAnalysis) { 29 | return; 30 | } 31 | 32 | try { 33 | if (!mQueryAnalysis) { 34 | mQueryAnalysis = new GSQueryAnalysisEntry(); 35 | } 36 | 37 | mQueryAnalysis->statement = NULL; 38 | mQueryAnalysis->type = NULL; 39 | mQueryAnalysis->value = NULL; 40 | mQueryAnalysis->valueType = NULL; 41 | 42 | if (queryAnalysis->statement) { 43 | Util::strdup(&(mQueryAnalysis->statement), queryAnalysis->statement); 44 | } 45 | 46 | if (queryAnalysis->type) { 47 | Util::strdup(&(mQueryAnalysis->type), queryAnalysis->type); 48 | } 49 | 50 | if (queryAnalysis->value) { 51 | Util::strdup(&(mQueryAnalysis->value), queryAnalysis->value); 52 | } 53 | 54 | if (queryAnalysis->valueType) { 55 | Util::strdup(&(mQueryAnalysis->valueType), queryAnalysis->valueType); 56 | } 57 | } catch (bad_alloc& ba) { 58 | this->freeMemory(); 59 | throw GSException(mQueryAnalysis, "Memory allocation error"); 60 | } 61 | 62 | //Copy value which queryAnalysis point to 63 | mQueryAnalysis->id = queryAnalysis->id; 64 | mQueryAnalysis->depth = queryAnalysis->depth; 65 | } 66 | 67 | QueryAnalysisEntry::~QueryAnalysisEntry() { 68 | this->close(); 69 | } 70 | 71 | /** 72 | * @brief Release QueryAnalysisEntry resource 73 | */ 74 | void QueryAnalysisEntry::close() { 75 | this->freeMemory(); 76 | if (mQueryAnalysis) { 77 | mQueryAnalysis = NULL; 78 | } 79 | } 80 | 81 | void QueryAnalysisEntry::freeMemory() { 82 | if (mQueryAnalysis) { 83 | if (mQueryAnalysis->statement) { 84 | delete[] mQueryAnalysis->statement; 85 | } 86 | if (mQueryAnalysis->type) { 87 | delete[] mQueryAnalysis->type; 88 | } 89 | if (mQueryAnalysis->value) { 90 | delete[] mQueryAnalysis->value; 91 | } 92 | if (mQueryAnalysis->valueType) { 93 | delete[] mQueryAnalysis->valueType; 94 | } 95 | delete mQueryAnalysis; 96 | } 97 | } 98 | 99 | /** 100 | * @brief get QueryAnalysisEntry data 101 | * @param *queryAnalysis Represents one of information entries composing a query plan and the results of analyzing a query operation. 102 | */ 103 | void QueryAnalysisEntry::get(GSQueryAnalysisEntry* queryAnalysis) { 104 | assert(queryAnalysis != NULL); 105 | queryAnalysis->id = mQueryAnalysis->id; 106 | queryAnalysis->depth = mQueryAnalysis->depth; 107 | queryAnalysis->statement = NULL; 108 | queryAnalysis->type = NULL; 109 | queryAnalysis->value = NULL; 110 | queryAnalysis->valueType = NULL; 111 | 112 | try { 113 | if (mQueryAnalysis->statement) { 114 | Util::strdup(&(queryAnalysis->statement), mQueryAnalysis->statement); 115 | } 116 | 117 | if (mQueryAnalysis->type) { 118 | Util::strdup(&(queryAnalysis->type), mQueryAnalysis->type); 119 | } 120 | 121 | if (mQueryAnalysis->value) { 122 | Util::strdup(&(queryAnalysis->value), mQueryAnalysis->value); 123 | } 124 | 125 | if (mQueryAnalysis->valueType) { 126 | Util::strdup(&(queryAnalysis->valueType), mQueryAnalysis->valueType); 127 | } 128 | } catch (bad_alloc& ba) { 129 | if (queryAnalysis->statement) { 130 | delete[] queryAnalysis->statement; 131 | } 132 | if (queryAnalysis->type) { 133 | delete[] queryAnalysis->type; 134 | } 135 | if (queryAnalysis->value) { 136 | delete[] queryAnalysis->value; 137 | } 138 | if (queryAnalysis->valueType) { 139 | delete[] queryAnalysis->valueType; 140 | } 141 | throw GSException(mQueryAnalysis, "Memory allocation error"); 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/QueryAnalysisEntry.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef SRC_QUERYANALYSISENTRY_H_ 18 | #define SRC_QUERYANALYSISENTRY_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include "gridstore.h" 24 | #include "GSException.h" 25 | #include "Util.h" 26 | 27 | using namespace std; 28 | 29 | namespace griddb { 30 | 31 | class QueryAnalysisEntry { 32 | private: 33 | GSQueryAnalysisEntry* mQueryAnalysis; 34 | void freeMemory(); 35 | 36 | public: 37 | QueryAnalysisEntry(GSQueryAnalysisEntry* queryAnalysis); 38 | ~QueryAnalysisEntry(); 39 | void close(); 40 | void get(GSQueryAnalysisEntry* queryAnalysis); 41 | 42 | }; 43 | 44 | } 45 | #endif /* SRC_QUERYANALYSISENTRY_H_ */ 46 | 47 | -------------------------------------------------------------------------------- /src/RowKeyPredicate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "RowKeyPredicate.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Constructor a new RowSet::RowSet object 23 | * @param *predicate Represents the condition that a row key satisfies. 24 | * @param type The type of Row key used as a matching condition 25 | */ 26 | RowKeyPredicate::RowKeyPredicate(GSRowKeyPredicate *predicate, GSType type): mPredicate(predicate), mType(type), 27 | timestamp_output_with_float(false){ 28 | } 29 | 30 | /** 31 | * @brief Destructor to free resource of RowKeyPredicate object 32 | */ 33 | RowKeyPredicate::~RowKeyPredicate() { 34 | close(); 35 | } 36 | 37 | /** 38 | * @brief Release RowKeyPredicate resource 39 | */ 40 | void RowKeyPredicate::close() { 41 | if (mPredicate != NULL) { 42 | gsCloseRowKeyPredicate(&mPredicate); 43 | mPredicate = NULL; 44 | } 45 | } 46 | 47 | /** 48 | * @brief Get key type 49 | * @return The type of Row key used as a matching condition 50 | */ 51 | GSType RowKeyPredicate::get_key_type() { 52 | return mType; 53 | } 54 | 55 | /** 56 | * @brief Get the value of Row key at the start and end position of the range condition 57 | * @param *startField The pointer to a variable to store the value of the Row key at the starting position 58 | * @param *finishField The pointer to a variable to store the value of the Row key at the end position 59 | */ 60 | void RowKeyPredicate::get_range(Field* startField, Field* finishField) { 61 | assert(startField != NULL); 62 | assert(finishField != NULL); 63 | startField->type = -1; // for all versions which do not support GS_TYPE_NULL 64 | finishField->type = -1; // for all versions which do not support GS_TYPE_NULL 65 | GSType key_type = get_key_type(); 66 | const GSValue *startKey = NULL; 67 | const GSValue *endKey = NULL; 68 | GSResult ret = gsGetPredicateStartKeyGeneral(mPredicate, &startKey); 69 | if (!GS_SUCCEEDED(ret)) { 70 | throw GSException(mPredicate, ret); 71 | } 72 | if (startKey != NULL) { 73 | startField->type = key_type; 74 | if (startField->type == GS_TYPE_STRING) { 75 | if (startKey->asString) { 76 | try { 77 | Util::strdup(&(startField->value.asString), startKey->asString); 78 | } catch (bad_alloc& ba) { 79 | throw GSException(mPredicate, "Memory allocation error"); 80 | } 81 | } else { 82 | startField->value.asString = NULL; 83 | } 84 | } else { 85 | startField->value = *startKey; 86 | } 87 | } 88 | ret = gsGetPredicateFinishKeyGeneral(mPredicate, &endKey); 89 | if (!GS_SUCCEEDED(ret)) { 90 | if (startField->type == GS_TYPE_STRING && startField->value.asString) { 91 | delete[] startField->value.asString; 92 | } 93 | throw GSException(mPredicate, ret); 94 | } 95 | if (endKey != NULL) { 96 | finishField->type = key_type; 97 | if (finishField->type == GS_TYPE_STRING) { 98 | if (endKey->asString) { 99 | try { 100 | Util::strdup(&(finishField->value.asString), endKey->asString); 101 | } catch (bad_alloc& ba) { 102 | if (startField->type == GS_TYPE_STRING && startField->value.asString) { 103 | delete[] startField->value.asString; 104 | } 105 | throw GSException(mPredicate, "Memory allocation error"); 106 | } 107 | } else { 108 | finishField->value.asString = NULL; 109 | } 110 | } else { 111 | finishField->value = *endKey; 112 | } 113 | } 114 | } 115 | 116 | /** 117 | * @brief Sets the value of Row key as the start and end position of the range conditions 118 | * @param *startKey The pointer to a variable to store the value of the Row key at the starting position 119 | * @param *finishKey The pointer to a variable to store the value of the Row key at the end position 120 | */ 121 | void RowKeyPredicate::set_range(Field* startKey, Field* finishKey) { 122 | assert(startKey != NULL); 123 | assert(finishKey != NULL); 124 | GSType key_type = get_key_type(); 125 | GSResult ret; 126 | 127 | switch (key_type) { 128 | case GS_TYPE_LONG: 129 | ret = gsSetPredicateStartKeyByLong(mPredicate, (int64_t*)&startKey->value.asLong); 130 | if (!GS_SUCCEEDED(ret)) { 131 | throw GSException(mPredicate, ret); 132 | } 133 | ret = gsSetPredicateFinishKeyByLong(mPredicate, (int64_t *) &finishKey->value.asLong); 134 | if (!GS_SUCCEEDED(ret)) { 135 | throw GSException(mPredicate, ret); 136 | } 137 | break; 138 | case GS_TYPE_INTEGER: 139 | ret = gsSetPredicateStartKeyByInteger(mPredicate, (const int32_t *) &startKey->value.asInteger); 140 | if (!GS_SUCCEEDED(ret)) { 141 | throw GSException(mPredicate, ret); 142 | } 143 | ret = gsSetPredicateFinishKeyByInteger(mPredicate, (const int32_t *)&finishKey->value.asInteger); 144 | if (!GS_SUCCEEDED(ret)) { 145 | throw GSException(mPredicate, ret); 146 | } 147 | break; 148 | case GS_TYPE_STRING: 149 | ret = gsSetPredicateStartKeyByString(mPredicate, startKey->value.asString); 150 | if (!GS_SUCCEEDED(ret)) { 151 | throw GSException(mPredicate, ret); 152 | } 153 | ret = gsSetPredicateFinishKeyByString(mPredicate, finishKey->value.asString); 154 | if (!GS_SUCCEEDED(ret)) { 155 | throw GSException(mPredicate, ret); 156 | } 157 | break; 158 | case GS_TYPE_TIMESTAMP: 159 | ret = gsSetPredicateStartKeyByTimestamp(mPredicate, 160 | (const GSTimestamp *) &(startKey->value.asTimestamp)); 161 | if (!GS_SUCCEEDED(ret)) { 162 | throw GSException(mPredicate, ret); 163 | } 164 | ret = gsSetPredicateFinishKeyByTimestamp(mPredicate, 165 | (const GSTimestamp *) &(finishKey->value.asTimestamp)); 166 | if (!GS_SUCCEEDED(ret)) { 167 | throw GSException(mPredicate, ret); 168 | } 169 | break; 170 | default: 171 | throw GSException(mPredicate, "Not support type"); 172 | break; 173 | } 174 | } 175 | 176 | /** 177 | * @brief Adds the value of Row key as one of the elements in the individual condition 178 | * @param *keys The value of Row key to be added as one of the elements in the individual condition 179 | * @param keyCount Number of distinct key 180 | */ 181 | void RowKeyPredicate::set_distinct_keys(const Field *keys, size_t keyCount) { 182 | assert(keys != NULL); 183 | GSType key_type = get_key_type(); 184 | GSResult ret; 185 | for (size_t i = 0; i < keyCount; i++) { 186 | const Field* key = keys + i; 187 | assert(key != NULL); 188 | switch (key_type) { 189 | case GS_TYPE_LONG: 190 | ret = gsAddPredicateKeyByLong(mPredicate, key->value.asLong); 191 | if (!GS_SUCCEEDED(ret)) { 192 | throw GSException(mPredicate, ret); 193 | } 194 | break; 195 | case GS_TYPE_INTEGER: 196 | ret = gsAddPredicateKeyByInteger(mPredicate, 197 | key->value.asInteger); 198 | if (!GS_SUCCEEDED(ret)) { 199 | throw GSException(mPredicate, ret); 200 | } 201 | break; 202 | case GS_TYPE_STRING: 203 | ret = gsAddPredicateKeyByString(mPredicate, key->value.asString); 204 | if (!GS_SUCCEEDED(ret)) { 205 | throw GSException(mPredicate, ret); 206 | } 207 | 208 | break; 209 | case GS_TYPE_TIMESTAMP: 210 | ret = gsAddPredicateKeyByTimestamp(mPredicate, 211 | key->value.asTimestamp); 212 | if (!GS_SUCCEEDED(ret)) { 213 | throw GSException(mPredicate, ret); 214 | } 215 | break; 216 | default: 217 | throw GSException(mPredicate, "Not support type"); 218 | break; 219 | } 220 | } 221 | } 222 | 223 | /** 224 | * @brief Get a set of the values of the Row keys that configure the individual condition. 225 | * @param **keys A pointer refers to list of Row key value 226 | * @param *keyCount A pointer stores number of distinct key 227 | */ 228 | void RowKeyPredicate::get_distinct_keys(Field **keys, size_t* keyCount) { 229 | assert(keys != NULL); 230 | assert(keyCount != NULL); 231 | 232 | size_t size; 233 | GSType key_type = get_key_type(); 234 | GSValue * keyList; 235 | GSResult ret = gsGetPredicateDistinctKeysGeneral(mPredicate, (const GSValue **)&keyList, &size); 236 | if (!GS_SUCCEEDED(ret)) { 237 | throw GSException(mPredicate, ret); 238 | } 239 | *keyCount = size; 240 | 241 | Field* keyFields; 242 | try { 243 | keyFields = new Field[size](); //will be free in typemap out 244 | for (int i = 0; i < size; i++) { 245 | keyFields[i].type = key_type; 246 | switch(key_type) { 247 | case GS_TYPE_STRING: 248 | if (keyList[i].asString) { 249 | Util::strdup(&(keyFields[i].value.asString), keyList[i].asString); 250 | } else { 251 | keyFields[i].value.asString = NULL; 252 | } 253 | break; 254 | default: 255 | keyFields[i].value = keyList[i]; 256 | break; 257 | } 258 | } 259 | *keys = keyFields; 260 | } catch (bad_alloc& ba) { 261 | if (keyFields) { 262 | for (int i = 0; i < size; i++) { 263 | if (keyFields[i].type == GS_TYPE_STRING && keyFields[i].value.asString) { 264 | delete[] keyFields[i].value.asString; 265 | } 266 | } 267 | delete[] keyFields; 268 | } 269 | 270 | throw GSException(mPredicate, "Memory allocation error"); 271 | } 272 | 273 | } 274 | 275 | /** 276 | * @brief Get GSRowKeyPredicate data in RowKeyPredicate object 277 | * @return A pointer stores GSRowKeyPredicate data in RowKeyPredicate object 278 | */ 279 | GSRowKeyPredicate* RowKeyPredicate::gs_ptr() { 280 | return mPredicate; 281 | } 282 | 283 | } /* namespace griddb */ 284 | -------------------------------------------------------------------------------- /src/RowKeyPredicate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _ROWKEYPREDICATE_H_ 18 | #define _ROWKEYPREDICATE_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "gridstore.h" 26 | #include "Field.h" 27 | #include "GSException.h" 28 | #include "Util.h" 29 | 30 | using namespace std; 31 | 32 | namespace griddb { 33 | 34 | class RowKeyPredicate { 35 | GSRowKeyPredicate *mPredicate; 36 | GSType mType; 37 | 38 | friend class Store; 39 | 40 | public: 41 | bool timestamp_output_with_float; 42 | ~RowKeyPredicate(); 43 | void close(); 44 | 45 | void get_range(Field* startField, Field* finishField); 46 | void set_range(Field* startKey, Field* finishKey); 47 | void set_distinct_keys(const Field *keys, size_t keyCount); 48 | void get_distinct_keys(Field **keys, size_t* keyCount); 49 | GSRowKeyPredicate* gs_ptr(); 50 | GSType get_key_type(); 51 | 52 | private: 53 | RowKeyPredicate(GSRowKeyPredicate *predicate, GSType type); 54 | 55 | }; 56 | 57 | } /* namespace griddb */ 58 | 59 | #endif /* _ROWKEYPREDICATE_H_ */ 60 | -------------------------------------------------------------------------------- /src/RowSet.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "RowSet.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Constructor a new RowSet::RowSet object 23 | * @param *rowSet A pointer manages a set of Rows obtained by a query 24 | * @param *containerInfo A pointer holding the information about a specific GSContainer 25 | * @param *gsRow A pointer holding the information about a row related to a specific GSContainer 26 | */ 27 | RowSet::RowSet(GSRowSet *rowSet, GSContainerInfo *containerInfo, GSRow *gsRow) : 28 | mRowSet(rowSet), mContainerInfo(containerInfo), mRow(gsRow), 29 | timestamp_output_with_float(false), typeList(NULL) { 30 | if (mRowSet != NULL) { 31 | mType = gsGetRowSetType(mRowSet); 32 | } else { 33 | throw GSException(mRowSet, "mRowSet is NULL"); 34 | } 35 | } 36 | 37 | /** 38 | * @brief Check if RowSet has next row data. 39 | * @return Returns whether a Row set has at least one Row ahead of the current cursor position 40 | */ 41 | bool RowSet::has_next() { 42 | GSRowSetType type; 43 | type = this->type(); 44 | switch(type) { 45 | case (GS_ROW_SET_CONTAINER_ROWS): 46 | case (GS_ROW_SET_AGGREGATION_RESULT): 47 | case (GS_ROW_SET_QUERY_ANALYSIS): 48 | return (bool) gsHasNextRow(mRowSet); 49 | default: 50 | return false; 51 | } 52 | } 53 | 54 | RowSet::~RowSet() { 55 | close(); 56 | if (typeList) { 57 | delete[] typeList; 58 | } 59 | } 60 | 61 | /** 62 | * @brief Release RowSet resource 63 | */ 64 | void RowSet::close() { 65 | if (mRowSet != NULL) { 66 | gsCloseRowSet(&mRowSet); 67 | mRowSet = NULL; 68 | } 69 | } 70 | 71 | /** 72 | * @brief Update current row from RowSet 73 | * @param *row A Row object representing the content of a Row to be put to database 74 | */ 75 | void RowSet::update(GSRow* row) { 76 | GSResult ret = gsUpdateCurrentRow(mRowSet, mRow); 77 | 78 | if (!GS_SUCCEEDED(ret)) { 79 | throw GSException(mRowSet, ret); 80 | } 81 | } 82 | 83 | /** 84 | * @brief Get next row data. 85 | * @param *hasNextRow Indicate whether there is any row in RowSet or not 86 | */ 87 | void RowSet::next_row(bool* hasNextRow) { 88 | *hasNextRow = this->has_next(); 89 | if (*hasNextRow) { 90 | GSResult ret = gsGetNextRow(mRowSet, mRow); 91 | if (!GS_SUCCEEDED(ret)) { 92 | throw GSException(mRowSet, ret); 93 | } 94 | } 95 | } 96 | 97 | /** 98 | * @brief Get next row or queryAnalysis or aggResult corresponding query command 99 | * @param *type The type of content that can be extracted from GSRowSet. 100 | * @param *hasNextRow Indicate whether there is any row in RowSet or not 101 | * @param **queryAnalysis Represents one of information entries composing a query plan and the results of analyzing a query operation. 102 | * @param **aggResult Stores the result of an aggregation operation. 103 | */ 104 | void RowSet::next(GSRowSetType* type, bool* hasNextRow, 105 | QueryAnalysisEntry** queryAnalysis, AggregationResult** aggResult){ 106 | assert(type != NULL); 107 | assert(hasNextRow != NULL); 108 | assert(queryAnalysis != NULL); 109 | assert(aggResult != NULL); 110 | *type = this->type(); 111 | switch(*type) { 112 | case (GS_ROW_SET_CONTAINER_ROWS): 113 | this->next_row(hasNextRow); 114 | break; 115 | case (GS_ROW_SET_AGGREGATION_RESULT): 116 | *hasNextRow = this->has_next(); 117 | *aggResult = this->get_next_aggregation(); 118 | break; 119 | case (GS_ROW_SET_QUERY_ANALYSIS): 120 | *queryAnalysis = this->get_next_query_analysis(); 121 | *hasNextRow = true; 122 | break; 123 | default: 124 | throw GSException(mRowSet, "type for rowset is not correct"); 125 | } 126 | } 127 | 128 | /** 129 | * @brief Get size of this rowset 130 | * @return Size of this rowset 131 | */ 132 | int32_t RowSet::size() { 133 | return gsGetRowSetSize(mRowSet); 134 | } 135 | 136 | /** 137 | * @brief Delete current row data. 138 | */ 139 | void RowSet::remove() { 140 | GSResult ret = gsDeleteCurrentRow(mRowSet); 141 | if (!GS_SUCCEEDED(ret)) { 142 | throw GSException(mRowSet, ret); 143 | } 144 | } 145 | 146 | /** 147 | * @brief Moves to the next Row in a Row set and returns the aggregation result at the moved position. 148 | * @return A pointer Stores the result of an aggregation operation. 149 | */ 150 | AggregationResult* RowSet::get_next_aggregation() { 151 | GSAggregationResult* pAggResult; 152 | 153 | GSResult ret = gsGetNextAggregation(mRowSet, &pAggResult); 154 | if (!GS_SUCCEEDED(ret)) { 155 | throw GSException(mRowSet, ret); 156 | } 157 | 158 | try { 159 | AggregationResult* aggResult = new AggregationResult(pAggResult); 160 | return aggResult; 161 | } catch (bad_alloc& ba) { 162 | gsCloseAggregationResult(&pAggResult); 163 | throw GSException(mRowSet, "Memory allocation error"); 164 | } 165 | } 166 | 167 | /** 168 | * @brief Get current row type. 169 | * @return The type of content that can be extracted from GSRowSet. 170 | */ 171 | GSRowSetType RowSet::type(){ 172 | return mType; 173 | } 174 | 175 | /** 176 | * @brief Get next query analysis 177 | * @return Represents one of information entries composing a query plan and the results of analyzing a query operation. 178 | */ 179 | QueryAnalysisEntry* RowSet::get_next_query_analysis(){ 180 | GSQueryAnalysisEntry gsQueryAnalysis = GS_QUERY_ANALYSIS_ENTRY_INITIALIZER; 181 | GSResult ret; 182 | ret = gsGetNextQueryAnalysis(mRowSet, &gsQueryAnalysis); 183 | if (!GS_SUCCEEDED(ret)) { 184 | throw GSException(mRowSet, ret); 185 | } 186 | 187 | try { 188 | QueryAnalysisEntry* queryAnalysis = new QueryAnalysisEntry(&gsQueryAnalysis); 189 | return queryAnalysis; 190 | } catch (bad_alloc& ba) { 191 | throw GSException(mRowSet, "Memory allocation error"); 192 | } 193 | } 194 | 195 | /** 196 | * @brief Get column name from RowSet. Use in python only. 197 | * @param ***listName List name of column 198 | * @param *num Number of column 199 | */ 200 | void RowSet::get_column_names(char*** listName, int* num){ 201 | assert(listName != NULL); 202 | assert(num != NULL); 203 | if (!mContainerInfo){ 204 | return; 205 | } 206 | 207 | //Memory will be free from typemap 208 | try { 209 | (*listName) = new char*[mContainerInfo->columnCount](); 210 | *num = mContainerInfo->columnCount; 211 | for (int i = 0; i < mContainerInfo->columnCount; i++){ 212 | if (mContainerInfo->columnInfoList[i].name) { 213 | Util::strdup((const GSChar**)(&((*listName)[i])), mContainerInfo->columnInfoList[i].name); 214 | } else { 215 | (*listName)[i] = NULL; 216 | } 217 | } 218 | } catch (bad_alloc& ba) { 219 | for (int i = 0; i < mContainerInfo->columnCount; i++){ 220 | if ((*listName)[i]) { 221 | delete[] (*listName)[i]; 222 | } 223 | } 224 | if ((*listName)) { 225 | delete[] (*listName); 226 | } 227 | throw GSException(mRowSet, "Memory allocation error"); 228 | } 229 | } 230 | 231 | /** 232 | * @brief Get list type of column in row 233 | * @return A list type of column in row 234 | */ 235 | GSType* RowSet::getGSTypeList(){ 236 | if (typeList == NULL) { 237 | try { 238 | typeList = new GSType[mContainerInfo->columnCount](); 239 | } catch (bad_alloc& ba) { 240 | throw GSException(mRowSet, "Memory allocation error"); 241 | } 242 | 243 | for (int i = 0; i < mContainerInfo->columnCount; i++){ 244 | typeList[i] = mContainerInfo->columnInfoList[i].type; 245 | } 246 | } 247 | return typeList; 248 | } 249 | 250 | /** 251 | * @brief Get number of column in row 252 | * @return Number of column in row 253 | */ 254 | int RowSet::getColumnCount(){ 255 | return mContainerInfo->columnCount; 256 | } 257 | 258 | /** 259 | * @brief Get row data in RowSet object 260 | * @return A pointer stores row data in RowSet object 261 | */ 262 | GSRow* RowSet::getGSRowPtr(){ 263 | return mRow; 264 | } 265 | 266 | } 267 | -------------------------------------------------------------------------------- /src/RowSet.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _ROWSET_H_ 18 | #define _ROWSET_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "gridstore.h" 27 | #include "Field.h" 28 | #include "AggregationResult.h" 29 | #include "QueryAnalysisEntry.h" 30 | #include "GSException.h" 31 | #include "Util.h" 32 | 33 | using namespace std; 34 | 35 | namespace griddb { 36 | 37 | /** 38 | * Convert from GSRowSet 39 | */ 40 | class RowSet { 41 | GSRowSet *mRowSet; 42 | GSContainerInfo *mContainerInfo; 43 | GSRow *mRow; 44 | GSType* typeList; 45 | 46 | friend class Query; 47 | 48 | GSRowSetType mType; 49 | 50 | public: 51 | bool timestamp_output_with_float; 52 | ~RowSet(); 53 | void close(); 54 | int32_t size(); 55 | // Iterator 56 | bool has_next(); 57 | void next(GSRowSetType* type, bool* hasNextRow, 58 | QueryAnalysisEntry** queryAnalysis, AggregationResult** aggResult); 59 | void update(GSRow* row); 60 | void remove(); 61 | GSRowSetType type(); 62 | void get_column_names(char*** listName, int* num); 63 | QueryAnalysisEntry* get_next_query_analysis(); 64 | AggregationResult* get_next_aggregation(); 65 | void next_row(bool* hasNextRow); 66 | GSType* getGSTypeList(); 67 | int getColumnCount(); 68 | 69 | GSRow* getGSRowPtr(); 70 | 71 | private: 72 | RowSet(GSRowSet *rowSet, GSContainerInfo *containerInfo, GSRow *mRow); 73 | }; 74 | 75 | } 76 | 77 | #endif /* _ROWSET_H_ */ 78 | -------------------------------------------------------------------------------- /src/Store.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "Store.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Constructor a new Store::Store object 23 | * @param *store A pointer which provides functions to manipulate the entire data managed in one GridDB system. 24 | */ 25 | Store::Store(GSGridStore *store) : mStore(store), timestamp_output_with_float(false) { 26 | } 27 | 28 | Store::~Store() { 29 | // allRelated = FALSE, since all container object is managed by Container class 30 | close(GS_FALSE); 31 | } 32 | 33 | /** 34 | * @brief Release Store resource 35 | */ 36 | void Store::close(GSBool allRelated) { 37 | // close store 38 | if (mStore != NULL) { 39 | gsCloseGridStore(&mStore, allRelated); 40 | mStore = NULL; 41 | } 42 | } 43 | 44 | /** 45 | * @brief Delete container with specified name 46 | * @param *name Container name 47 | */ 48 | void Store::drop_container(const char* name) { 49 | GSResult ret = gsDropContainer(mStore, name); 50 | if (!GS_SUCCEEDED(ret)) { 51 | throw GSException(mStore, ret); 52 | } 53 | } 54 | 55 | /** 56 | * @brief Get information object of a specific container 57 | * @param *name Container name 58 | * @return Return a pointer which stores all information of container 59 | */ 60 | ContainerInfo* Store::get_container_info(const char* name) { 61 | GSContainerInfo gsContainerInfo = GS_CONTAINER_INFO_INITIALIZER; 62 | GSChar bExists; 63 | GSResult ret = gsGetContainerInfo(mStore, name, &gsContainerInfo, &bExists); 64 | if (!GS_SUCCEEDED(ret)) { 65 | throw GSException(mStore, ret); 66 | } 67 | if (bExists == false) { 68 | return NULL; 69 | } 70 | 71 | try { 72 | ContainerInfo* containerInfo = new ContainerInfo(&gsContainerInfo); 73 | return containerInfo; 74 | } catch (bad_alloc& ba) { 75 | throw GSException(mStore, "Memory allocation error"); 76 | } 77 | } 78 | 79 | /** 80 | * @brief Creates or update a Container with the specified GSContainerInfo. 81 | * @param *info A pointer which stores all information of container 82 | * @param modifiable Indicates whether the column layout of the existing Container can be modified or not 83 | * @return The pointer to a pointer variable to store Container instance 84 | */ 85 | Container* Store::put_container(ContainerInfo* info, 86 | bool modifiable) { 87 | if (info == NULL) { 88 | throw GSException(mStore, "Invalid input for \"Store::put_container\" method. Argument container info can not be null"); 89 | } 90 | // Get Container information 91 | GSContainerInfo* gsInfo = info->gs_info(); 92 | GSContainer* pContainer = NULL; 93 | // Create new gsContainer 94 | GSResult ret = gsPutContainerGeneral(mStore, gsInfo->name, gsInfo, modifiable, &pContainer); 95 | if (!GS_SUCCEEDED(ret)) { 96 | throw GSException(mStore, ret); 97 | } 98 | 99 | try { 100 | Container* container = new Container(pContainer, gsInfo); 101 | return container; 102 | } catch (bad_alloc& ba) { 103 | gsCloseContainer(&pContainer, GS_FALSE); 104 | throw GSException(mStore, "Memory allocation error"); 105 | } 106 | } 107 | 108 | /** 109 | * @brief Get container object with corresponding name 110 | * @param *name Container name 111 | * @return The pointer to a pointer variable to store Container instance 112 | */ 113 | Container* Store::get_container(const char* name) { 114 | GSContainer* pContainer; 115 | GSResult ret = gsGetContainerGeneral(mStore, name, &pContainer); 116 | if (!GS_SUCCEEDED(ret)) { 117 | throw GSException(mStore, ret); 118 | } 119 | if (pContainer == NULL) { 120 | //If not found container, return NULL in target language 121 | return NULL; 122 | } 123 | GSContainerInfo containerInfo = GS_CONTAINER_INFO_INITIALIZER; 124 | GSChar bExists; 125 | ret = gsGetContainerInfo(mStore, name, &containerInfo, &bExists); 126 | if (!GS_SUCCEEDED(ret)) { 127 | gsCloseContainer(&pContainer, GS_FALSE); 128 | throw GSException(mStore, ret); 129 | } 130 | try { 131 | Container* container = new Container(pContainer, &containerInfo); 132 | return container; 133 | } catch (bad_alloc& ba) { 134 | gsCloseContainer(&pContainer, GS_FALSE); 135 | throw GSException(mStore, "Memory allocation error"); 136 | } 137 | } 138 | 139 | /** 140 | * @brief Query execution and fetch is carried out on a specified arbitrary number of Query, with the request unit enlarged as much as possible. 141 | * @param **queryList A list of query 142 | * @param queryCount Number of element in query list 143 | */ 144 | void Store::fetch_all(GSQuery* const* queryList, size_t queryCount) { 145 | GSResult ret = gsFetchAll(mStore, queryList, queryCount); 146 | if (!GS_SUCCEEDED(ret)) { 147 | throw GSException(mStore, ret); 148 | } 149 | } 150 | 151 | /** 152 | * @brief Get Partition controller. 153 | * @return The pointer to a pointer variable to store PartitionController instance 154 | */ 155 | PartitionController* Store::partition_info() { 156 | GSPartitionController* partitionController; 157 | 158 | GSResult ret = gsGetPartitionController(mStore, &partitionController); 159 | 160 | if (!GS_SUCCEEDED(ret)) { 161 | throw GSException(mStore, ret); 162 | } 163 | 164 | try { 165 | PartitionController* partition = new PartitionController(partitionController); 166 | return partition; 167 | } catch (bad_alloc& ba) { 168 | gsClosePartitionController(&partitionController); 169 | throw GSException(mStore, "Memory allocation error"); 170 | } 171 | } 172 | 173 | /** 174 | * @brief Create row key predicate. 175 | * @param type The type of Row key used as a matching condition 176 | * @return The pointer to a pointer variable to store RowKeyPredicate instance 177 | */ 178 | RowKeyPredicate* Store::create_row_key_predicate(GSType type) { 179 | GSRowKeyPredicate* predicate; 180 | 181 | GSResult ret = gsCreateRowKeyPredicate(mStore, type, &predicate); 182 | 183 | if (!GS_SUCCEEDED(ret)) { 184 | throw GSException(mStore, ret); 185 | } 186 | 187 | try { 188 | RowKeyPredicate* rowKeyPredicate = new RowKeyPredicate(predicate, type); 189 | return rowKeyPredicate; 190 | } catch (bad_alloc& ba) { 191 | gsCloseRowKeyPredicate(&predicate); 192 | throw GSException(mStore, "Memory allocation error"); 193 | } 194 | } 195 | 196 | /** 197 | * @brief New creation or update operation is carried out on an arbitrary number of rows of multiple Containers, with the request unit enlarged as much as possible. 198 | * @param ***listRow A pointer refers list of row data 199 | * @param *listRowContainerCount A array store number of list row for each container 200 | * @param **listContainerName list container name 201 | * @param containerCount Number of container 202 | */ 203 | void Store::multi_put(GSRow*** listRow, const int *listRowContainerCount, 204 | const char ** listContainerName, size_t containerCount) { 205 | assert(listRowContainerCount != NULL); 206 | assert(listContainerName != NULL); 207 | GSResult ret; 208 | GSContainerRowEntry* entryList; 209 | 210 | try { 211 | entryList = new GSContainerRowEntry[containerCount](); 212 | } catch (bad_alloc& ba) { 213 | throw GSException(mStore, "Memory allocation error"); 214 | } 215 | for (int i= 0; i < containerCount; i++) { 216 | entryList[i].containerName = listContainerName[i]; 217 | entryList[i].rowCount = listRowContainerCount[i]; 218 | entryList[i].rowList = (void* const*) listRow[i]; 219 | } 220 | ret = gsPutMultipleContainerRows(mStore, entryList, containerCount); 221 | delete[] entryList; 222 | if (!GS_SUCCEEDED(ret)) { 223 | throw GSException(mStore, ret); 224 | } 225 | } 226 | 227 | /** 228 | * @brief get multi row from multi container 229 | * @param **predicateList A pointer refers list of the specified condition entry by a container for representing the acquisition conditions for a plurality of containers. 230 | * @param predicateCount Number of predicate list 231 | * @param **entryList A pointer refers to a list of the Row contents entry by a container used when operating collectively a plurality of Rows of a plurality of containers. 232 | * @param *containerCount Number of container 233 | * @param **colNumList A pointer refers to an array stores number of column of each container 234 | * @param ***typeList A pointer refers to an array stores type of column of each container 235 | * @param **orderFromInput A pointer refers to an array stores order of each container for output 236 | */ 237 | void Store::multi_get(const GSRowKeyPredicateEntry* const * predicateList, 238 | size_t predicateCount, GSContainerRowEntry **entryList, size_t* containerCount, 239 | int **colNumList, GSType*** typeList, int **orderFromInput) { 240 | assert(predicateList != NULL); 241 | assert(predicateCount >= 0); 242 | assert(colNumList != NULL); 243 | assert(typeList != NULL); 244 | assert(orderFromInput != NULL); 245 | assert(containerCount != NULL); 246 | *colNumList = NULL; 247 | *typeList = NULL; 248 | *orderFromInput = NULL; 249 | *containerCount = 0; 250 | int length = (int) predicateCount; 251 | 252 | try { 253 | // get number of column of rows in each container. 254 | *colNumList = new int[predicateCount](); //will be free in argout 255 | *typeList = new GSType*[predicateCount](); //will be free in argout 256 | *orderFromInput = new int[length](); //will be free in argout 257 | } catch (bad_alloc& ba) { 258 | this->freeMemoryMultiGet(colNumList, typeList, length, orderFromInput); 259 | throw GSException(mStore, "Memory allocation error"); 260 | } 261 | 262 | bool setNumList = this->setMultiContainerNumList(predicateList, 263 | length, &colNumList, &typeList); 264 | if (!setNumList) { 265 | this->freeMemoryMultiGet(colNumList, typeList, length, orderFromInput); 266 | throw GSException(mStore, "Set multi containers number list and type list error"); 267 | } 268 | 269 | // Get data for entryList 270 | GSResult ret = gsGetMultipleContainerRows(mStore, predicateList, 271 | predicateCount, (const GSContainerRowEntry**) entryList, containerCount); 272 | if (!GS_SUCCEEDED(ret)) { 273 | this->freeMemoryMultiGet(colNumList, typeList, length, orderFromInput); 274 | throw GSException(mStore, ret); 275 | } 276 | 277 | // set data for orderFromInput 278 | for (int i = 0; i < length; i++) { 279 | for (int j = 0; j < length; j++) { 280 | if (strcmp((*predicateList)[i].containerName, (*entryList)[j].containerName) == 0){ 281 | (*orderFromInput)[i] = j; 282 | } 283 | } 284 | } 285 | } 286 | 287 | /** 288 | * Support free memory in multi_get function when exception happen 289 | */ 290 | void Store::freeMemoryMultiGet(int **colNumList, GSType*** typeList, 291 | int length, int **orderFromInput) { 292 | if (*colNumList) { 293 | delete [] *colNumList; 294 | *colNumList = NULL; 295 | } 296 | 297 | if (*typeList) { 298 | for (int i = 0; i < length; i++) { 299 | if ((*typeList)[i]) { 300 | delete[] (*typeList)[i]; 301 | } 302 | } 303 | delete [] *typeList; 304 | *typeList = NULL; 305 | } 306 | if (*orderFromInput) { 307 | delete [] *orderFromInput; 308 | *orderFromInput = NULL; 309 | } 310 | } 311 | 312 | /** 313 | * Support multi_get function to put data into colNumList and typeList 314 | */ 315 | bool Store::setMultiContainerNumList(const GSRowKeyPredicateEntry* const * predicateList, 316 | int length, int ***colNumList, GSType**** typeList) { 317 | for (int i = 0; i < length; i++) { 318 | Container *tmpContainer; 319 | try { 320 | tmpContainer = this->get_container((*predicateList)[i].containerName); 321 | } catch (GSException e) { 322 | return false; 323 | } 324 | if (tmpContainer == NULL) { 325 | return false; 326 | } 327 | (**colNumList)[i] = tmpContainer->getColumnCount(); 328 | 329 | try { 330 | //(**typeList)[i] will be freed in freeMemoryMultiGet() function or argout 331 | (**typeList)[i] = new GSType[(**colNumList)[i]](); 332 | } catch (bad_alloc& ba) { 333 | delete tmpContainer; 334 | return false; 335 | } 336 | 337 | for (int j = 0; j < (**colNumList)[i]; j++) { 338 | (**typeList)[i][j] = tmpContainer->getGSTypeList()[j]; 339 | } 340 | delete tmpContainer; 341 | } 342 | return true; 343 | } 344 | 345 | } 346 | -------------------------------------------------------------------------------- /src/Store.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _STORE_H_ 18 | #define _STORE_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "ContainerInfo.h" 25 | #include "Container.h" 26 | #include "PartitionController.h" 27 | #include "RowKeyPredicate.h" 28 | #include "GSException.h" 29 | 30 | using namespace std; 31 | 32 | namespace griddb { 33 | 34 | class Store { 35 | GSGridStore *mStore; 36 | 37 | friend class StoreFactory; 38 | 39 | public: 40 | bool timestamp_output_with_float; 41 | ~Store(); 42 | void close(GSBool allRelated = GS_FALSE); 43 | 44 | Container* put_container(ContainerInfo* info, bool modifiable = false); 45 | Container* get_container(const char* name); 46 | void drop_container(const char *name); 47 | 48 | void fetch_all(GSQuery* const * queryList, size_t queryCount); 49 | void multi_put(GSRow*** listRow, const int *listRowContainerCount, 50 | const char ** listContainerName, size_t containerCount); 51 | void multi_get(const GSRowKeyPredicateEntry* const * predicateList, 52 | size_t predicateCount, GSContainerRowEntry **entryList, size_t* containerCount, 53 | int **colNumList, GSType*** typeList, int **orderFromInput); 54 | 55 | ContainerInfo* get_container_info(const char *name); 56 | PartitionController* partition_info(); 57 | RowKeyPredicate* create_row_key_predicate(GSType type); 58 | 59 | private: 60 | Store(GSGridStore* store); 61 | void freeMemoryMultiGet(int** colNumList, GSType*** typeList, int length, int** orderFromInput); 62 | bool setMultiContainerNumList(const GSRowKeyPredicateEntry* const * predicateList, 63 | int length, int*** colNumList, GSType**** typeList); 64 | }; 65 | 66 | } 67 | 68 | #endif /* Define _STORE_H */ 69 | -------------------------------------------------------------------------------- /src/StoreFactory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "StoreFactory.h" 18 | 19 | #define MAX_PROPS 10 20 | 21 | namespace griddb { 22 | 23 | StoreFactory::StoreFactory() : mFactory(NULL) { 24 | } 25 | 26 | StoreFactory::~StoreFactory() { 27 | //allRelated = FALSE, since Gridstore object is managed by Store class 28 | close(GS_FALSE); 29 | } 30 | 31 | /** 32 | * @brief Release StoreFactory resource 33 | */ 34 | void StoreFactory::close(GSBool allRelated) { 35 | if (mFactory != NULL) { 36 | gsCloseFactory(&mFactory, allRelated); 37 | mFactory = NULL; 38 | } 39 | } 40 | 41 | /** 42 | * @brief Get a default GSGridStoreFactory instance. 43 | * @return The pointer to a pointer variable to store StoreFactory instance 44 | */ 45 | StoreFactory* StoreFactory::get_instance() { 46 | GSGridStoreFactory* pFactory = gsGetDefaultFactory(); 47 | 48 | try { 49 | StoreFactory* factory(new StoreFactory()); 50 | factory->set_factory(pFactory); 51 | 52 | return factory; 53 | } catch (bad_alloc& ba) { 54 | gsCloseFactory(&pFactory, GS_FALSE); 55 | throw GSException("Memory allocation error"); 56 | } 57 | } 58 | 59 | /* 60 | * set GSPropertyEntry 61 | */ 62 | void StoreFactory::set_property_entry(GSPropertyEntry *prop, const char* name, const char* value) { 63 | prop->name = name; 64 | prop->value = value; 65 | } 66 | 67 | /* 68 | * Check whether in MULTICAST mode 69 | */ 70 | bool StoreFactory::check_multicast(const char* address) { 71 | if (address && address[0] != '\0') { 72 | char* tmp; 73 | try { 74 | Util::strdup((const GSChar**)&tmp, address); 75 | } catch (bad_alloc& ba) { 76 | throw GSException("Memory allocation error"); 77 | } 78 | 79 | char *octets = strtok((char*)tmp, "."); 80 | if (octets) { 81 | int firstOctet = atoi(octets); 82 | int first4Bits = firstOctet >> 4 & 0x0f; 83 | if (first4Bits == 0x0E) { 84 | delete[] tmp; 85 | return true; 86 | } 87 | } 88 | delete[] tmp; 89 | } 90 | return false; 91 | } 92 | 93 | /** 94 | * @brief Get a Store with the specified properties 95 | * @param *host A destination host name 96 | * @param port A destination port number 97 | * @param *cluster_name A cluster name 98 | * @param *database A database name to be connected 99 | * @param *user A user name 100 | * @param *password A password for user authentication 101 | * @param *notification_member A list of address and port pairs in cluster 102 | * @param *notification_provider A URL of address provider 103 | * @return The pointer to a pointer variable to store Store instance 104 | */ 105 | Store* StoreFactory::get_store(const char* host, int32_t port, const char* cluster_name, 106 | const char* database, const char* user, const char* password, 107 | const char* notification_member, const char* notification_provider) { 108 | size_t index = 0; 109 | GSPropertyEntry local_props[MAX_PROPS] = {0}; 110 | std::string lport = std::to_string((long long int)port); 111 | 112 | if (check_multicast(host)) { 113 | set_property_entry(&local_props[0], "notificationAddress", host); 114 | set_property_entry(&local_props[1], "notificationPort", lport.c_str()); 115 | index += 2; 116 | } else if (host && host[0] != '\0') { 117 | set_property_entry(&local_props[0], "host", host); 118 | set_property_entry(&local_props[1], "port", lport.c_str()); 119 | index += 2; 120 | } 121 | 122 | if (notification_member && notification_member[0] != '\0') { 123 | set_property_entry(&local_props[index], "notificationMember", notification_member); 124 | index++; 125 | } 126 | if (notification_provider && notification_provider[0] != '\0') { 127 | set_property_entry(&local_props[index], "notificationProvider", notification_provider); 128 | index++; 129 | } 130 | if (cluster_name && cluster_name[0] != '\0') { 131 | set_property_entry(&local_props[index], "clusterName", cluster_name); 132 | index++; 133 | } 134 | if (database && database[0] != '\0') { 135 | set_property_entry(&local_props[index], "database", database); 136 | index++; 137 | } 138 | if (user && user[0] != '\0') { 139 | set_property_entry(&local_props[index], "user", user); 140 | index++; 141 | 142 | } 143 | if (password && password[0] != '\0') { 144 | set_property_entry(&local_props[index], "password", password); 145 | index++; 146 | } 147 | 148 | GSGridStore *gsStore; 149 | GSResult ret = gsGetGridStore(mFactory, local_props, index, &gsStore); 150 | 151 | // Check ret, if error, throw exception 152 | if (!GS_SUCCEEDED(ret)) { 153 | throw GSException(mFactory, ret); 154 | } 155 | 156 | try { 157 | //return new Store(store); 158 | Store* store = new Store(gsStore); 159 | return store; 160 | } catch (bad_alloc& ba) { 161 | gsCloseGridStore(&gsStore, GS_FALSE); 162 | throw GSException(mFactory, "Memory allocation error"); 163 | } 164 | } 165 | 166 | /** 167 | * @brief Get current client version 168 | * @return Client version name 169 | */ 170 | string StoreFactory::get_version() { 171 | return CLIENT_VERSION; 172 | } 173 | 174 | /* 175 | * Set attribute: mFactory 176 | */ 177 | void StoreFactory::set_factory(GSGridStoreFactory* factory) { 178 | mFactory = factory; 179 | } 180 | 181 | } 182 | -------------------------------------------------------------------------------- /src/StoreFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _STORE_FACTORY_H_ 18 | #define _STORE_FACTORY_H_ 19 | #define CLIENT_VERSION "GridDB Node.JS Client 0.8" 20 | 21 | #include 22 | #include 23 | 24 | #include "gridstore.h" 25 | #include "Store.h" 26 | #include "GSException.h" 27 | #include "Util.h" 28 | 29 | using namespace std; 30 | 31 | namespace griddb { 32 | 33 | /** 34 | * Class GridStoreFactory to contain GSGridStoreFactory object. 35 | * This class is implemented as singleton. 36 | */ 37 | class StoreFactory { 38 | private: 39 | GSGridStoreFactory* mFactory; 40 | 41 | public: 42 | ~StoreFactory(); 43 | void close(GSBool allRelated = GS_FALSE); 44 | static StoreFactory* get_instance(); 45 | Store* get_store(const char* host=NULL, int32_t port=0, const char* cluster_name=NULL, 46 | const char* database=NULL, const char* username=NULL, const char* password=NULL, 47 | const char* notification_member=NULL, const char* notification_provider=NULL); 48 | string get_version(); 49 | 50 | private: 51 | StoreFactory(); 52 | void set_property_entry(GSPropertyEntry *prop, const char* name, const char* value); 53 | bool check_multicast(const char* address); 54 | void set_factory(GSGridStoreFactory* factory); 55 | }; 56 | 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/TimeSeriesProperties.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "TimeSeriesProperties.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Constructor a new TimeSeriesProperties::TimeSeriesProperties object 23 | * @param *timeSeriesProps Represents the information about optional configuration settings used for newly creating or updating a TimeSeries 24 | */ 25 | TimeSeriesProperties::TimeSeriesProperties(const GSTimeSeriesProperties* timeSeriesProps) : mTsProps(*timeSeriesProps) { 26 | } 27 | 28 | /** 29 | * @brief Constructor a new TimeSeriesProperties::TimeSeriesProperties object 30 | * @param elapsedTime The elapsed time period of a Row to be used as the basis of the validity period 31 | * @param timeUnit The unit of elapsed time referenced for the expiration date of a Row 32 | * @param ExpirationDivisionCount The division number for the validity period as the number of expired Row data units to be released 33 | */ 34 | TimeSeriesProperties::TimeSeriesProperties(int32_t elapsedTime, GSTimeUnit timeUnit, 35 | int32_t ExpirationDivisionCount) : mTsProps{elapsedTime, timeUnit, -1, 36 | timeUnit, GS_COMPRESSION_NO, 0, NULL, ExpirationDivisionCount} { 37 | } 38 | 39 | TimeSeriesProperties::~TimeSeriesProperties() { 40 | } 41 | 42 | /** 43 | * @brief Set rowExpiration for TimeSeriesProperties. 44 | * @param elapsedTime The elapsed time period of a Row to be used as the basis of the validity period 45 | * @param timeUnit The unit of elapsed time referenced for the expiration date of a Row 46 | */ 47 | void TimeSeriesProperties::set_row_expiration_time(int elapsedTime, GSTimeUnit timeUnit) { 48 | mTsProps.rowExpirationTime = elapsedTime; 49 | mTsProps.rowExpirationTimeUnit = timeUnit; 50 | } 51 | 52 | /** 53 | * @brief Set expirationDivisionCount for TimeSeriesProperties 54 | * @param count The division number for the validity period as the number of expired Row data units to be released 55 | */ 56 | void TimeSeriesProperties::set_expiration_division_count(int count) { 57 | mTsProps.expirationDivisionCount = count; 58 | } 59 | 60 | /** 61 | * @brief Get rowExpirationTime from TimeSeriesProperties 62 | * @return The elapsed time period of a Row to be used as the basis of the validity period 63 | */ 64 | int TimeSeriesProperties::get_row_expiration_time() { 65 | return mTsProps.rowExpirationTime; 66 | } 67 | 68 | /** 69 | * @brief Get rowExpirationTimeUnit from TimeSeriesProperties 70 | * @return timeUnit The unit of elapsed time referenced for the expiration date of a Row 71 | */ 72 | GSTimeUnit TimeSeriesProperties::get_row_expiration_time_unit() { 73 | return mTsProps.rowExpirationTimeUnit; 74 | } 75 | 76 | /** 77 | * @brief Get expirationDivisionCount from TimeSeriesProperties 78 | * @return The division number for the validity period as the number of expired Row data units to be released 79 | */ 80 | int TimeSeriesProperties::get_expiration_division_count() { 81 | return mTsProps.expirationDivisionCount; 82 | } 83 | 84 | /** 85 | * @brief Get attribute: mTsProps 86 | * @return A pointer store GSTimeSeriesProperties of TimeSeriesProperties 87 | */ 88 | GSTimeSeriesProperties* TimeSeriesProperties::gs_ptr() { 89 | return &mTsProps; 90 | } 91 | 92 | } /* namespace griddb */ 93 | -------------------------------------------------------------------------------- /src/TimeSeriesProperties.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _TIMESERIESPROPERTIES_H_ 18 | #define _TIMESERIESPROPERTIES_H_ 19 | 20 | #include "gridstore.h" 21 | 22 | namespace griddb { 23 | 24 | class TimeSeriesProperties { 25 | private: 26 | GSTimeSeriesProperties mTsProps; 27 | 28 | public: 29 | TimeSeriesProperties(const GSTimeSeriesProperties* timeSeriesProps); 30 | TimeSeriesProperties(int32_t elapsedTime, GSTimeUnit timeUnit, int32_t ExpirationDivisionCount); 31 | ~TimeSeriesProperties(); 32 | // APIs to set values for expiration_time and expiration_division_count 33 | void set_row_expiration_time(int32_t elapsedTime, GSTimeUnit timeUnit); 34 | void set_expiration_division_count(int32_t count); 35 | // APIs to get values of expiration_time, expiration_time_unit, expiration_division_count and TimeSeriesProperties 36 | int get_row_expiration_time(); 37 | GSTimeUnit get_row_expiration_time_unit(); 38 | int get_expiration_division_count(); 39 | GSTimeSeriesProperties* gs_ptr(); 40 | }; 41 | 42 | } /* namespace griddb */ 43 | 44 | #endif /* Define _TIMESERIESPROPERTIES_H_ */ 45 | -------------------------------------------------------------------------------- /src/Util.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "Util.h" 18 | 19 | namespace griddb { 20 | 21 | /** 22 | * @brief Allocate new memory and setup string data from source string data for the new memory 23 | * @param **to A pointer variable that refers to new string data 24 | * @param *from A pointer stores source string data 25 | */ 26 | void Util::strdup(const GSChar** const to, const GSChar* from) { 27 | GSChar* temp = new char[strlen(from) + 1](); 28 | strcpy(temp, from); 29 | *to = temp; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _UTIL_H_ 18 | #define _UTIL_H_ 19 | 20 | #include 21 | #include "GSException.h" 22 | 23 | using namespace std; 24 | 25 | namespace griddb { 26 | 27 | class Util { 28 | public: 29 | static void strdup(const GSChar** const to, const GSChar* from); 30 | }; 31 | 32 | } 33 | 34 | #endif -------------------------------------------------------------------------------- /src/griddb.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | %ignore griddb::Container::getGSContainerPtr; 18 | %ignore griddb::Container::getGSTypeList; 19 | %ignore griddb::Container::getColumnCount; 20 | %ignore griddb::Container::getGSRowPtr; 21 | %ignore griddb::ContainerInfo::gs_info; 22 | %ignore griddb::Field; 23 | %ignore griddb::Query::gs_ptr; 24 | %ignore griddb::RowKeyPredicate::gs_ptr; 25 | %ignore griddb::RowSet::getGSTypeList; 26 | %ignore griddb::RowSet::getColumnCount; 27 | %ignore griddb::RowSet::getGSRowPtr; 28 | %ignore griddb::AggregationResult::AggregationResult; 29 | %ignore griddb::QueryAnalysisEntry::QueryAnalysisEntry; 30 | %ignore griddb::TimeSeriesProperties; 31 | %ignore griddb::GSException::GSException; 32 | 33 | %include "gstype.i" 34 | 35 | %include 36 | 37 | //Mark these methods below return new object, need to be free by target language 38 | %feature("new") griddb::Container::query; 39 | //%feature("new") griddb::ContainerInfo::get_time_series_properties; 40 | %feature("new") griddb::Query::fetch; 41 | %feature("new") griddb::Query::get_row_set; 42 | %feature("new") griddb::RowSet::get_next_query_analysis; 43 | %feature("new") griddb::RowSet::get_next_aggregation; 44 | %feature("new") griddb::Store::put_container; 45 | %feature("new") griddb::Store::get_container; 46 | %feature("new") griddb::Store::get_container_info; 47 | %feature("new") griddb::Store::create_row_key_predicate; 48 | %feature("new") griddb::Store::partition_info; 49 | %feature("new") griddb::StoreFactory::get_store; 50 | %feature("new") griddb::StoreFactory::get_instance; 51 | #if defined(SWIGJAVASCRIPT) 52 | //Mark attribute is new object 53 | %feature("new") griddb::Store::partitionInfo; 54 | #endif 55 | 56 | #if defined(SWIGPYTHON) 57 | %include "gstype_python.i" 58 | %module griddb_python 59 | #elif defined(SWIGRUBY) 60 | %include "gstype_ruby.i" 61 | %module griddb_ruby_client 62 | #elif defined(SWIGJAVASCRIPT) 63 | %include "gstype_js_v8.i" 64 | %module griddb_client 65 | #elif defined(SWIGPHP) 66 | %include "gstype_php.i" 67 | %module griddb_php_client 68 | #elif defined(SWIGGO) 69 | %include "gstype_go.i" 70 | %module griddb_go 71 | #endif 72 | 73 | %{ 74 | #include "gridstore.h" 75 | #include "GSException.h" 76 | #include "TimeSeriesProperties.h" 77 | #include "ExpirationInfo.h" 78 | #include "ContainerInfo.h" 79 | #include "Field.h" 80 | #include "QueryAnalysisEntry.h" 81 | #include "RowSet.h" 82 | #include "Query.h" 83 | #include "Container.h" 84 | #include "PartitionController.h" 85 | #include "RowKeyPredicate.h" 86 | #include "Store.h" 87 | #include "StoreFactory.h" 88 | %} 89 | #if !defined(SWIGJAVASCRIPT) 90 | %{ 91 | #include "TimestampUtils.h" 92 | %} 93 | #endif 94 | #if defined(SWIGJAVASCRIPT) || defined(SWIGPHP) 95 | %{ 96 | #include "EnumValue.h" 97 | %} 98 | #endif 99 | 100 | #if defined(SWIGPYTHON) 101 | %shared_ptr(griddb::Resource) 102 | %shared_ptr(griddb::AggregationResult) 103 | %shared_ptr(griddb::TimeSeriesProperties) 104 | %shared_ptr(griddb::ExpirationInfo) 105 | %shared_ptr(griddb::ContainerInfo) 106 | %shared_ptr(griddb::QueryAnalysisEntry) 107 | %shared_ptr(griddb::RowSet) 108 | %shared_ptr(griddb::Query) 109 | %shared_ptr(griddb::Container) 110 | %shared_ptr(griddb::StoreFactory) 111 | %shared_ptr(griddb::RowKeyPredicate) 112 | %shared_ptr(griddb::Store) 113 | %shared_ptr(griddb::PartitionController) 114 | #endif 115 | 116 | %include "GSException.h" 117 | %include "AggregationResult.h" 118 | %include "TimeSeriesProperties.h" 119 | %include "ExpirationInfo.h" 120 | %include "ContainerInfo.h" 121 | %include "Field.h" 122 | %include "QueryAnalysisEntry.h" 123 | %include "RowSet.h" 124 | %include "Query.h" 125 | %include "Container.h" 126 | %include "PartitionController.h" 127 | %include "RowKeyPredicate.h" 128 | %include "Store.h" 129 | %include "StoreFactory.h" 130 | #if !defined(SWIGJAVASCRIPT) 131 | %include "TimestampUtils.h" 132 | #endif 133 | #if defined(SWIGJAVASCRIPT) || defined(SWIGPHP) 134 | %include "EnumValue.h" 135 | #endif 136 | -------------------------------------------------------------------------------- /src/gstype.i: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 TOSHIBA Digital Solutions Corporation. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #if defined(SWIGPYTHON) 18 | %include "gstype_python.i" 19 | %module griddb_python 20 | %begin %{ 21 | #define SWIG_PYTHON_2_UNICODE 22 | %} 23 | #elif defined(SWIGRUBY) 24 | %include "gstype_ruby.i" 25 | %module griddb_ruby_client 26 | #elif defined(SWIGPHP) 27 | %module griddb_php_client 28 | #elif defined(SWIGJAVASCRIPT) 29 | %module griddb_client 30 | #endif 31 | 32 | %include 33 | %include 34 | %include 35 | %include 36 | #if defined(SWIGPYTHON) 37 | %include 38 | #endif 39 | 40 | %include 41 | %catches(griddb::GSException); 42 | 43 | #if !defined(SWIGGO) 44 | enum GSContainerTypeTag { 45 | GS_CONTAINER_COLLECTION, 46 | GS_CONTAINER_TIME_SERIES, 47 | }; 48 | #endif 49 | 50 | enum GSRowSetTypeTag { 51 | GS_ROW_SET_CONTAINER_ROWS, 52 | GS_ROW_SET_AGGREGATION_RESULT, 53 | GS_ROW_SET_QUERY_ANALYSIS 54 | }; 55 | 56 | #if !defined(SWIGGO) 57 | // Enum GSTypeTag 58 | enum GSTypeTag { 59 | GS_TYPE_STRING, 60 | GS_TYPE_BOOL, 61 | GS_TYPE_BYTE, 62 | GS_TYPE_SHORT, 63 | GS_TYPE_INTEGER, 64 | GS_TYPE_LONG, 65 | GS_TYPE_FLOAT, 66 | GS_TYPE_DOUBLE, 67 | GS_TYPE_TIMESTAMP, 68 | GS_TYPE_GEOMETRY, 69 | GS_TYPE_BLOB, 70 | GS_TYPE_STRING_ARRAY, 71 | GS_TYPE_BOOL_ARRAY, 72 | GS_TYPE_BYTE_ARRAY, 73 | GS_TYPE_SHORT_ARRAY, 74 | GS_TYPE_INTEGER_ARRAY, 75 | GS_TYPE_LONG_ARRAY, 76 | GS_TYPE_FLOAT_ARRAY, 77 | GS_TYPE_DOUBLE_ARRAY, 78 | GS_TYPE_TIMESTAMP_ARRAY, 79 | GS_TYPE_NULL = -1 80 | }; 81 | #endif 82 | 83 | #if !defined(SWIGGO) 84 | // Enum GSIndexTypeFlagTag 85 | enum GSIndexTypeFlagTag { 86 | GS_INDEX_FLAG_DEFAULT, 87 | GS_INDEX_FLAG_TREE, 88 | GS_INDEX_FLAG_HASH, 89 | GS_INDEX_FLAG_SPATIAL 90 | }; 91 | #endif 92 | 93 | enum GSFetchOptionTag { 94 | 95 | GS_FETCH_LIMIT, 96 | 97 | #if GS_INTERNAL_DEFINITION_VISIBLE 98 | #if !GS_COMPATIBILITY_DEPRECATE_FETCH_OPTION_SIZE 99 | 100 | GS_FETCH_SIZE = (GS_FETCH_LIMIT + 1) 101 | #endif 102 | #endif 103 | }; 104 | 105 | #if !defined(SWIGGO) 106 | enum GSTimeUnitTag { 107 | 108 | GS_TIME_UNIT_YEAR, 109 | 110 | GS_TIME_UNIT_MONTH, 111 | 112 | GS_TIME_UNIT_DAY, 113 | 114 | GS_TIME_UNIT_HOUR, 115 | 116 | GS_TIME_UNIT_MINUTE, 117 | 118 | GS_TIME_UNIT_SECOND, 119 | 120 | GS_TIME_UNIT_MILLISECOND 121 | }; 122 | #endif 123 | 124 | enum GSTypeOptionTag { 125 | 126 | GS_TYPE_OPTION_KEY = 1 << 0, 127 | 128 | GS_TYPE_OPTION_NULLABLE = 1 << 1, 129 | 130 | GS_TYPE_OPTION_NOT_NULL = 1 << 2 131 | }; 132 | 133 | typedef int32_t GSTypeOption; 134 | 135 | typedef int32_t GSIndexTypeFlags; 136 | 137 | typedef int64_t GSTimestamp; 138 | 139 | typedef int32_t GSEnum; 140 | 141 | typedef GSEnum GSRowSetType; 142 | 143 | typedef GSEnum GSContainerType; 144 | 145 | typedef GSEnum GSType; 146 | 147 | typedef int32_t GSResult; 148 | 149 | typedef char GSChar; 150 | 151 | typedef char GSBool; 152 | 153 | typedef GSEnum GSTimeUnit; 154 | 155 | typedef struct GSQueryAnalysisEntryTag GSQueryAnalysisEntry; 156 | --------------------------------------------------------------------------------