Package org.apache.calcite.util.mapping
Class Mappings.PartialMapping
java.lang.Object
org.apache.calcite.util.mapping.Mappings.AbstractMapping
org.apache.calcite.util.mapping.Mappings.FiniteAbstractMapping
org.apache.calcite.util.mapping.Mappings.PartialMapping
- All Implemented Interfaces:
Iterable<IntPair>,Mapping,Mappings.CoreMapping,Mappings.FunctionMapping,Mappings.SourceMapping,Mappings.TargetMapping
- Enclosing class:
Mappings
public static class Mappings.PartialMapping
extends Mappings.FiniteAbstractMapping
implements Mapping, Mappings.FunctionMapping, Mappings.TargetMapping
A mapping where a source has at most one target, and every target has at
most one source.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPartialMapping(int sourceCount, int targetCount, MappingType mappingType) Creates a partial mapping.PartialMapping(List<Integer> sourceList, int sourceCount, MappingType mappingType) Creates a partial mapping from a list. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all elements in the mapping.Returns the mapping type.intReturns the number of sources.intgetSourceOpt(int target) Returns the source that a target maps to, or -1 if it is not mapped.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.protected booleanisValid()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.FiniteAbstractMapping
equals, hashCodeMethods inherited from class org.apache.calcite.util.mapping.Mappings.AbstractMapping
getSource, getTarget, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.apache.calcite.util.mapping.Mappings.SourceMapping
getSourceMethods inherited from interface org.apache.calcite.util.mapping.Mappings.TargetMapping
getTarget
-
Field Details
-
sources
protected final int[] sources -
targets
protected final int[] targets
-
-
Constructor Details
-
PartialMapping
Creates a partial mapping.Initially, no element is mapped to any other:
Example source 0 1 2 target -1 -1 -1 Example target 0 1 2 3 source -1 -1 -1 -1 - Parameters:
sourceCount- Number of source elementstargetCount- Number of target elementsmappingType- Mapping type; must not allow multiple sources per target or multiple targets per source
-
PartialMapping
Creates a partial mapping from a list. For example,PartialMapping({1, 2, 4}, 6)creates the mappingExample source 0 1 2 3 4 5 target -1 0 1 -1 2 -1 - Parameters:
sourceList- List whose i'th element is the source of target #isourceCount- Number of elements in the source domainmappingType- Mapping type, must beMappingType.PARTIAL_SURJECTIONor stronger.
-
-
Method Details
-
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
-
clear
public void clear()Description copied from interface:MappingRemoves all elements in the mapping. -
size
public int size()Description copied from interface:MappingReturns 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
-
iterator
Description copied from interface:MappingReturns an iterator over the elements in this mapping.This method is optional; implementations may throw
UnsupportedOperationException. -
isValid
protected boolean isValid() -
set
public void set(int source, int target) - Specified by:
setin interfaceMappings.TargetMapping- Overrides:
setin classMappings.AbstractMapping
-
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
-
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
-
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
-