Sha256: e9c8c38cd746ea2195b72e52f763ce5245b90eb9ced8ad6043d95b698df5c0e4

Contents?: true

Size: 1.69 KB

Versions: 84

Compression:

Stored size: 1.69 KB

Contents

package org.embulk.standards;

import java.io.InputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
import org.embulk.config.Task;
import org.embulk.config.TaskSource;
import org.embulk.config.ConfigSource;
import org.embulk.config.ConfigInject;
import org.embulk.spi.DecoderPlugin;
import org.embulk.spi.BufferAllocator;
import org.embulk.spi.FileInput;
import org.embulk.spi.util.FileInputInputStream;
import org.embulk.spi.util.InputStreamFileInput;

public class GzipFileDecoderPlugin
        implements DecoderPlugin
{
    public interface PluginTask
            extends Task
    {
        @ConfigInject
        BufferAllocator getBufferAllocator();
    }

    @Override
    public void transaction(ConfigSource config, DecoderPlugin.Control control)
    {
        PluginTask task = config.loadConfig(PluginTask.class);
        control.run(task.dump());
    }

    @Override
    public FileInput open(TaskSource taskSource, FileInput fileInput)
    {
        PluginTask task = taskSource.loadTask(PluginTask.class);
        final FileInputInputStream files = new FileInputInputStream(fileInput);
        return new InputStreamFileInput(
                task.getBufferAllocator(),
                new InputStreamFileInput.Provider() {
                    public InputStream openNext() throws IOException
                    {
                        if (!files.nextFile()) {
                            return null;
                        }
                        return new GZIPInputStream(files, 8*1024);
                    }

                    public void close() throws IOException
                    {
                        files.close();
                    }
                });
    }
}

Version data entries

84 entries across 84 versions & 1 rubygems

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