Sha256: 8f9e22ab305180a9717c3db388d33cad2a7a5eeb46ceffeb06a4c159d1e17423

Contents?: true

Size: 1.47 KB

Versions: 116

Compression:

Stored size: 1.47 KB

Contents

package org.embulk.spi.util;

import java.util.Iterator;
import java.util.NoSuchElementException;

import org.embulk.spi.Exec;
import org.embulk.spi.FileInput;
import org.embulk.spi.Buffer;
import org.embulk.spi.time.Timestamp;
import org.embulk.spi.time.TimestampFormatter;
import org.joda.time.DateTimeZone;

public class Inputs
{
    private static abstract class AbstractPollIterator <E>
            implements Iterator<E>
    {
        private E next;

        protected abstract E poll();

        @Override
        public boolean hasNext()
        {
            if (next != null) {
                return true;
            } else {
                next = poll();
                return next != null;
            }
        }

        @Override
        public E next()
        {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            E l = next;
            next = null;
            return l;
        }

        @Override
        public void remove()
        {
            throw new UnsupportedOperationException();
        }
    }

    public static Iterable<Buffer> each(final FileInput input)
    {
        return new Iterable<Buffer>() {
            public Iterator<Buffer> iterator()
            {
                return new AbstractPollIterator<Buffer>() {
                    public Buffer poll()
                    {
                        return input.poll();
                    }
                };
            }
        };
    }
}

Version data entries

116 entries across 116 versions & 1 rubygems

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