Java Code Examples for org.datavec.api.split.partition.Partitioner#init()

The following examples show how to use org.datavec.api.split.partition.Partitioner#init() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PartitionerTests.java    From DataVec with Apache License 2.0 6 votes vote down vote up
@Test
public void testInputAddFile() throws Exception {
    Partitioner partitioner = new NumberOfRecordsPartitioner();
    File tmpDir = Files.createTempDir();
    FileSplit fileSplit = new FileSplit(tmpDir);
    assertTrue(fileSplit.needsBootstrapForWrite());
    fileSplit.bootStrapForWrite();
    Configuration configuration = new Configuration();
    configuration.set(NumberOfRecordsPartitioner.RECORDS_PER_FILE_CONFIG,String.valueOf(5));
    partitioner.init(configuration,fileSplit);
    partitioner.updatePartitionInfo(PartitionMetaData.builder().numRecordsUpdated(5).build());
    assertTrue(partitioner.needsNewPartition());
    OutputStream os = partitioner.openNewStream();
    os.close();
    assertNotNull(os);
    //run more than once to ensure output stream creation works properly
    partitioner.updatePartitionInfo(PartitionMetaData.builder().numRecordsUpdated(5).build());
    os = partitioner.openNewStream();
    os.close();
    assertNotNull(os);


}
 
Example 2
Source File: PartitionerTests.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Test
public void testInputAddFile() throws Exception {
    Partitioner partitioner = new NumberOfRecordsPartitioner();
    File tmpDir = Files.createTempDir();
    FileSplit fileSplit = new FileSplit(tmpDir);
    assertTrue(fileSplit.needsBootstrapForWrite());
    fileSplit.bootStrapForWrite();
    Configuration configuration = new Configuration();
    configuration.set(NumberOfRecordsPartitioner.RECORDS_PER_FILE_CONFIG,String.valueOf(5));
    partitioner.init(configuration,fileSplit);
    partitioner.updatePartitionInfo(PartitionMetaData.builder().numRecordsUpdated(5).build());
    assertTrue(partitioner.needsNewPartition());
    OutputStream os = partitioner.openNewStream();
    os.close();
    assertNotNull(os);
    //run more than once to ensure output stream creation works properly
    partitioner.updatePartitionInfo(PartitionMetaData.builder().numRecordsUpdated(5).build());
    os = partitioner.openNewStream();
    os.close();
    assertNotNull(os);


}
 
Example 3
Source File: ExcelRecordWriter.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(InputSplit inputSplit, Partitioner partitioner) throws Exception {
    this.conf = new Configuration();
    this.partitioner = partitioner;
    partitioner.init(inputSplit);
    out = new DataOutputStream(partitioner.currentOutputStream());
    initPoi();


}
 
Example 4
Source File: ExcelRecordWriter.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration configuration, InputSplit split, Partitioner partitioner) throws Exception {
    this.workBookName = configuration.get(WORKSHEET_NAME,DEFAULT_WORKSHEET_NAME);
    this.fileTypeToUse = configuration.get(FILE_TYPE,DEFAULT_FILE_TYPE);
    this.conf = configuration;
    partitioner.init(split);
    out = new DataOutputStream(partitioner.currentOutputStream());
    initPoi();
}
 
Example 5
Source File: FileRecordWriter.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(InputSplit inputSplit, Partitioner partitioner) throws Exception {
    partitioner.init(inputSplit);
    out = new DataOutputStream(partitioner.currentOutputStream());
    this.partitioner = partitioner;

}
 
Example 6
Source File: PartitionerTests.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Test
public void testRecordsPerFilePartition() {
    Partitioner partitioner = new NumberOfRecordsPartitioner();
    File tmpDir = Files.createTempDir();
    FileSplit fileSplit = new FileSplit(tmpDir);
    assertTrue(fileSplit.needsBootstrapForWrite());
    fileSplit.bootStrapForWrite();
    partitioner.init(fileSplit);
    assertEquals(1,partitioner.numPartitions());
}
 
Example 7
Source File: ExcelRecordWriter.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(InputSplit inputSplit, Partitioner partitioner) throws Exception {
    this.conf = new Configuration();
    this.partitioner = partitioner;
    partitioner.init(inputSplit);
    out = new DataOutputStream(partitioner.currentOutputStream());
    initPoi();


}
 
Example 8
Source File: ExcelRecordWriter.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration configuration, InputSplit split, Partitioner partitioner) throws Exception {
    this.workBookName = configuration.get(WORKSHEET_NAME,DEFAULT_WORKSHEET_NAME);
    this.fileTypeToUse = configuration.get(FILE_TYPE,DEFAULT_FILE_TYPE);
    this.conf = configuration;
    partitioner.init(split);
    out = new DataOutputStream(partitioner.currentOutputStream());
    initPoi();
}
 
Example 9
Source File: FileRecordWriter.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(InputSplit inputSplit, Partitioner partitioner) throws Exception {
    partitioner.init(inputSplit);
    out = new DataOutputStream(partitioner.currentOutputStream());
    this.partitioner = partitioner;

}
 
Example 10
Source File: PartitionerTests.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testRecordsPerFilePartition() {
    Partitioner partitioner = new NumberOfRecordsPartitioner();
    File tmpDir = Files.createTempDir();
    FileSplit fileSplit = new FileSplit(tmpDir);
    assertTrue(fileSplit.needsBootstrapForWrite());
    fileSplit.bootStrapForWrite();
    partitioner.init(fileSplit);
    assertEquals(1,partitioner.numPartitions());
}
 
Example 11
Source File: ArrowRecordWriter.java    From DataVec with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(InputSplit inputSplit, Partitioner partitioner) throws Exception {
    this.partitioner = partitioner;
    partitioner.init(inputSplit);

}
 
Example 12
Source File: FileRecordWriter.java    From DataVec with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Configuration configuration, InputSplit split, Partitioner partitioner) throws Exception {
    setConf(configuration);
    partitioner.init(configuration,split);
    initialize(split, partitioner);
}
 
Example 13
Source File: ArrowRecordWriter.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(InputSplit inputSplit, Partitioner partitioner) throws Exception {
    this.partitioner = partitioner;
    partitioner.init(inputSplit);

}
 
Example 14
Source File: FileRecordWriter.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Configuration configuration, InputSplit split, Partitioner partitioner) throws Exception {
    setConf(configuration);
    partitioner.init(configuration, split);
    initialize(split, partitioner);
}