All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.nosqlbench.virtdata.userlibs.streams.ByteBufferStreams Maven / Gradle / Ivy

There is a newer version: 4.15.102
Show newest version
package io.nosqlbench.virtdata.userlibs.streams;

import io.nosqlbench.virtdata.library.basics.shared.from_long.to_bytebuffer.HashedToByteBuffer;
import io.nosqlbench.virtdata.userlibs.streams.fillers.ChunkedByteBuffer;
import io.nosqlbench.virtdata.userlibs.streams.fillers.LongFunctionIterable;
import io.nosqlbench.virtdata.userlibs.streams.pojos.ByteBufferObject;
import org.jetbrains.annotations.NotNull;

import java.nio.ByteBuffer;
import java.util.Iterator;

public class ByteBufferStreams {


    public static Iterable byteBufferObjects(long startCycle, long endCycle, int bufsize) {
        HashedToByteBuffer htbb = new HashedToByteBuffer(bufsize);
        LongFunctionIterable bbi = new LongFunctionIterable<>(startCycle, endCycle, l -> new ByteBufferObject(htbb.apply(l)));
        return bbi;
//        LongFunctionIterable byteBuffers = new LongFunctionIterable<>(0L, new HashedToByteBuffer(bufsize));
    }

    public static Iterable byteBuffers(long startCycle, long endCycle, int bufsize) {
        HashedToByteBuffer htbb = new HashedToByteBuffer(bufsize);
        LongFunctionIterable bbi = new LongFunctionIterable<>(startCycle, endCycle, htbb);
        return bbi;
    }

    public static Iterable partialByteBuffers(int startCycle, int endCycle, int bufSize) {
        Iterable byteBuffers = byteBuffers(startCycle, endCycle, bufSize);
        return new ChunkedByteBuffer(byteBuffers);
    }

    private final static class ByteBufferObjectIterable implements Iterable {
        @NotNull
        @Override
        public Iterator iterator() {
            return new ByteBufferObjectIterator();
        }
        private final static class ByteBufferObjectIterator implements Iterator {
            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public ByteBufferObject next() {
                return null;
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy