1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-11-02 06:13:16 +03:00
Files
mariadb-columnstore-engine/writeengine/wrapper/we_colop.h
Sergey Zefirov 4545a86a80 Porting old MCOL-2044-update...: new interface for writeColRecs
Progress keep and test commit

Progress keep and test commit

Progress keep and test commit

Again, trying to pinpoint problematic part of a change

Revert "Again, trying to pinpoint problematic part of a change"

This reverts commit 71874e7c0d7e4eeed0c201b12d306b583c07b9e2.

Revert "Progress keep and test commit"

This reverts commit 63c7bc67ae55bdb81433ca58bbd239d6171a1031.

Revert "Progress keep and test commit"

This reverts commit 121c09febd78dacd37158caeab9ac70f65b493df.

Small steps - I walk minefield here

Propagating changes - now CPInfo in convertValArray

Progress keep commit

Restoring old functionality

Progress keep commit

Small steps to avoid/better locate old problem with the write engine.

Progress keeping commit

Thread the CPInfo up to convertValArray call in writeColumnRec

About to test changes - I should get no regression and no updates in
ranges either.

Testing out why I get a regression

Investigating source of regression

Debugging prints

Fix compile error

Debugging print - debug regression

I clearly see calls to writeColumnRec and prints there added to discern
between these.

Fix warning error

Possible culprit

Add forgotten default parameter for convertValArray

New logic to test

Max/min gets updated during value conversion

To test results of updates

Debug logs

Debug logs

An attempt to provide proper sequence index

Debug logs

An attempt to provide proper sequence index - now magic for resetting

Debug logs

Debug logs

Debug logs

Trying to perform correct updates

Trying to perform correct updates - seqNum woes fight

COMMIT after INSERT performs 'mark extent as invalid' operation - investigating

To test: cut setting of CPInfo upon commit from DML processor

It may be superfluous as write engine does that too

Debug logs

Debug logs

Better interface for CPMaxMin

Old interface forgot to set isBinaryColumn field

Possible fix for the problems

I forgot to reassign the value in cpinfoList

Debug logs

Computation of 'binary' column property

logs indicated that it was not set in getExtentCPMaxMin, and it was impossible to compute there so I had to move that into writeengine.

To test: code to allow cross-extent insertion

To test: removed another assertion for probable cause of errors

Debug logs

Dropped excessive logs

Better reset code

Again, trying to fix ordering

Fixing order of rowids for LBID computation

Debug logs

Remove update of second LBID in split insert

I have to validate incorrect behaviour for this test

Restoring the case where everything almost worked

Tracking changes in newly created extents

Progress keeping commit

Fixing build errors with recent server

An ability to get old values from blocks we update

Progress keeping commit

Adding analysis of old values to write engine code.

It is needed for updates and deletes.

Progress keeping commit

Moving max/min range update from convertValArray into separate function with simpler logic.

To test and debug - logic is there

Fix build errors

Update logic to debug

There is a suspicious write engine method updateColumnRecs which
receives a vector of column types but does not iterate over them
(otherwise it will be identical to updateColumnRec in logic).

Other than that, the updateColumnRec looks like the center of all
updates - deleteRow calls it, for example, dml processor also calls it.

Debug logs for insert bookkeeping regression

Set up operation type in externally-callable interface

Internal operations depend on the operation type and consistency is what matters there.

Debug logs

Fix for extent range update failure during update operation

Fix build error

Debug logs

Fix for update on deletion

I am not completely sure in it - to debug.

Debug log

writeColumnRec cannot set m_opType to UPDATE unconditionally

It is called from deleteRow

Better diagnostics

Debug logs

Fixed search condition

Debug logs

Debugging invalid LBID appearance

Debug logs - fixed condition

Fix problems with std::vector reallocation during growth

Fix growing std::vector data dangling access error

Still fixing indexing errors

Make in-range update to work

Correct sequence numbers

Debug logs

Debug logs

Remove range drop from DML part of write engine

A hack to test the culprit of range non-keeping

Tests - no results for now

MTR-style comments

Empty test results

To be filled with actual results.

Special database and result selects for all tests

Pleasing MTR with better folder name

Pleasing MTR - testing test result comparison

Pleasing MTR by disabling warnings

