Package org.apache.jena.atlas.lib.tuple
Class TupleMap
- java.lang.Object
-
- org.apache.jena.atlas.lib.tuple.TupleMap
-
public final class TupleMap extends java.lang.ObjectGeneral descriptor of a reordering (mapping) of slots in tuplesNaming: map is convert to the reordered form, unmap is get back.
map(tuple) is equivalent to create tuple(getSlotIdx(0) , getSlotIdx(1), ... getSlotIdx(n-1)) ;
ATupleMapholds twp maps: the "getTransform" and the "putTransform". The "getTransform" is here to get the item from in the mapper Tuple. In the case isSPO{@literal ->}POSthis is0{@literal <-}1, 1{@literal <-}2, 2{@literal <-}0and the "putTransform" is where to place the items:0{@literal ->}2, 1{@literal ->}0, 2{@literal ->}1.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TupleMapcreate(java.lang.String input, java.lang.String output)Construct a mapping that maps the input (one col, one char) to the outputstatic TupleMapcreate(java.lang.String label, java.lang.String input, java.lang.String output)Construct a mapping, with label, that maps the input (one col, one char) to the outputstatic <T> TupleMapcreate(java.lang.String label, java.util.List<T> input, java.util.List<T> output)Construct a mapping that maps the input to the outputstatic <T> TupleMapcreate(java.lang.String label, T[] input, T[] output)Construct a mapping that maps the input to the outputjava.lang.StringgetLabel()intgetSlotIdx(int idx)Get the index of the i'th slot as it appears from a mapping : for SPO->POS : 0'th slot is P so 0 returns 1 (the location in the tuple before mapping) The 0'th mapped slot istuple.get(tupleMap.getSlotIdx(0)).intlength()Length of mapping<T> Tuple<T>map(Tuple<T> src)Apply to an unmapped tuple to get a tuple with the tuple mapping applied.<T> T[]map(T[] src, T[] dst)Apply to an unmapped tuple to get a tuple with the tuple mapping applied.intmapIdx(int idx)Get the index of the i'th slot as it appears from a mapping : for SPO->POS : 0'th slot is P so 0 returns 1 (the location in the tuple before mapping) Equivalent togetSlotIdx(int).
The 0'th mapped slot istuple.get(tupleMap.mapIdx(0)).
Mapping a tuple ismap(tuple) == create(tuple.mapIdx(0) , tuple.mapIdx(1), ... tuple.mapIdx(n-1))<T> TmapSlot(int idx, Tuple<T> tuple)Apply to an unmapped tuple to get the i'th slot after mapping : SPO->POS : 0'th slot is P from SPO<T> TmapSlot(int idx, T[] tuple)Apply to an unmapped tuple to get the i'th slot after mapping : SPO->POS : 0'th slot is P from SPOintputSlotIdx(int idx)Get the index of the i'th slot as it appears after unmapping : SPO->POS : 0'th slot is S from POS so 0 returns 2TupleMapreverse()Return aTupleMapthat maps in the opposite directionbooleansameMapping(TupleMap other)Is this mapping the same (has the same effect) asother?java.lang.StringtoString()<T> Tuple<T>unmap(Tuple<T> src)Apply to a mapped tuple to get a tuple with the tuple mapping reverse-applied.<T> T[]unmap(T[] src, T[] dst)Apply to a mapped tuple to get a tuple with the tuple mapping reverse-applied.intunmapIdx(int idx)Get the index of the i'th slot as it appears after unmapping : SPO->POS : 0'th slot is S from POS so 0 returns 2 Equivalent toputSlotIdx(int).
The 0'th unmapped slot istuple.get(tupleMap.unmapIdx(0)).
Unmapping a tuple isunmap(tuple) == create(tuple.unmapIdx(0) , tuple.unmapIdx(1), ... tuple.unmapIdx(n-1))<T> TunmapSlot(int idx, Tuple<T> tuple)Apply to a mapped tuple to get the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS<T> TunmapSlot(int idx, T[] tuple)Apply to a mapped tuple to get the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS
-
-
-
Method Detail
-
create
public static TupleMap create(java.lang.String input, java.lang.String output)
Construct a mapping that maps the input (one col, one char) to the output
-
create
public static TupleMap create(java.lang.String label, java.lang.String input, java.lang.String output)
Construct a mapping, with label, that maps the input (one col, one char) to the output
-
create
public static <T> TupleMap create(java.lang.String label, java.util.List<T> input, java.util.List<T> output)
Construct a mapping that maps the input to the output
-
create
public static <T> TupleMap create(java.lang.String label, T[] input, T[] output)
Construct a mapping that maps the input to the output
-
reverse
public TupleMap reverse()
Return aTupleMapthat maps in the opposite directionthis.reverseMap().map is the same as this.unmap this.reverseMap().unmap is the same as this.map
-
length
public int length()
Length of mapping
-
getSlotIdx
public int getSlotIdx(int idx)
Get the index of the i'th slot as it appears from a mapping : for SPO->POS : 0'th slot is P so 0 returns 1 (the location in the tuple before mapping) The 0'th mapped slot istuple.get(tupleMap.getSlotIdx(0)).
-
putSlotIdx
public int putSlotIdx(int idx)
Get the index of the i'th slot as it appears after unmapping : SPO->POS : 0'th slot is S from POS so 0 returns 2
-
mapIdx
public int mapIdx(int idx)
Get the index of the i'th slot as it appears from a mapping : for SPO->POS : 0'th slot is P so 0 returns 1 (the location in the tuple before mapping) Equivalent togetSlotIdx(int).
The 0'th mapped slot istuple.get(tupleMap.mapIdx(0)).
Mapping a tuple ismap(tuple) == create(tuple.mapIdx(0) , tuple.mapIdx(1), ... tuple.mapIdx(n-1))
-
unmapIdx
public int unmapIdx(int idx)
Get the index of the i'th slot as it appears after unmapping : SPO->POS : 0'th slot is S from POS so 0 returns 2 Equivalent toputSlotIdx(int).
The 0'th unmapped slot istuple.get(tupleMap.unmapIdx(0)).
Unmapping a tuple isunmap(tuple) == create(tuple.unmapIdx(0) , tuple.unmapIdx(1), ... tuple.unmapIdx(n-1))
-
map
public <T> Tuple<T> map(Tuple<T> src)
Apply to an unmapped tuple to get a tuple with the tuple mapping applied.
-
unmap
public <T> Tuple<T> unmap(Tuple<T> src)
Apply to a mapped tuple to get a tuple with the tuple mapping reverse-applied.
-
map
public <T> T[] map(T[] src, T[] dst)Apply to an unmapped tuple to get a tuple with the tuple mapping applied. Returns the destination array.
-
unmap
public <T> T[] unmap(T[] src, T[] dst)Apply to a mapped tuple to get a tuple with the tuple mapping reverse-applied. Returns the destination array.
-
mapSlot
public <T> T mapSlot(int idx, Tuple<T> tuple)Apply to an unmapped tuple to get the i'th slot after mapping : SPO->POS : 0'th slot is P from SPO
-
unmapSlot
public <T> T unmapSlot(int idx, Tuple<T> tuple)Apply to a mapped tuple to get the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS
-
mapSlot
public <T> T mapSlot(int idx, T[] tuple)Apply to an unmapped tuple to get the i'th slot after mapping : SPO->POS : 0'th slot is P from SPO
-
unmapSlot
public <T> T unmapSlot(int idx, T[] tuple)Apply to a mapped tuple to get the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS
-
sameMapping
public boolean sameMapping(TupleMap other)
Is this mapping the same (has the same effect) asother?
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getLabel
public java.lang.String getLabel()
-
-