MCPcopy Create free account
hub / github.com/apache/madlib / newColumn

Method newColumn

src/modules/linalg/matrix_agg.cpp:55–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 }
54
55 typename HandleTraits<Handle>::MatrixTransparentHandleMap::ColXpr
56 newColumn(const Allocator& inAllocator) {
57 uint64_t numColsReserved = utils::nextPowerOfTwo(
58 static_cast<uint64_t>(numCols));
59
60 if (numColsReserved <= numCols) {
61 if (numColsReserved == 0)
62 numColsReserved = 1;
63 else
64 numColsReserved *= 2;
65
66 // Shallow copy to save the references
67 MatrixAggState oldSelf(*this);
68
69 // Allocate new storage
70 mStorage = inAllocator.allocateArray<double, dbal::AggregateContext,
71 dbal::DoZero, dbal::ThrowBadAlloc>(
72 arraySize(numRows, numColsReserved));
73 rebind(numRows, numColsReserved);
74
75 // Copy from old storage to new storage
76 numRows = oldSelf.numRows;
77 numCols = oldSelf.numCols;
78 matrix.leftCols(static_cast<Index>(numCols)) =
79 oldSelf.matrix.leftCols(static_cast<Index>(numCols));
80 }
81
82 // Not necessary for numCols = 0
83 rebind(numRows, numCols + 1);
84
85 return matrix.col(static_cast<Index>(numCols++));
86 }
87
88private:
89 static inline size_t arraySize(uint64_t inNumRows, uint64_t inNumCols) {

Callers 1

runMethod · 0.80

Calls 2

nextPowerOfTwoFunction · 0.85
rebindClass · 0.50

Tested by

no test coverage detected