All test results

Cleaning up result files

Reset ranges before update

Remove comments from results - point of failure in MTR

Remove empty line from result - another MTR failure point

Probably fix for deletes

Possible fix for remaining failed delete test

Fix a bug in writeRows

It should not affect delete-with-range test case, yet it is a bug.

Debug logs

Debug logs

Tests reorganization and description

Support for unsigned integer for new tests

Fix type omission

Fix test failure due to warnings on clean installation

Support for bigint to test

Fix for failed signed bigint test

Set proper unsignedness flag

Removed that assignment during refactoring.

Tests for types with column width 1 and 2

Support for types in new tests

Remove trailing empty lines from results

Tests had failed because of extra empty lines.

Remove debug logs

Update README with info about new tests

Move tests for easier testing

Add task tag to tests

Fix invalid unsaigned range check

Fix for signed types

Fix regressions - progress keeping commit

Do not set invalid ranges into valid state

A possible fix for mcs81_self_join test

MCOL 2044 test database cleanup

Missing expected results

Delete extraneous assignment to m_opType

nullptr instead of NULL

Refactor extended CPInfo with TypeHandler

Better handling of ranges - safer types, less copy-paste

Fix logic error related to typo

Fix logic error related to typo

Trying to figure out why invalid ranges aren't displayed as NULL..NULL

Debug logs

Debug logs

Debug logs

Debug logs for worker node

Debug logs for worker node in extent map

Debugging virtual table fill operation

Debugging virtual table fill operation

Fix for invalid range  computation

Remove debug logs

Change handling of invalid ranges

They are also set, but to invalid state.

Complete change

Fix typo

Remove unused code

"Fix" for tests - -1..0 instead of NULL..NULL for invalid unsigned ranges

Not a good change, yet I cannot do better for now.

MTR output requires tabs instead of spaces

Debug logs

Debug logs

Debug logs - fix build

Debug logs and logic error fix

Fix for clearly incorrect firstLBID in CPInfo being set - to test

Fix for system catalog operations suppot

Better interface to fix build errors

Delete tests we cannot satisfy due to extent rescan due to WHERE

Tests for wide decimals

Testing support for wide decimals

Fix for wide decimals tests

Fix for delete within range

Memory leak fix and, possible, double free fix

Dispatch on CalpontSystemCatalog::ColDataType is more robust

Add support for forgotten MEDINT type

Add forgottent BIGINT

empty() instead of size() > 0

Better layout

Remove confusing comment

Sensible names for special values of seqNum field

Tests for wide decimal support

Addressing concerns of drrtuy

Remove test we cannot satisfy

Final touches for PR

Remove unused result file
2021-04-05 14:18:22 +03:00

352 lines
13 KiB
C++

