Database-based data processing method and device and storage medium

By configuring a preset data structure in the memory, storing the log of vector data and using a pointer to point to the location, it solves the problems of wasteful performance and high transaction consumption of existing vector databases, realizes efficient transaction processing of vector and scalar data, and ensures ACID consistency.

CN118708450APending Publication Date: 2024-09-27BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410716294.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

Existing vector databases are wasteful in performance and transaction processing, and have insufficient support for transaction consistency of scalar data.

Method used

By configuring a preset data structure in the memory, store the log data of the change operations related to the vector data into the structure, and use pointers in the log data to point to the data location, reducing the burden on the transaction engine of the database and improving the efficiency of the vector data. Transaction capabilities without affecting the transaction capabilities of scalar data.

Benefits of technology

It improves the processing efficiency and performance of vector data, ensures the simultaneous transaction capabilities of vector data and scalar data, meets ACID consistency, and avoids the modification of the database transaction engine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708450A
    Figure CN118708450A
Patent Text Reader

Abstract

The embodiment of the invention provides a data processing method and device based on a database and a storage medium, and the method comprises the steps: receiving a change operation instruction for the database, and enabling the database to support the database operation processing of scalar data and vector data; executing a change operation in a database according to the change operation instruction, and generating corresponding log data; and if the change operation instruction indicates that the vector data is changed and the vector data needs to be written into the log data, storing first vector data to be written into the log data into a preset data structure in a memory when the log data is generated, and writing a pointer of the first vector data into the log data. The preset data structure is configured in the memory, and the to-be-written vector in the log data corresponding to the change operation related to the vector data is stored in the preset data structure, so that the transaction capability of the vector data is improved, the transaction capability of the scalar data is not influenced, and the transaction capability of the vector data and the transaction capability of the scalar data can be ensured at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of computer and network communication technology, and in particular, to a data processing method, device and storage medium based on a database. Background Art

[0002] In recent years, as artificial intelligence models such as large language models continue to develop in all walks of life in society, the demand for storage and search of vector data is increasing.

[0003] Some vector databases in the prior art are divided into two camps: one is a plug-in vector database, and the other is an independent vector database. However, they all have some shortcomings, such as performance waste, excessive transaction consumption, and insufficient support for transaction consistency of scalar data. Summary of the invention

[0004] The embodiments of the present disclosure provide a database-based data processing method, device, and storage medium to simultaneously ensure the transaction capabilities of vector data and scalar data.

[0005] In a first aspect, an embodiment of the present disclosure provides a data processing method based on a database, comprising:

[0006] Receiving a change operation instruction for a database; wherein the database is used to support database operation processing for scalar data and vector data;

[0007] Execute a corresponding change operation in the database according to the change operation instruction, and generate log data corresponding to the change operation;

[0008] If the change operation instruction indicates a change to vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure.

[0009] In a second aspect, an embodiment of the present disclosure provides a data processing device based on a database, comprising:

[0010] An input unit, used to receive a change operation instruction for a database; wherein the database is used to support database operation processing for scalar data and vector data;

[0011] An execution unit, configured to execute a corresponding change operation in the database according to the change operation instruction;

[0012] A log processing unit is used to generate log data corresponding to the change operation; if the change operation instruction indicates a change to vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure.

[0013] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: at least one processor and a memory;

[0014] The memory stores computer-executable instructions;

[0015] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the database-based data processing method as described in the first aspect and various possible designs of the first aspect.

[0016] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the database-based data processing method described in the first aspect and various possible designs of the first aspect is implemented.

[0017] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including computer execution instructions. When a processor executes the computer execution instructions, it implements the database-based data processing method described in the first aspect and various possible designs of the first aspect.

[0018] The data processing method, device and storage medium based on the database provided by the embodiment of the present disclosure receive a change operation instruction for the database; wherein the database is used to support database operation processing for scalar data and vector data; execute the corresponding change operation in the database according to the change operation instruction, and generate log data corresponding to the change operation; if the change operation instruction indicates a change for vector data, and vector data needs to be written in the log data, then when generating the log data, the first vector data to be written into the log data is stored in a preset data structure in the memory, and the pointer of the first vector data is written into the log data, and the pointer of the first vector data is used to point to the position of the first vector data in the preset data structure. By configuring the preset data structure in the memory, the vector to be written in the log data corresponding to the change operation related to the vector data is stored in the preset data structure, the processing efficiency and performance of the log data corresponding to the change operation related to the vector data can be improved, the transaction capability of the vector data is improved, and the transaction capability of the scalar data is not affected at the same time, and the transaction capability of the vector data and the scalar data can be guaranteed at the same time without modifying the transaction engine of the database. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0020] Figure 1 A diagram showing an example scenario of a database-based data processing method provided in one embodiment of the present disclosure;

[0021] Figure 2 A schematic diagram of a data processing method based on a database according to an embodiment of the present disclosure;

[0022] Figure 3 A schematic diagram of a database row format provided by an embodiment of the present disclosure;

[0023] Figure 4 A schematic diagram of a revocation log data format provided by an embodiment of the present disclosure;

[0024] Figure 5 A schematic diagram of a replay log data format provided by an embodiment of the present disclosure;

[0025] Figure 6 A schematic diagram of a preset data structure in a memory provided by an embodiment of the present disclosure;

[0026] Figure 7A structural block diagram of a data processing device based on a database provided in one embodiment of the present disclosure;

[0027] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0029] Some vector databases in the prior art are divided into two camps: one is plug-in vector databases, and the other is independent vector databases. However, they all have some shortcomings, such as performance waste, excessive transaction consumption, and insufficient support for transaction consistency of scalar data. The following first discusses their shortcomings:

[0030] The plug-in vector database is very simple to use. Take the vector plug-in pgvector of the PostgreSQL database as an example. In the PostgreSQL database, the vector data processing capability is realized mainly by adding vector fields and corresponding indexes of vectors and new search algorithms to the existing data storage, and the insertion and query processes of the previous engine are reused. The advantage is that it is very fast to develop. In the PostgreSQL database, the vector plug-in pgvector has only 18 files in total. Thanks to the powerful plug-in capability of the PostgreSQL database, it can be implemented quickly.

