Class Selector
- java.lang.Object
-
- org.apache.cassandra.cql3.selection.Selector
-
- Direct Known Subclasses:
SimpleSelector,TermSelector
public abstract class Selector extends java.lang.ObjectASelectoris used to convert the data returned by the storage engine into the data requested by the user. They correspond to the <selector> elements from the select clause.Since the introduction of aggregation,
Selectors cannot be called anymore by multiple threads as they have an internal state.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSelector.FactoryA factory forSelectorinstances.static classSelector.InputRowA row of data that need to be processed by aSelectorstatic classSelector.KindTheSelectorkinds.protected static classSelector.SelectorDeserializerstatic classSelector.Serializer
-
Field Summary
Fields Modifier and Type Field Description static Selector.SerializerserializerTheSelectorserializer.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSelector(Selector.Kind kind)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddFetchedColumns(ColumnFilter.Builder builder)Add to the provided builder the column (and potential subselections) to fetch for this selection.abstract voidaddInput(ProtocolVersion protocolVersion, Selector.InputRow input)Add the current value from the specifiedResultSetBuilder.abstract java.nio.ByteBuffergetOutput(ProtocolVersion protocolVersion)Returns the selector output.abstract AbstractType<?>getType()Returns theSelectoroutput type.booleanisTerminal()A selector is terminal if it doesn't require any input for it's output to be computed, i.e.Selector.Kindkind()Returns theSelectorkind.abstract voidreset()Reset the internal state of thisSelector.protected abstract voidserialize(DataOutputPlus out, int version)protected abstract intserializedSize(int version)protected static intsizeOf(AbstractType<?> type)voidvalidateForGroupBy()Checks that this selector is valid for GROUP BY clause.protected static voidwriteType(DataOutputPlus out, AbstractType<?> type)
-
-
-
Field Detail
-
serializer
public static final Selector.Serializer serializer
TheSelectorserializer.
-
-
Constructor Detail
-
Selector
protected Selector(Selector.Kind kind)
-
-
Method Detail
-
kind
public final Selector.Kind kind()
Returns theSelectorkind.- Returns:
- the
Selectorkind
-
addFetchedColumns
public abstract void addFetchedColumns(ColumnFilter.Builder builder)
Add to the provided builder the column (and potential subselections) to fetch for this selection.- Parameters:
builder- the builder to add columns and subselections to.
-
addInput
public abstract void addInput(ProtocolVersion protocolVersion, Selector.InputRow input)
Add the current value from the specifiedResultSetBuilder.- Parameters:
protocolVersion- protocol version used for serializationinput- the input row- Throws:
InvalidRequestException- if a problem occurs while adding the input row
-
getOutput
public abstract java.nio.ByteBuffer getOutput(ProtocolVersion protocolVersion) throws InvalidRequestException
Returns the selector output.- Parameters:
protocolVersion- protocol version used for serialization- Returns:
- the selector output
- Throws:
InvalidRequestException- if a problem occurs while computing the output value
-
getType
public abstract AbstractType<?> getType()
Returns theSelectoroutput type.- Returns:
- the
Selectoroutput type.
-
reset
public abstract void reset()
Reset the internal state of thisSelector.
-
isTerminal
public boolean isTerminal()
A selector is terminal if it doesn't require any input for it's output to be computed, i.e. ifgetOutput(org.apache.cassandra.transport.ProtocolVersion)result doesn't depend ofaddInput(org.apache.cassandra.transport.ProtocolVersion, org.apache.cassandra.cql3.selection.Selector.InputRow). This is typically the case of a constant value or functions on constant values.
-
validateForGroupBy
public void validateForGroupBy()
Checks that this selector is valid for GROUP BY clause.
-
serializedSize
protected abstract int serializedSize(int version)
-
serialize
protected abstract void serialize(DataOutputPlus out, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
writeType
protected static void writeType(DataOutputPlus out, AbstractType<?> type) throws java.io.IOException
- Throws:
java.io.IOException
-
sizeOf
protected static int sizeOf(AbstractType<?> type)
-
-