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;
}
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));
}
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());
}
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());
}
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());
}
Aggregations