[0031] Since the PostgreSQL database was originally designed to store relational databases, it has relatively higher requirements for data ACID (atomicity, consistency, isolation, and durability). As a result, when inserting vector data, the consumption of redo logs and MVCC (Multi-Version Concurrency Control, a database concurrency control mechanism) is greater than that of professional vector databases, resulting in reduced performance.

[0032] For independent vector databases, taking Milvus vector database as an example, its view is that it does not need to support complex transactions, multi-row or multi-table transactions are not needed, and it only needs to ensure row-level ACID. However, in actual business applications, there is still a large amount of scalar data that needs to be mixed with vector data, and the transaction consistency of these data, especially the cross-row consistency, is sometimes fatal. For example, the original text of the vector data is a text, and this text is only open to certain people. Therefore, who is open to is a very important scalar information. If there is only row-level transaction consistency, it may cause some problems; for example, the information should have been given to Zhang San in his department, but it was mistakenly given to Zhang San in other departments; at this time, modifying Zhang San A to Zhang San B may involve Zhang San's personal information row, which is multiple rows of data. If there is no multi-row transaction consistency, the person who modifies it may think that Zhang San B has been modified, while Zhang San A's permissions have not been removed. This leads to the leakage of confidential information, and the operator may not know it. Although the final consistency may be guaranteed, the inconsistency of transactions may cause the leakage of important information if it occurs over a period of time.

[0033] In summary, existing vector databases suffer from performance waste, excessive transaction consumption, and insufficient support for transaction consistency of scalar data.

[0034] In order to solve the above technical problems, the present disclosure provides a data processing method based on a database, by receiving a change operation instruction for a database; wherein the database is used to support database operation processing for scalar data and vector data; executing a corresponding change operation in the database according to the change operation instruction, and generating log data corresponding to the change operation; if the change operation instruction indicates a change for vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure; or, if the change operation instruction indicates a change for scalar data, and scalar data needs to be written into the log data, then when generating the log data, the scalar data to be written into the log data is directly written into the log data. By configuring a preset data structure in the memory and storing the vectors to be written in the log data corresponding to the change operations related to the vector data in the preset data structure, the processing efficiency and performance of the log data corresponding to the change operations related to the vector data can be improved, and the transaction capability of the vector data is improved without affecting the transaction capability of the scalar data. The transaction capability of both vector data and scalar data can be guaranteed without modifying the transaction engine of the database, thereby ensuring the ACID of the transaction.

[0035] The database-based data processing method provided in the embodiment of the present disclosure is applicable to Figure 1 In the application scenario shown, specifically, a change operation instruction for a database can be received; wherein the database is used to support database operation processing of scalar data and vector data; a corresponding change operation is performed in the database according to the change operation instruction, and log data corresponding to the change operation is generated; if the change operation instruction indicates a change for vector data, and vector data needs to be written into the log data, then when the log data is generated, the first vector data to be written into the log data is stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure; or, if the change operation instruction indicates a change for scalar data, and scalar data needs to be written into the log data, then when the log data is generated, the scalar data to be written into the log data is directly written into the log data.

[0036] The database-based data processing method disclosed in the present invention will be described in detail below in conjunction with specific embodiments.

[0037] refer to Figure 2 , Figure 2 A flowchart of a data processing method based on a database provided in an embodiment of the present disclosure. The method of this embodiment can be applied in electronic devices such as servers, and the data processing method based on a database includes:

[0038] S201, receiving a change operation instruction for a database; wherein the database is used to support database operation processing for scalar data and vector data.

[0039] In this embodiment, scalar data and vector data may be stored in a database at the same time, wherein the database may adopt any known database that can store scalar data and vector data at the same time, and this embodiment does not impose any limitation thereto.

[0040] Optionally, in this embodiment, the vector data may not be stored directly in the database, but the pointer (or storage path) of the vector data may be stored in the database. This reduces the requirements for the database. The database only needs to maintain scalar data and pointers to vector data. The database may be a relational database, or any other database that can maintain scalar data.

[0041] In a specific implementation, in one scenario, the database may store first scalar data and a pointer to second vector data associated with the first scalar data, and the pointer to the second vector data is used to point to the location of the second vector data in a preset storage space on the disk.

[0042] Take the InnoDB Compact row format of the MySQL database as an example. Figure 3 As shown, add a special field: vector_ptr( Figure 3 The rest of the content is the common content of the InnoDB Compact row format, such as row_id is the row identifier, trx_id is the transaction identifier, roll_ptr is the rollback pointer, col1 and col2 are the column names, etc., which are not repeated here), vector_ptr is the pointer of the second vector data, which is used to point to the location of the second vector data in the preset storage space on the disk. It is empty (NULL) by default and is not empty only when the second vector data actually exists.

[0043] S202: Execute a corresponding change operation in the database according to the change operation instruction.

[0044] In this embodiment, the corresponding change operation can be performed in the database according to the change operation instruction, wherein the change operation includes but is not limited to operations such as adding, deleting, modifying and checking the database, wherein the change operation can be a change operation only for scalar data, or a change operation only for vector data, or a change operation for both scalar data and vector data. Among them, the change operation related to scalar data (including the change operation only for scalar data, or the partial change operation for scalar data in the change operation for both scalar data and vector data) can be implemented by any known process, which is not limited in this embodiment.

[0045] For a change operation related to vector data (including a change operation only for vector data, or a partial change operation for vector data in a change operation for both scalar data and vector data), in a scenario where the database stores first scalar data and a pointer to second vector data associated with the first scalar data, executing a corresponding change operation in the database according to the change operation instruction may specifically include:

[0046] A pointer of the second vector data to be changed is determined from the database, and the change operation is performed on the second vector data to be changed in the preset storage space according to the pointer of the second vector data to be changed.

[0047] In this embodiment, the row where the pointer of the second vector data to be changed is located can be determined in the database according to the change operation related to the vector data, the pointer of the second vector data to be changed can be obtained from the row, and then the position of the second vector data to be changed can be located in the preset storage space in the disk according to the pointer of the second vector data to be changed, and then the change operation can be performed on the second vector data to be changed.

