Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCOL-4889 Vacuum cleaning for on-disk data empty records #3237

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbcon/dmlpackage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ADD_LIBRARY(dmlpackage SHARED
commanddmlpackage.cpp
dmlpkg.cpp
dmlparser.cpp
vacuumpartitiondmlpackage.cpp
${BISON_dml_gram_OUTPUTS}
${FLEX_dml_scan_OUTPUTS}
)
Expand Down
3 changes: 2 additions & 1 deletion dbcon/dmlpackage/dmlpkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ enum DML_TYPE
DML_UPDATE,
DML_DELETE,
DML_COMMAND,
DML_INVALID_TYPE
DML_INVALID_TYPE,
DML_VACUUM_PARTITION
};

/** @brief SqlStatement represents a toplevel
Expand Down
81 changes: 81 additions & 0 deletions dbcon/dmlpackage/vacuumpartitiondmlpackage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* Copyright (C) 2024 MariaDB Corporation

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. */

#define VACUUMPARTITIONDMLPKG_DLLEXPORT
#include "vacuumpartitiondmlpackage.h"
#undef VACUUMPARTITIONDMLPKG_DLLEXPORT

namespace dmlpackage
{

VacuumPartitionDMLPackage::VacuumPartitionDMLPackage(std::string schemaName, std::string tableName,
std::string dmlStatement, int sessionID,
BRM::LogicalPartition partition)
: CalpontDMLPackage(schemaName, tableName, dmlStatement, sessionID), fPartition(partition)
{
}

VacuumPartitionDMLPackage::~VacuumPartitionDMLPackage() = default;

int VacuumPartitionDMLPackage::write(messageqcpp::ByteStream& bytestream)
{
bytestream << (uint8_t)DML_VACUUM_PARTITION;
bytestream << (uint32_t)fSessionID;

bytestream << fDMLStatement;
bytestream << fSchemaName;
bytestream << fTableName;

fPartition.serialize(bytestream);

return 1;
}

int VacuumPartitionDMLPackage::read(messageqcpp::ByteStream& bytestream)
{
bytestream >> fSessionID;

bytestream >> fDMLStatement;
bytestream >> fSchemaName;
bytestream >> fTableName;

fPartition.unserialize(bytestream);

return 1;
}

int VacuumPartitionDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
{
throw std::logic_error("VacuumPartitionDMLPackage::buildFromSqlStatement is not implemented yet.");
return 1;
}

int VacuumPartitionDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows)
{
throw std::logic_error("VacuumPartitionDMLPackage::buildFromBuffer is not implemented yet.");
return 1;
}

int VacuumPartitionDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap,
int columns, int rows, NullValuesBitset& nullValues)
{
throw std::logic_error("VacuumPartitionDMLPackage::buildFromMysqlBuffer is not implemented yet.");
return 1;
}

} // namespace dmlpackage
95 changes: 95 additions & 0 deletions dbcon/dmlpackage/vacuumpartitiondmlpackage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* Copyright (C) 2024 MariaDB Corporation

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. */

#pragma once

#include <string>
#include "calpontdmlpackage.h"
#include "bytestream.h"

#define EXPORT

namespace dmlpackage
{
/** @brief concrete implementation of a CalpontDMLPackage
* Specifically for representing MCS_VACUUM_PARTITION_BLOAT Statements
*/
class VacuumPartitionDMLPackage : public CalpontDMLPackage
{
public:
EXPORT VacuumPartitionDMLPackage() = default;

/** @brief ctor
*
* @param schemaName the schema of the table being operated on
* @param tableName the name of the table being operated on
* @param dmlStatement the dml statement
* @param sessionID the session ID
* @param partition partition to be vacuumed
*/
EXPORT VacuumPartitionDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement,
int sessionID, BRM::LogicalPartition partition);

/** @brief dtor
*/
EXPORT virtual ~VacuumPartitionDMLPackage();

/** @brief write a VacuumPartitionDMLPackage to a ByteStream
*
* @param bytestream the ByteStream to write to
*/
EXPORT int write(messageqcpp::ByteStream& bytestream);

/** @brief read a VacuumPartitionDMLPackage from a ByteStream
*
* @param bytestream the ByteStream to read from
*/
EXPORT int read(messageqcpp::ByteStream& bytestream);

/** @brief build a VacuumPartitionDMLPackage from a string buffer
*
* @param buffer [rowId, columnName, colValue]
* @param columns the number of columns in the buffer
* @param rows the number of rows in the buffer
*/
EXPORT int buildFromBuffer(std::string& buffer, int columns, int rows);

/** @brief build a VacuumPartitionDMLPackage from a parsed DeleteSqlStatement
*
* @param sqlStatement the parsed DeleteSqlStatement
*/
EXPORT int buildFromSqlStatement(SqlStatement& sqlStatement);
/** @brief build a InsertDMLPackage from MySQL buffer
*
* @param colNameList, tableValuesMap
* @param rows the number of rows in the buffer
*/
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns,
int rows, NullValuesBitset& nullValues);

BRM::LogicalPartition getPartition() const
{
return fPartition;
}

private:
BRM::LogicalPartition fPartition; // The partition number
};
} // namespace dmlpackage

#undef EXPORT
3 changes: 2 additions & 1 deletion dbcon/dmlpackageproc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ set(dmlpackageproc_LIB_SRCS
updatepackageprocessor.cpp
commandpackageprocessor.cpp
autoincrementdata.cpp
tablelockdata.cpp)
tablelockdata.cpp
vacuumpartitionpackageprocessor.cpp)

add_library(dmlpackageproc SHARED ${dmlpackageproc_LIB_SRCS})

Expand Down
3 changes: 2 additions & 1 deletion dbcon/dmlpackageproc/dmlpackageprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class DMLPackageProcessor
JOB_ERROR,
JOB_CANCELED,
DBRM_READ_ONLY,
PP_LOST_CONNECTION
PP_LOST_CONNECTION,
VACUUM_ERROR
};

enum DebugLevel /** @brief Debug level type enumeration */
Expand Down
Loading