-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
status/need-designThis needs more in depth design workThis needs more in depth design workstatus/need-investigationThis needs more in-depth investigationThis needs more in-depth investigationtype/enhancementA general enhancementA general enhancement
Milestone
Description
Motivation
see #3309
Desired solution
We can use constant int characteristics (see https://docs.oracle.com/javase/8/docs/api/java/util/Spliterator.html#characteristics--) as a more straightforward solution to do faster type check and avoid expensive type check
public interface CorePublisher<T> extends Publisher<T> {
/**
* An internal {@link Publisher#subscribe(Subscriber)} that will bypass
* {@link Hooks#onLastOperator(Function)} pointcut.
* <p>
* In addition to behave as expected by {@link Publisher#subscribe(Subscriber)}
* in a controlled manner, it supports direct subscribe-time {@link Context} passing.
*
* @param subscriber the {@link Subscriber} interested into the published sequence
* @see Publisher#subscribe(Subscriber)
*/
void subscribe(CoreSubscriber<? super T> subscriber);
/**
* Better instanceof
*
* @return all characteristic of the given source
*/
int characteristics();
interface Characteristics {
int FUSEABLE = 0b0000_0000_0000_0000_0000_0000_0000_0001;
int SIZED = 0b0000_0000_0000_0000_0000_0000_0000_0010;
int CALLABLE = 0b0000_0000_0000_0000_0000_0000_0000_0100;
int SCALAR = 0b0000_0000_0000_0000_0000_0000_0000_1000;
int OPTIMIZABLE_OPERATOR = 0b0000_0000_0000_0000_0000_0000_0001_0000;
static boolean isCallable(int characteristics) {
return (characteristics & CALLABLE) == CALLABLE;
}
static boolean isFuseable(int characteristics) {
return (characteristics & FUSEABLE) == FUSEABLE;
}
static boolean isScalar(int characteristics) {
return (characteristics & SCALAR) == SCALAR;
}
static boolean isOptimizableOperator(int characteristics) {
return (characteristics & OPTIMIZABLE_OPERATOR) == OPTIMIZABLE_OPERATOR;
}
}
}
Considered alternatives
Additional context
Metadata
Metadata
Assignees
Labels
status/need-designThis needs more in depth design workThis needs more in depth design workstatus/need-investigationThis needs more in-depth investigationThis needs more in-depth investigationtype/enhancementA general enhancementA general enhancement