[0048] Among them, if the change operation is to delete vector data or modify vector data, the position of the second vector data to be changed is located in the preset storage space in the disk, and the second vector data is deleted or modified; if the change operation is to insert vector data, the vector data is inserted in the preset storage space, and the pointer of the vector data is recorded in the corresponding row of the database.

[0049] S203, generate log data corresponding to the change operation; if the change operation instruction indicates a change to vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure.

[0050] In this embodiment, before executing the change operation, or during the execution of the change operation, or after the change operation is executed, log data corresponding to the change operation is generated, wherein the log data includes but is not limited to at least one of the following log data: undo log data (undo log), replay log data (redo log), binary log data (binlog), etc.

[0051] Among them, if the change operation is an operation only for scalar data, the process of generating log data corresponding to the change operation can adopt any known generation method. If it is necessary to record scalar data in the log data, the scalar data to be written into the log data is directly written into the log data, and the subsequent undo operation and replay operation of the change operation on the scalar data, as well as the query operation of the scalar data in the database can be implemented by any known operation method.

[0052] If the change operation instruction indicates a change to vector data (including a change operation only to vector data, or a partial change operation to vector data in a change operation to both scalar data and vector data), since some log data may involve the need to record vector data, if all vector data is written into the log data, it will cause performance waste, excessive transaction consumption, and low efficiency. Therefore, in this embodiment, for the situation where vector data needs to be written into the log data, a new log generation method is provided, in which a preset data structure is pre-configured in the memory for storing the vector data in the log data. Specifically, in the process of generating log data, if vector data needs to be written to the log data, the first vector data to be written into the log data is stored in the preset data structure in the memory, and a pointer is used to point to the position of the first vector data in the preset data structure, and the pointer to the first vector data is written into the log data. In this way, there is no need to store a large amount of vector data in the log data, making the log data more lightweight, reducing transaction consumption, and improving efficiency and performance.

[0053] Optionally, an asynchronous write operation can be used to store the first vector data of the log data to be written into the preset data structure in the memory, without waiting for the return of the write operation, that is, when generating log data, only the pointer of the log data to be written needs to be obtained to complete the generation process, without waiting for all the log data to be written to be written into the preset data structure, which can improve the generation efficiency of log data. In addition, in the case of master-slave backup, the first vector data is first written to the host's memory without falling to the disk, and the update of the preset data structure in the slave's memory can be asynchronously updated without waiting.

[0054] Optionally, each change operation corresponds to a transaction identifier (transaction ID), and the transaction identifier corresponding to the change operation can be obtained, and the transaction identifier and the first vector data are associated and stored in a preset data structure, and the transaction identifier can be written into the log data as a pointer to the first vector data, and the first vector data can be searched and read according to the transaction identifier when the first vector data needs to be read later. The transaction identifier can be a sequence ID of a redo log or an undo log.

[0055] Furthermore, the preset data structure in the memory can be a key-value pair data structure (key-value structure), in which the transaction identifier is the primary key (key), and the first vector data is the value (value) corresponding to the primary key, so as to facilitate storage and query. In addition, the memory can be a high-availability memory, and the key-value pair data structure is deployed in the high-availability memory, which increases the read and write speed of the vector data.

[0056] The data processing method based on a database provided in this embodiment receives a change operation instruction for a database; the database is used to support database operation processing for scalar data and vector data; the corresponding change operation is performed in the database according to the change operation instruction, and log data corresponding to the change operation is generated; if the change operation instruction indicates a change for vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and the pointer of the first vector data is written into the log data, and the pointer of the first vector data is used to point to the position of the first vector data in the preset data structure. By configuring a preset data structure in the memory, storing the vector to be written in the log data corresponding to the change operation related to the vector data into the preset data structure, the processing efficiency and performance of the log data corresponding to the change operation related to the vector data can be improved, the transaction capability of the vector data is improved, and the transaction capability of the scalar data is not affected at the same time. The transaction capability of the vector data and the scalar data can be guaranteed at the same time without modifying the transaction engine of the database, and the ACID of the transaction is guaranteed.

[0057] Based on any of the above embodiments, the log data includes at least one of the following log data: undo log data (undo log), replay log data (redo log), and binary log data (binlog).

[0058] The following describes the improvements to undo log data (undo log), replay log data (redo log), and binary log data (binlog).

[0059] 1) Improvements to undo log

[0060] like Figure 4 As shown, a field is added to the undo log: undo_vector_log_ptr( Figure 4The rest of the undo log is the regular content of the undo log, for example, end of record indicates the end of this undo log, undo type indicates the log type of the undo log, undo no indicates the number of the undo log, table id indicates the data table identifier corresponding to the undo log, info bits records the value of the first 4 bits of the header information and the value of record_type, roll_pointer is used to point to the undo log when the current record is rolled back, start of record indicates the start of this undo log, p key info indicates the primary key information, n_update indicates how many columns are updated, info_before indicates the original information, len of index colinfo indicates the storage space occupied by the information of each column of the index column, index info indicates the index information, etc., which will not be repeated here), undo_vector_log_ptr is a pointer to the first vector data to be written into the undo log, and is used to point to the position of the first vector data in the preset data structure in the memory.

[0061] When it is necessary to undo the change operation, in response to the undo operation instruction of the change operation, read the undo log (or binlog); if the undo log (and / or binlog) includes a pointer to the first vector data, read the first vector data from the preset data structure according to the pointer to the first vector data; perform the undo operation according to the undo log (and / or binlog) and the read first vector data.

[0062] 2) Improvements to redo log

[0063] In daily production practice, a parameter innodb_flush_log_at_trx_commit is usually set for the database to control the log refresh policy. This parameter is usually set to 1, which means that the log data will be written to the disk immediately when the transaction is committed, and the disk cache will be refreshed. Therefore, in this embodiment, it can be considered that the redo log is refreshed to the disk in real time. If vector data needs to be written to the redo log, and the transaction consistency requirement is not so high, writing the vector data to the redo log is not cost-effective in terms of performance. Therefore, the changes to the redo log are as follows: Figure 5 As shown:

[0064] A field is added to the redo log: redo_vector_ptr, which is a pointer to the first vector data to be written into the redo log, and is used to point to the location of the first vector data in the preset data structure in the memory. There is no need to ensure atomicity, and the pointer can be updated to redo_vector_ptr when the first vector data is written into the preset data structure;

[0065] In addition, a field is added to the redo log: redo_vector_dirty_flag, which is recorded as the first flag and is used to record whether the change operation inserts or updates vector data. Its purpose is to ensure the atomicity of the redo log and other fields.

[0066] When the change operation needs to be replayed, in response to the replay operation instruction of the change operation, the redo log (and / or binlog) is read; if the redo log (and / or binlog) includes a pointer to the first vector data, the first vector data is read from a preset data structure in the memory according to the pointer to the first vector data; and the replay operation is performed according to the redo log (and / or binlog) and the read first vector data.

[0067] It should be noted that if a device fails, the vector data in the preset data structure in the memory may be lost. Since the vector data in the preset data structure is not dropped to the disk, it cannot be recovered. Therefore, when reading the redo log at this time, the position pointed to by redo_vector_ptr is NULL (empty), but the first flag redo_vector_dirty_flag records that there is an insertion of vector data or an update of vector data in this change operation. At this time, a prompt message for entering the first vector data can be displayed to prompt the user to re-enter the lost first vector data, and receive the first vector data entered by the user according to the prompt message, and then the replay operation can be performed according to the redo log (and / or binlog) and the first vector data entered by the user. Optionally, this embodiment can also provide an interactive interface for inputting the first vector data, in which the user can input the original data of the first vector data, and convert the original data into the first vector data through a vectorization (embedding) operation.

[0068] Of course, when there is a slave machine, the first vector data can also be obtained from the preset data structure in the slave machine's memory; and when both the host machine and the slave machine fail, a prompt message for entering the first vector data is displayed, and the user re-enters the lost first vector data.

[0069] 3) Improvements to binlog

[0070] Binlog can be interpreted as a series of SQL statements, and its specific format is not limited here. For binlog, the first vector data involved needs to be directly removed, especially in the redo log, the first vector data has been written into the preset data structure in the memory, so there is no need to write the first vector data into the preset data structure again. You only need to modify the SQL statement and mark the original first vector data field as a pointer to the first vector data, or mark it as the transaction identifier [ID: XXXXX] corresponding to the first vector data. However, this SQL statement will not be able to be executed when the master-slave database is replicated. It is necessary to obtain the first vector data on the slave side (memory) (the master-slave memory has been asynchronously updated), and then implement the execution of the SQL statement on the slave database based on the SQL statement and the first vector data.

[0071] When master-slave database replication is required, in response to the master-slave database replication operation instruction, the binlog is read (which can be read by the slave end); if the binlog includes a pointer to the first vector data, the first vector data is read from a preset data structure in the memory of the host end or the slave end according to the pointer to the first vector data; the master-slave database replication operation is performed according to the binlog and the read first vector data, that is, the same change operation is performed in the slave database.

[0072] Through the above improvements to undo log, redo log, and binlog, the storage, deletion, and modification of vector data can be separated from the standard transaction engine of scalar data, so that different ACID attitudes can be adopted for different data usage scenarios.

[0073] Based on the above embodiment, the operation process of adding, deleting, modifying and checking the database is described in detail below.

[0074] 1) Insert

[0075] Different databases adopt similar behaviors when implementing data writing to ensure MVCC and transactions. Generally, the database insertion process requires three stages:

[0076] Phase 1: Connection and identity authentication;

[0077] Phase 2: Syntax parsing of SQL statements Syntax analysis, building a syntax tree to facilitate subsequent execution;

[0078] Phase 3: Execution of SQL statements. Here, the appropriate execution plan will be selected based on the specific content, and data will be inserted from the storage engine.

[0079] In this embodiment, the above insertion process (or other insertion processes) may be used to insert data into the database.

[0080] When inserting data, since there is no data to be inserted in the database, there is no need to retain historical data in the undo log. At the same time, the undo log only needs to record the row id of the inserted data.

[0081] The redo log needs to write the data to be inserted. If the data to be inserted is vector data, the vector data information does not need to be written into the redo log. Instead, the vector data is written into the preset data structure of the memory as in the above embodiment, and the pointer of the vector data is written into the redo log, thereby avoiding the vector data from being written to the disk following the redo log. Generally speaking, a vector data write has an amount of 4 bytes * 512 or 4 bytes * 1536 written. Moreover, with the development of artificial intelligence technologies such as large prediction models, especially the subsequent development of multi-modality, the requirement for multi-dimensional vectors is an inevitable trend. The method of this embodiment can reduce the consumption of writing vector data in the redo log and writing it to the disk.

[0082] At the same time, because the newly inserted data generally needs to be synchronized to the slave through binlog, the vector data is discarded during binlog synchronization, and the slave also needs to make changes during replay and obtain the vector data from the preset data structure in the memory.

[0083] 2) Delete

[0084] In this embodiment, the process of deleting data from the database is similar to the native method, which is to mark the data and delete it asynchronously.

[0085] The undo log needs to record the original data before deletion. If the deleted data is vector data, the deleted vector data needs to be written into the undo log. The method in the above embodiment can be used to write the deleted vector data into a preset data structure in the memory and write the pointer of the vector data into the undo log.

[0086] 3) Update

[0087] When updating data in the database, it is necessary to record the data before and after the update. If the data before and after the update is vector data, the vector data before and after the update can be written into the preset data structure in the memory, and the pointer of the vector data before the update is written in the undo log, and the pointer of the vector data after the update is written in the redo log, saving the consumption of undolog and redo log.

[0088] For scalar data, the previous method is still used to record redo log and undo log.

[0089] Therefore, different processing levels of vector data and scalar data can be guaranteed here during MVCC. For scalar data, the accuracy of rollback is guaranteed, and for vector data, the preset data structure in memory is put into the memory, and the memory size limit is guaranteed as much as possible, but it is not written to the disk.

[0090] 4) Query (Select)

[0091] In this embodiment, the scalar data and vector data are stored in the database in the following manner:

[0092] The row structure of the database stores first scalar data and a pointer to second vector data associated with the first scalar data, wherein the pointer to the second vector data is used to point to a location of the second vector data in a preset storage space in the disk;

[0093] When querying, you need to use this pointer to obtain the actual vector data, and combine it with the row data into a set and return it to the query end. This has several advantages:

