use of org.apache.apex.malhar.lib.appdata.gpo.GPOMutable in project apex-malhar by apache.
the class AggregatorMin method aggregate.
@Override
public void aggregate(Aggregate dest, InputEvent src) {
GPOMutable destAggs = dest.getAggregates();
GPOMutable srcAggs = src.getAggregates();
{
byte[] destByte = destAggs.getFieldsByte();
if (destByte != null) {
byte[] srcByte = srcAggs.getFieldsByte();
int[] srcIndices = context.indexSubsetAggregates.fieldsByteIndexSubset;
for (int index = 0; index < destByte.length; index++) {
byte tempVal = srcByte[srcIndices[index]];
if (destByte[index] > tempVal) {
destByte[index] = tempVal;
}
}
}
}
{
short[] destShort = destAggs.getFieldsShort();
if (destShort != null) {
short[] srcShort = srcAggs.getFieldsShort();
int[] srcIndices = context.indexSubsetAggregates.fieldsShortIndexSubset;
for (int index = 0; index < destShort.length; index++) {
short tempVal = srcShort[srcIndices[index]];
if (destShort[index] > tempVal) {
destShort[index] = tempVal;
}
}
}
}
{
int[] destInteger = destAggs.getFieldsInteger();
if (destInteger != null) {
int[] srcInteger = srcAggs.getFieldsInteger();
int[] srcIndices = context.indexSubsetAggregates.fieldsIntegerIndexSubset;
for (int index = 0; index < destInteger.length; index++) {
int tempVal = srcInteger[srcIndices[index]];
if (destInteger[index] > tempVal) {
destInteger[index] = tempVal;
}
}
}
}
{
long[] destLong = destAggs.getFieldsLong();
if (destLong != null) {
long[] srcLong = srcAggs.getFieldsLong();
int[] srcIndices = context.indexSubsetAggregates.fieldsLongIndexSubset;
for (int index = 0; index < destLong.length; index++) {
long tempVal = srcLong[srcIndices[index]];
if (destLong[index] > tempVal) {
destLong[index] = tempVal;
}
}
}
}
{
float[] destFloat = destAggs.getFieldsFloat();
if (destFloat != null) {
float[] srcFloat = srcAggs.getFieldsFloat();
int[] srcIndices = context.indexSubsetAggregates.fieldsFloatIndexSubset;
for (int index = 0; index < destFloat.length; index++) {
float tempVal = srcFloat[srcIndices[index]];
if (destFloat[index] > tempVal) {
destFloat[index] = tempVal;
}
}
}
}
{
double[] destDouble = destAggs.getFieldsDouble();
if (destDouble != null) {
double[] srcDouble = srcAggs.getFieldsDouble();
int[] srcIndices = context.indexSubsetAggregates.fieldsDoubleIndexSubset;
for (int index = 0; index < destDouble.length; index++) {
double tempVal = srcDouble[srcIndices[index]];
if (destDouble[index] > tempVal) {
destDouble[index] = tempVal;
}
}
}
}
}
use of org.apache.apex.malhar.lib.appdata.gpo.GPOMutable in project apex-malhar by apache.
the class AggregatorMin method aggregate.
@Override
public void aggregate(Aggregate dest, Aggregate src) {
GPOMutable destAggs = dest.getAggregates();
GPOMutable srcAggs = src.getAggregates();
{
byte[] destByte = destAggs.getFieldsByte();
if (destByte != null) {
byte[] srcByte = srcAggs.getFieldsByte();
for (int index = 0; index < destByte.length; index++) {
if (destByte[index] > srcByte[index]) {
destByte[index] = srcByte[index];
}
}
}
}
{
short[] destShort = destAggs.getFieldsShort();
if (destShort != null) {
short[] srcShort = srcAggs.getFieldsShort();
for (int index = 0; index < destShort.length; index++) {
if (destShort[index] > srcShort[index]) {
destShort[index] = srcShort[index];
}
}
}
}
{
int[] destInteger = destAggs.getFieldsInteger();
if (destInteger != null) {
int[] srcInteger = srcAggs.getFieldsInteger();
for (int index = 0; index < destInteger.length; index++) {
if (destInteger[index] > srcInteger[index]) {
destInteger[index] = srcInteger[index];
}
}
}
}
{
long[] destLong = destAggs.getFieldsLong();
if (destLong != null) {
long[] srcLong = srcAggs.getFieldsLong();
for (int index = 0; index < destLong.length; index++) {
if (destLong[index] > srcLong[index]) {
destLong[index] = srcLong[index];
}
}
}
}
{
float[] destFloat = destAggs.getFieldsFloat();
if (destFloat != null) {
float[] srcFloat = srcAggs.getFieldsFloat();
for (int index = 0; index < destFloat.length; index++) {
if (destFloat[index] > srcFloat[index]) {
destFloat[index] = srcFloat[index];
}
}
}
}
{
double[] destDouble = destAggs.getFieldsDouble();
if (destDouble != null) {
double[] srcDouble = srcAggs.getFieldsDouble();
for (int index = 0; index < destDouble.length; index++) {
if (destDouble[index] > srcDouble[index]) {
destDouble[index] = srcDouble[index];
}
}
}
}
}
use of org.apache.apex.malhar.lib.appdata.gpo.GPOMutable in project apex-malhar by apache.
the class AbstractAppDataSnapshotServer method processData.
protected void processData(List<INPUT_EVENT> rows) {
currentData.clear();
for (INPUT_EVENT inputEvent : rows) {
GPOMutable gpoRow = convert(inputEvent);
currentData.add(gpoRow);
}
}
use of org.apache.apex.malhar.lib.appdata.gpo.GPOMutable in project apex-malhar by apache.
the class DimensionsEventTest method eventKeyEqualsHashCodeTest.
@Test
public void eventKeyEqualsHashCodeTest() {
Map<String, Type> fieldToTypeA = Maps.newHashMap();
fieldToTypeA.put("a", Type.LONG);
fieldToTypeA.put("b", Type.STRING);
FieldsDescriptor fdA = new FieldsDescriptor(fieldToTypeA);
GPOMutable gpoA = new GPOMutable(fdA);
gpoA.setField("a", 1L);
gpoA.setField("b", "hello");
EventKey eventKeyA = new EventKey(1, 1, 1, gpoA);
Map<String, Type> fieldToTypeB = Maps.newHashMap();
fieldToTypeB.put("a", Type.LONG);
fieldToTypeB.put("b", Type.STRING);
FieldsDescriptor fdB = new FieldsDescriptor(fieldToTypeB);
GPOMutable gpoB = new GPOMutable(fdB);
gpoB.setField("a", 1L);
gpoB.setField("b", "hello");
EventKey eventKeyB = new EventKey(1, 1, 1, gpoB);
Assert.assertEquals("The two hashcodes should equal", eventKeyA.hashCode(), eventKeyB.hashCode());
Assert.assertEquals("The two event keys should equal", eventKeyA, eventKeyB);
}
use of org.apache.apex.malhar.lib.appdata.gpo.GPOMutable in project apex-malhar by apache.
the class DataResultSnapshotSerializerTest method simpleCountdownTest.
@Test
public void simpleCountdownTest() throws Exception {
List<GPOMutable> dataValues = createValues();
DataQuerySnapshot gQuery = new DataQuerySnapshot("1", new Fields(Sets.newHashSet("a", "b")));
DataResultSnapshot result = new DataResultSnapshot(gQuery, dataValues, 2);
DataResultSnapshotSerializer serializer = new DataResultSnapshotSerializer();
String resultJSON = serializer.serialize(result, new ResultFormatter());
JSONObject rjo = new JSONObject(resultJSON);
long countdown = rjo.getLong(Result.FIELD_COUNTDOWN);
Assert.assertEquals(2, countdown);
}
Aggregations