Class TupleMap


  • public final class TupleMap
    extends java.lang.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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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
      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
      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
      static <T> TupleMap create​(java.lang.String label, T[] input, T[] output)
      Construct a mapping that maps the input to the output
      java.lang.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> 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
      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?
      java.lang.String toString()  
      <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 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 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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getLabel

        public java.lang.String getLabel()