[0094] i) Based on the general B+ tree structure of relational databases, the changes are minor, and operations such as defragmentation and movement of newly added fields will not be affected by attaching a relatively large amount of data;

[0095] ii) Vector data is generally a number of float types. These numbers are inherently different from the scalar data mentioned above. When choosing a compression algorithm, separate storage allows for more flexibility in choosing the appropriate compression algorithm for the vector data.

[0096] iii) Since vector data and scalar data coexist, two sets of indexes are required. Therefore, if the vector data and scalar data are not stored separately, when the scalar data needs to be moved, the address of the vector data pointed to by the vector index needs to be modified, which is troublesome.

[0097] Specifically, when performing data query, if the query operation instruction of the received database only includes scalar data query conditions, the query is directly performed in the database, and any feasible query method can be used; if the query operation instruction only includes vector data query conditions, the query is directly performed in the preset storage space of the disk storing the vector data, wherein the query process can be implemented in the form of vector similarity, and any feasible query method can be used; if the query operation instruction includes both vector query conditions and scalar query conditions, any of the following methods can be used to perform the query:

[0098] Method 1:

[0099] The candidate second vector data satisfying the vector query condition is queried from the preset storage space, and then the candidate first scalar data associated with the candidate second vector data in the database is queried for the candidate first scalar data satisfying the scalar query condition, and the candidate first scalar data and the candidate second vector data associated with it are determined as the query result corresponding to the query operation instruction. That is, in the first method, the vector data is queried first, and then the scalar data is queried.

[0100] Method 2:

[0101] The candidate first scalar data satisfying the scalar query condition is queried from the database, and then the candidate second vector data satisfying the vector query condition is queried from the second vector data associated with the candidate first scalar data in the preset storage space, and the candidate second vector data and the candidate first scalar data associated therewith are determined as the query result corresponding to the query operation instruction. That is, in the second method, the scalar data is queried first, and then the vector data is queried.

[0102] Method 3:

[0103] The vector query cost and the scalar query cost are obtained according to the vector query condition and the scalar query condition, and the query method is selected according to the vector query cost and the scalar query cost. If the vector query cost is smaller, the above method 1 can be selected, and if the scalar query cost is smaller, the above method 2 can be selected. The vector query cost and the scalar query cost can be determined in any feasible manner, and are not limited here.

[0104] Based on any of the above embodiments, the preset data structure in the memory can be specifically as follows: Figure 6 As shown, there are three variables:

[0105] vector_log_buffer_page: indicates the storage location of each vector data. Its size is automatically determined by the dimension of the vector data and does not need to be set.

[0106] vector_log_buffer_number: indicates the maximum number of vector data that can be cached, which can be set as needed;

[0107] vector_log_buffer_size: indicates the total size of the preset data structure. It is used to monitor and view the total size of this preset data structure and does not need to be set.

[0108] When storing the first vector data in a preset data structure in the memory, if the storage locations in the preset data structure are insufficient, the first vector data will overwrite the earliest stored vector data in the preset data structure, that is, the storage locations in the preset data structure can be used cyclically.

[0109] In addition, if Figure 6 In the case where instance A and instance B are master-slave backup, instance A is a preset data structure in the host memory, and instance B is a preset data structure in the slave memory, which can be updated asynchronously.

[0110] Corresponding to the data processing method based on the database in the above embodiment, Figure 7 A structural block diagram of a data processing device based on a database provided in an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 7 The database-based data processing device 700 includes: an input unit 701, an execution unit 702, and a log processing unit 703.

[0111] The input unit 701 is used to receive a change operation instruction for a database; wherein the database is used to support database operation processing for scalar data and vector data;

[0112] An execution unit 702 is used to execute a corresponding change operation in the database according to the change operation instruction;

[0113] The log processing unit 703 is used to generate log data corresponding to the change operation; if the change operation instruction indicates a change to vector data, and vector data needs to be written into the log data, then when the log data is generated, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure; or, if the change operation instruction indicates a change to scalar data, and scalar data needs to be written into the log data, then when the log data is generated, the scalar data to be written into the log data is directly written into the log data.

[0114] In one or more embodiments of the present disclosure, when the log processing unit 703 synchronously stores the first vector data to be written into the log data into a preset data structure in the memory and writes the pointer of the first vector data into the log data, it is used to:

[0115] Acquire a transaction identifier corresponding to the change operation, and associate the transaction identifier with the first vector data and store them in the preset data structure;

[0116] The transaction identifier is written into the log data as a pointer to the first vector data.

[0117] In one or more embodiments of the present disclosure, the preset data structure is a key-value pair data structure; accordingly, when the log processing unit 703 associates the transaction identifier with the first vector data and stores them in the preset data structure, it is used to:

[0118] The transaction identifier is used as a primary key, and the first vector data is used as a value corresponding to the primary key, and is stored in the preset data structure.

[0119] In one or more embodiments of the present disclosure, the log data includes at least one of the following log data: undo log data, replay log data, and binary log data.

[0120] In one or more embodiments of the present disclosure, when generating the log data, the log processing unit 703 is further configured to:

[0121] For the replay log data, a first identifier is added to the replay log data, and the first identifier is used to record whether the change operation inserts vector data or updates vector data.

[0122] In one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the execution unit 702 is further configured to:

[0123] In response to an undo operation instruction for the change operation, reading undo log data and / or binary log data;

[0124] If the undo log data and / or the binary log data include a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0125] An undo operation is performed according to the undo log data and / or the binary log data and the first vector data.

[0126] In one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the execution unit 702 is further configured to:

[0127] In response to the master-slave database replication operation instruction, read the binary log data;

[0128] If the binary log data includes a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0129] A master-slave database replication operation is performed according to the binary log data and the first vector data.

[0130] In one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the execution unit 702 is further configured to:

[0131] In response to a replay operation instruction for the change operation, reading replay log data and / or binary log data;

[0132] If the replay log data and / or the binary log data include a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0133] A replay operation is performed according to the replay log data and / or the binary log data and the first vector data.

[0134] In one or more embodiments of the present disclosure, when the execution unit 702 reads the first vector data from the preset data structure according to the pointer of the first vector data, it is configured to:

