use of uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints in project Gaffer by gchq.
the class SampleDataForSplitPointsTest method shouldJSONSerialiseAndDeserialise.
@Test
public void shouldJSONSerialiseAndDeserialise() throws SerialisationException {
// Given
final Map<String, String> inputMapperPairs = new HashMap<>();
inputMapperPairs.put(INPUT_DIRECTORY, MapperGenerator.class.getName());
final String resultPath = "/result";
final SampleDataForSplitPoints op = new SampleDataForSplitPoints();
op.setInputMapperPairs(inputMapperPairs);
op.setValidate(true);
op.setProportionToSample(0.1f);
op.setSplitsFilePath(resultPath);
op.setNumMapTasks(5);
// When
byte[] json = JSONSerialiser.serialise(op, true);
final SampleDataForSplitPoints deserialisedOp = JSONSerialiser.deserialise(json, SampleDataForSplitPoints.class);
// Then
assertEquals(MapperGenerator.class.getName(), deserialisedOp.getInputMapperPairs().get(INPUT_DIRECTORY));
assertEquals(resultPath, deserialisedOp.getSplitsFilePath());
assertTrue(deserialisedOp.isValidate());
assertEquals(0.1f, deserialisedOp.getProportionToSample(), 1);
assertEquals(new Integer(5), deserialisedOp.getNumMapTasks());
assertEquals(new Integer(1), deserialisedOp.getNumReduceTasks());
}
use of uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints in project Gaffer by gchq.
the class SampleDataForSplitPointsTest method shouldShallowCloneOperation.
@Test
@Override
public void shouldShallowCloneOperation() {
// Given
final SampleDataForSplitPoints sampleDataForSplitPoints = new SampleDataForSplitPoints.Builder().addInputMapperPair(INPUT_DIRECTORY, MapperGenerator.class.getName()).splitsFilePath("/test").proportionToSample(0.1f).mappers(5).validate(true).option(TEST_OPTION_KEY, "true").build();
// When
SampleDataForSplitPoints clone = sampleDataForSplitPoints.shallowClone();
// Then
assertNotSame(sampleDataForSplitPoints, clone);
assertEquals(MapperGenerator.class.getName(), clone.getInputMapperPairs().get(INPUT_DIRECTORY));
assertEquals("true", clone.getOption(TEST_OPTION_KEY));
assertEquals("/test", clone.getSplitsFilePath());
assertTrue(clone.isValidate());
assertEquals(0.1f, clone.getProportionToSample(), 1);
assertEquals(new Integer(5), clone.getNumMapTasks());
}
use of uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints in project Gaffer by gchq.
the class SampleDataForSplitPointsTest method builderShouldCreatePopulatedOperation.
@Test
@Override
public void builderShouldCreatePopulatedOperation() {
final SampleDataForSplitPoints sampleDataForSplitPoints = new SampleDataForSplitPoints.Builder().addInputMapperPair(INPUT_DIRECTORY, MapperGenerator.class.getName()).splitsFilePath("/test").proportionToSample(0.1f).mappers(5).validate(true).option(TEST_OPTION_KEY, "true").build();
assertEquals(MapperGenerator.class.getName(), sampleDataForSplitPoints.getInputMapperPairs().get(INPUT_DIRECTORY));
assertEquals("true", sampleDataForSplitPoints.getOption(TEST_OPTION_KEY));
assertEquals("/test", sampleDataForSplitPoints.getSplitsFilePath());
assertTrue(sampleDataForSplitPoints.isValidate());
assertEquals(0.1f, sampleDataForSplitPoints.getProportionToSample(), 1);
assertEquals(new Integer(5), sampleDataForSplitPoints.getNumMapTasks());
}
use of uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints in project Gaffer by gchq.
the class SampleDataForSplitPointsTest method expectIllegalArgumentExceptionWhenTryingToSetReducers.
@Test
public void expectIllegalArgumentExceptionWhenTryingToSetReducers() {
final SampleDataForSplitPoints op = getTestObject();
assertThatIllegalArgumentException().isThrownBy(() -> op.setNumReduceTasks(10)).extracting("message").isNotNull();
}
use of uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints in project Gaffer by gchq.
the class SampleDataForSplitPointsTest method shouldShallowCloneOperationWithMinAndMaxMappers.
@Test
public void shouldShallowCloneOperationWithMinAndMaxMappers() {
// Given
final SampleDataForSplitPoints sampleDataForSplitPoints = new SampleDataForSplitPoints.Builder().addInputMapperPair(INPUT_DIRECTORY, MapperGenerator.class.getName()).splitsFilePath("/test").proportionToSample(0.1f).maxMappers(10).minMappers(2).validate(true).option(TEST_OPTION_KEY, "true").build();
// When
SampleDataForSplitPoints clone = sampleDataForSplitPoints.shallowClone();
// Then
assertEquals(MapperGenerator.class.getName(), clone.getInputMapperPairs().get(INPUT_DIRECTORY));
assertEquals("true", clone.getOption(TEST_OPTION_KEY));
assertEquals("/test", clone.getSplitsFilePath());
assertTrue(clone.isValidate());
assertEquals(0.1f, clone.getProportionToSample(), 1);
assertEquals(new Integer(10), clone.getMaxMapTasks());
assertEquals(new Integer(2), clone.getMinMapTasks());
}
Aggregations