ColumnStoreDriver Class

COLUMNSTORE_INSTALL_DIR

The optional environment variable containing the path to the ColumnStore installation. Used by ColumnStoreDriver

class ColumnStoreDriver

This is the parent class for mcsapi. 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()

ColumnStoreDriver::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 ColumnStoreConfigError:
 When the Columnstore.xml file cannot be found or cannot be parsed

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    mcsapi::ColumnStoreDriver* driver = nullptr;
    try {
        driver = new mcsapi::ColumnStoreDriver();
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught " << e.what() << std::endl;
    }
    delete driver;
    return 0;
}
ColumnStoreDriver::ColumnStoreDriver(const std::string &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 ColumnStoreConfigError:
 When the Columnstore.xml file cannot be found or cannot be parsed

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    mcsapi::ColumnStoreDriver* driver = nullptr;
    try {
        driver = new mcsapi::ColumnStoreDriver("/usr/local/mariadb/columnstore/etc/Columnstore.xml");
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught " << e.what() << std::endl;
    }
    delete driver;
    return 0;
}

createBulkInsert()

ColumnStoreBulkInsert *ColumnStoreDriver::createBulkInsert(const std::string &db, const std::string &table, uint8_t mode, uint16_t pm)

Allocates and configures an instance of ColumnStoreBulkInsert to be used for bulk inserts with the ColumnStore installation reference by the driver. The resulting object should be freed by the application using the library.

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 ColumnStoreServerError:
 

If a table lock cannot be acquired for the desired table

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    std::string table("t1");
    std::string db("test");
    mcsapi::ColumnStoreDriver* driver = nullptr;
    mcsapi::ColumnStoreBulkInsert* bulkInsert = nullptr;
    try {
        driver = new mcsapi::ColumnStoreDriver();
        bulkInsert = driver->createBulkInsert(db, table, 0, 0);
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught " << e.what() << std::endl;
    }
    delete bulkInsert;
    delete driver;
    return 0;
}

getVersion()

const char *ColumnStoreDriver::getVersion()

Returns the version of the 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 version string

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    try {
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        const char* version = driver->getVersion();
        std::cout << version << std::endl;
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}

setDebug()

void ColumnStoreDriver::setDebug(uint8_t 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
 9
10
11
12
13
14
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    try {
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        driver->setDebug(true);
        // Debugging output is now enabled
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}

getSystemCatalog()

ColumnStoreSystemCatalog &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
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    try {
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        mcsapi::ColumnStoreSystemCatalog sysCat = driver->getSystemCatalog();

        mcsapi::ColumnStoreSystemCatalogTable tbl = sysCat.getTable("test", "t1");
        std::cout << "t1 has " << tbl.getColumnCount() << " columns" << endl;

        mcsapi::ColumnStoreSystemCatalogColumn col1 = tbl.getColumn(0);
        std::cout << "The first column in t1 is " << col1.getColumnName() << endl;
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}

listTableLocks()

std::vector<mcsapi::TableLockInfo> ColumnStoreDriver::listTableLocks()

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

Returns:A vector of mcsapi::TableLockInfo objects

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    try{
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        std::vector<mcsapi::TableLockInfo> tliv = driver.listTableLocks();
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}

isTableLocked()

bool ColumnStoreDriver::isTableLocked(const std::string &db, const std::string &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 ColumnStoreServerError:
 

If the specified table is not existent

Note

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

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    try{
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        bool locked = driver.isTableLocked("test","tmp1");
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}
bool ColumnStoreDriver::isTableLocked(const std::string &db, const std::string &table, TableLockInfo &rtn)

Returns true if the specified table is locked and false if it is not locked. Further information about the table lock can be accessed through the referrenced TableLockInfo.

Parameters:
  • db – The database name for the table to check
  • table – The tabe name to check
  • rtn – The TableLockInfo object reference to store further information about the table lock into.
Returns:

true if the specified table is locked, otherwise false

Raises ColumnStoreServerError:
 

If the specified table is not existent

Note

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

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    try{
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        mcsapi::TableLockInfo tli;
        bool locked = driver.isTableLocked("test","tmp1",tli);
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}

clearTableLock()

void ColumnStoreDriver::clearTableLock(uint64_t 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
10
11
12
13
14
#include <iostream>
int main(void)
{
    try{
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        std::vector<mcsapi::TableLockInfo> tliv = driver.listTableLocks();
        for( auto& tli : tliv ){
            driver.clearTableLock(tli.id);
        }
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}
void ColumnStoreDriver::clearTableLock(mcsapi::TableLockInfo tli)

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

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

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    try{
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        std::vector<mcsapi::TableLockInfo> tliv = driver.listTableLocks();
        for( auto& tli : tliv ){
            driver.clearTableLock(tli);
        }
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}
void ColumnStoreDriver::clearTableLock(const std::string &db, const std::string &table)

Clears a table lock of given database table combinationd

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

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <iostream>
#include <libmcsapi/mcsapi.h>

int main(void)
{
    try{
        mcsapi::ColumnStoreDriver* driver = new mcsapi::ColumnStoreDriver();
        driver.clearTableLock("test","tmp1");
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    return 0;
}