[0135] If the position pointed to by the pointer of the first vector data in the preset data structure is a null value, and the first identifier in the replay log data records that the change operation inserts vector data or updates vector data, a prompt message for inputting the first vector data is displayed, and the first vector data input by the user according to the prompt message is received;

[0136] The performing a replay operation according to the replay log data and / or the binary log data and the first vector data includes:

[0137] A replay operation is performed according to the replay log data and / or the binary log data and the first vector data input by a user.

[0138] In one or more embodiments of the present disclosure, the database stores first scalar data and a pointer to second vector data associated with the first scalar data, the pointer to the second vector data being used to point to a location of the second vector data in a preset storage space in a disk;

[0139] Accordingly, when the execution unit 702 executes the corresponding change operation in the database according to the change operation instruction, it is used to:

[0140] If the change operation instruction indicates a change to vector data, a pointer to the second vector data to be changed is determined from the database, and the change operation is performed on the second vector data to be changed in the preset storage space according to the pointer to the second vector data to be changed.

[0141] In one or more embodiments of the present disclosure, the execution unit 702 is further configured to:

[0142] Receiving a query operation instruction for the database, wherein the query operation instruction includes a vector query condition and a scalar query condition;

[0143] Querying the preset storage space for alternative second vector data satisfying the vector query condition, and then querying the database for alternative first scalar data associated with the alternative second vector data for alternative first scalar data satisfying the scalar query condition, and determining the alternative first scalar data and its associated alternative second vector data as the query result corresponding to the query operation instruction; or

[0144] Query the database for alternative first scalar data that meets the scalar query condition, then query the preset storage space for alternative second vector data associated with the alternative first scalar data that meets the vector query condition, and determine the alternative second vector data and its associated alternative first scalar data as the query results corresponding to the query operation instruction.

[0145] In one or more embodiments of the present disclosure, after receiving the query operation instruction for the database, the execution unit 702 is further configured to:

[0146] A vector query cost and a scalar query cost are obtained according to the vector query condition and the scalar query condition, and a query method is selected according to the vector query cost and the scalar query cost.

[0147] In one or more embodiments of the present disclosure, the synchronously storing the first vector data to be written into the log data into a preset data structure in the memory includes:

[0148] If the storage locations in the preset data structure are insufficient, the first vector data will overwrite the earliest stored vector data in the preset data structure.

[0149] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.

[0150] refer to Figure 8, which shows a schematic diagram of the structure of an electronic device 800 suitable for implementing the embodiment of the present disclosure, and the electronic device 800 may be a terminal device or a server. The terminal device may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0151] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 to a random access memory (RAM) 803. Various programs and data required for the operation of the electronic device 800 are also stored in the RAM 803. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0152] Typically, the following devices may be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 808 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 The electronic device 800 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0153] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 809, or installed from the storage device 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0154] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0155] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0156] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.

[0157] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0158] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0159] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".

[0160] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0161] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0162] In a first aspect, according to one or more embodiments of the present disclosure, a method for processing data based on a database is provided, comprising:

[0163] Receiving a change operation instruction for a database; wherein the database is used to support database operation processing for scalar data and vector data;

[0164] Execute a corresponding change operation in the database according to the change operation instruction, and generate log data corresponding to the change operation;

[0165] If the change operation instruction indicates a change to vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure; or

[0166] If the change operation instruction indicates a change to scalar data, and scalar data needs to be written into the log data, then when the log data is generated, the scalar data to be written into the log data is directly written into the log data.

[0167] According to one or more embodiments of the present disclosure, the synchronously storing the first vector data to be written into the log data into a preset data structure in the memory, and writing the pointer of the first vector data into the log data, includes:

[0168] Acquire a transaction identifier corresponding to the change operation, and associate the transaction identifier with the first vector data and store them in the preset data structure;

[0169] The transaction identifier is written into the log data as a pointer to the first vector data.

[0170] According to one or more embodiments of the present disclosure, the preset data structure is a key-value pair data structure; accordingly, the associating the transaction identifier with the first vector data and storing them in the preset data structure includes:

[0171] The transaction identifier is used as a primary key, and the first vector data is used as a value corresponding to the primary key, and is stored in the preset data structure.

[0172] According to one or more embodiments of the present disclosure, the log data includes at least one of the following log data: undo log data, replay log data, and binary log data.

[0173] According to one or more embodiments of the present disclosure, when generating the log data, it also includes:

[0174] For the replay log data, a first identifier is added to the replay log data, and the first identifier is used to record whether the change operation inserts vector data or updates vector data.

[0175] According to one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the method further includes:

[0176] In response to an undo operation instruction for the change operation, reading undo log data and / or binary log data;

[0177] If the undo log data and / or the binary log data include a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0178] An undo operation is performed according to the undo log data and / or the binary log data and the first vector data.

[0179] According to one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the method further includes:

[0180] In response to the master-slave database replication operation instruction, read the binary log data;

[0181] If the binary log data includes a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0182] A master-slave database replication operation is performed according to the binary log data and the first vector data.

[0183] According to one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the method further includes:

[0184] In response to a replay operation instruction for the change operation, reading replay log data and / or binary log data;

[0185] If the replay log data and / or the binary log data include a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0186] A replay operation is performed according to the replay log data and / or the binary log data and the first vector data.

[0187] According to one or more embodiments of the present disclosure, when the first vector data is read from the preset data structure according to the pointer of the first vector data, it includes:

[0188] If the position pointed to by the pointer of the first vector data in the preset data structure is a null value, and the first identifier in the replay log data records that the change operation inserts vector data or updates vector data, a prompt message for inputting the first vector data is displayed, and the first vector data input by the user according to the prompt message is received;

[0189] The performing a replay operation according to the replay log data and / or the binary log data and the first vector data includes:

[0190] A replay operation is performed according to the replay log data and / or the binary log data and the first vector data input by a user.

[0191] According to one or more embodiments of the present disclosure, the database stores first scalar data and a pointer to second vector data associated with the first scalar data, the pointer to the second vector data being used to point to a location of the second vector data in a preset storage space in a disk;

[0192] Accordingly, performing a corresponding change operation in the database according to the change operation instruction includes:

