use of uk.gov.gchq.gaffer.parquetstore.operation.handler.utilities.AggregateGafferRowsFunction in project Gaffer by gchq.
the class AggregateGafferRowsFunctionTest method mergeEntityRowsTest.
@Test
public void mergeEntityRowsTest() throws OperationException, IOException {
final String group = "BasicEntity";
final SchemaElementDefinition elementSchema = utils.getGafferSchema().getElement(group);
final GafferGroupObjectConverter converter = utils.getConverter(group);
final String[] gafferProperties = new String[elementSchema.getProperties().size()];
elementSchema.getProperties().toArray(gafferProperties);
final byte[] aggregatorJson = JSONSerialiser.serialise(elementSchema.getIngestAggregator());
final AggregateGafferRowsFunction aggregator = new AggregateGafferRowsFunction(gafferProperties, true, elementSchema.getGroupBy(), utils.getColumnToPaths(group), aggregatorJson, converter);
final GenericRowWithSchema row1 = DataGen.generateEntityRow(utils, group, "vertex", (byte) 'a', 0.2, 3f, TestUtils.getTreeSet1(), 5L, (short) 6, TestUtils.DATE, TestUtils.getFreqMap1(), null);
final GenericRowWithSchema row2 = DataGen.generateEntityRow(utils, group, "vertex", (byte) 'c', 0.7, 4f, TestUtils.getTreeSet2(), 7L, (short) 4, TestUtils.DATE, TestUtils.getFreqMap2(), null);
final Row merged = aggregator.call(row1, row2);
final List<Object> actual = new ArrayList<>(11);
for (int i = 0; i < merged.length(); i++) {
actual.add(merged.apply(i));
}
final List<Object> expected = new ArrayList<>(11);
expected.add("vertex");
expected.add(new byte[] { (byte) 'c' });
expected.add(0.8999999999999999);
expected.add(7f);
expected.add(new String[] { "A", "B", "C" });
expected.add(12L);
expected.add(10);
expected.add(TestUtils.DATE.getTime());
expected.add(JavaConversions$.MODULE$.mapAsScalaMap(TestUtils.MERGED_FREQMAP));
expected.add(2);
assertThat(expected).containsExactly(actual.toArray());
}
use of uk.gov.gchq.gaffer.parquetstore.operation.handler.utilities.AggregateGafferRowsFunction in project Gaffer by gchq.
the class AggregateGafferRowsFunctionTest method mergeEdgeRowsTest.
@Test
public void mergeEdgeRowsTest() throws OperationException, SerialisationException {
final String group = "BasicEdge";
final SchemaElementDefinition elementSchema = utils.getGafferSchema().getElement(group);
final byte[] aggregatorJson = JSONSerialiser.serialise(elementSchema.getIngestAggregator());
final GafferGroupObjectConverter converter = utils.getConverter(group);
final String[] gafferProperties = new String[elementSchema.getProperties().size()];
elementSchema.getProperties().toArray(gafferProperties);
final AggregateGafferRowsFunction aggregator = new AggregateGafferRowsFunction(gafferProperties, false, elementSchema.getGroupBy(), utils.getColumnToPaths(group), aggregatorJson, converter);
final GenericRowWithSchema row1 = DataGen.generateEdgeRow(utils, group, "src", "dst", true, (byte) 'a', 0.2, 3f, TestUtils.getTreeSet1(), 5L, (short) 6, TestUtils.DATE, TestUtils.getFreqMap1(), null);
final GenericRowWithSchema row2 = DataGen.generateEdgeRow(utils, group, "src", "dst", true, (byte) 'c', 0.7, 4f, TestUtils.getTreeSet2(), 7L, (short) 4, TestUtils.DATE, TestUtils.getFreqMap2(), null);
final Row merged = aggregator.call(row1, row2);
final List<Object> actual = new ArrayList<>(13);
for (int i = 0; i < merged.length(); i++) {
actual.add(merged.apply(i));
}
final List<Object> expected = new ArrayList<>(13);
expected.add("src");
expected.add("dst");
expected.add(true);
expected.add(new byte[] { (byte) 'c' });
expected.add(0.8999999999999999);
expected.add(7f);
expected.add(new String[] { "A", "B", "C" });
expected.add(12L);
expected.add(10);
expected.add(TestUtils.DATE.getTime());
expected.add(JavaConversions$.MODULE$.mapAsScalaMap(TestUtils.MERGED_FREQMAP));
expected.add(2);
assertThat(expected).containsExactly(actual.toArray());
}
Aggregations