Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static PyObject * ConvertInt32(PyObject * object)
Py_DecRef((PyObject *)pArray);
return NULL;
}
pInt32[i] = (int32_t)val;
pInt32[i] = static_cast<int32_t>(val);
}
return (PyObject *)pArray;
}
Expand Down
8 changes: 4 additions & 4 deletions src/BasicMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static const inline T MaxOp(T x, T y)
// x & y; }

static const int64_t NAN_FOR_INT64 = (int64_t)0x8000000000000000LL;
static const int64_t NAN_FOR_INT32 = (int32_t)0x80000000;
static const int64_t NAN_FOR_INT32 = 0x80000000;
Comment thread
staffantj marked this conversation as resolved.

template <typename T>
static const inline double DivOp(T x, T y)
Expand Down Expand Up @@ -3428,9 +3428,9 @@ PyObject * TwoInputsInternal(CTwoInputs & twoInputs, int64_t funcNumber)
if (twoInputs.len2 > 1)
fl.Input2Strides = PyArray_STRIDE(twoInputs.inArr2, 0);

fl.InputItemSize =
twoInputs.len1 >= twoInputs.len2 ? PyArray_ITEMSIZE(twoInputs.inArr) : PyArray_ITEMSIZE(twoInputs.inArr2);
fl.OutputItemSize = PyArray_ITEMSIZE(outputArray);
fl.InputItemSize = twoInputs.len1 >= twoInputs.len2 ? static_cast<int32_t>(PyArray_ITEMSIZE(twoInputs.inArr)) :
static_cast<int32_t>(PyArray_ITEMSIZE(twoInputs.inArr2));
fl.OutputItemSize = static_cast<int32_t>(PyArray_ITEMSIZE(outputArray));

fl.NumpyOutputType = wantedOutputType;
fl.NumpyType = twoInputs.len1 >= twoInputs.len2 ? twoInputs.numpyInType1 : twoInputs.numpyInType2;
Expand Down
8 changes: 4 additions & 4 deletions src/Compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ void FillInNumpyHeader(NUMPY_HEADERSIZE * pstNumpyHeader, int32_t dtype, int32_t
pstNumpyHeader->magic = COMPRESSION_MAGIC;
pstNumpyHeader->compressiontype = COMPRESSION_TYPE_ZSTD;

pstNumpyHeader->dtype = (int8_t)(dtype);
pstNumpyHeader->ndim = (int8_t)ndim;
pstNumpyHeader->dtype = static_cast<int8_t>(dtype);
pstNumpyHeader->ndim = static_cast<int8_t>(ndim);

pstNumpyHeader->flags = flags;
pstNumpyHeader->itemsize = (int32_t)itemsize;
pstNumpyHeader->itemsize = static_cast< int32_t >(itemsize);

if (pstNumpyHeader->ndim > 3)
{
Expand Down Expand Up @@ -188,7 +188,7 @@ PyObject * CompressDecompressArrays(PyObject * self, PyObject * args)
pstCompressArrays->pNumpyHeaders[t] =
AllocCompressedMemory(aInfo[t].ArrayLength, aInfo[t].NumpyDType, aInfo[t].NDim,
(int64_t *)(((PyArrayObject_fields *)aInfo[t].pObject)->dimensions),
PyArray_FLAGS(aInfo[t].pObject), aInfo[t].ItemSize);
PyArray_FLAGS(aInfo[t].pObject), static_cast<int32_t>(aInfo[t].ItemSize));
}

// This will kick off the workerthread and call CompressMemoryArray
Expand Down
44 changes: 34 additions & 10 deletions src/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "Reduce.h"

#include <algorithm>
#include <exception>
#include <string>

