java.lang.Object
org.apache.arrow.algorithm.misc.PartialSumUtils
Partial sum related utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
findPositionInPartialSumVector
(BaseIntVector partialSumVector, long value) Given a value and a partial sum vector, finds its position in the partial sum vector.static void
toDeltaVector
(BaseIntVector partialSumVector, BaseIntVector deltaVector) Converts an input vector to the delta vector.static void
toPartialSumVector
(BaseIntVector deltaVector, BaseIntVector partialSumVector, long sumBase) Converts an input vector to a partial sum vector.
-
Method Details
-
toPartialSumVector
public static void toPartialSumVector(BaseIntVector deltaVector, BaseIntVector partialSumVector, long sumBase) Converts an input vector to a partial sum vector. This is an inverse operation oftoDeltaVector(BaseIntVector, BaseIntVector)
. Suppose we have input vector a and output vector b. Then we have b(0) = sumBase; b(i + 1) = b(i) + a(i) (i = 0, 1, 2, ...).- Parameters:
deltaVector
- the input vector.partialSumVector
- the output vector.sumBase
- the base of the partial sums.
-
toDeltaVector
Converts an input vector to the delta vector. This is an inverse operation oftoPartialSumVector(BaseIntVector, BaseIntVector, long)
. Suppose we have input vector a and output vector b. Then we have b(i) = a(i + 1) - a(i) (i = 0, 1, 2, ...).- Parameters:
partialSumVector
- the input vector.deltaVector
- the output vector.
-
findPositionInPartialSumVector
Given a value and a partial sum vector, finds its position in the partial sum vector. In particular, given an integer value a and partial sum vector v, we try to find a position i, so that v(i) <= a < v(i + 1). The algorithm is based on binary search, so it takes O(log(n)) time, where n is the length of the partial sum vector.- Parameters:
partialSumVector
- the input partial sum vector.value
- the value to search.- Returns:
- the position in the partial sum vector, if any, or -1, if none is found.
-