docs / it.uniroma3.dbtree.spi / Connector

Connector

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

Interface for the database connector.

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

All operation modifying the state of the database should be performed within a transaction, in order not to cause inconsistencies.

Parameters

K - the KeyParser parameter, actually, the key type.

Properties

connectionUrl

abstract val connectionUrl: String

databaseName

abstract val databaseName: String

kp

The KeyParser attribute for the Connector.

abstract val kp: KeyParser<K>

password

abstract val password: String

tableBaseName

abstract val tableBaseName: String

username

abstract val username: String

Functions

close

Disconnects from the underlying database.

abstract fun close(): Unit

connect

Connects with the underlying database.

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

create

Insert a batch of new nodes into the database.

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

Insert a node into the database.

abstract fun create(node: NodeTransfer): Unit

delete

Delete a batch of nodes from the database.

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

Delete node from the database.

abstract 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.

abstract 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.

abstract 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.

abstract 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.

abstract 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.

abstract 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.

abstract 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.

abstract 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.

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

getRoot

Returns the DBTree's root node.

abstract fun getRoot(): NodeTransfer

isClosed

Informs about the state of the current connection.

abstract fun isClosed(): Boolean

update

Update a batch of nodes of the database.

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

Update a node of the database.

abstract fun update(node: NodeTransfer): Unit

updateDBTree

Update the DB-tree persisted state.

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

Inheritors

SQLConnector

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

class SQLConnector<K> : Connector<K> where K : Comparable<K>, K : Serializable