#define LOGGING(...)
//#define LOGGING printf
Expand Down Expand Up @@ -1049,8 +1051,8 @@ void * GetInvalid(int dtype)
// NOTE: if they are the same type, special fast routine called
PyObject * ConvertSafeInternal(PyArrayObject * const inArr1, const int64_t out_dtype)
{
const int32_t numpyOutType = (int32_t)out_dtype;
const int32_t numpyInType = PyArray_TYPE(inArr1);
const int32_t numpyOutType = static_cast<int32_t>(out_dtype);
const int32_t numpyInType = static_cast<int32_t>(PyArray_TYPE(inArr1));

if (numpyOutType < 0 || numpyInType > NPY_LONGDOUBLE || numpyOutType > NPY_LONGDOUBLE)
{
Expand Down Expand Up @@ -1251,8 +1253,8 @@ PyObject * ConvertSafe(PyObject * self, PyObject * args)
// GetConversionFunctionUnsafe.
PyObject * ConvertUnsafeInternal(PyArrayObject * inArr1, int64_t out_dtype)
{
const int32_t numpyOutType = (int32_t)out_dtype;
const int32_t numpyInType = ObjectToDtype(inArr1);
const int32_t numpyOutType = static_cast<int32_t>(out_dtype);
const int32_t numpyInType = static_cast<int32_t>(ObjectToDtype(inArr1));

if (numpyOutType < 0 || numpyInType < 0 || numpyInType > NPY_LONGDOUBLE || numpyOutType > NPY_LONGDOUBLE)
{
Expand Down Expand Up @@ -2085,6 +2087,12 @@ int64_t Combine1Filter(void * pInputIndex,
{
for (int64_t i = 0; i < arrayLength; i++)
{
if (i > std::numeric_limits<INDEX>::max())
{
std::string errmsg{"Combine1Filter has attempted to exceed the size of the index value "};
errmsg += std::to_string(i);
throw std::overflow_error(errmsg);
}
if (pFilter[i])
{
INDEX index = pInput[i];
Expand All @@ -2096,7 +2104,7 @@ int64_t Combine1Filter(void * pInputIndex,
if (pHash[index] == 0)
{
// First time, assign FirstKey
pNewFirst[uniquecount] = (int32_t)i;
pNewFirst[uniquecount] = static_cast<int32_t>(i);
uniquecount++;

// printf("reassign index:%lld to bin:%d\n", (int64_t)index,
Expand All @@ -2110,7 +2118,7 @@ int64_t Combine1Filter(void * pInputIndex,
{
// Get reassigned key
// printf("exiting index:%lld to bin:%d\n", (int64_t)index,
// (int32_t)pHash[index]);
// pHash[index]);
pOutput[i] = (INDEX)pHash[index];
}
}
Expand All @@ -2132,6 +2140,12 @@ int64_t Combine1Filter(void * pInputIndex,
// When no filter provided
for (int64_t i = 0; i < arrayLength; i++)
{
if (i > std::numeric_limits<INDEX>::max())
{
std::string errmsg{"Combine1Filter has attempted to exceed the size of the index value, no filter provided "};
errmsg += std::to_string(i);
throw std::overflow_error(errmsg);
}
INDEX index = pInput[i];
// printf("[%lld] got index\n", (int64_t)index);

Expand All @@ -2141,7 +2155,7 @@ int64_t Combine1Filter(void * pInputIndex,
if (pHash[index] == 0)
{
// First time, assign FirstKey
pNewFirst[uniquecount] = (int32_t)i;
pNewFirst[uniquecount] = static_cast<int32_t>(i);
uniquecount++;

// ReassignKey
Expand Down Expand Up @@ -2258,7 +2272,17 @@ PyObject * CombineAccum1Filter(PyObject * self, PyObject * args)
{
int32_t * pFirst = (int32_t *)PyArray_BYTES(firstArray);

int64_t uniqueCount = pFunction(pDataIn1, PyArray_BYTES(outArray), pFirst, pFilterIn, arraySize1, hashSize);
int64_t uniqueCount{};

try
{
uniqueCount = pFunction(pDataIn1, PyArray_BYTES(outArray), pFirst, pFilterIn, arraySize1, hashSize);
}
catch ( std::exception &e )
{
PyErr_Format(PyExc_ValueError, e.what());
return nullptr;
}

if (uniqueCount < arraySize1)
{
Expand Down Expand Up @@ -3242,7 +3266,7 @@ PyObject * HomogenizeArrays(PyObject * self, PyObject * args)

if (aInfo)
{
int32_t dtype = (int32_t)PyLong_AsLong(dtypeObject);
int32_t dtype = PyLong_AsLong(dtypeObject);

if (dtype != -1)
{
Expand Down Expand Up @@ -4017,7 +4041,7 @@ PyObject * ApplyRows(PyObject * self, PyObject * args, PyObject * kwargs)

if (aInfo)
{
int32_t dtype = (int32_t)PyLong_AsLong(dtypeObject);
int32_t dtype = PyLong_AsLong(dtypeObject);

if (dtype != -1)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Ema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ static void CumSum(void * pKeyT, void * pAccumBin, void * pColumn, int64_t numUn

U Invalid = GET_INVALID(pDest[0]);

int32_t windowSize = (int32_t)windowSize1;
int32_t windowSize = std::lround(windowSize1);

LOGGING("cumsum %lld %lld %lld %p %p\n", numUnique, totalInputRows, (int64_t)Invalid, pIncludeMask, pResetMask);

Expand Down Expand Up @@ -848,7 +848,7 @@ static void CumProd(void * pKeyT, void * pAccumBin, void * pColumn, int64_t numU

U Invalid = GET_INVALID(pDest[0]);

int32_t windowSize = (int32_t)windowSize1;
int32_t windowSize = std::lround(windowSize1);

LOGGING("cumprod %lld %lld %p %p\n", numUnique, totalInputRows, pIncludeMask, pResetMask);

Expand Down Expand Up @@ -1196,7 +1196,7 @@ class EmaByBase
// (double)pLastEma[location], (double)-decayRate, (double)pTime[i],
// (double)pLastTime[location] );
pLastEma[location] = pSrc[i] + pLastEma[location] * exp(-decayRate * (pTime[i] - pLastTime[location]));
// printf("[%d][%d] %lf\n", i, (int32_t)location,
// printf("[%d][%d] %lf\n", i, location,
// (double)pLastEma[location]);
pLastTime[location] = pTime[i];
pDest[i] = pLastEma[location];
Expand Down Expand Up @@ -1827,7 +1827,7 @@ void EmaByCall(void * pEmaBy, int64_t i)

//---------------------------------------------------------------
// Arg1 = LIST of numpy arrays which has the values to accumulate (often all the
// columns in a dataset) Arg2 = iKey = numpy array (int32_t) which has the index
// columns in a dataset) Arg2 = iKey = numpy array which has the index
// to the unique keys (ikey from MultiKeyGroupBy32) Arg3 = integer unique rows
// Arg4 = integer (function number to execute for cumsum, ema)
// Arg5 = params for function must be (decay/window, time, includemask,
Expand Down Expand Up @@ -1958,7 +1958,7 @@ PyObject * EmaAll32(PyObject * self, PyObject * args)
stEma32 * pstEma32 = (stEma32 *)WORKSPACE_ALLOC((sizeof(stEma32) + 8 + sizeof(stEmaReturn)) * tupleSize);

pstEma32->aInfo = aInfo;
pstEma32->funcNum = (int32_t)funcNum;
pstEma32->funcNum = static_cast<int32_t>(funcNum);
pstEma32->pKey = (int32_t *)PyArray_BYTES(iKey);
pstEma32->tupleSize = tupleSize;
pstEma32->uniqueRows = unique_rows;
Expand Down
16 changes: 8 additions & 8 deletions src/FileReadWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ DWORD CFileReadWrite::ReadChunk(void * buffer, uint32_t count)
OverlappedIO.hEvent = NULL;
OverlappedIO.InternalHigh = 0;
OverlappedIO.Internal = 0;
OverlappedIO.OffsetHigh = (uint32_t)(BufferPos >> 32);
OverlappedIO.Offset = (uint32_t)BufferPos;
OverlappedIO.OffsetHigh = (BufferPos >> 32);
OverlappedIO.Offset = BufferPos;

bool bReadDone;

Expand Down Expand Up @@ -215,8 +215,8 @@ DWORD CFileReadWrite::ReadChunkAsync(void * buffer, uint32_t count, DWORD * last
{
pOverlapped->InternalHigh = 0;
pOverlapped->Internal = 0;
pOverlapped->OffsetHigh = (uint32_t)(BufferPos >> 32);
pOverlapped->Offset = (uint32_t)BufferPos;
pOverlapped->OffsetHigh = (BufferPos >> 32);
pOverlapped->Offset = BufferPos;

bool bReadDone;

Expand Down Expand Up @@ -330,8 +330,8 @@ DWORD CFileReadWrite::WriteChunk(void * buffer, uint32_t count)
OverlappedIO.hEvent = 0;
OverlappedIO.InternalHigh = 0;
OverlappedIO.Internal = 0;
OverlappedIO.OffsetHigh = (uint32_t)(BufferPos >> 32);
OverlappedIO.Offset = (uint32_t)BufferPos;
OverlappedIO.OffsetHigh = (BufferPos >> 32);
OverlappedIO.Offset = BufferPos;

bool bWriteDone;

Expand Down Expand Up @@ -391,8 +391,8 @@ DWORD CFileReadWrite::WriteChunkAsync(void * buffer, uint32_t count, DWORD * las
{
pOverlapped->InternalHigh = 0;
pOverlapped->Internal = 0;
pOverlapped->OffsetHigh = (uint32_t)(BufferPos >> 32);
pOverlapped->Offset = (uint32_t)BufferPos;
pOverlapped->OffsetHigh = (BufferPos >> 32);
pOverlapped->Offset = BufferPos;

bool bWriteDone;

Expand Down
Loading