Skip to content

Commit 73e9b39

Browse files
committed
Update source code: Using int64_t instead of long
1 parent a846b16 commit 73e9b39

3 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/TimestampUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace griddb {
2727
/**
2828
* Convert from Python timestamp to GridDB timestamp
2929
*/
30-
long TimestampUtils::get_time_millis(double timestamp){
31-
return long(timestamp * 1000);
30+
int64_t TimestampUtils::get_time_millis(double timestamp){
31+
return int64_t(timestamp * 1000);
3232
}
3333

3434
} /* namespace griddb */

src/TimestampUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TimestampUtils {
2929
public:
3030
TimestampUtils();
3131
~TimestampUtils();
32-
static long get_time_millis(double timestamp);
32+
static int64_t get_time_millis(double timestamp);
3333
};
3434

3535
} /* namespace griddb */

src/gstype_python.i

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static PyObject* convertFieldToObject(GSValue* value, GSType type, bool timestam
214214
int i;
215215
switch (type) {
216216
case GS_TYPE_LONG:
217-
return PyLong_FromLong(value->asLong);
217+
return SWIG_From_dec(long long)(value->asLong);
218218
case GS_TYPE_STRING:
219219
return convertStrToObj(value->asString);
220220
case GS_TYPE_INTEGER:
@@ -291,7 +291,9 @@ static bool convertObjectToGSTimestamp(PyObject* value, GSTimestamp* timestamp)
291291
}
292292
return true;
293293
} else if (checkPyObjIsLong(value)) {
294-
utcTimestamp = PyLong_AsLong(value);
294+
int64_t tmp;
295+
SWIG_AsVal_dec(long long)(value, (long long *)&tmp);
296+
utcTimestamp = tmp;
295297
if (utcTimestamp == 0) { // int type for timestamp input is not correct except 0 value.
296298
*timestamp = 0;
297299
return true;
@@ -345,8 +347,8 @@ static bool convertObjectToDouble(PyObject* value, double* floatValPtr) {
345347
}
346348
if (PyInt_Check(value)) {
347349
//input can be integer
348-
long int intVal;
349-
checkConvert = SWIG_AsVal_long(value, &intVal);
350+
int64_t intVal;
351+
checkConvert = SWIG_AsVal_dec(long long)(value, (long long *)&intVal);
350352
if (!SWIG_IsOK(checkConvert)) {
351353
return false;
352354
}
@@ -376,8 +378,8 @@ static bool convertObjectToFloat(PyObject* value, float* floatValPtr) {
376378
}
377379
if (PyInt_Check(value)) {
378380
//input can be integer
379-
long int intVal;
380-
checkConvert = SWIG_AsVal_long(value, &intVal);
381+
int64_t intVal;
382+
checkConvert = SWIG_AsVal_dec(long long)(value, (long long *)&intVal);
381383
if (!SWIG_IsOK(checkConvert)) {
382384
return false;
383385
}
@@ -553,7 +555,7 @@ static bool convertToRowKeyFieldWithType(griddb::Field &field, PyObject* value,
553555
if (PyBool_Check(value)) {
554556
return false;
555557
}
556-
checkConvert = SWIG_AsVal_long(value, &field.value.asLong);
558+
checkConvert = SWIG_AsVal_dec(long long)(value, (long long *)&field.value.asLong);
557559
if (!SWIG_IsOK(checkConvert)) {
558560
return false;
559561
}
@@ -611,7 +613,7 @@ static bool convertToFieldWithType(GSRow *row, int column, PyObject* value, GSTy
611613
if (PyBool_Check(value)) {
612614
return false;
613615
}
614-
checkConvert = SWIG_AsVal_long(value, &longVal);
616+
checkConvert = SWIG_AsVal_dec(long long)(value, (long long *)&longVal);
615617
if (!SWIG_IsOK(checkConvert)) {
616618
return false;
617619
}
@@ -840,7 +842,7 @@ static bool convertToFieldWithType(GSRow *row, int column, PyObject* value, GSTy
840842
}
841843
for (i = 0; i < size; i++) {
842844
vbool = PyBool_Check(PyList_GetItem(value, i));
843-
checkConvert = SWIG_AsVal_long(PyList_GetItem(value, i), ((int64_t *)longArrVal + i));
845+
checkConvert = SWIG_AsVal_dec(long long)(PyList_GetItem(value, i), ((long long *)longArrVal + i));
844846
if (!SWIG_IsOK(checkConvert) || vbool) {
845847
delete [] longArrVal;
846848
return false;
@@ -1466,7 +1468,7 @@ static bool getRowFields(GSRow* row, int columnCount, GSType* typeList, bool tim
14661468
case GS_TYPE_LONG: {
14671469
int64_t longValue;
14681470
ret = gsGetRowFieldAsLong(row, (int32_t) i, &longValue);
1469-
PyList_SetItem(outList, i, PyLong_FromLong(longValue));
1471+
PyList_SetItem(outList, i, SWIG_From_dec(long long)(longValue));
14701472
break;
14711473
}
14721474
case GS_TYPE_STRING: {
@@ -1590,7 +1592,7 @@ static bool getRowFields(GSRow* row, int columnCount, GSType* typeList, bool tim
15901592
ret = gsGetRowFieldAsLongArray(row, (int32_t) i, (const int64_t **)&longArr, &size);
15911593
PyObject* list = PyList_New(size);
15921594
for (int j = 0; j < size; j++) {
1593-
PyList_SetItem(list, j, PyLong_FromLong(longArr[j]));
1595+
PyList_SetItem(list, j, SWIG_From_dec(long long)(longArr[j]));
15941596
}
15951597
PyList_SetItem(outList, i, list);
15961598
break;
@@ -2126,7 +2128,7 @@ static bool getRowFields(GSRow* row, int columnCount, GSType* typeList, bool tim
21262128
SWIG_fail;
21272129
}
21282130
$1.columnInfo[i].name = v;
2129-
$1.columnInfo[i].type = PyLong_AsLong(PyList_GetItem(columInfoList, 1));
2131+
$1.columnInfo[i].type = PyInt_AsLong(PyList_GetItem(columInfoList, 1));
21302132
}
21312133
}
21322134
}

0 commit comments

Comments
 (0)