Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
Gh-1068: Fix alpha6 (#1069)
Browse files Browse the repository at this point in the history
* Fixed CommonConstant and ToCsv

* Spotless apply
  • Loading branch information
t92549 authored May 12, 2023
1 parent a0d1388 commit 0e815f4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -13,23 +13,22 @@
* 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;
import org.apache.hadoop.io.BytesWritable;
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;

Expand All @@ -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));
}

Expand Down
4 changes: 2 additions & 2 deletions python-shell/src/gafferpy_examples/Gaffer-Python-Demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion python-shell/src/gafferpy_examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions python-shell/src/test/test_gaffer_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 0e815f4

Please sign in to comment.