ColumnStoreDriver Class

class ColumnStoreDriver

This is the parent class for pymcsapi. It uses the Columnstore.xml file to discover the layout of the ColumnStore cluster. It therefore needs to be able to discover the path to the ColumnStore installation.

ColumnStoreDriver()

pymcsapi.ColumnStoreDriver()

Creates an instance of the ColumnStoreDriver. This will search for the environment variable COLUMNSTORE_INSTALL_DIR, if this isn’t found then the default path of /usr/local/mariadb/columnstore/ is used.

Raises:RuntimeError – When the Columnstore.xml file cannot be found or cannot be parsed

Example

1
2
3
4
5
6
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
except RuntimeError as err:
    print("Error caught: %s" % (err,))
pymcsapi.ColumnStoreDriver(path)

Creates an instance of ColumnStoreDriver using the specified path to the Columnstore.xml file (including filename).

Parameters:path – The path to the Columnstore.xml (including filename)
Raises:RuntimeError – When the Columnstore.xml file cannot be found or cannot be parsed

Example

1
2
3
4
5
6
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver('/usr/local/mariadb/columnstore/etc/Columnstore.xml')
except RuntimeError as err:
    print("Error caught: %s" % (err,))

createBulkInsert()

ColumnStoreDriver.createBulkInsert(db, table, mode, pm)

Allocates and configures an instance of ColumnStoreBulkInsert to be used for bulk inserts with the ColumnStore installation reference by the driver.

Parameters:
  • db – The database name for the table to insert into
  • table – The tabe name to insert into
  • mode – Future use, must be set to 0
  • pm – Future use, must be set to 0. For now batches of inserts use a round-robin between the PM servers.
Returns:

An instance of ColumnStoreBulkInsert

Raises:

RuntimeError – If a table lock cannot be acquired for the desired table

Example

1
2
3
4
5
6
7
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    bulkInsert = driver.createBulkInsert("test", "t1", 0, 0);
except RuntimeError as err:
    print("Error caught: %s" % (err,))

getVersion()

ColumnStoreDriver.getVersion()

Returns the version of the mcsapi library in the format 1.0.0-0393456-dirty where 1.0.0 is the version number, 0393456 is the short git tag and dirty signifies there is uncommitted code making up this build.

Returns:The mcsapi version string

Example

1
2
3
4
5
6
7
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    print("mcsapi version: %s" % (driver.getVersion(),))
except RuntimeError as err:
    print("Error caught: %s" % (err,))

setDebug()

ColumnStoreDriver.setDebug(level)

Enables/disables verbose debugging output which is sent to stderr upon execution. Levels are as follows:

  • 0 - Off
  • 1 - Show messages and binary packets truncated at 1000 bytes
  • 2 - Show full messages, full length binary packets and ASCII translations

Note

This is a global setting which will apply to all instances of all of the API’s classes after it is set until it is turned off.

Parameters:level – Set to the log level required, 0 = off.

Example

1
2
3
4
5
6
7
8
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    driver.setDebug(True)
    # Debugging output is now enabled
except RuntimeError as err:
    print("Error caught: %s" % (err,))

getSystemCatalog()

ColumnStoreDriver.getSystemCatalog()

Returns an instance of the ColumnStore system catalog which contains all of the ColumnStore table and column details

Returns:The system catalog

Example

1
2
3
4
5
6
7
8
9
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    sysCat = driver.getSystemCatalog()
    table = sysCat.getTable("test", "t1")
    print("t1 has %d columns" % (table.getColumnCount(),))
except RuntimeError as err:
    print("Error caught: %s" % (err,))

listTableLocks()

ColumnStoreDriver.listTableLocks()

Returns a tuple of TableLockInfo objects that contains information about the current table locks in the ColumnStore system.

Returns:A tuple of TableLockInfo objects

Example

1
2
3
4
5
6
7
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    tliv = driver.listTableLocks()
except RuntimeError as err:
    print("Error caught: %s" % (err,))

isTableLocked()

ColumnStoreDriver.isTableLocked(db, table)

Returns True if the specified table is locked and False if it is not locked.

Parameters:
  • db – The database name for the table to check
  • table – The tabe name to check
Returns:

True if the specified table is locked, otherwise False

Raises:

RuntimeError – If the specified table is not existent

Example

1
2
3
4
5
6
7
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    locked = driver.isTableLocked("test","tmp1")
except RuntimeError as err:
    print("Error caught: %s" % (err,))

Note

Only locks of tables that have been existent when ColumnStoreDriver was created can be detected.

clearTableLock()

ColumnStoreDriver.clearTableLock(lockId)

Clears a table lock with given id

Parameters:lockId – The id of the table lock to clear

Example

1
2
3
4
5
6
7
8
9
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    tliv = driver.listTableLocks()
    for tli in tliv:
        driver.clearTableLock(tli.id)
except RuntimeError as err:
    print("Error caught: %s" % (err,))
ColumnStoreDriver.clearTableLock(tableLockInfo)

Clears a table lock with given TableLockInfo element using its lock id

Parameters:lockId – The TableLockInfo object whose id will be used to clear the lock

Example

1
2
3
4
5
6
7
8
9
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    tliv = driver.listTableLocks()
    for tli in tliv:
        driver.clearTableLock(tli)
except RuntimeError as err:
    print("Error caught: %s" % (err,))
ColumnStoreDriver.clearTableLock(db, table)

Clears a table lock of given database table combination

Parameters:
  • db – The database name for the table to clear
  • table – The tabe name to clear

Example

1
2
3
4
5
6
7
import pymcsapi

try:
    driver = pymcsapi.ColumnStoreDriver()
    driver.clearTableLock("test","tmp1")
except RuntimeError as err:
    print("Error caught: %s" % (err,))