MCPcopy Create free account
hub / github.com/ByConity/ByConity / commit

Method commit

src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:781–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

779}
780
781void MaterializeMySQLSyncThread::Buffers::commit(ContextPtr context, const MySQLReplication::Position & position)
782{
783 try
784 {
785 if (position.binlog_name.empty())
786 throw Exception("binlog is empty when try to committing data for MaterializedMySQL", ErrorCodes::LOGICAL_ERROR);
787
788 MySQLBinLogInfo binlog;
789 binlog.binlog_file = position.binlog_name;
790 binlog.binlog_position = position.binlog_pos;
791 binlog.executed_gtid_set = position.gtid_sets.toString();
792
793 /// XXX: Here we can just support for one table to flush
794 for (auto & table_name_and_buffer : data)
795 {
796 auto query_context = MaterializedMySQL::createQueryContext(context);
797
798 prepareCommit(query_context, table_name_and_buffer.first + "_" + table_suffix, binlog);
799
800 OneBlockInputStream input(table_name_and_buffer.second->first);
801 BlockOutputStreamPtr out = getTableOutput(database, table_name_and_buffer.first + "_" + table_suffix, query_context, true);
802 Stopwatch watch;
803 copyData(input, *out);
804 LOG_DEBUG(&Poco::Logger::get("MaterializeMySQLThread ({})"), "Copied {} rows and elapsed {} ms",
805 table_name_and_buffer.first, table_name_and_buffer.second->first.rows(), watch.elapsedMilliseconds());
806 }
807
808 data.clear();
809 max_block_rows = 0;
810 max_block_bytes = 0;
811 total_blocks_rows = 0;
812 total_blocks_bytes = 0;
813 }
814 catch (...)
815 {
816 data.clear();
817 throw;
818 }
819}
820
821MaterializeMySQLSyncThread::Buffers::BufferAndUniqueColumnsPtr MaterializeMySQLSyncThread::Buffers::getTableDataBuffer(
822 const String & table_name, ContextPtr context)

Callers 9

readSuffixMethod · 0.45
dropTableMethod · 0.45
renameTableMethod · 0.45
commitCreateTableMethod · 0.45
commitAlterTableMethod · 0.45
flushBuffersDataMethod · 0.45
onEventMethod · 0.45

Calls 10

createQueryContextFunction · 0.85
getTableOutputFunction · 0.70
ExceptionClass · 0.50
copyDataFunction · 0.50
getFunction · 0.50
emptyMethod · 0.45
toStringMethod · 0.45
rowsMethod · 0.45
elapsedMillisecondsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected