Package org.apache.cassandra.cql3
Class Relation
- java.lang.Object
-
- org.apache.cassandra.cql3.Relation
-
- Direct Known Subclasses:
MultiColumnRelation,SingleColumnRelation,TokenRelation
public abstract class Relation extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected OperatorrelationType
-
Constructor Summary
Constructors Constructor Description Relation()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.util.List<? extends Term.Raw>getInValues()Returns the list of raw IN values for this relation, or null if this is not an IN relation.abstract Term.RawgetValue()Returns the raw value for this relation, or null if this is an IN relation.booleanisContains()Checks if the operator of this relation is aCONTAINS.booleanisContainsKey()Checks if the operator of this relation is aCONTAINS_KEY.booleanisEQ()Checks if the operator of this relation is aEQ.booleanisIN()Checks if the operator of this relation is aIN.booleanisLIKE()booleanisMultiColumn()Checks if this relation apply to multiple columns.booleanisSlice()Checks if the operator of this relation is aSlice(GT, GTE, LTE, LT).protected abstract RestrictionnewContainsRestriction(TableMetadata table, VariableSpecifications boundNames, boolean isKey)Creates a new Contains restriction instance.protected abstract RestrictionnewEQRestriction(TableMetadata table, VariableSpecifications boundNames)Creates a new EQ restriction instance.protected abstract RestrictionnewINRestriction(TableMetadata table, VariableSpecifications boundNames)Creates a new IN restriction instance.protected abstract RestrictionnewIsNotRestriction(TableMetadata table, VariableSpecifications boundNames)protected abstract RestrictionnewLikeRestriction(TableMetadata table, VariableSpecifications boundNames, Operator operator)protected abstract RestrictionnewSliceRestriction(TableMetadata table, VariableSpecifications boundNames, Bound bound, boolean inclusive)Creates a new Slice restriction instance.booleanonToken()Checks if this relation is a token relation (e.g.Operatoroperator()abstract RelationrenameIdentifier(ColumnIdentifier from, ColumnIdentifier to)Renames an identifier in this Relation, if applicable.abstract java.lang.StringtoCQLString()Returns a CQL representation of this relation.RestrictiontoRestriction(TableMetadata table, VariableSpecifications boundNames)Converts thisRelationinto aRestriction.java.lang.StringtoString()protected abstract TermtoTerm(java.util.List<? extends ColumnSpecification> receivers, Term.Raw raw, java.lang.String keyspace, VariableSpecifications boundNames)Converts the specifiedRawinto aTerm.protected java.util.List<Term>toTerms(java.util.List<? extends ColumnSpecification> receivers, java.util.List<? extends Term.Raw> raws, java.lang.String keyspace, VariableSpecifications boundNames)Converts the specifiedRawterms into aTerms.
-
-
-
Field Detail
-
relationType
protected Operator relationType
-
-
Method Detail
-
operator
public Operator operator()
-
getValue
public abstract Term.Raw getValue()
Returns the raw value for this relation, or null if this is an IN relation.
-
getInValues
public abstract java.util.List<? extends Term.Raw> getInValues()
Returns the list of raw IN values for this relation, or null if this is not an IN relation.
-
isMultiColumn
public boolean isMultiColumn()
Checks if this relation apply to multiple columns.- Returns:
trueif this relation apply to multiple columns,falseotherwise.
-
onToken
public boolean onToken()
Checks if this relation is a token relation (e.g.token(a) = token(1)
).- Returns:
trueif this relation is a token relation,falseotherwise.
-
isContains
public final boolean isContains()
Checks if the operator of this relation is aCONTAINS.- Returns:
trueif the operator of this relation is aCONTAINS,falseotherwise.
-
isContainsKey
public final boolean isContainsKey()
Checks if the operator of this relation is aCONTAINS_KEY.- Returns:
trueif the operator of this relation is aCONTAINS_KEY,falseotherwise.
-
isIN
public final boolean isIN()
Checks if the operator of this relation is aIN.- Returns:
trueif the operator of this relation is aIN,falseotherwise.
-
isEQ
public final boolean isEQ()
Checks if the operator of this relation is aEQ.- Returns:
trueif the operator of this relation is aEQ,falseotherwise.
-
isLIKE
public final boolean isLIKE()
-
isSlice
public final boolean isSlice()
Checks if the operator of this relation is aSlice(GT, GTE, LTE, LT).- Returns:
trueif the operator of this relation is aSlice,falseotherwise.
-
toRestriction
public final Restriction toRestriction(TableMetadata table, VariableSpecifications boundNames)
Converts thisRelationinto aRestriction.- Parameters:
table- the Column Family meta databoundNames- the variables specification where to collect the bind variables- Returns:
- the
Restrictioncorresponding to thisRelation - Throws:
InvalidRequestException- if thisRelationis not valid
-
newEQRestriction
protected abstract Restriction newEQRestriction(TableMetadata table, VariableSpecifications boundNames)
Creates a new EQ restriction instance.- Parameters:
table- the table meta databoundNames- the variables specification where to collect the bind variables- Returns:
- a new EQ restriction instance.
- Throws:
InvalidRequestException- if the relation cannot be converted into an EQ restriction.
-
newINRestriction
protected abstract Restriction newINRestriction(TableMetadata table, VariableSpecifications boundNames)
Creates a new IN restriction instance.- Parameters:
table- the table meta databoundNames- the variables specification where to collect the bind variables- Returns:
- a new IN restriction instance
- Throws:
InvalidRequestException- if the relation cannot be converted into an IN restriction.
-
newSliceRestriction
protected abstract Restriction newSliceRestriction(TableMetadata table, VariableSpecifications boundNames, Bound bound, boolean inclusive)
Creates a new Slice restriction instance.- Parameters:
table- the table meta databoundNames- the variables specification where to collect the bind variablesbound- the slice boundinclusive-trueif the bound is included.- Returns:
- a new slice restriction instance
- Throws:
InvalidRequestException- if theRelationis not valid
-
newContainsRestriction
protected abstract Restriction newContainsRestriction(TableMetadata table, VariableSpecifications boundNames, boolean isKey)
Creates a new Contains restriction instance.- Parameters:
table- the table meta databoundNames- the variables specification where to collect the bind variablesisKey-trueif the restriction to create is a CONTAINS KEY- Returns:
- a new Contains
Restrictioninstance - Throws:
InvalidRequestException- if theRelationis not valid
-
newIsNotRestriction
protected abstract Restriction newIsNotRestriction(TableMetadata table, VariableSpecifications boundNames)
-
newLikeRestriction
protected abstract Restriction newLikeRestriction(TableMetadata table, VariableSpecifications boundNames, Operator operator)
-
toTerm
protected abstract Term toTerm(java.util.List<? extends ColumnSpecification> receivers, Term.Raw raw, java.lang.String keyspace, VariableSpecifications boundNames)
Converts the specifiedRawinto aTerm.- Parameters:
receivers- the columns to which the values must be associated atraw- the raw term to convertkeyspace- the keyspace nameboundNames- the variables specification where to collect the bind variables- Returns:
- the
Termcorresponding to the specifiedRaw - Throws:
InvalidRequestException- if theRawterm is not valid
-
toTerms
protected final java.util.List<Term> toTerms(java.util.List<? extends ColumnSpecification> receivers, java.util.List<? extends Term.Raw> raws, java.lang.String keyspace, VariableSpecifications boundNames)
Converts the specifiedRawterms into aTerms.- Parameters:
receivers- the columns to which the values must be associated atraws- the raw terms to convertkeyspace- the keyspace nameboundNames- the variables specification where to collect the bind variables- Returns:
- the
Terms corresponding to the specifiedRawterms - Throws:
InvalidRequestException- if theRawterms are not valid
-
renameIdentifier
public abstract Relation renameIdentifier(ColumnIdentifier from, ColumnIdentifier to)
Renames an identifier in this Relation, if applicable.- Parameters:
from- the old identifierto- the new identifier- Returns:
- this object, if the old identifier is not in the set of entities that this relation covers; otherwise a new Relation with "from" replaced by "to" is returned.
-
toCQLString
public abstract java.lang.String toCQLString()
Returns a CQL representation of this relation.- Returns:
- a CQL representation of this relation
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-