Sha256: 25d90f6343af9822bc86d97b623a6e1a254f3a56458c30c8f5c1a255c3c994bc

Contents?: true

Size: 1.76 KB

Versions: 42

Compression:

Stored size: 1.76 KB

Contents

package org.embulk.test;

import org.embulk.config.ConfigDiff;
import org.embulk.config.ConfigSource;
import org.embulk.config.Task;
import org.embulk.config.TaskReport;
import org.embulk.config.TaskSource;
import org.embulk.exec.PreviewResult;
import org.embulk.spi.Exec;
import org.embulk.spi.InputPlugin;
import org.embulk.spi.Page;
import org.embulk.spi.PageOutput;
import org.embulk.spi.Schema;

import java.util.List;

import static com.google.common.base.Preconditions.checkState;

/**
 * This plugin is used for TestingEmbulk.InputBuilder.preview().
 */
public final class PreviewResultInputPlugin
        implements InputPlugin
{
    private static PreviewResult previewResult;

    public static void setPreviewResult(PreviewResult result)
    {
        previewResult = result;
    }

    @Override
    public ConfigDiff transaction(ConfigSource config, Control control)
    {
        checkState(previewResult != null, "PreviewResult object must be set");
        return resume(config.loadConfig(Task.class).dump(), previewResult.getSchema(), 1, control);
    }

    @Override
    public ConfigDiff resume(TaskSource taskSource, Schema schema, int taskCount, Control control)
    {
        control.run(taskSource, schema, taskCount);
        return Exec.newConfigDiff();
    }

    @Override
    public void cleanup(TaskSource taskSource, Schema schema, int taskCount, List<TaskReport> successTaskReports)
    {
    }

    @Override
    public TaskReport run(TaskSource taskSource, Schema schema, int taskIndex, PageOutput output)
    {
        for (Page page : previewResult.getPages()) {
            output.add(page);
        }
        return Exec.newTaskReport();
    }

    @Override
    public ConfigDiff guess(ConfigSource config)
    {
        return Exec.newConfigDiff();
    }
}

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
embulk-0.8.39 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.39-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.38 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.38-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.37 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.37-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.36 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.36-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.35 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.35-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.34 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.34-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.33 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.33-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.32 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.32-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.31 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.31-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.30 embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java
embulk-0.8.30-java embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java