AbstractBulkOperation.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* AbstractBulkOperation.qc Copyright 2015 - 2017 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// minimum required Qore version
// require type definitions everywhere
// enable all warnings
// assume local scope for variables, do not use "$" signs
namespace BulkSqlUtil {
class AbstractBulkOperation {
public:
const OptionKeys = ...;
const OptionDefaults = ...;
protected:
SqlUtil::AbstractTable table;
softint block_size;
hash hbuf;
hash cval;
list cval_keys;
*code info_log;
int row_count = 0;
string opname;
list ret_args = ();
public:
constructor(string name, SqlUtil::Table target, *hash opts);
constructor(string name, SqlUtil::AbstractTable target, *hash opts);
destructor();
queueData(hash data);
queueData(list l);
int size();
protected:
init(*hash opts);
public:
protected:
setupInitialRowColumns(hash row);
public:
protected:
setupInitialRow(hash row);
public:
flush();
protected:
flushIntern();
public:
discard();
nothing commit();
nothing rollback();
string getTableName();
SqlUtil::AbstractTable getTable();
Qore::SQL::AbstractDatasource getDatasource();
int getRowCount();
protected:
abstract flushImpl();
public:
};
};
BulkSqlUtil::AbstractBulkOperation::cval
hash cval
"constant" row values; must be equal in all calls to queueData
Definition: AbstractBulkOperation.qc.dox.h:107
BulkSqlUtil::AbstractBulkOperation::info_log
*code info_log
an optional info logging callback; must accept a sprintf()-style format specifier and optional argume...
Definition: AbstractBulkOperation.qc.dox.h:113
BulkSqlUtil::AbstractBulkOperation::getTable
SqlUtil::AbstractTable getTable()
returns the underlying SqlUtil::AbstractTable object
BulkSqlUtil::AbstractBulkOperation::getDatasource
Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
BulkSqlUtil::AbstractBulkOperation::flushImpl
abstract flushImpl()
flushes queued data to the database
BulkSqlUtil::AbstractBulkOperation::queueData
queueData(hash data)
queues row data in the block buffer; the block buffer is flushed to the DB if the buffer size reaches...
BulkSqlUtil::AbstractBulkOperation::discard
discard()
discards any buffered batched data; this method should be called before destroying the object if an e...
BulkSqlUtil::AbstractBulkOperation::setupInitialRow
setupInitialRow(hash row)
sets up the block buffer given the initial template row for inserting
BulkSqlUtil::AbstractBulkOperation::row_count
int row_count
row count
Definition: AbstractBulkOperation.qc.dox.h:116
BulkSqlUtil::AbstractBulkOperation::OptionKeys
const OptionKeys
option keys for this object
Definition: AbstractBulkOperation.qc.dox.h:89
BulkSqlUtil
Qore AbstractBulkOperation class definition.
Definition: AbstractBulkOperation.qc.dox.h:34
Qore::SQL::AbstractDatasource
BulkSqlUtil::AbstractBulkOperation::getTableName
string getTableName()
returns the table name
BulkSqlUtil::AbstractBulkOperation::flushIntern
flushIntern()
flushes queued data to the database
list
list< auto > list(...)
BulkSqlUtil::AbstractBulkOperation::rollback
nothing rollback()
discards any queued data and rolls back the transaction
BulkSqlUtil::AbstractBulkOperation::constructor
constructor(string name, SqlUtil::Table target, *hash opts)
creates the object from the supplied arguments
BulkSqlUtil::AbstractBulkOperation::getRowCount
int getRowCount()
returns the affected row count
BulkSqlUtil::AbstractBulkOperation::opname
string opname
operation name
Definition: AbstractBulkOperation.qc.dox.h:119
BulkSqlUtil::AbstractBulkOperation::setupInitialRowColumns
setupInitialRowColumns(hash row)
sets up the block buffer given the initial template hash of lists for inserting
BulkSqlUtil::AbstractBulkOperation::commit
nothing commit()
flushes any queued data and commits the transaction
hash
hash< auto > hash(object obj)
BulkSqlUtil::AbstractBulkOperation::table
SqlUtil::AbstractTable table
the target table object
Definition: AbstractBulkOperation.qc.dox.h:98
BulkSqlUtil::AbstractBulkOperation::destructor
destructor()
throws an exception if there is data pending in the internal row data cache; make sure to call flush(...
BulkSqlUtil::AbstractBulkOperation::OptionDefaults
const OptionDefaults
default option values
Definition: AbstractBulkOperation.qc.dox.h:93
BulkSqlUtil::AbstractBulkOperation::cval_keys
list cval_keys
"constant" row value keys
Definition: AbstractBulkOperation.qc.dox.h:110
BulkSqlUtil::AbstractBulkOperation::flush
flush()
flushes any remaining batched data to the database; this method should always be called before commit...
BulkSqlUtil::AbstractBulkOperation
base class for bulk DML operations
Definition: AbstractBulkOperation.qc.dox.h:85
BulkSqlUtil::AbstractBulkOperation::ret_args
list ret_args
list of "returning" columns
Definition: AbstractBulkOperation.qc.dox.h:122
BulkSqlUtil::AbstractBulkOperation::size
int size()
returns the current size of the cache as a number of rows
BulkSqlUtil::AbstractBulkOperation::hbuf
hash hbuf
buffer for bulk operations
Definition: AbstractBulkOperation.qc.dox.h:104
BulkSqlUtil::AbstractBulkOperation::init
init(*hash opts)
common constructor initialization
BulkSqlUtil::AbstractBulkOperation::block_size
softint block_size
bulk operation block size
Definition: AbstractBulkOperation.qc.dox.h:101