@@ -1348,18 +1348,25 @@ static bool convertToFieldWithType(GSRow *row, int column, PyObject* value, GSTy
13481348}
13491349
13501350/* *
1351- * Typemaps input for get_multi_container_row () function
1351+ * Typemaps input for multi_get () function
13521352*/
13531353
1354- %typemap(in, fragment = " SWIG_AsCharPtrAndSize" ) (const GSRowKeyPredicateEntry *const * predicateList, size_t predicateCount)
1354+ %typemap(in, fragment = " SWIG_AsCharPtrAndSize" ) (const GSRowKeyPredicateEntry *const * predicateList, size_t predicateCount
1355+ , GSContainerRowEntry **entryList, size_t * containerCount, int **colNumList, GSType*** typeList, int **orderFromInput)
13551356 (PyObject* key, PyObject* val, std::shared_ptr<griddb::RowKeyPredicate> pPredicate, GSRowKeyPredicateEntry* pList = NULL ,
1356- void *vpredicate, Py_ssize_t si, int i, int res = 0 , size_t size = 0 , int * alloc = 0 , char * v = 0 ) {
1357+ void *vpredicate, Py_ssize_t si, int i, int res = 0 , size_t size = 0 , int * alloc = 0 , char * v = 0 ,
1358+ GSContainerRowEntry *tmpEntryList, size_t tmpContainerCount, int *tmpcolNumList, GSType** tmpTypeList, int *tmpOrderFromInput) {
13571359 if (!PyDict_Check ($input)) {
13581360 PyErr_SetString (PyExc_ValueError, " Expected a Dict" );
13591361 SWIG_fail;
13601362 }
13611363 $2 = (size_t )PyInt_AsLong (PyLong_FromSsize_t (PyDict_Size ($input)));
13621364 $1 = NULL ;
1365+ $3 = &tmpEntryList;
1366+ $4 = &tmpContainerCount;
1367+ $5 = &tmpcolNumList;
1368+ $6 = &tmpTypeList;
1369+ $7 = &tmpOrderFromInput;
13631370 i = 0 ;
13641371 si = 0 ;
13651372 if ($2 > 0 ) {
@@ -1377,15 +1384,13 @@ static bool convertToFieldWithType(GSRow *row, int column, PyObject* value, GSTy
13771384 GSRowKeyPredicateEntry *predicateEntry = &pList[i];
13781385 res = SWIG_AsCharPtrAndSize (key, &v, &size, &alloc[i]);
13791386 if (!SWIG_IsOK (res)) {
1380- free ((void *) pList);
13811387 %variable_fail (res, " String" , " containerName" );
13821388 }
13831389 predicateEntry->containerName = v;
13841390 // Get GSRowKeyPredicate pointer from RowKeyPredicate pyObject
13851391 int newmem = 0 ;
13861392 res = SWIG_ConvertPtrAndOwn (val, (void **) &vpredicate, $descriptor (std::shared_ptr<griddb::RowKeyPredicate>*), %convertptr_flags, &newmem);
13871393 if (!SWIG_IsOK (res)) {
1388- free ((void *) pList);
13891394 %argument_fail (res, " $type" , $symname, $argnum);
13901395 }
13911396 if (vpredicate) {
@@ -1401,7 +1406,44 @@ static bool convertToFieldWithType(GSRow *row, int column, PyObject* value, GSTy
14011406 }
14021407}
14031408
1404- %typemap(freearg, fragment = " cleanString" ) (const GSRowKeyPredicateEntry *const * predicateList, size_t predicateCount) (int i) {
1409+ %typemap(argout, numinputs = 1 , fragment = " convertStrToObj" , fragment = " getRowFields" )
1410+ (const GSRowKeyPredicateEntry *const * predicateList, size_t predicateCount
1411+ , GSContainerRowEntry **entryList, size_t * containerCount, int **colNumList, GSType*** typeList, int **orderFromInput) () {
1412+ PyObject* dict = PyDict_New ();
1413+ GSRow* row;
1414+ bool retVal;
1415+ int errorColumn;
1416+ GSType errorType;
1417+ for (int i = 0 ; i < *$4 ; i++) {
1418+ PyObject* key = convertStrToObj ((*$3 )[i].containerName );
1419+ PyObject* list = PyList_New ((*$3 )[i].rowCount );
1420+ for (int j = 0 ; j < (*$3 )[i].rowCount ; j++) {
1421+ row = (GSRow*)(*$3 )[i].rowList [j];
1422+ PyObject *outList = PyList_New ((*$5 )[i]);
1423+ if (outList == NULL ) {
1424+ PyErr_SetString (PyExc_ValueError, " Memory allocation for row is error" );
1425+ SWIG_fail;
1426+ }
1427+ retVal = getRowFields (row, (*$5 )[i], (*$6 )[i], arg1->timestamp_output_with_float , &errorColumn, &errorType, outList);
1428+ if (retVal == false ) {
1429+ char errorMsg[60 ];
1430+ sprintf (errorMsg, " Can't get data for field %d with type %d" , errorColumn, errorType);
1431+ PyErr_SetString (PyExc_ValueError, errorMsg);
1432+ SWIG_fail;
1433+ }
1434+ PyList_SetItem (list, j, outList);
1435+ }
1436+
1437+ // Add entry to map
1438+ PyDict_SetItem (dict, key, list);
1439+ Py_DECREF (key);
1440+ Py_DECREF (list);
1441+ }
1442+ $result = dict;
1443+ }
1444+
1445+ %typemap(freearg, fragment = " cleanString" ) (const GSRowKeyPredicateEntry *const * predicateList, size_t predicateCount
1446+ , GSContainerRowEntry **entryList, size_t * containerCount, int **colNumList, GSType*** typeList, int **orderFromInput) (int i) {
14051447 if ($1 && *$1 ) {
14061448 for (int i = 0 ; i < $2 ; i++) {
14071449 cleanString ((*$1 )[i].containerName , alloc$argnum[i]);
@@ -1414,6 +1456,30 @@ static bool convertToFieldWithType(GSRow *row, int column, PyObject* value, GSTy
14141456 if (alloc$argnum) {
14151457 free (alloc$argnum);
14161458 }
1459+
1460+ if (*$5 ) {
1461+ delete [] *$5 ;
1462+ }
1463+ if (*$6 ) {
1464+ for (int j = 0 ; j < (int ) $2 ; j++) {
1465+ if ((*$6 )[j]) {
1466+ free ((void *) (*$6 )[j]);
1467+ }
1468+ }
1469+ delete [] (*$6 );
1470+ }
1471+ if ($3 ) {
1472+ GSRow* row;
1473+ for (int i = 0 ; i < *$4 ; i++) {
1474+ for (int j = 0 ; j < (*$3 )[i].rowCount ; j++) {
1475+ row = (GSRow*)(*$3 )[i].rowList [j];
1476+ gsCloseRow (&row);
1477+ }
1478+ }
1479+ }
1480+ if (*$7 ) {
1481+ delete [] *$7 ;
1482+ }
14171483}
14181484
14191485/* *
@@ -2039,69 +2105,6 @@ static bool getRowFields(GSRow* row, int columnCount, GSType* typeList, bool tim
20392105 if ($3 ) delete $3 ;
20402106}
20412107
2042- /* *
2043- * Typemaps output for Store.multi_get() function
2044- */
2045- %typemap(in, numinputs = 0 ) (GSContainerRowEntry **entryList, size_t * containerCount, int **colNumList, GSType*** typeList)
2046- (GSContainerRowEntry *tmpEntryList, size_t tmpContainerCount, int *tmpcolNumList, GSType** tmpTypeList) {
2047- $1 = &tmpEntryList;
2048- $2 = &tmpContainerCount;
2049- $3 = &tmpcolNumList;
2050- $4 = &tmpTypeList;
2051- }
2052-
2053- %typemap(argout, numinputs = 0 , fragment = " convertStrToObj" , fragment = " getRowFields" )
2054- (GSContainerRowEntry **entryList, size_t * containerCount, int **colNumList, GSType*** typeList) () {
2055- PyObject* dict = PyDict_New ();
2056- GSRow* row;
2057- bool retVal;
2058- int errorColumn;
2059- GSType errorType;
2060- for (int i = 0 ; i < *$2 ; i++) {
2061- PyObject* key = convertStrToObj ((*$1 )[i].containerName );
2062- PyObject* list = PyList_New ((*$1 )[i].rowCount );
2063- for (int j = 0 ; j < (*$1 )[i].rowCount ; j++) {
2064- row = (GSRow*)(*$1 )[i].rowList [j];
2065- PyObject *outList = PyList_New ((*$3 )[i]);
2066- if (outList == NULL ) {
2067- PyErr_SetString (PyExc_ValueError, " Memory allocation for row is error" );
2068- SWIG_fail;
2069- }
2070- retVal = getRowFields (row, (*$3 )[i], (*$4 )[i], arg1->timestamp_output_with_float , &errorColumn, &errorType, outList);
2071- if (retVal == false ) {
2072- char errorMsg[60 ];
2073- sprintf (errorMsg, " Can't get data for field %d with type %d" , errorColumn, errorType);
2074- PyErr_SetString (PyExc_ValueError, errorMsg);
2075- SWIG_fail;
2076- }
2077- PyList_SetItem (list, j, outList);
2078- }
2079-
2080- // Add entry to map
2081- PyDict_SetItem (dict, key, list);
2082- Py_DECREF (key);
2083- Py_DECREF (list);
2084- }
2085- if (*$4 ) {
2086- for (int j = 0 ; j < *$2 ;j++) {
2087- if ((*$4 )[j]) {
2088- free ((void *) (*$4 )[j]);
2089- }
2090- }
2091- delete [] (*$4 );
2092- }
2093- if (*$3 ) {
2094- delete [] (*$3 );
2095- }
2096- for (int i = 0 ; i < *$2 ; i++) {
2097- for (int j = 0 ; j < (*$1 )[i].rowCount ; j++) {
2098- row = (GSRow*)(*$1 )[i].rowList [j];
2099- gsCloseRow (&row);
2100- }
2101- }
2102- $result = dict;
2103- }
2104-
21052108/* *
21062109 * Typemap for QueryAnalysisEntry.get()
21072110 */
@@ -2313,20 +2316,16 @@ static bool getRowFields(GSRow* row, int columnCount, GSType* typeList, bool tim
23132316 columInfoList = PyList_GetItem ($input, i);
23142317 if (!PyList_Check (columInfoList)) {
23152318 PyErr_SetString (PyExc_ValueError, " Expected a List" );
2316- free ((void *) $1 .columnInfo );
23172319 SWIG_fail;
23182320 }
23192321 size_t sizeColumn = (size_t )PyInt_AsLong (PyLong_FromSsize_t (PyList_Size (columInfoList)));
23202322 if (sizeColumn < 2 ) {
23212323 PyErr_SetString (PyExc_ValueError, " Expect column info has 3 elements" );
2322- free ((void *) $1 .columnInfo );
23232324 SWIG_fail;
23242325 }
23252326
23262327 res = SWIG_AsCharPtrAndSize (PyList_GetItem (columInfoList, 0 ), &v, &stringSize, &alloc[i]);
23272328 if (!SWIG_IsOK (res)) {
2328- free ((void *) $1 .columnInfo );
2329- $1 .columnInfo = NULL ;
23302329 PyErr_SetString (PyExc_ValueError, " Can't convert field to string" );
23312330 SWIG_fail;
23322331 }
@@ -2358,10 +2357,12 @@ static bool getRowFields(GSRow* row, int columnCount, GSType* typeList, bool tim
23582357 for (int i = 0 ; i < size; i++) {
23592358 cleanString ($1 .columnInfo [i].name , alloc$argnum[i]);
23602359 }
2361- free (alloc$argnum);
23622360 }
23632361 free ((void *) $1 .columnInfo );
23642362 }
2363+ if (alloc$argnum) {
2364+ free (alloc$argnum);
2365+ }
23652366}
23662367
23672368%typemap(out, fragment = " convertStrToObj" ) (ColumnInfoList) {
0 commit comments