Search in sources :

Example 46 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class GeoPointFieldBinding method extractFieldData.

@Override
public BaseModelData[] extractFieldData(BaseModelData[] dataArray, ColumnSet columnSet) {
    ColumnView latitude = columnSet.getColumnView(latExpr.asExpression());
    ColumnView longitude = columnSet.getColumnView(lonExpr.asExpression());
    for (int i = 0; i < columnSet.getNumRows(); i++) {
        if (!latitude.isMissing(i)) {
            dataArray[i].set(GEO_LATITUDE_COLUMN, latitude.getDouble(i));
        }
        if (!longitude.isMissing(i)) {
            dataArray[i].set(GEO_LONGITUDE_COLUMN, longitude.getDouble(i));
        }
    }
    return dataArray;
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView)

Example 47 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class CoalesceFunctionTest method combineDouble.

@Test
public void combineDouble() {
    DoubleArrayColumnView x = new DoubleArrayColumnView(new double[] { 80, NaN, 82, NaN, 84 });
    DoubleArrayColumnView y = new DoubleArrayColumnView(new double[] { 90, NaN, 92, 93, NaN });
    ColumnView z = CoalesceFunction.combineDouble(new ColumnView[] { x, y });
    assertThat(z.getDouble(0), equalTo(80.0));
    assertThat(z.getDouble(1), equalTo(NaN));
    assertThat(z.getDouble(2), equalTo(82.0));
    assertThat(z.getDouble(3), equalTo(93.0));
    assertThat(z.getDouble(4), equalTo(84.0));
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView) DoubleArrayColumnView(org.activityinfo.model.query.DoubleArrayColumnView) DoubleArrayColumnView(org.activityinfo.model.query.DoubleArrayColumnView) Test(org.junit.Test)

Example 48 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class CompactingDoubleColumnBuilderTest method comprehensiveByte8.

@Test
public void comprehensiveByte8() {
    CompactingDoubleColumnBuilder builder = new CompactingDoubleColumnBuilder(new PendingSlot<ColumnView>(), DUMMY);
    builder.onNext(Double.NaN);
    for (int i = 0; i < IntColumnView8.MAX_RANGE; i++) {
        builder.onNext(i);
    }
    ColumnView result = builder.build();
    assertThat(result, instanceOf(IntColumnView8.class));
    assertEquivalent(result, builder.buildDouble());
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView) Test(org.junit.Test)

Example 49 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class CompactingDoubleColumnBuilderTest method sparse.

@Test
public void sparse() {
    CompactingDoubleColumnBuilder builder = new CompactingDoubleColumnBuilder(new PendingSlot<ColumnView>(), DUMMY);
    for (int i = 0; i < 10_000; i++) {
        if (i == 3) {
            builder.onNext(44.5);
        } else if (i == 1431) {
            builder.onNext(1e6);
        } else {
            builder.onNext(Double.NaN);
        }
    }
    ColumnView result = builder.build();
    assertThat(result, instanceOf(SparseNumberColumnView.class));
    assertEquivalent(result, builder.buildDouble());
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView) Test(org.junit.Test)

Example 50 with ColumnView

use of org.activityinfo.model.query.ColumnView in project activityinfo by bedatadriven.

the class CompactingDoubleColumnBuilderTest method number16.

@Test
public void number16() {
    CompactingDoubleColumnBuilder builder = new CompactingDoubleColumnBuilder(new PendingSlot<ColumnView>(), DUMMY);
    builder.onNext(-10);
    builder.onNext(55);
    builder.onNext(31);
    builder.onNext(Double.NaN);
    builder.onNext(-3);
    builder.onNext(-23555);
    builder.onNext(3455);
    builder.onNext(0);
    ColumnView result = builder.build();
    assertThat(result, instanceOf(IntColumnView16.class));
    assertEquivalent(result, builder.buildDouble());
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView) Test(org.junit.Test)

Aggregations

ColumnView (org.activityinfo.model.query.ColumnView)67 ColumnSet (org.activityinfo.model.query.ColumnSet)22 Test (org.junit.Test)22 QueryModel (org.activityinfo.model.query.QueryModel)21 ColumnSetBuilder (org.activityinfo.store.query.server.ColumnSetBuilder)8 ResourceId (org.activityinfo.model.resource.ResourceId)7 NullFormSupervisor (org.activityinfo.store.query.shared.NullFormSupervisor)7 DoubleArrayColumnView (org.activityinfo.model.query.DoubleArrayColumnView)6 NullFormScanCache (org.activityinfo.store.query.shared.NullFormScanCache)6 DimensionCategory (org.activityinfo.legacy.shared.reports.content.DimensionCategory)5 FormClass (org.activityinfo.model.form.FormClass)5 FormTree (org.activityinfo.model.formTree.FormTree)5 FormulaNode (org.activityinfo.model.formula.FormulaNode)4 Nullable (javax.annotation.Nullable)3 FormulaSyntaxException (org.activityinfo.model.formula.diagnostic.FormulaSyntaxException)3 ColumnModel (org.activityinfo.model.query.ColumnModel)3 RecordRef (org.activityinfo.model.type.RecordRef)3 PrintWriter (java.io.PrintWriter)2 HashSet (java.util.HashSet)2 EntityCategory (org.activityinfo.legacy.shared.reports.content.EntityCategory)2