Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package sh
    Definition Classes
    org
  • package db
    Definition Classes
    sh
  • object MergedIndex

    purpose of this code:

    purpose of this code:

    Sometimes we have two tables (say INR withdraws and BTC withdraws) as below

    Table INR withdraws Table BTC withdraws ------------------------------------------- --------------------------------------------

    | time | withdrawID | Amount | userID | ... | time | withdrawID | Amount | userID | ...

    |------|------------|--------|--------|---- -------|------------|-----------------------

    | 23 | wjdejduejd | 34544 | alice | ... | 20 | ecjerjcruc | 146 | alice | ...

    | 45 | gtfcnmecnv | 4434 | bob | ... | 29 | roijfoirjf | 444 | carol | ...

    | 54 | 4jto4rkmkc | 3444 | alice | ... | 34 | i4jf4jifjj | 3944 | carol | ...

    Sometimes we may need a combined table for both INR and BTC withdraws sorted by time and search by max/offset This is not possible with two separate tables

    The MergedIndex object below takes care of this

    It provides a "merged table" M with the above two tables as "left-half" and "right-half" of that table

    The HalfTable encapsulates each half table

    case class HalfTable(db:DBManager, indexCol:Col, priKeyCol:Col, filterCol:Col, wheres:Where*){

    If sorting by time, then indexCol will be time. Each table should have a primary key column that can be uniqely used to reference a row Finally the filterCol is the one we will use to filter the results by (say userID). Each half table is declared using the above rule.

    The resulying MergedTable M will appear like this --------------------------------------

    indexCol

    priKeyCol

    filterCol

    23

    wjdejduejd

    alice

    45

    gtfcnmecnv

    bob

    54

    4jto4rkmkc

    alice

    20

    ecjerjcruc

    alice

    29

    roijfoirjf

    carol

    34

    i4jf4jifjj

    carol

    When giving a from-to search query (possibly with a filter on userID), the resulting output will be a (nested query) representing the set of ids from the priKeyCol that can be used to search the original tables

    so suppose if we search for time =< 30 and time >= 20 in decreasing order, the the getPriKeys will return a nested query that returns the following keys

    ecjerjcruc (corresponding to indexCol 20) wjdejduejd (corresponding to indexCol 23) roijfoirjf (corresponding to indexCol 29)

    similarly if we search for time =< 30 and time >= 20 in decreasing order with filter == "alice", the the getPriKeys will return a nested query that returns the following keys

    ecjerjcruc (corresponding to indexCol 20) wjdejduejd (corresponding to indexCol 23)

    ** A Nested query is an "lazy query", i.e., a query exactly like a normal query except that it has not yet been run. However, when it will run, it will return the above data. Examples of nested queries:

    SELECT amount FROM T1, (SELECT ID FROM .. AS T2) where T1.ID = T2.ID

    OR

    SELECT amount FROM T1 where T1.ID IN (SELECT ID FROM T2)

    In both examples the value inside ( ) is a nested query

    Now suppose M is going to used as a half table in another merged table T (say, transactions), then we can use connectToLeftOf to connect to left of T (we can use connectToRightOf to connect to right)

    Then whenever any entry is added to INR withdraws, it will first cause an entry to be added to M and then (through the chaning) to T (Note that we could have done the same thing by manually creating a MergedTable using M and accessing the values (indexCol, priKeyCol, filterCol) of that)

    Definition Classes
    db
  • HalfTable
  • MergedTable
c

org.sh.db.MergedIndex

HalfTable

case class HalfTable(db: DBManager, indexCol: Col, priKeyCol: Col, filterCol: Col, wheres: Where*) extends Product with Serializable

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. HalfTable
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new HalfTable(db: DBManager, indexCol: Col, priKeyCol: Col, filterCol: Col, wheres: Where*)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. val db: DBManager
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. val filterCol: Col
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hash: String
  12. val indexCol: Col
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. val priKeyCol: Col
  18. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  19. val table: Table
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  23. def where(wheres: Where*): HalfTable
  24. val wheres: Where*

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped