Sha256: f862e3090fbe684e41ca1d865e0d309338c63b3d26fff0b5fcc4201ccf38df0a

Contents?: true

Size: 1.15 KB

Versions: 155

Compression:

Stored size: 1.15 KB

Contents

package org.embulk.spi.util;

import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import org.embulk.spi.Buffer;
import org.embulk.spi.FileInput;

public class ListFileInput
        implements FileInput
{
    private Iterator<? extends Iterable<Buffer>> files;
    private Iterator<Buffer> currentBuffers;

    public ListFileInput(Iterable<? extends Iterable<Buffer>> files)
    {
        this.files = files.iterator();
    }

    public boolean nextFile()
    {
        if (!files.hasNext()) {
            return false;
        }
        currentBuffers = files.next().iterator();
        return true;
    }

    public Buffer poll()
    {
        if (currentBuffers == null) {
            throw new IllegalStateException("FileInput.nextFile is not called");
        }
        if (!currentBuffers.hasNext()) {
            return null;
        }
        return currentBuffers.next();
    }

    public void close()
    {
        do {
            while (true) {
                Buffer b = poll();
                if (b == null) {
                    break;
                }
                b.release();
            }
        } while (nextFile());
    }
}

Version data entries

155 entries across 155 versions & 1 rubygems

Version Path
embulk-0.8.39 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.39-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.38 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.38-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.37 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.37-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.36 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.36-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.35 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.35-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.34 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.34-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.33 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.33-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.32 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.32-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.31 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.31-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.30 embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java
embulk-0.8.30-java embulk-core/src/main/java/org/embulk/spi/util/ListFileInput.java