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.29 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.29-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.28 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.28-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.27 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.27-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.26 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.26-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.25 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.25-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.24 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.24-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.23 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.23-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.22 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.22-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.21 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.21-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.20 embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java
embulk-0.8.20-java embulk-standards/src/main/java/org/embulk/standards/GzipFileDecoderPlugin.java