docs / it.uniroma3.dbtree.spi.impl.connectors / SQLConnector

SQLConnector

class SQLConnector<K> : Connector<K> where K : Comparable<K>, K : Serializable (source)

Connector reference implementation for an underlying SQL database. (Tested on PostgreSQL and mySQL)

This class provides methods to establish and exploit the connection with the underlying Postgres database. The DB-tree class will refer to this class to create, retrieve, update and delete the persisted nodes necessary to the application logic.

Parameters

K - the KeyParser parameter.

Constructors

<init>

Connector reference implementation for an underlying SQL database. (Tested on PostgreSQL and mySQL)

SQLConnector(connectionUrl: String, databaseName: String, username: String, password: String, tableBaseName: String, kp: KeyParser<K>)

Properties

connectionUrl

val connectionUrl: String

databaseName

val databaseName: String

kp

The KeyParser attribute for the Connector.

val kp: KeyParser<K>

password

val password: String

tableBaseName

val tableBaseName: String

username

val username: String

Functions

close

Disconnects from the underlying database.

fun close(): Unit

connect

Connects with the underlying database.

fun connect(aggrFunName: String, maxLevel: Int, initRootContext: String): Unit

create

Insert a batch of new nodes into the database.

fun create(nodes: Collection<NodeTransfer>): Unit

Insert a node into the database.

fun create(node: NodeTransfer): Unit

delete

Delete a batch of nodes from the database.

fun delete(nodes: Collection<Triple<Int, String, String>>): Unit

Delete node from the database.

fun delete(node: Triple<Int, String, String>): Unit

getDelete

Retrieve from the database all nodes n s.t. n.min <= k <= n.max, ordered by ascending level.

fun getDelete(k: K): List<NodeTransfer>

getGroupByL

Retrieve from the database all nodes n s.t. y1 < n.k_max.y ≤ y2 ∧ (n.k_min.y < y1 ∨ n.k_min.x ≠ n.k_max.x), ordered by ascending level.

fun getGroupByL(y1: List<Any>, y2: List<Any>): List<NodeTransfer>

getGroupByNBar

Retrieve from the database all pairs (x,n) s.t. x ∈ X ∧ n.k_min < (x, y1) < (x, y2) < n.k_max, having maximum level.

fun getGroupByNBar(y1: List<Any>, y2: List<Any>): Map<List<Any>, NodeTransfer>

getGroupByR

Retrieve from the database all nodes n s.t. y1 ≤ n.k_min.y < y2 ∧ (y2 < n.k_max.y ∨ n.k_min.x ≠ n.k_max.x), ordered by ascending level.

fun getGroupByR(y1: List<Any>, y2: List<Any>): List<NodeTransfer>

getIncludingK

Retrieve from the database all nodes n s.t. n.k_min < k < n.k_max, ordered by ascending level.

fun getIncludingK(k: K): List<NodeTransfer>

getRangeQueryL

Retrieve from the database all nodes n s.t. n.k_min < k1 < n.k_max ≤ k2, ordered by ascending level.

fun getRangeQueryL(k1: K, k2: K): List<NodeTransfer>

getRangeQueryNBar

Retrieve from the database the node n s.t. k1 <= n.k_min <= n.k_max <= k2, having maximum level.

fun getRangeQueryNBar(k1: K, k2: K): List<NodeTransfer>

getRangeQueryR

Retrieve from the database all nodes n s.t. k1 ≤ n.k_min < k2 < n.k_max, ordered by ascending level.

fun getRangeQueryR(k1: K, k2: K): List<NodeTransfer>

getRoot

Returns the DBTree's root node.

fun getRoot(): NodeTransfer

isClosed

Informs about the state of the current connection.

fun isClosed(): Boolean

update

Update a batch of nodes of the database.

fun update(nodes: Collection<NodeTransfer>): Unit

Update a node of the database.

fun update(node: NodeTransfer): Unit

updateDBTree

Update the DB-tree persisted state.

fun updateDBTree(create: Collection<NodeTransfer>, update: Collection<NodeTransfer>, delete: Collection<Triple<Int, String, String>>): Unit