diff --git a/c/colmapping.c b/c/colmapping.c index 8d1a1aaaa2..c1cce48ec2 100644 --- a/c/colmapping.c +++ b/c/colmapping.c @@ -3,7 +3,7 @@ ColMapping* -ColMapping_from_array(ssize_t *array, ssize_t length, DataTable *dt) +ColMapping_from_array(int64_t *array, int64_t length, DataTable *dt) { ColMapping *res = malloc(sizeof(ColMapping)); if (res == NULL) return NULL; @@ -12,7 +12,7 @@ ColMapping_from_array(ssize_t *array, ssize_t length, DataTable *dt) res->stypes = malloc(sizeof(SType) * (size_t)length); if (res->stypes == NULL) goto fail; Column **columns = dt->columns; - for (ssize_t i = 0; i < length; i++) { + for (int64_t i = 0; i < length; i++) { res->stypes[i] = columns[array[i]]->stype; } return res; @@ -24,12 +24,12 @@ ColMapping_from_array(ssize_t *array, ssize_t length, DataTable *dt) /* -ColMapping* ColMapping_alloc(ssize_t length) +ColMapping* ColMapping_alloc(int64_t length) { ColMapping *res = malloc(sizeof(ColMapping)); if (res == NULL) return NULL; res->length = length; - res->indices = malloc(sizeof(ssize_t) * length); + res->indices = malloc(sizeof(int64_t) * length); res->coltypes = malloc(sizeof(LType) * length); if (res->indices == NULL || res->coltypes == NULL) goto fail; return res; diff --git a/c/colmapping.h b/c/colmapping.h index fa7af2b35f..4ebc3df0bc 100644 --- a/c/colmapping.h +++ b/c/colmapping.h @@ -5,14 +5,14 @@ typedef struct ColMapping { - ssize_t length; - ssize_t *indices; + int64_t length; + int64_t *indices; SType *stypes; } ColMapping; -ColMapping* ColMapping_from_array(ssize_t *array, ssize_t len, DataTable *dt); -// ColMapping* ColMapping_alloc(ssize_t length); +ColMapping* ColMapping_from_array(int64_t *array, int64_t len, DataTable *dt); +// ColMapping* ColMapping_alloc(int64_t length); void ColMapping_dealloc(ColMapping *colmapping); diff --git a/c/column.c b/c/column.c index 53680e4ec2..9037a1a2e3 100644 --- a/c/column.c +++ b/c/column.c @@ -82,9 +82,9 @@ Column* column_extract(Column *col, RowMapping *rowmapping) // the required elements manually. switch (stype) { #define JINIT_SLICE \ - ssize_t start = rowmapping->slice.start; \ - ssize_t step = rowmapping->slice.step; \ - ssize_t j = start - step; + int64_t start = rowmapping->slice.start; \ + int64_t step = rowmapping->slice.step; \ + int64_t j = start - step; #define JITER_SLICE \ j += step; #define JINIT_ARR(bits) \ diff --git a/c/datatable.c b/c/datatable.c index d1edfed8d4..dd15e2336c 100644 --- a/c/datatable.c +++ b/c/datatable.c @@ -12,8 +12,8 @@ DataTable* dt_DataTable_call( DataTable *self, RowMapping *rowmapping, ColMapping *colmapping) { - ssize_t ncols = colmapping->length; - ssize_t nrows = rowmapping->length; + int64_t ncols = colmapping->length; + int64_t nrows = rowmapping->length; // Computed on-demand only if we detect that it is needed RowMapping *merged_rowindex = NULL; @@ -21,8 +21,8 @@ DataTable* dt_DataTable_call( Column **columns = calloc(sizeof(Column*), (size_t)ncols); if (columns == NULL) return NULL; - for (ssize_t i = 0; i < ncols; ++i) { - ssize_t j = colmapping->indices[i]; + for (int64_t i = 0; i < ncols; ++i) { + int64_t j = colmapping->indices[i]; Column *colj = self->columns[j]; if (colj->mtype == MT_VIEW) { if (merged_rowindex == NULL) { @@ -64,7 +64,6 @@ DataTable* dt_DataTable_call( - /** * Free memory occupied by the :class:`DataTable` object. This function should * be called from `DataTable_PyObject`s deallocator only. diff --git a/c/datatable.h b/c/datatable.h index 93548a1674..a77a137ecb 100644 --- a/c/datatable.h +++ b/c/datatable.h @@ -53,8 +53,8 @@ typedef struct DataTable DataTable; * which determines the actual struct type. */ typedef struct DataTable { - ssize_t nrows; - ssize_t ncols; + int64_t nrows; + int64_t ncols; DataTable *source; RowMapping *rowmapping; Column **columns; diff --git a/c/datatablemodule.c b/c/datatablemodule.c index 90cf645d1b..cbb53574bf 100644 --- a/c/datatablemodule.c +++ b/c/datatablemodule.c @@ -24,7 +24,7 @@ PyObject *dt_from_memmap(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &list)) return NULL; - ssize_t ncols = PyList_Size(list); + int64_t ncols = PyList_Size(list); DataTable *dt = malloc(sizeof(DataTable)); if (dt == NULL) return NULL; @@ -34,7 +34,7 @@ PyObject *dt_from_memmap(PyObject *self, PyObject *args) dt->columns = malloc(sizeof(Column) * (size_t)ncols); if (dt->columns == NULL) return NULL; - ssize_t nrows = -1; + int64_t nrows = -1; for (int i = 0; i < ncols; i++) { PyObject *item = PyList_GetItem(list, i); char *colname = PyUnicode_AsUTF8(item); @@ -85,7 +85,7 @@ PyObject *dt_from_memmap(PyObject *self, PyObject *args) // After memory-mapping the file, its descriptor is no longer needed close(fd); - ssize_t nelems = (ssize_t)filesize / (ssize_t)elemsize; + int64_t nelems = (int64_t)filesize / (int64_t)elemsize; if (nrows == -1) nrows = nelems; else if (nrows != nelems) { @@ -156,8 +156,8 @@ static PyModuleDef datatablemodule = { 0,0,0,0, }; -static_assert(sizeof(ssize_t) == sizeof(Py_ssize_t), - "ssize_t and Py_ssize_t should refer to the same type"); +static_assert(sizeof(int64_t) == sizeof(Py_ssize_t), + "int64_t and Py_ssize_t should refer to the same type"); /* Called when Python program imports the module */ PyMODINIT_FUNC diff --git a/c/fread_impl.c b/c/fread_impl.c index 56cea934e1..83f39b9dcd 100644 --- a/c/fread_impl.c +++ b/c/fread_impl.c @@ -41,7 +41,7 @@ static char *filename = NULL; static char *input = NULL; static char **na_strings = NULL; -static ssize_t ncols = 0; +static int64_t ncols = 0; static int8_t *types = NULL; static int8_t *sizes = NULL; static StrBuf **strbufs = NULL; @@ -120,7 +120,7 @@ void cleanup_fread_session(freadMainArgs *frargs) { Py_XDECREF(frargs->freader); } if (strbufs) { - for (ssize_t i = 0; i < ncols; i++) { + for (int64_t i = 0; i < ncols; i++) { if (strbufs[i]) { free(strbufs[i]->buf); free(strbufs[i]); @@ -159,7 +159,7 @@ size_t allocateDT(int8_t *types_, int8_t *sizes_, int ncols_, int ndrop, int64_t nrows) { types = types_; sizes = sizes_; - ncols = (ssize_t) ncols_; + ncols = (int64_t) ncols_; if (nrows > INTPTR_MAX) { PyErr_Format(PyExc_ValueError, @@ -199,7 +199,7 @@ size_t allocateDT(int8_t *types_, int8_t *sizes_, int ncols_, int ndrop, } dt = malloc(sizeof(DataTable)); - dt->nrows = (ssize_t) nrows; + dt->nrows = (int64_t) nrows; dt->ncols = ncols - ndrop; dt->source = NULL; dt->rowmapping = NULL; diff --git a/c/py_colmapping.c b/c/py_colmapping.c index 87ba6e3b8d..29f575a4f6 100644 --- a/c/py_colmapping.c +++ b/c/py_colmapping.c @@ -19,7 +19,7 @@ ColMapping_PyObject* ColMappingPy_from_array(PyObject *self, PyObject *args) DataTable_PyObject *dt; ColMapping *colmapping = NULL; ColMapping_PyObject *res = NULL; - ssize_t *data = NULL; + int64_t *data = NULL; // Unpack arguments and check their validity if (!PyArg_ParseTuple(args, "O!O!:ColMapping.from_array", @@ -27,9 +27,9 @@ ColMapping_PyObject* ColMappingPy_from_array(PyObject *self, PyObject *args) return NULL; // Convert Pythonic List into a regular C array of longs - ssize_t len = PyList_Size(list); - data = MALLOC(sizeof(ssize_t) * (size_t)len); - for (ssize_t i = 0; i < len; ++i) { + int64_t len = PyList_Size(list); + data = MALLOC(sizeof(int64_t) * (size_t)len); + for (int64_t i = 0; i < len; ++i) { data[i] = PyLong_AsSsize_t(PyList_GET_ITEM(list, i)); } diff --git a/c/py_datatable.c b/c/py_datatable.c index 00287f122c..0ae35429c9 100644 --- a/c/py_datatable.c +++ b/c/py_datatable.c @@ -239,7 +239,7 @@ PyObject* write_column_to_file(PyObject *self, PyObject *args) const void *ptr = col->data; while (bytes_written < total_size) { int64_t nbytes = min(total_size - bytes_written, buff_size); - ssize_t written = write(fd, ptr, (size_t)nbytes); + int64_t written = write(fd, ptr, (size_t)nbytes); if (written <= 0) { PyErr_Format(PyExc_RuntimeError, "Error %d when writing to file", errno); diff --git a/c/py_datatable_fromlist.c b/c/py_datatable_fromlist.c index c09f69b121..ef11290225 100644 --- a/c/py_datatable_fromlist.c +++ b/c/py_datatable_fromlist.c @@ -38,14 +38,14 @@ pyDataTable_from_list_of_lists(PyTypeObject *type, PyObject *args) dt->ncols = 0; // If the supplied list is empty, return the empty Datatable object - ssize_t listsize = Py_SIZE(list); // works both for lists and tuples + int64_t listsize = Py_SIZE(list); // works both for lists and tuples if (listsize == 0) { return pyDataTable_from_DataTable(dt); } // Basic check validity of the provided data. - ssize_t item0size = Py_SIZE(PyList_GET_ITEM(list, 0)); - for (ssize_t i = 0; i < listsize; ++i) { + int64_t item0size = Py_SIZE(PyList_GET_ITEM(list, 0)); + for (int64_t i = 0; i < listsize; ++i) { PyObject *item = PyList_GET_ITEM(list, i); if (!PyList_Check(item)) { PyErr_SetString(PyExc_ValueError, @@ -64,7 +64,7 @@ pyDataTable_from_list_of_lists(PyTypeObject *type, PyObject *args) dt->columns = CALLOC(sizeof(Column), dt->ncols); // Fill the data - for (ssize_t i = 0; i < dt->ncols; i++) { + for (int64_t i = 0; i < dt->ncols; i++) { PyObject *src = PyList_GET_ITEM(list, i); dt->columns[i] = TRY(column_from_list(src)); } diff --git a/c/py_datawindow.c b/c/py_datawindow.c index 08e4801313..088240976a 100644 --- a/c/py_datawindow.c +++ b/c/py_datawindow.c @@ -8,8 +8,8 @@ #include "py_types.h" // Forward declarations -static int _check_consistency(DataTable *dt, ssize_t row0, ssize_t row1, - ssize_t col0, ssize_t col1); +static int _check_consistency(DataTable *dt, int64_t row0, int64_t row1, + int64_t col0, int64_t col1); int init_py_datawindow(PyObject *module) { @@ -38,7 +38,7 @@ static int __init__(DataWindow_PyObject *self, PyObject *args, PyObject *kwds) DataTable *dt; PyObject *stypes = NULL, *ltypes = NULL, *view = NULL; int n_init_cols = 0; - ssize_t row0, row1, col0, col1; + int64_t row0, row1, col0, col1; // Parse arguments and check their validity static char *kwlist[] = {"dt", "row0", "row1", "col0", "col1", NULL}; @@ -50,14 +50,14 @@ static int __init__(DataWindow_PyObject *self, PyObject *args, PyObject *kwds) return -1; // Window dimensions - ssize_t ncols = col1 - col0; - ssize_t nrows = row1 - row0; + int64_t ncols = col1 - col0; + int64_t nrows = row1 - row0; // Create and fill-in the `stypes` list stypes = PyList_New((Py_ssize_t) ncols); ltypes = PyList_New((Py_ssize_t) ncols); if (stypes == NULL || ltypes == NULL) goto fail; - for (ssize_t i = col0; i < col1; i++) { + for (int64_t i = col0; i < col1; i++) { Column *column = dt->columns[i]; SType stype = column->stype; LType ltype = stype_info[stype].ltype; @@ -71,13 +71,13 @@ static int __init__(DataWindow_PyObject *self, PyObject *args, PyObject *kwds) int rindex_is_slice = rindex && rindex->type == RM_SLICE; int32_t *rindexarr32 = rindex_is_arr32? rindex->ind32 : NULL; int64_t *rindexarr64 = rindex_is_arr64? rindex->ind64 : NULL; - ssize_t rindexstart = rindex_is_slice? rindex->slice.start : 0; - ssize_t rindexstep = rindex_is_slice? rindex->slice.step : 0; + int64_t rindexstart = rindex_is_slice? rindex->slice.start : 0; + int64_t rindexstep = rindex_is_slice? rindex->slice.step : 0; // Create and fill-in the `data` list view = PyList_New((Py_ssize_t) ncols); if (view == NULL) goto fail; - for (ssize_t i = col0; i < col1; ++i) { + for (int64_t i = col0; i < col1; ++i) { Column *column = dt->columns[i]; void *coldata = column->data; int isdata = (column->mtype != MT_VIEW); @@ -91,10 +91,10 @@ static int __init__(DataWindow_PyObject *self, PyObject *args, PyObject *kwds) PyList_SET_ITEM(view, n_init_cols++, py_coldata); int n_init_rows = 0; - for (ssize_t j = row0; j < row1; ++j) { - ssize_t irow = isdata? j : + for (int64_t j = row0; j < row1; ++j) { + int64_t irow = isdata? j : rindex_is_arr32? rindexarr32[j] : - rindex_is_arr64? (ssize_t) rindexarr64[j] : + rindex_is_arr64? (int64_t) rindexarr64[j] : rindexstart + rindexstep * j; PyObject *value = py_stype_formatters[column->stype](column, irow); if (value == NULL) goto fail; @@ -134,7 +134,7 @@ static int __init__(DataWindow_PyObject *self, PyObject *args, PyObject *kwds) * :returns: 1 on success, 0 on failure */ static int _check_consistency( - DataTable *dt, ssize_t row0, ssize_t row1, ssize_t col0, ssize_t col1) + DataTable *dt, int64_t row0, int64_t row1, int64_t col0, int64_t col1) { // check correctness of the data window if (col0 < 0 || col1 < col0 || col1 > dt->ncols || @@ -175,7 +175,7 @@ static int _check_consistency( rindex->length, dt->nrows); return 0; } - for (ssize_t j = row0; j < row1; ++j) { + for (int64_t j = row0; j < row1; ++j) { int32_t jsrc = rindex->ind32[j]; if (jsrc < 0 || jsrc >= dt->source->nrows) { PyErr_Format(PyExc_RuntimeError, diff --git a/c/py_evaluator.c b/c/py_evaluator.c index 66c4491ea6..b0c32caeb7 100644 --- a/c/py_evaluator.c +++ b/c/py_evaluator.c @@ -102,7 +102,7 @@ static PyObject* get_stack_value(Evaluator_PyObject *self, PyObject *args) case 258: { int64_t n = v.i8; int64_t *arr = (int64_t*) self->stack[idx + 1].ptr; - RowMapping *rwm = rowmapping_from_i64_array(arr, (ssize_t)n); + RowMapping *rwm = rowmapping_from_i64_array(arr, (int64_t)n); return (PyObject*) RowMappingPy_from_rowmapping(rwm); } default: diff --git a/c/py_rowmapping.c b/c/py_rowmapping.c index ea8731a42c..17b56e85e5 100644 --- a/c/py_rowmapping.c +++ b/c/py_rowmapping.c @@ -59,7 +59,7 @@ RowMappingPy_from_slice(PyObject *self, PyObject *args) } RowMapping *res = rowmapping_from_slice( - (ssize_t)start, (ssize_t)count, (ssize_t)step + (int64_t)start, (int64_t)count, (int64_t)step ); return RowMappingPy_from_rowmapping(res); } @@ -75,7 +75,7 @@ RowMapping_PyObject* RowMappingPy_from_slicelist(PyObject *self, PyObject *args) { PyObject *pystarts = NULL, *pycounts = NULL, *pysteps = NULL; - ssize_t *starts = NULL, *counts = NULL, *steps = NULL; + int64_t *starts = NULL, *counts = NULL, *steps = NULL; RowMapping *res = NULL; // Unpack arguments @@ -84,19 +84,19 @@ RowMappingPy_from_slicelist(PyObject *self, PyObject *args) &PyList_Type, &pysteps)) return NULL; - ssize_t n1 = PyList_Size(pystarts); - ssize_t n2 = PyList_Size(pycounts); - ssize_t n3 = PyList_Size(pysteps); + int64_t n1 = PyList_Size(pystarts); + int64_t n2 = PyList_Size(pycounts); + int64_t n3 = PyList_Size(pysteps); VALASSERT(n1 >= n2, "counts array cannot be longer than the starts array") VALASSERT(n1 >= n3, "steps array cannot be longer than the starts array") - starts = TRY(malloc(sizeof(ssize_t) * (size_t)n1)); - counts = TRY(malloc(sizeof(ssize_t) * (size_t)n1)); - steps = TRY(malloc(sizeof(ssize_t) * (size_t)n1)); + starts = TRY(malloc(sizeof(int64_t) * (size_t)n1)); + counts = TRY(malloc(sizeof(int64_t) * (size_t)n1)); + steps = TRY(malloc(sizeof(int64_t) * (size_t)n1)); // Convert Pythonic lists into regular C arrays of longs - ssize_t start, count, step; - ssize_t total_count = 0; - for (ssize_t i = 0; i < n1; i++) { + int64_t start, count, step; + int64_t total_count = 0; + for (int64_t i = 0; i < n1; i++) { start = PyLong_AsSsize_t(PyList_GET_ITEM(pystarts, i)); count = i < n2? PyLong_AsSsize_t(PyList_GET_ITEM(pycounts, i)) : 1; step = i < n3? PyLong_AsSsize_t(PyList_GET_ITEM(pysteps, i)) : 1; @@ -148,10 +148,10 @@ RowMapping_PyObject* RowMappingPy_from_array(PyObject *self, PyObject *args) return NULL; // Convert Pythonic List into a regular C array of int32's/int64's - ssize_t len = PyList_Size(list); + int64_t len = PyList_Size(list); data32 = TRY(malloc(4 * (size_t)len)); - for (ssize_t i = 0; i < len; i++) { - ssize_t x = PyLong_AsSsize_t(PyList_GET_ITEM(list, i)); + for (int64_t i = 0; i < len; i++) { + int64_t x = PyLong_AsSsize_t(PyList_GET_ITEM(list, i)); if (x == -1 && PyErr_Occurred()) goto fail; VALASSERT(x >= 0, "Negative indices not allowed: %zd", x) if (data64) { @@ -161,7 +161,7 @@ RowMapping_PyObject* RowMappingPy_from_array(PyObject *self, PyObject *args) } else { assert(_64BIT_); data64 = TRY(malloc(8 * (size_t)len)); - for (ssize_t j = 0; j < i; j++) + for (int64_t j = 0; j < i; j++) data64[j] = (int64_t) data32[j]; free(data32); data32 = NULL; diff --git a/c/rowmapping.c b/c/rowmapping.c index f086f6757d..7b6c015c1c 100644 --- a/c/rowmapping.c +++ b/c/rowmapping.c @@ -15,30 +15,30 @@ static_assert(offsetof(RowMapping, ind32) == offsetof(RowMapping, ind64), /** * Internal macro to help iterate over a rowmapping. Assumes that macro `CODE` * is defined in scope, and substitutes it into the body of each loop. Within - * the macro, variable `ssize_t j` can be used to refer to the source row that - * was rowmapped, and `ssize_t i` is the "destination" index. + * the macro, variable `int64_t j` can be used to refer to the source row that + * was rowmapped, and `int64_t i` is the "destination" index. */ #define ITER_ALL { \ RowMappingType rmtype = rowmapping->type; \ - ssize_t nrows = rowmapping->length; \ + int64_t nrows = rowmapping->length; \ if (rmtype == RM_SLICE) { \ - ssize_t start = rowmapping->slice.start; \ - ssize_t step = rowmapping->slice.step; \ - for (ssize_t i = 0, j = start; i < nrows; i++, j+= step) { \ + int64_t start = rowmapping->slice.start; \ + int64_t step = rowmapping->slice.step; \ + for (int64_t i = 0, j = start; i < nrows; i++, j+= step) { \ CODE \ } \ } \ else if (rmtype == RM_ARR32) { \ int32_t *indices = rowmapping->ind32; \ - for (ssize_t i = 0; i < nrows; i++) { \ - ssize_t j = (ssize_t) indices[i]; \ + for (int64_t i = 0; i < nrows; i++) { \ + int64_t j = (int64_t) indices[i]; \ CODE \ } \ } \ else if (rmtype == RM_ARR64) { \ int64_t *indices = rowmapping->ind64; \ - for (ssize_t i = 0; i < nrows; i++) { \ - ssize_t j = (ssize_t) indices[i]; \ + for (int64_t i = 0; i < nrows; i++) { \ + int64_t j = (int64_t) indices[i]; \ CODE \ } \ } \ @@ -55,7 +55,7 @@ _Bool rowmapping_compactify(RowMapping *rwm) { if (rwm->type != RM_ARR64) return 0; assert(rwm->length > 0); - ssize_t len = rwm->length; + int64_t len = rwm->length; int64_t first = rwm->ind64[0]; int64_t last = rwm->ind64[len - 1]; // Quick check: if the first or the last elements (or the length) are OOB @@ -67,7 +67,7 @@ _Bool rowmapping_compactify(RowMapping *rwm) int64_t *src = rwm->ind64; int32_t *res = malloc(sizeof(int32_t) * (size_t)len); if (res == NULL) return 0; - for (ssize_t i = 0; i < len; i++) { + for (int64_t i = 0; i < len; i++) { int64_t j = src[i]; if (j <= INT32_MAX) res[i] = (int32_t) j; @@ -97,7 +97,7 @@ _Bool rowmapping_compactify(RowMapping *rwm) * * Returns a new `RowMapping` object, or NULL if such object cannot be created. */ -RowMapping* rowmapping_from_slice(ssize_t start, ssize_t count, ssize_t step) +RowMapping* rowmapping_from_slice(int64_t start, int64_t count, int64_t step) { RowMapping *res = NULL; res = TRY(malloc(sizeof(RowMapping))); @@ -128,7 +128,7 @@ RowMapping* rowmapping_from_slice(ssize_t start, ssize_t count, ssize_t step) * one is sufficient to hold all the indices. */ RowMapping* rowmapping_from_slicelist( - ssize_t *starts, ssize_t *counts, ssize_t *steps, ssize_t n) + int64_t *starts, int64_t *counts, int64_t *steps, int64_t n) { if (n < 0) return NULL; size_t nn = (size_t) n; @@ -138,18 +138,18 @@ RowMapping* rowmapping_from_slicelist( // Compute the total number of elements, and the largest index that needs // to be stored. Also check for potential overflows / invalid values. - ssize_t count = 0; - ssize_t maxidx = 0; + int64_t count = 0; + int64_t maxidx = 0; for (size_t i = 0; i < nn; i++) { - ssize_t start = starts[i]; - ssize_t step = steps[i]; - ssize_t len = counts[i]; + int64_t start = starts[i]; + int64_t step = steps[i]; + int64_t len = counts[i]; if (len == 0) continue; if (len < 0 || start < 0) goto fail; if (len > 1 && step < -(start/(len - 1))) goto fail; if (len > 1 && step > (INTPTR_MAX - start)/(len - 1)) goto fail; if (count + len > INTPTR_MAX) goto fail; - ssize_t end = start + step*(len - 1); + int64_t end = start + step*(len - 1); if (end > maxidx) maxidx = end; if (start > maxidx) maxidx = start; count += len; @@ -198,7 +198,7 @@ RowMapping* rowmapping_from_slicelist( */ #define ROWMAPPING_FROM_IXX_ARRAY(bits) \ RowMapping* \ - rowmapping_from_i ## bits ## _array(intXX(bits)* array, ssize_t n) \ + rowmapping_from_i ## bits ## _array(intXX(bits)* array, int64_t n) \ { \ RowMapping *res = NULL; \ res = TRY(malloc(sizeof(RowMapping))); \ @@ -225,7 +225,7 @@ ROWMAPPING_FROM_IXX_ARRAY(64) * This function will create an RM_ARR32/64 RowMapping, depending on what is * minimally required. */ -RowMapping* rowmapping_from_datacolumn(Column *col, ssize_t nrows) +RowMapping* rowmapping_from_datacolumn(Column *col, int64_t nrows) { RowMapping *res = NULL; res = TRY(malloc(sizeof(RowMapping))); @@ -234,9 +234,9 @@ RowMapping* rowmapping_from_datacolumn(Column *col, ssize_t nrows) if (col->stype != ST_BOOLEAN_I1) goto fail; int8_t *data = col->data; - ssize_t nout = 0; - ssize_t maxrow = 0; - for (ssize_t i = 0; i < nrows; i++) + int64_t nout = 0; + int64_t maxrow = 0; + for (int64_t i = 0; i < nrows; i++) if (data[i] == 1) { nout++; maxrow = i; @@ -244,7 +244,7 @@ RowMapping* rowmapping_from_datacolumn(Column *col, ssize_t nrows) #define MAKE_ROWMAPPING(bits) \ intXX(bits) *out = TRY(malloc((bits >> 3) * (size_t)nout)); \ - for (ssize_t i = 0, j = 0; i < nrows; i++) { \ + for (int64_t i = 0, j = 0; i < nrows; i++) { \ if (data[i] == 1) \ out[j++] = (intXX(bits)) i; \ } \ @@ -286,8 +286,8 @@ rowmapping_from_column_with_rowmapping(Column *col, RowMapping *rowmapping) int8_t *data = col->data; - ssize_t nouts = 0; - ssize_t maxrow = 0; + int64_t nouts = 0; + int64_t maxrow = 0; #define CODE \ if (data[j] == 1) { \ nouts++; \ @@ -345,15 +345,15 @@ RowMapping* rowmapping_merge(RowMapping *rwm_ab, RowMapping *rwm_bc) RowMapping *res = NULL; res = TRY(malloc(sizeof(RowMapping))); - ssize_t n = rwm_bc->length; + int64_t n = rwm_bc->length; RowMappingType type_bc = rwm_bc->type; RowMappingType type_ab = rwm_ab == NULL? 0 : rwm_ab->type; res->length = n; switch (type_bc) { case RM_SLICE: { - ssize_t start_bc = rwm_bc->slice.start; - ssize_t step_bc = rwm_bc->slice.step; + int64_t start_bc = rwm_bc->slice.start; + int64_t step_bc = rwm_bc->slice.step; if (rwm_ab == NULL) { res->type = RM_SLICE; res->slice.start = start_bc; @@ -361,8 +361,8 @@ RowMapping* rowmapping_merge(RowMapping *rwm_ab, RowMapping *rwm_bc) } else if (type_ab == RM_SLICE) { // Product of 2 slices is again a slice. - ssize_t start_ab = rwm_ab->slice.start; - ssize_t step_ab = rwm_ab->slice.step; + int64_t start_ab = rwm_ab->slice.start; + int64_t step_ab = rwm_ab->slice.step; res->type = RM_SLICE; res->slice.start = start_ab + step_ab * start_bc; res->slice.step = step_ab * step_bc; @@ -374,8 +374,8 @@ RowMapping* rowmapping_merge(RowMapping *rwm_ab, RowMapping *rwm_bc) res->type = RM_SLICE; res->slice.step = 0; res->slice.start = (type_ab == RM_ARR32) - ? (ssize_t) rwm_ab->ind32[start_bc] - : (ssize_t) rwm_ab->ind64[start_bc]; + ? (int64_t) rwm_ab->ind32[start_bc] + : (int64_t) rwm_ab->ind64[start_bc]; } else if (type_ab == RM_ARR32) { // if A->B is ARR32, then all indices in B are int32, and thus @@ -383,7 +383,7 @@ RowMapping* rowmapping_merge(RowMapping *rwm_ab, RowMapping *rwm_bc) // a slice with step_bc = 0 and n > INT32_MAX). int32_t *rowsres = TRY(malloc(sizeof(int32_t) * (size_t)n)); int32_t *rowssrc = rwm_ab->ind32; - for (ssize_t i = 0, ic = start_bc; i < n; i++, ic += step_bc) { + for (int64_t i = 0, ic = start_bc; i < n; i++, ic += step_bc) { rowsres[i] = rowssrc[ic]; } res->type = RM_ARR32; @@ -395,7 +395,7 @@ RowMapping* rowmapping_merge(RowMapping *rwm_ab, RowMapping *rwm_bc) // attempt to compactify later. int64_t *rowsres = TRY(malloc(sizeof(int64_t) * (size_t)n)); int64_t *rowssrc = rwm_ab->ind64; - for (ssize_t i = 0, ic = start_bc; i < n; i++, ic += step_bc) { + for (int64_t i = 0, ic = start_bc; i < n; i++, ic += step_bc) { rowsres[i] = rowssrc[ic]; } res->type = RM_ARR64; @@ -413,17 +413,17 @@ RowMapping* rowmapping_merge(RowMapping *rwm_ab, RowMapping *rwm_bc) memcpy(res->ind32, rwm_bc->ind32, elemsize * (size_t)n); } else if (type_ab == RM_SLICE) { - ssize_t start_ab = rwm_ab->slice.start; - ssize_t step_ab = rwm_ab->slice.step; + int64_t start_ab = rwm_ab->slice.start; + int64_t step_ab = rwm_ab->slice.step; int64_t *rowsres = TRY(malloc(sizeof(int64_t) * (size_t)n)); if (type_bc == RM_ARR32) { int32_t *rows_bc = rwm_bc->ind32; - for (ssize_t i = 0; i < n; i++) { + for (int64_t i = 0; i < n; i++) { rowsres[i] = start_ab + rows_bc[i] * step_ab; } } else { int64_t *rows_bc = rwm_bc->ind64; - for (ssize_t i = 0; i < n; i++) { + for (int64_t i = 0; i < n; i++) { rowsres[i] = start_ab + rows_bc[i] * step_ab; } } @@ -435,7 +435,7 @@ RowMapping* rowmapping_merge(RowMapping *rwm_ab, RowMapping *rwm_bc) int32_t *rows_ac = TRY(malloc(sizeof(int32_t) * (size_t)n)); int32_t *rows_ab = rwm_ab->ind32; int32_t *rows_bc = rwm_bc->ind32; - for (ssize_t i = 0; i < n; i++) { + for (int64_t i = 0; i < n; i++) { rows_ac[i] = rows_ab[rows_bc[i]]; } res->type = RM_ARR32; @@ -446,7 +446,7 @@ RowMapping* rowmapping_merge(RowMapping *rwm_ab, RowMapping *rwm_bc) #define CASE_AB_BC(bits_ab, bits_bc) \ intXX(bits_ab) *rows_ab = rwm_ab->ind ## bits_ab; \ intXX(bits_bc) *rows_bc = rwm_bc->ind ## bits_bc; \ - for (ssize_t i = 0; i < n; i++) { \ + for (int64_t i = 0; i < n; i++) { \ rows_ac[i] = rows_ab[rows_bc[i]]; \ } if (type_ab == RM_ARR32 && type_bc == RM_ARR64) { diff --git a/c/rowmapping.h b/c/rowmapping.h index 322735cd8c..23c2776cdf 100644 --- a/c/rowmapping.h +++ b/c/rowmapping.h @@ -41,17 +41,17 @@ typedef enum RowMappingType { * start, start + step, start + 2*step, ..., start + (length - 1)*step * The `start` is a nonnegative number, while `step` may be positive, * negative or zero (however `start + (length - 1)*step` must be nonnegative - * and being able to fit inside `ssize_t`). The variable `start` is declared - * as `ssize_t` because if it was `size_t` then it wouldn't be possible to + * and being able to fit inside `int64_t`). The variable `start` is declared + * as `int64_t` because if it was `size_t` then it wouldn't be possible to * do simple addition `start + step`. */ typedef struct RowMapping { RowMappingType type; - ssize_t length; + int64_t length; union { int32_t *ind32; int64_t *ind64; - struct { ssize_t start, step; } slice; + struct { int64_t start, step; } slice; }; } RowMapping; @@ -70,7 +70,7 @@ _Bool rowmapping_compactify(RowMapping *rwm); /** * Construct a "slice" RowMapping object from triple `(start, count, step)`. */ -RowMapping* rowmapping_from_slice(ssize_t start, ssize_t count, ssize_t step); +RowMapping* rowmapping_from_slice(int64_t start, int64_t count, int64_t step); /** * Construct an "array" RowMapping object from a series of triples `(start, @@ -78,19 +78,19 @@ RowMapping* rowmapping_from_slice(ssize_t start, ssize_t count, ssize_t step); * depending on the sizes and indices within the slicelist. */ RowMapping* rowmapping_from_slicelist( - ssize_t *starts, ssize_t *counts, ssize_t *steps, ssize_t n); + int64_t *starts, int64_t *counts, int64_t *steps, int64_t n); /** * Construct a `RowMapping` object from a plain list of int64_t/int32_t row * indices. */ -RowMapping* rowmapping_from_i64_array(int64_t *array, ssize_t n); -RowMapping* rowmapping_from_i32_array(int32_t *array, ssize_t n); +RowMapping* rowmapping_from_i64_array(int64_t *array, int64_t n); +RowMapping* rowmapping_from_i32_array(int32_t *array, int64_t n); /** * Construct a `RowMapping` object using a boolean data column `col`. */ -RowMapping* rowmapping_from_datacolumn(Column *col, ssize_t nrows); +RowMapping* rowmapping_from_datacolumn(Column *col, int64_t nrows); /** * Construct a `RowMapping` object using a boolean data column `col` with diff --git a/c/types.c b/c/types.c index e07333c1e0..7cdf2143ec 100644 --- a/c/types.c +++ b/c/types.c @@ -14,7 +14,7 @@ static_assert(INTPTR_MAX == INT64_MAX, static_assert(sizeof(void*) == 8, "Expected size(void*) to be 8 bytes"); static_assert(sizeof(void*) == sizeof(size_t), "size(size_t) != size(void*)"); -static_assert(sizeof(void*) == sizeof(ssize_t), "size(ssize_t) != size(void*)"); +static_assert(sizeof(void*) == sizeof(int64_t), "size(int64_t) != size(void*)"); static_assert(sizeof(int8_t) == 1, "int8_t should be 1-byte"); static_assert(sizeof(int16_t) == 2, "int16_t should be 2-byte"); diff --git a/c/types.h b/c/types.h index f66df301a1..ea51d9450a 100644 --- a/c/types.h +++ b/c/types.h @@ -9,10 +9,6 @@ // etc. #define intXX(bits) int ## bits ## _t -#ifndef _SSIZE_T -#define _SSIZE_T 1 -typedef int64_t ssize_t; -#endif //============================================================================== diff --git a/datatable/expr/_expr.py b/datatable/expr/_expr.py index fe12c7f45e..6f399b876a 100644 --- a/datatable/expr/_expr.py +++ b/datatable/expr/_expr.py @@ -8,9 +8,9 @@ class ExprNode(object): """ - Basic building block for the evaluation expression(s) which could be passed - as parameters ``rows``, ``select``, etc in the main ``datatable(...)`` call. - For example, an expression such as + Basic building block for evaluation expression(s) that are passed as + parameters ``rows``, ``select``, etc in the main ``datatable(...)`` call. + For example, expression f.colX > f.colY + 5 diff --git a/tests/munging/test_dt_rows.py b/tests/munging/test_dt_rows.py index d697ee4759..fa9c0a4cdb 100644 --- a/tests/munging/test_dt_rows.py +++ b/tests/munging/test_dt_rows.py @@ -14,9 +14,9 @@ def dt0(): nan = float("nan") return dt.DataTable({ # 0 1 2 3 4 5 6 7 8 9 - "colA": [0, 1, 1, None, 0, 0, 1, None, 1, 1], - "colB": [7, -11, 9, 10000, None, 0, 0, -1, 1, None], - "colC": [5, 1, 1.3, 0.1, 1e5, 0, -2.6, -14, nan, 2], + "colA": [0, 1, 1, None, 0, 0, 1, None, 1, 1], # bool + "colB": [7, -11, 9, 10000, None, 0, 0, -1, 1, None], # int + "colC": [5, 1, 1.3, 0.1, 1e5, 0, -2.6, -14, nan, 2], # real })