[0193] If the change operation instruction indicates a change to vector data, a pointer to the second vector data to be changed is determined from the database, and the change operation is performed on the second vector data to be changed in the preset storage space according to the pointer to the second vector data to be changed.

[0194] According to one or more embodiments of the present disclosure, the method further includes:

[0195] Receiving a query operation instruction for the database, wherein the query operation instruction includes a vector query condition and a scalar query condition;

[0196] Querying the preset storage space for alternative second vector data satisfying the vector query condition, and then querying the database for alternative first scalar data associated with the alternative second vector data for alternative first scalar data satisfying the scalar query condition, and determining the alternative first scalar data and its associated alternative second vector data as the query result corresponding to the query operation instruction; or

[0197] Query the database for alternative first scalar data that meets the scalar query condition, then query the preset storage space for alternative second vector data associated with the alternative first scalar data that meets the vector query condition, and determine the alternative second vector data and its associated alternative first scalar data as the query results corresponding to the query operation instruction.

[0198] According to one or more embodiments of the present disclosure, after receiving the query operation instruction for the database, the method further includes:

[0199] A vector query cost and a scalar query cost are obtained according to the vector query condition and the scalar query condition, and a query method is selected according to the vector query cost and the scalar query cost.

[0200] According to one or more embodiments of the present disclosure, the synchronously storing the first vector data to be written into the log data into a preset data structure in the memory includes:

[0201] If the storage locations in the preset data structure are insufficient, the first vector data will overwrite the earliest stored vector data in the preset data structure.

[0202] In a second aspect, according to one or more embodiments of the present disclosure, there is provided a data processing device based on a database, comprising:

[0203] An input unit, used to receive a change operation instruction for a database; wherein the database is used to support database operation processing for scalar data and vector data;

[0204] An execution unit, configured to execute a corresponding change operation in the database according to the change operation instruction;

[0205] A log processing unit, used for generating log data corresponding to the change operation; if the change operation instruction indicates a change to vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure; or, if the change operation instruction indicates a change to scalar data, and scalar data needs to be written into the log data, then when generating the log data, the scalar data to be written into the log data is directly written into the log data.

[0206] According to one or more embodiments of the present disclosure, when the log processing unit synchronously stores the first vector data to be written into the log data into a preset data structure in the memory and writes the pointer of the first vector data into the log data, it is used to:

[0207] Acquire a transaction identifier corresponding to the change operation, and associate the transaction identifier with the first vector data and store them in the preset data structure;

[0208] The transaction identifier is written into the log data as a pointer to the first vector data.

[0209] According to one or more embodiments of the present disclosure, the preset data structure is a key-value pair data structure; accordingly, when the log processing unit associates the transaction identifier with the first vector data and stores them in the preset data structure, it is used to:

[0210] The transaction identifier is used as a primary key, and the first vector data is used as a value corresponding to the primary key, and is stored in the preset data structure.

[0211] According to one or more embodiments of the present disclosure, the log data includes at least one of the following log data: undo log data, replay log data, and binary log data.

[0212] According to one or more embodiments of the present disclosure, when generating the log data, the log processing unit is further used to:

[0213] For the replay log data, a first identifier is added to the replay log data, and the first identifier is used to record whether the change operation inserts vector data or updates vector data.

[0214] According to one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the execution unit is further configured to:

[0215] In response to an undo operation instruction for the change operation, reading undo log data and / or binary log data;

[0216] If the undo log data and / or the binary log data include a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0217] An undo operation is performed according to the undo log data and / or the binary log data and the first vector data.

[0218] According to one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the execution unit is further configured to:

[0219] In response to the master-slave database replication operation instruction, read the binary log data;

[0220] If the binary log data includes a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0221] A master-slave database replication operation is performed according to the binary log data and the first vector data.

[0222] According to one or more embodiments of the present disclosure, if the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the execution unit is further configured to:

[0223] In response to a replay operation instruction for the change operation, reading replay log data and / or binary log data;

[0224] If the replay log data and / or the binary log data include a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data;

[0225] A replay operation is performed according to the replay log data and / or the binary log data and the first vector data.

[0226] According to one or more embodiments of the present disclosure, when the execution unit reads the first vector data from the preset data structure according to the pointer of the first vector data, it is configured to:

[0227] If the position pointed to by the pointer of the first vector data in the preset data structure is a null value, and the first identifier in the replay log data records that the change operation inserts vector data or updates vector data, a prompt message for inputting the first vector data is displayed, and the first vector data input by the user according to the prompt message is received;

[0228] The performing a replay operation according to the replay log data and / or the binary log data and the first vector data includes:

[0229] A replay operation is performed according to the replay log data and / or the binary log data and the first vector data input by a user.

[0230] According to one or more embodiments of the present disclosure, the database stores first scalar data and a pointer to second vector data associated with the first scalar data, the pointer to the second vector data being used to point to a location of the second vector data in a preset storage space in a disk;

[0231] Accordingly, when the execution unit executes the corresponding change operation in the database according to the change operation instruction, it is used to:

[0232] If the change operation instruction indicates a change to vector data, a pointer to the second vector data to be changed is determined from the database, and the change operation is performed on the second vector data to be changed in the preset storage space according to the pointer to the second vector data to be changed.

[0233] According to one or more embodiments of the present disclosure, the execution unit is further configured to:

[0234] Receiving a query operation instruction for the database, wherein the query operation instruction includes a vector query condition and a scalar query condition;

[0235] Querying the preset storage space for alternative second vector data satisfying the vector query condition, and then querying the database for alternative first scalar data associated with the alternative second vector data for alternative first scalar data satisfying the scalar query condition, and determining the alternative first scalar data and its associated alternative second vector data as the query result corresponding to the query operation instruction; or

[0236] Query the database for alternative first scalar data that meets the scalar query condition, then query the preset storage space for alternative second vector data associated with the alternative first scalar data that meets the vector query condition, and determine the alternative second vector data and its associated alternative first scalar data as the query results corresponding to the query operation instruction.

[0237] According to one or more embodiments of the present disclosure, after receiving the query operation instruction for the database, the execution unit is further used to:

[0238] A vector query cost and a scalar query cost are obtained according to the vector query condition and the scalar query condition, and a query method is selected according to the vector query cost and the scalar query cost.

