Class TupleMap

java.lang.Object
org.apache.jena.atlas.lib.tuple.TupleMap

public final class TupleMap extends Object
General descriptor of a reordering (mapping) of slots in tuples

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.
  • Method Summary

    Modifier and Type
    Method
    Description
    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, List<T> input, List<T> output)
    Construct a mapping that maps the input to the output
    static <T> TupleMap
    create(String label, T[] input, T[] output)
    Construct a mapping that maps the input to the output
     
    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 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.
    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 map(tuple) == create(tuple.mapIdx(0) , tuple.mapIdx(1), ... tuple.mapIdx(n-1))
    <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
    <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
    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
    Return a TupleMap that maps in the opposite direction
    boolean
    Is this mapping the same (has the same effect) as other?
     
    <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.
    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 unmap(tuple) == create(tuple.unmapIdx(0) , tuple.unmapIdx(1), ... tuple.unmapIdx(n-1))
    <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
    <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

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • create

      public static TupleMap create(String input, String output)
      Construct a mapping that maps the input (one col, one char) to the output
    • create

      public 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
    • create

      public static <T> TupleMap create(String label, List<T> input, List<T> output)
      Construct a mapping that maps the input to the output
    • create

      public static <T> TupleMap create(String label, T[] input, T[] output)
      Construct a mapping that maps the input to the output
    • reverse

      public TupleMap reverse()
      Return a 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
        
    • 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 is tuple.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 to getSlotIdx(int).
      The 0'th mapped slot is tuple.get(tupleMap.mapIdx(0)).
      Mapping a tuple is map(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 to putSlotIdx(int).
      The 0'th unmapped slot is tuple.get(tupleMap.unmapIdx(0)).
      Unmapping a tuple is unmap(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) as other?
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getLabel

      public String getLabel()