Package org.apache.calcite.util.mapping
Class Mappings.IdentityMapping
java.lang.Object
org.apache.calcite.util.mapping.Mappings.AbstractMapping
org.apache.calcite.util.mapping.Mappings.IdentityMapping
- All Implemented Interfaces:
Iterable<IntPair>,Mapping,Mappings.CoreMapping,Mappings.FunctionMapping,Mappings.SourceMapping,Mappings.TargetMapping
- Enclosing class:
Mappings
public static class Mappings.IdentityMapping
extends Mappings.AbstractMapping
implements Mappings.FunctionMapping, Mappings.TargetMapping, Mappings.SourceMapping
The identity mapping, of a given size, or infinite.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all elements in the mapping.Returns the mapping type.intgetSource(int target) Returns the source that a target maps to.intReturns the number of sources.intgetSourceOpt(int target) Returns the source that a target maps to, or -1 if it is not mapped.intgetTarget(int source) Returns the target that a source maps to.intReturns the number of targets.intgetTargetOpt(int source) Returns the target that a source maps to, or -1 if it is not mapped.inverse()booleanReturns whether this mapping is the identity.iterator()Returns an iterator over the elements in this mapping.voidset(int source, int target) intsize()Returns the number of elements in the mapping.Methods inherited from class org.apache.calcite.util.mapping.Mappings.AbstractMapping
toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
IdentityMapping
public IdentityMapping(int size) Creates an identity mapping.- Parameters:
size- Size, or -1 if infinite.
-
-
Method Details
-
clear
public void clear()Description copied from interface:MappingRemoves all elements in the mapping. -
size
public int size()Description copied from interface:Mappings.CoreMappingReturns the number of elements in the mapping.- Specified by:
sizein interfaceMapping- Specified by:
sizein interfaceMappings.CoreMapping
-
inverse
- Specified by:
inversein interfaceMappings.SourceMapping- Specified by:
inversein interfaceMappings.TargetMapping
-
isIdentity
public boolean isIdentity()Description copied from interface:MappingReturns whether this mapping is the identity.- Specified by:
isIdentityin interfaceMapping- Specified by:
isIdentityin interfaceMappings.SourceMapping- Overrides:
isIdentityin classMappings.AbstractMapping
-
set
public void set(int source, int target) - Specified by:
setin interfaceMappings.TargetMapping- Overrides:
setin classMappings.AbstractMapping
-
getMappingType
Description copied from interface:Mappings.CoreMappingReturns the mapping type.- Specified by:
getMappingTypein interfaceMapping- Specified by:
getMappingTypein interfaceMappings.CoreMapping- Specified by:
getMappingTypein interfaceMappings.FunctionMapping- Specified by:
getMappingTypein interfaceMappings.SourceMapping- Returns:
- Mapping type
-
getSourceCount
public int getSourceCount()Description copied from interface:MappingReturns the number of sources. Valid sources will be in the range 0 .. sourceCount.- Specified by:
getSourceCountin interfaceMapping- Specified by:
getSourceCountin interfaceMappings.FunctionMapping- Specified by:
getSourceCountin interfaceMappings.SourceMapping- Specified by:
getSourceCountin interfaceMappings.TargetMapping- Overrides:
getSourceCountin classMappings.AbstractMapping
-
getTargetCount
public int getTargetCount()Description copied from interface:MappingReturns the number of targets. Valid targets will be in the range 0 .. targetCount.- Specified by:
getTargetCountin interfaceMapping- Specified by:
getTargetCountin interfaceMappings.SourceMapping- Specified by:
getTargetCountin interfaceMappings.TargetMapping- Overrides:
getTargetCountin classMappings.AbstractMapping
-
getTarget
public int getTarget(int source) Returns the target that a source maps to.- Specified by:
getTargetin interfaceMappings.FunctionMapping- Specified by:
getTargetin interfaceMappings.TargetMapping- Overrides:
getTargetin classMappings.AbstractMapping- Parameters:
source- source- Returns:
- target
-
getTargetOpt
public int getTargetOpt(int source) Returns the target that a source maps to, or -1 if it is not mapped.- Specified by:
getTargetOptin interfaceMappings.FunctionMapping- Specified by:
getTargetOptin interfaceMappings.SourceMapping- Specified by:
getTargetOptin interfaceMappings.TargetMapping- Overrides:
getTargetOptin classMappings.AbstractMapping- Parameters:
source- source- Returns:
- target
-
getSource
public int getSource(int target) Returns the source that a target maps to.- Specified by:
getSourcein interfaceMappings.SourceMapping- Overrides:
getSourcein classMappings.AbstractMapping- Parameters:
target- target- Returns:
- source
-
getSourceOpt
public int getSourceOpt(int target) Returns the source that a target maps to, or -1 if it is not mapped.- Specified by:
getSourceOptin interfaceMappings.SourceMapping- Specified by:
getSourceOptin interfaceMappings.TargetMapping- Overrides:
getSourceOptin classMappings.AbstractMapping- Parameters:
target- target- Returns:
- source
-
iterator
Description copied from interface:MappingReturns an iterator over the elements in this mapping.This method is optional; implementations may throw
UnsupportedOperationException.
-