/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
// $Id: we_colop.h 4728 2013-08-08 19:26:10Z chao $
/** @file */
#ifndef _WE_COLOP_H_
#define _WE_COLOP_H_
#include <stdlib.h>
#include "we_dbfileop.h"
#include "brmtypes.h"
#include "we_dbrootextenttracker.h"
#include "we_tablemetadata.h"
#include "../dictionary/we_dctnry.h"
#if defined(_MSC_VER) && defined(WRITEENGINE_DLLEXPORT)
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
/** Namespace WriteEngine */
namespace WriteEngine
{
class Log;
//const int COL_DATATYPE_NUM = 15;
//const char ColDataTypeStr[COL_DATATYPE_NUM][20] = { "bit", "tinyint", "char", "smallint", "decimal", "medint", "integer", "float", "date", "bigint",
// "double", "datetime", "varchar", "clob", "blob" };
/** Class ColumnOp */
class ColumnOp : public DbFileOp
{
public:
/**
* @brief Constructor
*/
EXPORT ColumnOp();
EXPORT ColumnOp(Log* logger);
/**
* @brief Default Destructor
*/
EXPORT virtual ~ColumnOp();
EXPORT virtual int allocRowId(const TxnID& txnid,
bool useStartingExtent,
Column& column,
uint64_t totalRow,
RID* rowIdArray,
HWM& hwm,
bool& newExtent,
uint64_t& rowsLeft,
HWM& newHwm,
bool& newFile,
ColStructList& newColStructList,
DctnryStructList& newDctnryStructList,
std::vector<boost::shared_ptr<DBRootExtentTracker> >& dbRootExtentTrackers,
bool insertSelect,
bool isBatchInsert,
OID tableOid, bool isFirstBatchPm,
std::vector<BRM::LBID_t>* newEtents);
/**
* @brief Create column file(s)
*/
EXPORT virtual int createColumn(Column& column,
int colNo,
int colWidth,
execplan::CalpontSystemCatalog::ColDataType colDataType,
ColType colType,
FID dataFid,
uint16_t dbRoot,
uint32_t partition);
/**
* @brief Fills up a column with null/default values in all non-empty rows as the reference column. The reference column
* would typically be another column of the same table.
*
* @param column The new colum
* @param refCol The reference column for identifying valid rows
* @param defaultVal The default value of the new column
* @param dictOid The dictionary store OID for a dictionary column
* @param dictColWidth The dictionary string width for a dictionary column
*/
//BUG931
EXPORT virtual int fillColumn(const TxnID& txnid,
Column& column,
Column& refCol,
void* defaultVal,
Dctnry* dctnry,
ColumnOp* refColOp,
const OID dictOid = 0,
const int dictColWidth = 0,
const std::string defaultValStr = "",
bool autoincrement = false);
/**
* @brief Create a table file
*/
EXPORT virtual int createTable() const;
/**
* @brief Drop column file(s)
*/
EXPORT virtual int dropColumn(const FID dataFid);
/**
* @brief Drop column and dictionary file(s)
*/
EXPORT virtual int dropFiles(const std::vector<int32_t>& dataFids);
/**
* @brief Delete file(s) for the given partition
*/
EXPORT virtual int dropPartitions(const std::vector<OID>& dataFids,
const std::vector<BRM::PartitionInfo>& partitions);
EXPORT virtual int deleteOIDsFromExtentMap(const std::vector<int32_t>& dataFids);
/**
* @brief Drop a table file
*/
int dropTable() const
{
return NO_ERROR;
}
/**
* @brief Expand the abbreviated extent to a full extent for this column.
*/
EXPORT virtual int expandAbbrevExtent(const Column& column);
/**
* @brief Add an extent to the specified column OID and DBRoot.
* When this function returns, the file position will be located at the
* end of the file. If the applicable column segment file does not exist,
* extendColumn() will create the new segment file.
* The extent must already exist in the extentmap prior to calling this fctn.
*
* @param column Column struct with input column attributes.
* @param leaveFileOpen Leave the db file open when leaving this function
* @param hwm The fbo of the column segment file where the new extent begins
* @param startLbid The starting LBID for the new extent.
* @param allocSize Number of blocks to be written for an extent
* @param dbRoot The DBRoot of the file with the new extent.
* @param partition Partition num of the file with the new extent.
* @param segment The segment number of the file with the new extent.
* @param segFile (out) Name of segment file to which the extent is added.
* @param pFile (out) FILE ptr to the file where the extent is added.
* @param newFile (out) Indicates if extent was added to new or existing file
* @param hdrs (out) Contents of headers if file is compressed.
* @return returns NO_ERROR if success.
*/
EXPORT int extendColumn(const Column& column,
bool leaveFileOpen,
HWM hwm,
BRM::LBID_t startLbid,
int allocSize,
uint16_t dbRoot,
uint32_t partition,
uint16_t segment,
std::string& segFile,
IDBDataFile*& pFile,
bool& newFile,
char* hdrs = NULL);
/**
* @brief Add an extent to the OID specified in the column argument.
* When this function returns, the file position will be located at the
* end of the file.
*
* @param column Column struct with input column attributes.
* @param dbRoot (in) The DBRoot of the file with the new extent.
* @param partition (in) The partition num of the file with the new extent.
* @param segment (in) The segment number of the file with the new extent.
* @param segFile (out) Name of segment file to which the extent is added.
* @param startLbid (out) The starting LBID for the new extent.
* @param newFile (out) Indicates if extent was added to new or existing file
* @param hdsr (out) Contents of headers if file is compressed.
* @param allocSize (out) number of blocks to be written for an extent
* @return returns NO_ERROR if success.
*/
EXPORT int addExtent(const Column& column,
uint16_t dbRoot,
uint32_t partition,
uint16_t segment,
std::string& segFile,
BRM::LBID_t& startLbid,
bool& newFile,
int& allocSize,
char* hdrs = NULL);
/**
* @brief Get columne data type
*/
EXPORT virtual bool getColDataType(const char* name, execplan::CalpontSystemCatalog::ColDataType& colDataType) const;
/**
* @brief Initialize the column
*/
EXPORT virtual void initColumn(Column& column) const;
/**
* @brief Check whether it is an empty row
*/
EXPORT virtual bool isEmptyRow(uint64_t* curVal,
const uint8_t* emptyVal,
const int colWidth);
/**
* @brief Check whether it is a valid column
*/
EXPORT virtual bool isValid(Column& column) const;
/**
* @brief Open column file, segFile is set to the name of the column
* segment file that is opened.
*/
EXPORT virtual int openColumnFile(Column& column,
std::string& segFile,
bool useTmpSuffix,
int ioBuffSize = DEFAULT_BUFSIZ) const;
/**
* @brief Open table file
*/
int openTableFile() const
{
return NO_ERROR;
}
/**
* @brief Delete a file
*/
EXPORT virtual void setColParam(Column& column, int colNo = 0,
int colWidth = 0,
execplan::CalpontSystemCatalog::ColDataType colDataType = execplan::CalpontSystemCatalog::INT,
ColType colType = WR_INT,
FID dataFid = 0,
int comppre = 0,
uint16_t dbRoot = 0,
uint32_t partition = 0,
uint16_t segment = 0) const;
/**
* @brief Write row(s)
*/
EXPORT virtual int writeRow(Column& curCol,
uint64_t totalRow,
const RID* rowIdArray,
const void* valArray,
void* oldValArray =0,
bool bDelete = false);
/**
* @brief Write row(s) for delete @Bug 1886,2870
*/
EXPORT virtual int writeRows(Column& curCol,
uint64_t totalRow,
const RIDList& ridList,
const void* valArray,
void* oldValArray = 0,
bool bDelete = false);
/**
* @brief Write row(s) for update @Bug 1886,2870
*/
EXPORT virtual int writeRowsValues(Column& curCol,
uint64_t totalRow,
const RIDList& ridList,
const void* valArray,
void* oldValArray = 0);
/**
* @brief Test if the pFile is an abbreviated extent.
*/
virtual bool abbreviatedExtent(IDBDataFile* pFile, int colWidth) const = 0;
/**
* @brief Caculate the number of blocks in file.
*/
virtual int blocksInFile(IDBDataFile* pFile) const = 0;
/**
* @brief Clear a column
*/
EXPORT void clearColumn(Column& column) const;
/**
* @brief open a data file of column
*/
virtual IDBDataFile* openFile(const Column& column, uint16_t dbRoot, uint32_t partition,
uint16_t segment, std::string& segFile, bool useTmpSuffix, const char* mode = "r+b",
int ioBuffSize = DEFAULT_BUFSIZ) const = 0;
/**
* @brief backup blocks to version buffer
*/
int writeVB(IDBDataFile* pSource, const OID sourceOid, IDBDataFile* pTarget, const OID targetOid,
const std::vector<uint32_t>& fboList, const BRM::VBRange& freeList,
size_t& nBlocksProcessed, const size_t fboCurrentOffset);
/**
* @brief restore blocks from version buffer
*/
int copyVB(IDBDataFile* pSource, const BRM::VER_t txnD, const OID oid, std::vector<uint32_t>& fboList,
std::vector<BRM::LBIDRange>& rangeList);
/**
* @brief close column file
*/
EXPORT virtual void closeColumnFile(Column& column) const;
protected:
/**
* @brief populate readBuf with data in block #lbid
*/
virtual int readBlock(IDBDataFile* pFile, unsigned char* readBuf, const uint64_t fbo) = 0;
/**
* @brief output writeBuf to pFile starting at position fbo
*/
virtual int saveBlock(IDBDataFile* pFile, const unsigned char* writeBuf, const uint64_t fbo) = 0;
private:
};
} //end of namespace
#undef EXPORT
#endif // _WE_COLOP_H_