Search in sources :

Example 1 with DoubleArrayList

use of it.unimi.dsi.fastutil.doubles.DoubleArrayList in project pinot by linkedin.

the class PercentileMVAggregationFunction method aggregate.

@Override
public void aggregate(int length, @Nonnull AggregationResultHolder aggregationResultHolder, @Nonnull BlockValSet... blockValSets) {
    double[][] valuesArray = blockValSets[0].getDoubleValuesMV();
    DoubleArrayList doubleArrayList = aggregationResultHolder.getResult();
    if (doubleArrayList == null) {
        doubleArrayList = new DoubleArrayList();
        aggregationResultHolder.setValue(doubleArrayList);
    }
    for (int i = 0; i < length; i++) {
        for (double value : valuesArray[i]) {
            doubleArrayList.add(value);
        }
    }
}
Also used : DoubleArrayList(it.unimi.dsi.fastutil.doubles.DoubleArrayList)

Example 2 with DoubleArrayList

use of it.unimi.dsi.fastutil.doubles.DoubleArrayList in project pinot by linkedin.

the class PercentileAggregationFunction method aggregateGroupByMV.

@Override
public void aggregateGroupByMV(int length, @Nonnull int[][] groupKeysArray, @Nonnull GroupByResultHolder groupByResultHolder, @Nonnull BlockValSet... blockValSets) {
    double[] valueArray = blockValSets[0].getDoubleValuesSV();
    for (int i = 0; i < length; i++) {
        double value = valueArray[i];
        for (int groupKey : groupKeysArray[i]) {
            DoubleArrayList doubleArrayList = groupByResultHolder.getResult(groupKey);
            if (doubleArrayList == null) {
                doubleArrayList = new DoubleArrayList();
                groupByResultHolder.setValueForKey(groupKey, doubleArrayList);
            }
            doubleArrayList.add(value);
        }
    }
}
Also used : DoubleArrayList(it.unimi.dsi.fastutil.doubles.DoubleArrayList)

Example 3 with DoubleArrayList

use of it.unimi.dsi.fastutil.doubles.DoubleArrayList in project pinot by linkedin.

the class PercentileAggregationFunction method aggregate.

@Override
public void aggregate(int length, @Nonnull AggregationResultHolder aggregationResultHolder, @Nonnull BlockValSet... blockValSets) {
    double[] valueArray = blockValSets[0].getDoubleValuesSV();
    DoubleArrayList doubleArrayList = aggregationResultHolder.getResult();
    if (doubleArrayList == null) {
        doubleArrayList = new DoubleArrayList();
        aggregationResultHolder.setValue(doubleArrayList);
    }
    for (int i = 0; i < length; i++) {
        doubleArrayList.add(valueArray[i]);
    }
}
Also used : DoubleArrayList(it.unimi.dsi.fastutil.doubles.DoubleArrayList)

Example 4 with DoubleArrayList

use of it.unimi.dsi.fastutil.doubles.DoubleArrayList in project pinot by linkedin.

the class ObjectCustomSerDeTest method testDoubleArrayList.

/**
   * Test for ser/de of {@link DoubleArrayList}.
   */
@Test
public void testDoubleArrayList() throws IOException {
    for (int i = 0; i < NUM_ITERATIONS; i++) {
        int size = RANDOM.nextInt(100);
        DoubleArrayList expected = new DoubleArrayList(size);
        for (int j = 0; j < size; j++) {
            expected.add(RANDOM.nextDouble());
        }
        byte[] bytes = ObjectCustomSerDe.serialize(expected);
        DoubleArrayList actual = ObjectCustomSerDe.deserialize(bytes, ObjectType.DoubleArrayList);
        Assert.assertEquals(actual, expected, ERROR_MESSAGE);
    }
}
Also used : DoubleArrayList(it.unimi.dsi.fastutil.doubles.DoubleArrayList) Test(org.testng.annotations.Test)

Example 5 with DoubleArrayList

use of it.unimi.dsi.fastutil.doubles.DoubleArrayList in project angel by Tencent.

the class CooLongDoubleMatrix method getRow.

@Override
public Vector getRow(int idx) {
    LongArrayList cols = new LongArrayList();
    DoubleArrayList data = new DoubleArrayList();
    for (int i = 0; i < rowIndices.length; i++) {
        if (rowIndices[i] == idx) {
            cols.add(colIndices[i]);
            data.add(values[i]);
        }
    }
    LongDoubleSparseVectorStorage storage = new LongDoubleSparseVectorStorage(shape[1], cols.toLongArray(), data.toDoubleArray());
    return new LongDoubleVector(getMatrixId(), idx, getClock(), shape[1], storage);
}
Also used : LongDoubleVector(com.tencent.angel.ml.math2.vector.LongDoubleVector) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) LongDoubleSparseVectorStorage(com.tencent.angel.ml.math2.storage.LongDoubleSparseVectorStorage) DoubleArrayList(it.unimi.dsi.fastutil.doubles.DoubleArrayList)

Aggregations

DoubleArrayList (it.unimi.dsi.fastutil.doubles.DoubleArrayList)14 IntDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSparseVectorStorage)4 IntDoubleVector (com.tencent.angel.ml.math2.vector.IntDoubleVector)4 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)4 LongDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleSparseVectorStorage)2 LongDoubleVector (com.tencent.angel.ml.math2.vector.LongDoubleVector)2 LongArrayList (it.unimi.dsi.fastutil.longs.LongArrayList)2 ByteBuffer (java.nio.ByteBuffer)1 Test (org.testng.annotations.Test)1