Search in sources :

Example 1 with DynamicSourceSplit

use of com.google.api.services.dataflow.model.DynamicSourceSplit in project beam by apache.

the class WorkerCustomSourcesTest method testNegativeEstimatedSizesNotSet.

@Test
public void testNegativeEstimatedSizesNotSet() throws Exception {
    WorkerCustomSources.BoundedSourceSplit<Integer> boundedSourceSplit = new WorkerCustomSources.BoundedSourceSplit<Integer>(new SourceProducingNegativeEstimatedSizes(), new SourceProducingNegativeEstimatedSizes());
    DynamicSourceSplit dynamicSourceSplit = WorkerCustomSources.toSourceSplit(boundedSourceSplit);
    assertNull(dynamicSourceSplit.getPrimary().getSource().getMetadata().getEstimatedSizeBytes());
    assertNull(dynamicSourceSplit.getResidual().getSource().getMetadata().getEstimatedSizeBytes());
}
Also used : DynamicSourceSplit(com.google.api.services.dataflow.model.DynamicSourceSplit) Test(org.junit.Test)

Example 2 with DynamicSourceSplit

use of com.google.api.services.dataflow.model.DynamicSourceSplit in project beam by apache.

the class WorkerCustomSources method toSourceSplit.

public static DynamicSourceSplit toSourceSplit(BoundedSourceSplit<?> sourceSplitResult) {
    DynamicSourceSplit sourceSplit = new DynamicSourceSplit();
    com.google.api.services.dataflow.model.Source primarySource;
    com.google.api.services.dataflow.model.Source residualSource;
    try {
        primarySource = serializeSplitToCloudSource(sourceSplitResult.primary);
        residualSource = serializeSplitToCloudSource(sourceSplitResult.residual);
    } catch (Exception e) {
        throw new RuntimeException("Failed to serialize one of the parts of the source split", e);
    }
    sourceSplit.setPrimary(new DerivedSource().setDerivationMode("SOURCE_DERIVATION_MODE_INDEPENDENT").setSource(primarySource));
    sourceSplit.setResidual(new DerivedSource().setDerivationMode("SOURCE_DERIVATION_MODE_INDEPENDENT").setSource(residualSource));
    return sourceSplit;
}
Also used : DerivedSource(com.google.api.services.dataflow.model.DerivedSource) DynamicSourceSplit(com.google.api.services.dataflow.model.DynamicSourceSplit) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException)

Aggregations

DynamicSourceSplit (com.google.api.services.dataflow.model.DynamicSourceSplit)2 DerivedSource (com.google.api.services.dataflow.model.DerivedSource)1 IOException (java.io.IOException)1 NoSuchElementException (java.util.NoSuchElementException)1 Test (org.junit.Test)1