io.deephaven.engine.table.iterators.ByteColumnIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-api Show documentation
Show all versions of deephaven-engine-api Show documentation
Engine API: Engine API module, suitable as a compile-time dependency for most queries
The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY
// ****** Edit CharacterColumnIterator and run "./gradlew replicateColumnIterators" to regenerate
//
// @formatter:off
package io.deephaven.engine.table.iterators;
import io.deephaven.engine.primitive.function.ByteToIntFunction;
import io.deephaven.engine.primitive.iterator.CloseablePrimitiveIteratorOfByte;
import io.deephaven.util.QueryConstants;
import io.deephaven.util.annotations.FinalDefault;
import io.deephaven.util.type.TypeUtils;
import org.jetbrains.annotations.NotNull;
import java.util.PrimitiveIterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Consumer;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
* {@link ColumnIterator} implementation for columns of primitive bytes.
*/
public interface ByteColumnIterator extends ColumnIterator, CloseablePrimitiveIteratorOfByte {
@Override
@FinalDefault
default Byte next() {
return TypeUtils.box(nextByte());
}
@Override
@FinalDefault
default void forEachRemaining(@NotNull final Consumer super Byte> action) {
forEachRemaining((final byte element) -> action.accept(TypeUtils.box(element)));
}
/**
* Create a {@link IntStream} over the remaining elements of this ChunkedByteColumnIterator by applying
* {@code adapter} to each element. The result must be {@link java.util.stream.BaseStream#close() closed}
* in order to ensure resources are released. A try-with-resources block is strongly encouraged.
*
* @return A {@link IntStream} over the remaining contents of this iterator. Must be {@link Stream#close() closed}.
*/
@Override
@FinalDefault
default IntStream streamAsInt(@NotNull final ByteToIntFunction adapter) {
final PrimitiveIterator.OfInt adapted = adaptToOfInt(adapter);
return StreamSupport.intStream(
Spliterators.spliterator(
adapted,
remaining(),
Spliterator.IMMUTABLE | Spliterator.ORDERED),
false)
.onClose(this::close);
}
/**
* Create an unboxed {@link IntStream} over the remaining elements of this ChunkedByteColumnIterator by casting
* each element to {@code int} with the appropriate adjustment of {@link io.deephaven.util.QueryConstants#NULL_BYTE
* NULL_BYTE} to {@link io.deephaven.util.QueryConstants#NULL_INT NULL_INT}. The result must be
* {@link java.util.stream.BaseStream#close() closed} in order to ensure resources are released. A
* try-with-resources block is strongly encouraged.
*
* @return An unboxed {@link IntStream} over the remaining contents of this iterator. Must be {@link Stream#close()
* closed}.
*/
@Override
@FinalDefault
default IntStream streamAsInt() {
return streamAsInt(
(final byte value) -> value == QueryConstants.NULL_BYTE ? QueryConstants.NULL_INT : (int) value);
}
/**
* Create a boxed {@link Stream} over the remaining elements of this ByteColumnIterator. The result must be
* {@link java.util.stream.BaseStream#close() closed} in order to ensure resources are released. A
* try-with-resources block is strongly encouraged.
*
* @return A boxed {@link Stream} over the remaining contents of this iterator. Must be {@link Stream#close()
* closed}.
*/
@Override
@FinalDefault
default Stream stream() {
return StreamSupport.stream(
Spliterators.spliterator(
this,
remaining(),
Spliterator.IMMUTABLE | Spliterator.ORDERED),
false)
.onClose(this::close);
}
}