use of uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile in project Gaffer by gchq.
the class AccumuloAddElementsFromHdfsJobFactoryTest method shouldSetNumberOfReducersBetweenMinAndMaxSpecified.
@Test
public void shouldSetNumberOfReducersBetweenMinAndMaxSpecified() throws IOException, StoreException, OperationException {
// Given
store.initialise("graphId", SCHEMA, PROPERTIES);
final JobConf localConf = createLocalConf();
final FileSystem fs = FileSystem.getLocal(localConf);
fs.mkdirs(new Path(outputDir));
fs.mkdirs(new Path(splitsDir));
final BufferedWriter writer = new BufferedWriter(new FileWriter(splitsFile));
for (int i = 100; i < 200; i++) {
writer.write(i + "\n");
}
writer.close();
final SplitStoreFromFile splitTable = new SplitStoreFromFile.Builder().inputPath(splitsFile).build();
store.execute(splitTable, new Context(new User()));
final AccumuloAddElementsFromHdfsJobFactory factory = getJobFactory();
final Job job = Job.getInstance(localConf);
// When
AddElementsFromHdfs operation = new AddElementsFromHdfs.Builder().outputPath(outputDir).addInputMapperPair(inputDir, TextMapperGeneratorImpl.class.getName()).minReducers(10).maxReducers(20).splitsFilePath("target/data/splits.txt").build();
factory.setupJob(job, operation, TextMapperGeneratorImpl.class.getName(), store);
// Then
assertTrue(job.getNumReduceTasks() >= 10);
assertTrue(job.getNumReduceTasks() <= 20);
// When
operation = new AddElementsFromHdfs.Builder().outputPath(outputDir).addInputMapperPair(inputDir, TextMapperGeneratorImpl.class.getName()).minReducers(100).maxReducers(200).splitsFilePath("target/data/splits.txt").build();
factory.setupJob(job, operation, TextMapperGeneratorImpl.class.getName(), store);
// Then
assertTrue(job.getNumReduceTasks() >= 100);
assertTrue(job.getNumReduceTasks() <= 200);
// When
operation = new AddElementsFromHdfs.Builder().outputPath(outputDir).addInputMapperPair(inputDir, TextMapperGeneratorImpl.class.getName()).minReducers(1000).maxReducers(2000).splitsFilePath("target/data/splits.txt").build();
factory.setupJob(job, operation, TextMapperGeneratorImpl.class.getName(), store);
// Then
assertTrue(job.getNumReduceTasks() >= 1000);
assertTrue(job.getNumReduceTasks() <= 2000);
}
use of uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile in project Gaffer by gchq.
the class AccumuloAddElementsFromHdfsJobFactoryTest method shouldSetNoMoreThanMaxNumberOfReducersSpecified.
@Test
public void shouldSetNoMoreThanMaxNumberOfReducersSpecified() throws IOException, StoreException, OperationException {
// Given
store.initialise("graphId", SCHEMA, PROPERTIES);
final JobConf localConf = createLocalConf();
final FileSystem fs = FileSystem.getLocal(localConf);
fs.mkdirs(new Path(outputDir));
fs.mkdirs(new Path(splitsDir));
final BufferedWriter writer = new BufferedWriter(new FileWriter(splitsFile.toString()));
for (int i = 100; i < 200; i++) {
writer.write(i + "\n");
}
writer.close();
final SplitStoreFromFile splitTable = new SplitStoreFromFile.Builder().inputPath(splitsFile.toString()).build();
store.execute(splitTable, new Context(new User()));
final AccumuloAddElementsFromHdfsJobFactory factory = getJobFactory();
final Job job = Job.getInstance(localConf);
// When
AddElementsFromHdfs operation = new AddElementsFromHdfs.Builder().outputPath(outputDir.toString()).addInputMapperPair(inputDir.toString(), TextMapperGeneratorImpl.class.getName()).maxReducers(10).splitsFilePath("target/data/splits.txt").build();
factory.setupJob(job, operation, TextMapperGeneratorImpl.class.getName(), store);
// Then
assertTrue(job.getNumReduceTasks() <= 10);
// When
operation = new AddElementsFromHdfs.Builder().outputPath(outputDir.toString()).addInputMapperPair(inputDir.toString(), TextMapperGeneratorImpl.class.getName()).maxReducers(100).splitsFilePath("target/data/splits.txt").build();
factory.setupJob(job, operation, TextMapperGeneratorImpl.class.getName(), store);
// Then
assertTrue(job.getNumReduceTasks() <= 100);
// When
operation = new AddElementsFromHdfs.Builder().outputPath(outputDir.toString()).addInputMapperPair(inputDir.toString(), TextMapperGeneratorImpl.class.getName()).maxReducers(1000).splitsFilePath("target/data/splits.txt").build();
factory.setupJob(job, operation, TextMapperGeneratorImpl.class.getName(), store);
// Then
assertTrue(job.getNumReduceTasks() <= 1000);
}
Aggregations