From 0e815f4ebe74c599f89b652793672f6b8d7bc19d Mon Sep 17 00:00:00 2001 From: t92549 <80890692+t92549@users.noreply.github.com> Date: Fri, 12 May 2023 14:21:05 +0100 Subject: [PATCH] Gh-1068: Fix alpha6 (#1069) * Fixed CommonConstant and ToCsv * Spotless apply --- .../ingest/BytesWritableMapperGenerator.java | 18 ++++++------------ .../gafferpy_examples/Gaffer-Python-Demo.ipynb | 4 ++-- python-shell/src/gafferpy_examples/example.py | 2 +- .../src/test/test_gaffer_operations.py | 4 ++-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableMapperGenerator.java b/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableMapperGenerator.java index 0d92a4e86..42d17f2fb 100644 --- a/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableMapperGenerator.java +++ b/performance-testing/performance-testing-accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/BytesWritableMapperGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 Crown Copyright + * Copyright 2017-2023 Crown Copyright * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package uk.gov.gchq.gaffer.accumulostore.performancetesting.ingest; import org.apache.hadoop.conf.Configuration; @@ -20,16 +21,14 @@ import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.mapreduce.MapContext; -import uk.gov.gchq.gaffer.commonutil.CommonConstants; import uk.gov.gchq.gaffer.data.element.Element; -import uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException; import uk.gov.gchq.gaffer.data.generator.ElementGenerator; import uk.gov.gchq.gaffer.hdfs.operation.handler.job.factory.SampleDataForSplitPointsJobFactory; import uk.gov.gchq.gaffer.hdfs.operation.mapper.generator.MapperGenerator; import uk.gov.gchq.gaffer.store.schema.Schema; import uk.gov.gchq.gaffer.store.serialiser.ElementSerialiser; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -46,14 +45,9 @@ public BytesWritableMapperGenerator(final BytesWritableElementGenerator elementG } private void createElementGenerator(final Configuration conf) { - final Schema schema; - try { - schema = Schema.fromJson(conf - .get(SampleDataForSplitPointsJobFactory.SCHEMA) - .getBytes(CommonConstants.UTF_8)); - } catch (final UnsupportedEncodingException e) { - throw new SchemaException("Unable to deserialise Store Schema from JSON", e); - } + final Schema schema = Schema.fromJson(conf + .get(SampleDataForSplitPointsJobFactory.SCHEMA) + .getBytes(StandardCharsets.UTF_8)); this.elementGenerator = new BytesWritableElementGenerator(new ElementSerialiser(schema)); } diff --git a/python-shell/src/gafferpy_examples/Gaffer-Python-Demo.ipynb b/python-shell/src/gafferpy_examples/Gaffer-Python-Demo.ipynb index 16910ad31..72dde2c8c 100644 --- a/python-shell/src/gafferpy_examples/Gaffer-Python-Demo.ipynb +++ b/python-shell/src/gafferpy_examples/Gaffer-Python-Demo.ipynb @@ -269,7 +269,7 @@ " g.If( \n", " then=g.ToCsv( \n", " include_header=True, \n", - " element_generator=g.CsvGenerator( \n", + " csv_generator=g.CsvGenerator( \n", " quoted=False, \n", " constants={}, \n", " comma_replacement=\" \", \n", @@ -394,7 +394,7 @@ " g.If( \n", " then=g.ToCsv( \n", " include_header=True, \n", - " element_generator=g.CsvGenerator( \n", + " csv_generator=g.CsvGenerator( \n", " quoted=False, \n", " constants={}, \n", " comma_replacement=\" \", \n", diff --git a/python-shell/src/gafferpy_examples/example.py b/python-shell/src/gafferpy_examples/example.py index f4dc53a80..449cbad18 100755 --- a/python-shell/src/gafferpy_examples/example.py +++ b/python-shell/src/gafferpy_examples/example.py @@ -947,7 +947,7 @@ def complex_op_chain(gc): include_incoming_out_going=g.InOutType.OUT ), g.ToCsv( - element_generator=g.CsvGenerator( + csv_generator=g.CsvGenerator( fields={ 'VERTEX': 'Junction', 'busCount': 'Bus Count' diff --git a/python-shell/src/test/test_gaffer_operations.py b/python-shell/src/test/test_gaffer_operations.py index 2553f9285..74f302746 100755 --- a/python-shell/src/test/test_gaffer_operations.py +++ b/python-shell/src/test/test_gaffer_operations.py @@ -3012,7 +3012,7 @@ class GafferOperationsTest(unittest.TestCase): } ] }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToCsv", - "elementGenerator" : { + "csvGenerator" : { "class" : "uk.gov.gchq.gaffer.data.generator.CsvGenerator", "fields" : { "GROUP" : "Edge group", @@ -3040,7 +3040,7 @@ class GafferOperationsTest(unittest.TestCase): ), g.ToCsv( include_header=True, - element_generator=g.CsvGenerator( + csv_generator=g.CsvGenerator( fields={ 'GROUP': 'Edge group', 'VERTEX': 'vertex',