[0239] According to one or more embodiments of the present disclosure, the synchronously storing the first vector data to be written into the log data into a preset data structure in the memory includes:

[0240] If the storage locations in the preset data structure are insufficient, the first vector data will overwrite the earliest stored vector data in the preset data structure.

[0241] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: at least one processor and a memory;

[0242] The memory stores computer-executable instructions;

[0243] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the database-based data processing method as described in the first aspect and various possible designs of the first aspect.

[0244] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer execution instructions. When a processor executes the computer execution instructions, the database-based data processing method described in the first aspect and various possible designs of the first aspect is implemented.

[0245] In a fifth aspect, according to one or more embodiments of the present disclosure, a computer program product is provided, comprising computer execution instructions. When a processor executes the computer execution instructions, the database-based data processing method as described in the first aspect and various possible designs of the first aspect is implemented.

[0246] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0247] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0248] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A data processing method based on a database, characterized in that: include: Receive change operation instructions for the database; The database is used to support database operation processing of scalar data and vector data; Execute a corresponding change operation in the database according to the change operation instruction, and generate log data corresponding to the change operation; If the change operation instruction indicates a change to vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure.

2. The method according to claim 1, characterized in that The synchronously storing the first vector data to be written into the log data into a preset data structure in the memory, and writing the pointer of the first vector data into the log data, comprises: Acquire a transaction identifier corresponding to the change operation, and associate the transaction identifier with the first vector data and store them in the preset data structure; The transaction identifier is written into the log data as a pointer to the first vector data.

3. The method according to claim 2, characterized in that The preset data structure is a key-value pair data structure; accordingly, the associating the transaction identifier with the first vector data and storing them in the preset data structure includes: The transaction identifier is used as a primary key, and the first vector data is used as a value corresponding to the primary key, and is stored in the preset data structure.

4. The method according to any one of claims 1 to 3, characterized in that: The log data includes at least one of the following log data: undo log data, replay log data, and binary log data.

5. The method according to claim 4, characterized in that When generating the log data, it also includes: For the replay log data, a first identifier is added to the replay log data, and the first identifier is used to record whether the change operation inserts vector data or updates vector data.

6. The method according to claim 4, characterized in that If the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the method further includes: In response to an undo operation instruction for the change operation, reading undo log data and / or binary log data; If the undo log data and / or the binary log data include a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data; An undo operation is performed according to the undo log data and / or the binary log data and the first vector data.

7. The method according to claim 4, characterized in that If the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the method further includes: In response to the master-slave database replication operation instruction, read the binary log data; If the binary log data includes a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data; A master-slave database replication operation is performed according to the binary log data and the first vector data.

8. The method according to claim 5, characterized in that If the change operation instruction indicates a change to vector data, after generating log data corresponding to the change operation, the method further includes: In response to a replay operation instruction for the change operation, reading replay log data and / or binary log data; If the replay log data and / or the binary log data include a pointer to the first vector data, reading the first vector data from the preset data structure according to the pointer to the first vector data; A replay operation is performed according to the replay log data and / or the binary log data and the first vector data.

9. The method according to claim 8, characterized in that When the first vector data is read from the preset data structure according to the pointer of the first vector data, it includes: If the position pointed to by the pointer of the first vector data in the preset data structure is a null value, and the first identifier in the replay log data records that the change operation inserts vector data or updates vector data, a prompt message for inputting the first vector data is displayed, and the first vector data input by the user according to the prompt message is received; The performing a replay operation according to the replay log data and / or the binary log data and the first vector data includes: A replay operation is performed according to the replay log data and / or the binary log data and the first vector data input by a user.

10. The method according to claim 1, characterized in that The database stores first scalar data and a pointer to second vector data associated with the first scalar data, wherein the pointer to the second vector data is used to point to a location of the second vector data in a preset storage space in a disk; Accordingly, performing a corresponding change operation in the database according to the change operation instruction includes: If the change operation instruction indicates a change to vector data, a pointer to the second vector data to be changed is determined from the database, and the change operation is performed on the second vector data to be changed in the preset storage space according to the pointer to the second vector data to be changed.

11. The method according to claim 10, characterized in that The method further comprises: Receiving a query operation instruction for the database, wherein the query operation instruction includes a vector query condition and a scalar query condition; Querying the preset storage space for alternative second vector data satisfying the vector query condition, and then querying the database for alternative first scalar data associated with the alternative second vector data for alternative first scalar data satisfying the scalar query condition, and determining the alternative first scalar data and its associated alternative second vector data as the query result corresponding to the query operation instruction; or Query the database for alternative first scalar data that meets the scalar query condition, then query the preset storage space for alternative second vector data associated with the alternative first scalar data that meets the vector query condition, and determine the alternative second vector data and its associated alternative first scalar data as the query results corresponding to the query operation instruction.

12. The method according to claim 11, characterized in that After receiving the query operation instruction for the database, the method further includes: A vector query cost and a scalar query cost are obtained according to the vector query condition and the scalar query condition, and a query method is selected according to the vector query cost and the scalar query cost.

13. The method according to any one of claims 1 to 3, characterized in that: The synchronously storing the first vector data to be written into the log data into a preset data structure in the memory includes: If the storage locations in the preset data structure are insufficient, the first vector data will overwrite the earliest stored vector data in the preset data structure.

14. A data processing device based on a database, characterized in that: include: An input unit, used for receiving a change operation instruction for a database; The database is used to support database operation processing of scalar data and vector data; An execution unit, configured to execute a corresponding change operation in the database according to the change operation instruction; A log processing unit is used to generate log data corresponding to the change operation; if the change operation instruction indicates a change to vector data, and vector data needs to be written into the log data, then when generating the log data, the first vector data to be written into the log data is synchronously stored in a preset data structure in the memory, and a pointer to the first vector data is written into the log data, and the pointer to the first vector data is used to point to the position of the first vector data in the preset data structure.

15. An electronic device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method according to any one of claims 1 to 13.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the method according to any one of claims 1 to 13 is implemented.

17. A computer program product, characterized in that The method comprises computer-executable instructions, and when a processor executes the computer-executable instructions, the method according to any one of claims 1 to 13 is implemented.