Create a record
| Command | Return values | Parameters | Feature description |
|---|---|---|---|
| void ILogRecord::setSrcType(int type) | No return value. | type: Valid values: 0x00, 0x01, 0x02, 0x03, 0x04, and 0x05, which respectively correspond to MySQL, OceanBase, Hbase, Oracle, OceanBase_1_0, and DB2. Note The value set for obcdc is 0x04, which indicates that the data source is OceanBase_1_0. |
Sets the type of the data source. |
| void ILogRecord::setCheckpoint(uint64_t file, uint64_t offset) | No return value. | file: A unix timestamp, in seconds. offset: A unix timestamp in the file parameter, in microseconds. | Sets the information about the current analysis timestamp. |
| int ILogRecord::setRecordType(int aType) | The return value is fixed to 0. | aType: Seven types are supported: insert operation 0x00(EINSERT), update operation 0 x01(EUPDATE), delete operation 0x02(EDELETE), heartbeat packet 0x04(HEARTBEAT), transaction start 0x06(EBEGIN), transaction commit 0x07(ECOMMIT), and DDL operation 0x08(EDDL). | Sets the operation type for a record. |
| void ILogRecord::setDbname(const char *dbname) | No return value. | dbname: The name of the database from which the record originates. | Sets the source database name for a record. |
| void ILogRecord::setTbname(const char *tbname) | No return value. | dbname: The name of the record table. | Sets the table name for a record. |
| void ILogRecord::setTableMeta(ITableMeta* tblMeta) | No return value. | tblMeta: The metadata information about the record. The memory is applied for and released by the caller. | Sets the metadata information for a record. |
| void ITableMeta::setName(const char* name) | No return value. | name: The name of the table. | Sets the table name in the metadata. |
| void ITableMeta::setUKs(const char* uks) | No return value. | uks: A string of the names of unique key (UK) fields in the (col1,col2,col3....) format. For example, (col1,col2) and (col2,col3) must be combined into the (col1,col2,col3) string before being passed in. | Sets the names of UK fields in the metadata. |
| void ITableMeta::setPKs(const char* pks) | No return value. | pks: A string of the names of the primary key (PK) fields in the (col1,col2,col3...) format. | Sets the names of the PK fields in the metadata. |
| void ITableMeta::setPkinfo(const char* info) | No return value. | info: A string of the IDs of the PK fields in the (0,1,2,3...) format, starting from 0. | Sets the IDs of the PK fields in the metadata. |
| void ITableMeta::setUkinfo(const char* info) | No return value. | info: A string of the IDs of UK fields in the (0,1,2,3...) format. For multiple UKs, pass them in the (0,1),(1,2),(0,3)... format. | Sets the IDs of UK fields in the metadata. |
| int ITableMeta::append(const char* colName, IColMeta* colMeta) | -1: The column name already exists in the table and cannot be added. 0: Added successfully. | colName: The column name. colMeta: The metadata information about the column. | Adds the metadata information about a column to the metadata information about a table. |
| void IColMeta::setName(const char* name) | No return value. | name: The name of the column. | Sets the column name for the metadata information about a column. |
| void IColMeta::setType(int type) | No return value. | type: The type of the column. For more information about the valid values, see the enum logmsg_field_types section of include/MetaInfo.h. | Sets the data type of the column. |
| void IColMeta::setLength(long length) | No return value. | length: The byte length of the column. | Sets the byte length of the column. |
| void IColMeta::setIsPK(bool b) | No return value. | b: If this parameter is set to true, this column is a PK column. If this parameter is set to false, this column is not a PK column. | Sets whether the column is a PK column. |
| void IColMeta::setIsUK(bool b) | No return value. | b: If this parameter is set to true, this column is a UK column. If this parameter is set to false, this column is not a UK column. | Sets whether the column is a UK column. |
| void IColMeta::setNotNull(bool b) | No return value. | b: If this parameter is set to true, this column cannot contain null values. If this parameter is set to false, this column can contain null values. | Sets whether the column can contain null values. |
| void ILogRecord::setOldColumn(BinLogBuf* buf, int size) | No return value. | buf: The first address of the space. size: The number of BinLogBufs in the space. Typically, it is the number of fields in the table. | Initializes a space to store the field values of the beforeimage. The size of the space is determined by the value you specified for the size parameter, which means the number of BinLogBufs in the space. The value of the size parameter must be equal to or greater than the number of fields in the table. This space is applied for and released by the caller. |
| void ILogRecord::setNewColumn(BinLogBuf* buf, int size) | No return value. | buf: The first address of the space. size: The number of BinLogBufs in the space. Typically, it is the number of fields in the table. | Initializes a space to store the field values of the afterimage. The size of the space is determined by the value you specified for the size parameter, which means the number of BinLogBufs in the space. The value of the size parameter must be equal to or greater than the number of fields in the table. This space is applied for and released by the caller. |
| int ILogRecord::putOld(const char* pos, int len) | The return value is fixed to 0. | pos: The start address of the field value. len: The length of the field value. | Adds the value of a field in the beforeimage to the record. |
| int ILogRecord::putNew(const char* pos, int len) | The return value is fixed to 0. | pos: The start address of the field value. len: The length of the field value. | Adds the value of a field in the afterimage to the record. |
| const char* ILogRecord::toString(size_t *size, bool reserveMemory) | NULL: Serialization failed. Non-null pointer: The start address of the serialized data. | size: A size_t type address. After serialization, the length of the serialized data is written to this address. reserveMemory: Specifies whether to reserve the serialized data in the data area of the record. If not, data stored in this record is cleared after serialization and becomes unavailable. | Serializes a record. |
| bool ILogRecord::parsedOK() | true: The record has been serialized or is created upon deserialization of a piece of data. false: This record has not been serialized. | Checks whether a record has been serialized. |
Deserialize a record or parse data from a serialized record (where ILogRecord::parsedOK() returns true)
| Command | Return values | Parameters | Description |
|---|---|---|---|
| int ILogRecord::parse(const void* ptr, size_t size) | 0: The operation is successful. Other values: The operation failed. | ptr: The start address that stores the serialized data. size: The size of the serialized data. | Deserializes a record. |
| int ILogRecord::getSrcType() | Returns an int value. Valid values: 0x00, 0x01, 0x02, 0x03, 0x04, and 0x05, which respectively correspond to MySQL, OceanBase, Hbase, Oracle, OceanBase_1_0, and DB2. Note The value set for obcdc is 0x04, which indicates that the data source is OceanBase_1_0. |
Queries the type of the data source. | |
| uint64_t ILogRecord::getCheckpoint1()/uint64_t ILogRecord::getCheckpoint2() | getCheckpoint1: returns a unix timestamp, in seconds. getCheckpoint2: returns a unix timestamp, in milliseconds. You can use getCheckpoint1*1000000+getCheckpoint2 as the analysis timestamp. | The command obtains the analysis timestamp. | |
| int ILogRecord::recordType() | An int value is returned. The valid values include the insert operation 0x00(EINSERT), update operation 0x01(EUPDATE), delete operation 0x02(EDELETE), heartbeat packet 0x04(HEARTBEAT), transaction start 0x06(EBEGIN), transaction commit 0x07(ECOMMIT), and DDL operation 0x08(EDDL). | Retrieves the operation type of a record. | |
| const char* ILogRecord::dbname() const | A pointer of the char* type is returned, pointing to the name of the source database of the record. | Retrieves the name of the source database of a record. | |
| const char* ILogRecord::tbname() const | A pointer of the char* type is returned, pointing to the name of the source table of the record. | Retrieves the name of the source table of a record. | |
| int ILogRecord::getTableMeta(ITableMeta*& tblMeta) | 0: The operation is successful. Other values: The operation failed. | tblMeta: The start address of table metadata. | Retrieves the metadata information about a table from a record. The caller applies for and releases the memory for tblMeta when retrieving values from a serialized record. |
| const char* ITableMeta::getName() | A pointer of the char* type is returned, pointing to the table name in the metadata of the record. | name: The name of the table. | Retrieves the table name from the metadata. |
| const char* ITableMeta::getUKs() | A pointer of the char* type is returned, pointing to the string of UK field names in the (col1,col2,col3...) format. | Retrieves UK field names from the metadata. | |
| const char* ITableMeta::getPKs() | A pointer of the char* type is returned, pointing to the string containing the primary key field names in the format of (col1,col2,col3...). | Retrieves the names of PK field names from the metadata. | |
| const char* ITableMeta::getPkinfo() | A pointer of the char* type is returned, pointing to the string of PK field IDs in the (0,1,2,3...) format. | Retrieves PK field IDs from the metadata, starting from 0. | |
| const char* ITableMeta::getUkinfo() | A pointer of the char* type is returned, pointing to the string of UK field IDs in the (0,1,2,3...) format. | Retrieves UK field IDs from the metadata, starting from 0. | |
| int ITableMeta::getColCount() | The number of fields is returned. | Obtains the number of fields in the metadata. | |
| const char* IColMeta::getName() | A pointer of the char* type is returned, pointing to the column name of the metadata. | Retrieves the name of a column in the metadata. | |
| int IColMeta::getType() | A value of the int type is returned. For more information about the valid values, see the enum logmsg_field_types section of include/MetaInfo.h. | Obtains the type of the column. | |
| long IColMeta::getLength() | The byte length of the column. | Obtains the byte length of the column. | |
| bool IColMeta::isPK() | A value of the bool type is returned. If the value is true, this column is a PK column. If the value is false, this column is not a PK column. | Checks whether the column is a PK column. | |
| bool IColMeta::isUK() | A value of the bool type is returned. If the value is true, this column is a UK column. If the value is false, this column is not a UK column. | Checks whether the column is a UK column. | |
| bool IColMeta::isNotNull() | A value of the bool type is returned. If the value is true, this column cannot contain null values. If the value is false, this column can null values. | Checks whether the column can contain null values. | |
| StrArray* ILogRecord::parsedOldCols() const | A pointer of the StrArray type is returned, pointing to the value that holds the beforeimage data. You can call the StrArray->size() operation to obtain the number of columns of the data, or call the StrArray->elementAt(int i, const char*& s, size_t& length) operation to obtain the data of each column. | Retrieves all field values in the beforeimage of the record. | |
| StrArray* ILogRecord::parsedNewCols() const | A pointer of the StrArray type is returned, pointing to the value that holds the afterimage data. You can call the StrArray->size() interface to obtain the number of columns of the data, or call the StrArray->elementAt(int i, const char*& s, size_t& length) interface to obtain the data of each column. | Retrieves all field values in the afterimage of the record. |
Parse the beforeimage and afterimage field data from an unserialized record (where ILogRecord::parsedOK() returns false)
| Command | Return values | Parameters | Description |
|---|---|---|---|
| int ILogRecord::getTableMeta(ITableMeta*& tblMeta) | 0: The operation is successful. Other values: The operation failed. | tblMeta: must be a null pointer. This interface points this pointer to the metadata address of the record. The memory is managed by logmessage and the caller does not need to release the memory. | Retrieves the metadata information about a table from a record. To retrieve values from an unserialized record, tblMeta must be a null pointer. |
| BinLogBuf* ILogRecord::newCols(unsigned int& count) | A pointer of the BinLogBuf type is returned, pointing to a space with a number of BinLogBufs specified by count. Each BinLogBuf.buf member is a field value, and BinLogBuf.buf_used_size is the length of the field value. | count: The number of columns in the returned data. | Retrieves all field values in the afterimage of the record. |
| BinLogBuf* ILogRecord::oldCols(unsigned int& count) | A pointer of the BinLogBuf type is returned, pointing to a space with a number of BinLogBufs specified by count. Each BinLogBuf.buf member is a field value, and BinLogBuf.buf_used_size is the length of the field value. | count: The number of columns in the returned data. | Retrieves all field values in the afterimage of the record. |