public final class TupleMap extends Object
Naming: 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)) ;A
TupleMap holds twp maps: the "getTransform" and the "putTransform".
The "getTransform" is here to get the item from in the mapper Tuple.
In the case is SPO{@literal ->}POS this is
0{@literal <-}1, 1{@literal <-}2, 2{@literal <-}0
and the "putTransform" is where to place the items: 0{@literal ->}2, 1{@literal ->}0, 2{@literal ->}1.| Modifier and Type | Method and Description |
|---|---|
static <T> TupleMap |
create(String label,
List<T> input,
List<T> output)
Construct a mapping that maps the input to the output
|
static TupleMap |
create(String input,
String output)
Construct a mapping that maps the input (one col, one char) to the output
|
static TupleMap |
create(String label,
String input,
String output)
Construct a mapping, with label, that maps the input (one col, one char) to the output
|
static <T> TupleMap |
create(String label,
T[] input,
T[] output)
Construct a mapping that maps the input to the output
|
String |
getLabel() |
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 is
tuple.get(tupleMap.getSlotIdx(0)). |
int |
length()
Length of mapping
|
<T> T[] |
map(T[] src,
T[] dst)
Apply to an unmapped tuple to get a tuple with the tuple mapping applied.
|
<T> Tuple<T> |
map(Tuple<T> src)
Apply to an unmapped tuple to get a tuple with the tuple mapping applied.
|
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 to
getSlotIdx(int).The 0'th mapped slot is tuple.get(tupleMap.mapIdx(0)).Mapping a tuple is {@code map(tuple) == create(tuple.mapIdx(0) , tuple.mapIdx(1), ... |
<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
|
<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
|
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
|
TupleMap |
reverse()
Return a
TupleMap that maps in the opposite direction |
boolean |
sameMapping(TupleMap other)
Is this mapping the same (has the same effect) as
other? |
String |
toString() |
<T> T[] |
unmap(T[] src,
T[] dst)
Apply to a mapped tuple to get a tuple with the tuple mapping reverse-applied.
|
<T> Tuple<T> |
unmap(Tuple<T> src)
Apply to a mapped tuple to get a tuple with the tuple mapping reverse-applied.
|
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 to
putSlotIdx(int).The 0'th unmapped slot is tuple.get(tupleMap.unmapIdx(0)).Unmapping a tuple is {@code unmap(tuple) == create(tuple.unmapIdx(0) , tuple.unmapIdx(1), ... |
<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
|
<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
|
public static TupleMap create(String input, String output)
public static TupleMap create(String label, String input, String output)
public static <T> TupleMap create(String label, List<T> input, List<T> output)
public static <T> TupleMap create(String label, T[] input, T[] output)
public TupleMap reverse()
TupleMap that maps in the opposite direction
this.reverseMap().map is the same as this.unmap this.reverseMap().unmap is the same as this.map
public int length()
public int getSlotIdx(int idx)
tuple.get(tupleMap.getSlotIdx(0)).public int putSlotIdx(int idx)
public int mapIdx(int idx)
getSlotIdx(int).tuple.get(tupleMap.mapIdx(0)).map(tuple) == create(tuple.mapIdx(0) , tuple.mapIdx(1), ... tuple.mapIdx(n-1))public int unmapIdx(int idx)
putSlotIdx(int).tuple.get(tupleMap.unmapIdx(0)).unmap(tuple) == create(tuple.unmapIdx(0) , tuple.unmapIdx(1), ... tuple.unmapIdx(n-1))public <T> Tuple<T> map(Tuple<T> src)
public <T> Tuple<T> unmap(Tuple<T> src)
public <T> T[] map(T[] src,
T[] dst)
public <T> T[] unmap(T[] src,
T[] dst)
public <T> T mapSlot(int idx,
Tuple<T> tuple)
public <T> T unmapSlot(int idx,
Tuple<T> tuple)
public <T> T mapSlot(int idx,
T[] tuple)
public <T> T unmapSlot(int idx,
T[] tuple)
public boolean sameMapping(TupleMap other)
other?public String getLabel()
Licenced under the Apache License, Version 2.0