Package org.apache.calcite.util.mapping
Class Mappings.InverseMapping
- java.lang.Object
-
- org.apache.calcite.util.mapping.Mappings.InverseMapping
-
- All Implemented Interfaces:
java.lang.Iterable<IntPair>
,Mapping
,Mappings.CoreMapping
,Mappings.FunctionMapping
,Mappings.SourceMapping
,Mappings.TargetMapping
- Enclosing class:
- Mappings
private static class Mappings.InverseMapping extends java.lang.Object implements Mapping
Decorator which converts anyMapping
into the inverse of itself.If the mapping does not have an inverse -- for example, if a given source can have more than one target -- then the corresponding method call of the underlying mapping will raise a runtime exception.
-
-
Constructor Summary
Constructors Constructor Description InverseMapping(Mapping parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all elements in the mapping.MappingType
getMappingType()
Returns the mapping type.int
getSource(int target)
int
getSourceCount()
Returns the number of sources.int
getSourceOpt(int target)
int
getTarget(int source)
Returns the target that a source maps to.int
getTargetCount()
Returns the number of targets.int
getTargetOpt(int source)
Returns the target that a source maps to, or -1 if it is not mapped.Mapping
inverse()
boolean
isIdentity()
Returns whether this mapping is the identity.java.util.Iterator<IntPair>
iterator()
Returns an iterator over the elements in this mapping.void
set(int source, int target)
int
size()
Returns the number of elements in the mapping.
-
-
-
Field Detail
-
parent
private final Mapping parent
-
-
Constructor Detail
-
InverseMapping
InverseMapping(Mapping parent)
-
-
Method Detail
-
iterator
public java.util.Iterator<IntPair> iterator()
Description copied from interface:Mapping
Returns an iterator over the elements in this mapping.This method is optional; implementations may throw
UnsupportedOperationException
.
-
clear
public void clear()
Description copied from interface:Mapping
Removes all elements in the mapping.
-
size
public int size()
Description copied from interface:Mapping
Returns the number of elements in the mapping.- Specified by:
size
in interfaceMapping
- Specified by:
size
in interfaceMappings.CoreMapping
-
getSourceCount
public int getSourceCount()
Description copied from interface:Mapping
Returns the number of sources. Valid sources will be in the range 0 .. sourceCount.- Specified by:
getSourceCount
in interfaceMapping
- Specified by:
getSourceCount
in interfaceMappings.FunctionMapping
- Specified by:
getSourceCount
in interfaceMappings.SourceMapping
- Specified by:
getSourceCount
in interfaceMappings.TargetMapping
-
getTargetCount
public int getTargetCount()
Description copied from interface:Mapping
Returns the number of targets. Valid targets will be in the range 0 .. targetCount.- Specified by:
getTargetCount
in interfaceMapping
- Specified by:
getTargetCount
in interfaceMappings.SourceMapping
- Specified by:
getTargetCount
in interfaceMappings.TargetMapping
-
getMappingType
public MappingType getMappingType()
Description copied from interface:Mappings.CoreMapping
Returns the mapping type.- Specified by:
getMappingType
in interfaceMapping
- Specified by:
getMappingType
in interfaceMappings.CoreMapping
- Specified by:
getMappingType
in interfaceMappings.FunctionMapping
- Specified by:
getMappingType
in interfaceMappings.SourceMapping
- Returns:
- Mapping type
-
isIdentity
public boolean isIdentity()
Description copied from interface:Mapping
Returns whether this mapping is the identity.- Specified by:
isIdentity
in interfaceMapping
- Specified by:
isIdentity
in interfaceMappings.SourceMapping
-
getTargetOpt
public int getTargetOpt(int source)
Description copied from interface:Mappings.FunctionMapping
Returns the target that a source maps to, or -1 if it is not mapped.- Specified by:
getTargetOpt
in interfaceMappings.FunctionMapping
- Specified by:
getTargetOpt
in interfaceMappings.SourceMapping
- Specified by:
getTargetOpt
in interfaceMappings.TargetMapping
-
getTarget
public int getTarget(int source)
Description copied from interface:Mappings.FunctionMapping
Returns the target that a source maps to.- Specified by:
getTarget
in interfaceMappings.FunctionMapping
- Specified by:
getTarget
in interfaceMappings.TargetMapping
- Parameters:
source
- source- Returns:
- target
-
getSource
public int getSource(int target)
- Specified by:
getSource
in interfaceMappings.SourceMapping
-
getSourceOpt
public int getSourceOpt(int target)
- Specified by:
getSourceOpt
in interfaceMappings.SourceMapping
- Specified by:
getSourceOpt
in interfaceMappings.TargetMapping
-
inverse
public Mapping inverse()
- Specified by:
inverse
in interfaceMappings.SourceMapping
- Specified by:
inverse
in interfaceMappings.TargetMapping
-
set
public void set(int source, int target)
- Specified by:
set
in interfaceMappings.TargetMapping
-
-