Skip to content

Commit ce4ec25

Browse files
committed
reflect source codes of Node.JS client(0.8.0)
1 parent dd94deb commit ce4ec25

18 files changed

Lines changed: 194 additions & 162 deletions

src/AggregationResult.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class AggregationResult {
3939
void get(GSType type, griddb::Field *agValue);
4040
AggregationResult(GSAggregationResult* aggResult);
4141

42-
private:
43-
4442
};
4543

4644
} /* namespace griddb */

src/Container.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
*/
1616

1717
#include "Container.h"
18-
#include "GSException.h"
1918

2019
namespace griddb {
2120

2221
Container::Container(GSContainer *container, GSContainerInfo* containerInfo) : mContainer(container),
2322
mContainerInfo(NULL), mRow(NULL), mTypeList(NULL), timestamp_output_with_float(false) {
24-
GSResult ret;
25-
if ((ret = gsCreateRowByContainer(mContainer, &mRow)) != GS_RESULT_OK) {
23+
GSResult ret = gsCreateRowByContainer(mContainer, &mRow);
24+
if (ret != GS_RESULT_OK) {
2625
throw GSException(ret, "can not create row from Container");
2726
}
2827

@@ -234,8 +233,7 @@ namespace griddb {
234233
key = &keyFields->value.asString;
235234
break;
236235
case GS_TYPE_INTEGER:
237-
if (!(mContainerInfo->columnInfoList[0].type == GS_TYPE_INTEGER ||
238-
mContainerInfo->columnInfoList[0].type == GS_TYPE_LONG)) {
236+
if (mContainerInfo->columnInfoList[0].type != GS_TYPE_INTEGER) {
239237
throw GSException("wrong type of rowKey");
240238
}
241239
key = &keyFields->value.asInteger;
@@ -283,8 +281,7 @@ namespace griddb {
283281
ret = gsDeleteRow(mContainer, &keyFields->value.asString, &exists);
284282
break;
285283
case GS_TYPE_INTEGER:
286-
if (!(mContainerInfo->columnInfoList[0].type == GS_TYPE_INTEGER ||
287-
mContainerInfo->columnInfoList[0].type == GS_TYPE_LONG)) {
284+
if (mContainerInfo->columnInfoList[0].type != GS_TYPE_INTEGER) {
288285
throw GSException("wrong type of rowKey");
289286
}
290287
ret = gsDeleteRow(mContainer, &keyFields->value.asInteger, &exists);

src/Container.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "Field.h"
2121
#include "Query.h"
22+
#include "GSException.h"
2223

2324
using namespace std;
2425

@@ -37,7 +38,7 @@ class Container {
3738
public:
3839
bool timestamp_output_with_float;
3940
~Container();
40-
void close(GSBool allRelated);
41+
void close(GSBool allRelated = GS_FALSE);
4142
GSContainerType get_type();
4243
void create_index(const char* column_name, GSIndexTypeFlags index_type = GS_INDEX_FLAG_DEFAULT, const char* name=NULL);
4344
void drop_index(const char* column_name, GSIndexTypeFlags index_type = GS_INDEX_FLAG_DEFAULT, const char* name=NULL);

src/ContainerInfo.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ namespace griddb {
132132
delete mExpInfo;
133133
}
134134
}
135-
135+
/*
136+
* Set attribute: mContainerInfo.name
137+
*/
136138
void ContainerInfo::set_name(GSChar* containerName) {
137139
if (mContainerInfo.name) {
138140
free((void*) mContainerInfo.name);
@@ -143,27 +145,39 @@ namespace griddb {
143145
mContainerInfo.name = strdup(containerName);
144146
}
145147
}
146-
148+
/*
149+
* Set attribute: mContainerInfo.type
150+
*/
147151
void ContainerInfo::set_type(GSContainerType containerType) {
148152
mContainerInfo.type = containerType;
149153
}
150-
154+
/*
155+
* Set attribute: mContainerInfo.rowKeyAssigned
156+
*/
151157
void ContainerInfo::set_row_key_assigned(bool rowKeyAssigned) {
152158
mContainerInfo.rowKeyAssigned = rowKeyAssigned;
153159
}
154-
160+
/*
161+
* Get attribute: mContainerInfo.name
162+
*/
155163
const GSChar* ContainerInfo::get_name() {
156164
return mContainerInfo.name;
157165
}
158-
166+
/*
167+
* Get attribute: mContainerInfo.type
168+
*/
159169
GSContainerType ContainerInfo::get_type() {
160170
return mContainerInfo.type;
161171
}
162-
172+
/*
173+
* Get attribute: mContainerInfo.columnInfoList
174+
*/
163175
GSColumnInfo ContainerInfo::get_column_info(size_t column) {
164176
return mContainerInfo.columnInfoList[column];
165177
}
166-
178+
/*
179+
* Get attribute: mContainerInfo.rowKeyAssigned
180+
*/
167181
bool ContainerInfo::get_row_key_assigned() {
168182
return mContainerInfo.rowKeyAssigned;
169183
}

src/ContainerInfo.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
#include <string>
2121
#include <cstring>
22+
#include <utility>
2223
#include "TimeSeriesProperties.h"
2324
#include "ExpirationInfo.h"
24-
#include <utility>
2525
#include "GSException.h"
2626

2727
//Support column_info_list attribute
@@ -38,13 +38,14 @@ class ContainerInfo {
3838
/**
3939
* Contains information about a specific container
4040
*/
41-
GSContainerInfo mContainerInfo;
41+
private:
42+
GSContainerInfo mContainerInfo;
4243

43-
//tmp attribute to get column info list
44-
ColumnInfoList mColumnInfoList;
44+
//tmp attribute to get column info list
45+
ColumnInfoList mColumnInfoList;
4546

46-
//tmp attribute support get expiration attribute
47-
ExpirationInfo* mExpInfo;
47+
//tmp attribute support get expiration attribute
48+
ExpirationInfo* mExpInfo;
4849

4950
public:
5051
ContainerInfo(GSContainerInfo *containerInfo);

src/ExpirationInfo.h

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,27 @@ class ExpirationInfo {
5050
mTimeSeriesProps.compressionWindowSize = 0;
5151
mTimeSeriesProps.compressionWindowSizeUnit = GS_TIME_UNIT_YEAR;
5252
};
53-
~ExpirationInfo() {};
54-
int get_time() {return mTimeSeriesProps.rowExpirationTime;};
55-
void set_time(int time) {mTimeSeriesProps.rowExpirationTime = time;};
56-
GSTimeUnit get_time_unit() {return mTimeSeriesProps.rowExpirationTimeUnit;};
57-
void set_time_unit(GSTimeUnit unit) {mTimeSeriesProps.rowExpirationTimeUnit = unit;};
58-
int get_division_count() {return mTimeSeriesProps.expirationDivisionCount;};
59-
void set_division_count(int division_count) {mTimeSeriesProps.expirationDivisionCount = division_count;};
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+
};
6074
GSTimeSeriesProperties* gs_ts() {
6175
return &mTimeSeriesProps;
6276
};

src/Field.h

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
#ifndef _FIELD_H_
1818
#define _FIELD_H_
1919

20-
#include "gridstore.h"
2120
#include <iostream>
2221
#include <string.h>
2322

23+
#include "gridstore.h"
24+
2425
using namespace std;
2526

2627
namespace griddb {
@@ -33,32 +34,24 @@ struct Field {
3334
};
3435

3536
~Field() {
36-
switch (type){
37+
switch (type) {
3738
case GS_TYPE_STRING:
3839
if (value.asString) {
3940
free(const_cast<GSChar*>(value.asString));
40-
value.asString = NULL;
4141
}
4242
break;
4343
case GS_TYPE_BLOB:
4444
if (value.asBlob.data) {
4545
free(const_cast<void*>(value.asBlob.data));
46-
value.asBlob.data = NULL;
4746
}
4847
break;
49-
case GS_TYPE_INTEGER_ARRAY:
5048
#if GS_COMPATIBILITY_VALUE_1_1_106
49+
case GS_TYPE_INTEGER_ARRAY:
5150
if (value.asIntegerArray.elements) {
5251
free(const_cast<int32_t*> (value.asIntegerArray.elements));
5352
}
54-
#else
55-
if (value.asArray.elements.asInteger) {
56-
free(const_cast<int32_t*> (value.asArray.elements.asInteger));
57-
}
58-
#endif
5953
break;
6054
case GS_TYPE_STRING_ARRAY:
61-
#if GS_COMPATIBILITY_VALUE_1_1_106
6255
if (value.asStringArray.elements) {
6356
for (int j = 0; j < value.asStringArray.size; j++) {
6457
if (value.asStringArray.elements[j]) {
@@ -67,7 +60,49 @@ struct Field {
6760
}
6861
free(const_cast<GSChar**> (value.asStringArray.elements));
6962
}
63+
break;
64+
case GS_TYPE_BOOL_ARRAY:
65+
if (value.asBoolArray.elements) {
66+
free(const_cast<GSBool*> (value.asBoolArray.elements));
67+
}
68+
break;
69+
case GS_TYPE_BYTE_ARRAY:
70+
if (value.asByteArray.elements) {
71+
free(const_cast<int8_t*> (value.asByteArray.elements));
72+
}
73+
break;
74+
case GS_TYPE_SHORT_ARRAY:
75+
if (value.asShortArray.elements) {
76+
free(const_cast<int16_t*> (value.asShortArray.elements));
77+
}
78+
break;
79+
case GS_TYPE_LONG_ARRAY:
80+
if (value.asLongArray.elements) {
81+
free(const_cast<int64_t*> (value.asLongArray.elements));
82+
}
83+
break;
84+
case GS_TYPE_FLOAT_ARRAY:
85+
if (value.asFloatArray.elements) {
86+
free(const_cast<float*> (value.asFloatArray.elements));
87+
}
88+
break;
89+
case GS_TYPE_DOUBLE_ARRAY:
90+
if (value.asDoubleArray.elements) {
91+
free(const_cast<double*> (value.asDoubleArray.elements));
92+
}
93+
break;
94+
case GS_TYPE_TIMESTAMP_ARRAY:
95+
if (value.asTimestampArray.elements) {
96+
free(const_cast<GSTimestamp*> (value.asTimestampArray.elements));
97+
}
98+
break;
7099
#else
100+
case GS_TYPE_INTEGER_ARRAY:
101+
if (value.asArray.elements.asInteger) {
102+
free(const_cast<int32_t*> (value.asArray.elements.asInteger));
103+
}
104+
break;
105+
case GS_TYPE_STRING_ARRAY:
71106
if (value.asArray.elements.asString) {
72107
for (int j = 0; j < value.asArray.length; j++) {
73108
if (value.asArray.elements.asString[j]) {
@@ -76,86 +111,45 @@ struct Field {
76111
}
77112
free(const_cast<GSChar**> (value.asArray.elements.asString));
78113
}
79-
#endif
80114
break;
81115
case GS_TYPE_BOOL_ARRAY:
82-
#if GS_COMPATIBILITY_VALUE_1_1_106
83-
if (value.asBoolArray.elements) {
84-
free(const_cast<GSBool*> (value.asBoolArray.elements));
85-
}
86-
#else
87116
if (value.asArray.elements.asBool) {
88117
free(const_cast<GSBool*> (value.asArray.elements.asBool));
89118
}
90-
#endif
91119
break;
92120
case GS_TYPE_BYTE_ARRAY:
93-
#if GS_COMPATIBILITY_VALUE_1_1_106
94-
if (value.asByteArray.elements) {
95-
free(const_cast<int8_t*> (value.asByteArray.elements));
96-
value.asByteArray.elements = NULL;
97-
}
98-
#else
99121
if (value.asArray.elements.asByte) {
100122
free(const_cast<int8_t*> (value.asArray.elements.asByte));
101-
value.asArray.elements.asByte = NULL;
102123
}
103-
#endif
104124
break;
105125
case GS_TYPE_SHORT_ARRAY:
106-
#if GS_COMPATIBILITY_VALUE_1_1_106
107-
if (value.asShortArray.elements) {
108-
free(const_cast<int16_t*> (value.asShortArray.elements));
109-
}
110-
#else
111126
if (value.asArray.elements.asShort) {
112127
free(const_cast<int16_t*> (value.asArray.elements.asShort));
113128
}
114-
#endif
115129
break;
116130
case GS_TYPE_LONG_ARRAY:
117-
#if GS_COMPATIBILITY_VALUE_1_1_106
118-
if (value.asLongArray.elements) {
119-
free(const_cast<int64_t*> (value.asLongArray.elements));
120-
}
121-
#else
122131
if (value.asArray.elements.asLong) {
123132
free(const_cast<int64_t*> (value.asArray.elements.asLong));
124133
}
125-
#endif
126134
break;
127135
case GS_TYPE_FLOAT_ARRAY:
128-
#if GS_COMPATIBILITY_VALUE_1_1_106
129-
if (value.asFloatArray.elements) {
130-
free(const_cast<float*> (value.asFloatArray.elements));
131-
}
132-
#else
133136
if (value.asArray.elements.asFloat) {
134137
free(const_cast<float*> (value.asArray.elements.asFloat));
135138
}
136-
#endif
137139
break;
138140
case GS_TYPE_DOUBLE_ARRAY:
139-
#if GS_COMPATIBILITY_VALUE_1_1_106
140-
if (value.asDoubleArray.elements) {
141-
free(const_cast<double*> (value.asDoubleArray.elements));
142-
}
143-
#else
144141
if (value.asArray.elements.asDouble) {
145142
free(const_cast<double*> (value.asArray.elements.asDouble));
146143
}
147-
#endif
148144
break;
149145
case GS_TYPE_TIMESTAMP_ARRAY:
150-
#if GS_COMPATIBILITY_VALUE_1_1_106
151-
if (value.asTimestampArray.elements) {
152-
free(const_cast<GSTimestamp*> (value.asTimestampArray.elements));
153-
}
154-
#else
155146
if (value.asArray.elements.asTimestamp) {
156147
free(const_cast<GSTimestamp*> (value.asArray.elements.asTimestamp));
157148
}
149+
break;
158150
#endif
151+
default:
152+
//not need to free allocation
159153
break;
160154
}
161155
}

0 commit comments

Comments
 (0)