Search in sources :

Example 1 with SampleDataForSplitPoints

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());
}
Also used : HashMap(java.util.HashMap) MapperGenerator(uk.gov.gchq.gaffer.hdfs.operation.mapper.generator.MapperGenerator) SampleDataForSplitPoints(uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 2 with SampleDataForSplitPoints

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());
}
Also used : MapperGenerator(uk.gov.gchq.gaffer.hdfs.operation.mapper.generator.MapperGenerator) SampleDataForSplitPoints(uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 3 with SampleDataForSplitPoints

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());
}
Also used : MapperGenerator(uk.gov.gchq.gaffer.hdfs.operation.mapper.generator.MapperGenerator) SampleDataForSplitPoints(uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 4 with SampleDataForSplitPoints

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();
}
Also used : SampleDataForSplitPoints(uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 5 with SampleDataForSplitPoints

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());
}
Also used : MapperGenerator(uk.gov.gchq.gaffer.hdfs.operation.mapper.generator.MapperGenerator) SampleDataForSplitPoints(uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)5 SampleDataForSplitPoints (uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints)5 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)5 MapperGenerator (uk.gov.gchq.gaffer.hdfs.operation.mapper.generator.MapperGenerator)4 HashMap (java.util.HashMap)1