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.9 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.9-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.8 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.8-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.7 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.7-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.6 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.6-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.5 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.5-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.4 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.4-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.3 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.3-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.7.11 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.7.11-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.2 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.2-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.1 embulk-core/src/main/java/org/embulk/spi/util/Inputs.java
embulk-0.8.1-java embulk-core/src/main/java/org/embulk/spi/util/Inputs.java