CN115794813A - Data line identifier generation method and query and partition exchange method and device - Google Patents

Data line identifier generation method and query and partition exchange method and device Download PDF

Info

Publication number
CN115794813A
CN115794813A CN202211358911.2A CN202211358911A CN115794813A CN 115794813 A CN115794813 A CN 115794813A CN 202211358911 A CN202211358911 A CN 202211358911A CN 115794813 A CN115794813 A CN 115794813A
Authority
CN
China
Prior art keywords
partition
data
data row
identifier
queried
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211358911.2A
Other languages
Chinese (zh)
Inventor
李洪嵚
谢振江
赵裕众
杨佳伟
王桃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Oceanbase Technology Co Ltd
Original Assignee
Beijing Oceanbase Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Oceanbase Technology Co Ltd filed Critical Beijing Oceanbase Technology Co Ltd
Priority to CN202211358911.2A priority Critical patent/CN115794813A/en
Publication of CN115794813A publication Critical patent/CN115794813A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present specification provides a method for generating a data row identifier, a method for querying, and a method for exchanging partitions, which are used for generating a corresponding data row identifier for a data row in a master-key-free table stored in a database, where the master-key-free table is divided into a plurality of partitions; the method comprises the following steps: determining a target data row to be marked in the target partition aiming at the target partition without the primary key table; and generating a data row identifier of the target data row, wherein the data row identifier comprises partition description information unique to the target partition at least in the primary key-free table and a unique identifier of the target data row in the target partition.

Description

Data line identifier generation method and query and partition exchange method and device
Technical Field
The embodiment of the specification belongs to the technical field of databases, and particularly relates to a data row identifier generation method, and a query and partition exchange method and device.
Background
A primary key, i.e., primary key, is one or more fields in a data table whose value is used to uniquely identify a row of data in the table. The main key table is a table containing main keys in the data table, after the main key table is created in the database, a part of the database automatically creates a global unique index for the main key column, and the main keys are used as keys of a bottom-layer storage engine in the other part of the database, so that data rows can be quickly positioned through the main keys. A no primary key table refers to a table in a data table that does not have a primary key assigned, and a no primary key table typically uses data row identification to quickly locate a data row.
In the related art, there are two ways to generate the data line identifier: one data row identification consists of a timestamp of data storage and an execution node ID of the distributed database, and the other data row identification consists of a random number and a unique identification of the data row in a data table. When the two data row identifications are used for carrying out data row query, the data rows of the whole database need to be subjected to binary query, and the query efficiency is low.
Disclosure of Invention
The purpose of the present specification is to provide a method for generating a data line identifier, and a method and an apparatus for querying and partition exchanging.
According to a first aspect of one or more embodiments of the present specification, a data row identifier generating method is provided, configured to generate a corresponding data row identifier for a data row in a primary key-free table stored in a database, where the primary key-free table is divided into multiple partitions; the method comprises the following steps:
determining a target data row to be marked in the target partition aiming at the target partition without the primary key table;
and generating a data row identifier of the target data row, wherein the data row identifier comprises partition description information unique to the target partition at least in the primary key-free table and a unique identifier of the target data row in the target partition.
According to a second aspect of one or more embodiments of the present specification, there is provided a query method for querying a data row in a masterless table stored in a database, the masterless table being partitioned into a plurality of partitions; the method comprises the following steps:
acquiring a query request, wherein the query request comprises a data row identifier of a data row to be queried, the data row to be queried is any data row or multiple data rows stored in the database, and the data row identifier comprises globally unique partition description information of a partition corresponding to the data row to be queried in the database and a unique identifier of the data row to be queried in the partition corresponding to the data row to be queried;
determining a partition corresponding to the data line to be queried according to the partition description information contained in the data line identifier of the data line to be queried;
and reading the unique identifier of the data line to be inquired in the determined partition from the data line identifier of the data line to be inquired, and searching the data line to be inquired from the determined partition.
According to a third aspect of one or more embodiments of the present specification, a partition exchange method is provided, configured to perform partition exchange on partitions to be exchanged in different non-master key tables stored in a database, where each non-master key table is divided into multiple partitions, and each data row corresponds to a data row identifier, where the data row identifier includes globally unique partition description information of a partition to be exchanged in the database and a unique identifier of a data row in the partition to be exchanged; the method comprises the following steps:
acquiring a partition exchange request, wherein the partition exchange request is used for requesting partition exchange of a first partition and a second partition which belong to different non-primary key tables;
and in the mapping relation between the primary key-free table and the partitions, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
According to a fourth aspect of one or more embodiments of the present specification, there is provided a data row identifier generating apparatus, configured to generate a corresponding data row identifier for a data row in a masterless table stored in a database, where the masterless table is divided into a plurality of partitions; the device comprises:
a first determination unit: determining a target data row to be marked in the target partition aiming at the target partition without the primary key table;
a generation unit: and generating a data row identifier of the target data row, wherein the data row identifier comprises partition description information unique to the target partition at least in the primary key-free table and a unique identifier of the target data row in the target partition.
According to a fifth aspect of one or more embodiments of the present specification, there is provided a query apparatus for querying a data row in a masterless table stored in a database, the masterless table being divided into a plurality of partitions; the device comprises:
an acquisition unit: acquiring a query request, wherein the query request comprises a data row identifier of a data row to be queried, the data row to be queried is any data row or multiple data rows stored in the database, and the data row identifier comprises unique partition description information of a partition corresponding to the data row to be queried at least in the non-master key table and unique identifier of the data row to be queried in the partition corresponding to the data row to be queried;
a determination unit: determining a partition corresponding to the data line to be queried according to the partition description information contained in the data line identifier of the data line to be queried;
a reading unit: and reading the unique identifier of the data line to be inquired in the determined partition from the data line identifier of the data line to be inquired, and searching the data line to be inquired from the determined partition.
According to a sixth aspect of one or more embodiments of the present specification, a partition exchanging apparatus is provided, configured to perform partition exchange on partitions to be exchanged in different non-primary key tables stored in a database, where each non-primary key table is divided into multiple partitions, and each data row corresponds to a data row identifier, where the data row identifier includes partition description information that is globally unique in the database for the partition to be exchanged and a unique identifier of the data row in the partition to be exchanged; the device comprises:
an acquisition unit: acquiring a partition exchange request, wherein the partition exchange request is used for requesting partition exchange of a first partition and a second partition which belong to different non-primary key tables;
interchanging units: and in the mapping relation between the primary key-free table and the partitions, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
According to a seventh aspect of one or more embodiments of the present specification, there is provided an electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of any one of the first, second or third aspects by executing the executable instructions.
According to an eighth aspect of one or more embodiments of the present specification, there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method according to any one of the first, second or third aspects.
In the embodiment of the present specification, since the data row identifier includes the unique partition description information of the target partition at least in the non-primary key table, when the database queries the data row using the data row identifier, the partition where the data row to be queried is located may be determined through the partition description information, and then only the data row needs to be located in the determined partition without involving other partitions, which greatly improves the efficiency of data query. Besides the partition description information, the data row identification also comprises a unique identification of the data row in the target partition, so that the database can be positioned to the data row to be queried through the unique identification after the database is positioned to the partition where the data row to be queried is positioned.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments described in the present disclosure, and it is obvious for a person skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1a is a schematic diagram of a data row identification provided by an exemplary embodiment.
FIG. 1b is a schematic illustration of another data row identification provided by an exemplary embodiment.
FIG. 2 is a schematic diagram of a database storage scheme provided by an exemplary embodiment.
Fig. 3 is a flowchart of a method for generating a data row identifier according to an exemplary embodiment.
FIG. 4 is a diagram of a masterless key table, according to an exemplary embodiment.
Fig. 5 is a diagram of an LSM tree structure provided in an exemplary embodiment.
Fig. 6 is a diagram of a partition exchange provided in an exemplary embodiment.
FIG. 7 is a flow chart of a query method provided by an exemplary embodiment.
Fig. 8 is a flowchart of a partition switching method provided in an exemplary embodiment.
Fig. 9 is a schematic structural diagram of an apparatus according to an exemplary embodiment.
Fig. 10 is a block diagram of an apparatus for generating a data row identifier according to an exemplary embodiment.
Fig. 11 is a block diagram of a query device according to an exemplary embodiment.
Fig. 12 is a block diagram of a partition switching device according to an exemplary embodiment.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step should fall within the scope of protection of the present specification.
Before describing the method for generating the data row identifier provided in this specification, two data row identifiers in the related art are described:
the CRDB (CockroachDB, scalable source database capable of realizing synchronization across data centers) is a distributed database, and a data row in a primary key-free table stored in the database has a corresponding data row identifier 101, as shown in fig. 1a, the data row identifier 101 is shaped by 64 bits and is composed of an insertion timestamp 102 of 49 bits and an execution node ID103 of 15 bits. The insertion timestamp 102 refers to a timestamp generated when data is stored in a database, and includes: information such as time, table ID, etc. is generated. The distributed database includes a plurality of execution nodes, and the subjects of the execution data storage operations can be different execution nodes. The execution node ID103 refers to an ID of a node in the distributed database that performs a data storage operation. The disadvantages of this data line identification are: 1. the timestamp is determined by a clock source configured by a database, and a reliable clock source is needed to generate the timestamp which still keeps the local uniqueness after the downtime restart in order to ensure the global uniqueness of the data row identifier; 2. when the data row identifier is used for querying the data row, the database needs to perform binary query on the data row of the whole database, and the query efficiency is low; 3. when data storage is carried out, a user often expects data lines stored at the same time to be adjacent in physical position, but the position of the data lines stored in the CRDB depends on an execution node, which is different from the result expected by the user; 4. the byte number of the insertion timestamp 102 and the execution node ID103 are both hard-coded into the key of the storage engine, and cannot be dynamically adjusted, which has a certain limitation when performing database docking.
The TiDB is a converged distributed database supporting both online transaction processing and online analysis processing, and there is a corresponding data row identifier 104 in the data row in the non-primary key table stored in the database, as shown in fig. 1b, the data row identifier 104 is a shaping 64 and is composed of a random number 105 and a self-increment serial number 106 in the data table. Where the random number 105 is determined by a user through a function specific to the TiDB, the self-incrementing sequence number 106 in the data table may be a sequence number generated for a data row by a self-incrementing sequence in the data table, which is a unique identification of the data row in the data table. The disadvantages of data line identification are: 1. because the self-increment serial number 106 in the data table is only unique in the data table, when online partition exchange is carried out, data rows in different data tables may collide, and online partition exchange cannot be supported; 2. when the data row identifier is used for querying the data row, the database needs to perform binary query on the data row of the whole database, and the query efficiency is low; 3. when data storage is performed, a user often expects data rows stored at the same time to be adjacent in physical position, but the positions of the data rows stored in the TiDB are random, which is different from the result expected by the user; 4. the byte digits of the random number 105 and the self-increment serial number 106 in the data table are all hard-coded into keys of the storage engine, cannot be dynamically adjusted, and have certain limitation when the database is docked.
The present specification provides a new data line identifier structure, which solves at least some of the technical problems of the related art.
FIG. 2 is a schematic diagram of a database storage scheme provided by an exemplary embodiment. As shown in fig. 2, the architecture diagram includes: database 201, no primary key table 202, partition 203, partition 204, lsm tree 205.
The database 201 stores a plurality of non-primary key tables similar to the non-primary key table 202, and the non-primary key table 202 is divided into two partitions: partition 203 and partition 204. Therein, partition 203 comprises one data line and partition 204 comprises two data lines. The database 201 may divide rows of data in the masterless key table 202 into partitions 203 and 204, fig. 2, with ages less than 18, and into partitions 204, according to the configured program. Of course, the division of the partitions is not limited thereto, for example: partitions may be partitioned according to score fields; or, the data lines may be divided by the number of data lines, each data line being divided into a partition; alternatively, a user may configure a specific rule function to divide a specified data line into a partition. The specification does not limit the specific manner of partitioning.
Each partition in the masterless key table 202 is organized according to the LSM tree structure, with partitions corresponding to the LSM tree one-to-one, e.g., partition 204 corresponds to LSM tree 205. The present specification will be described in detail later with respect to the related contents of storing data according to the structure of the LSM tree, and will not be described herein again. Of course, the technical solution proposed in this specification is not limited to organizing according to the structure of the LSM tree, for example: may be in the structure of a B + tree or other key value storage structure.
FIG. 3 is a flowchart of a method for generating data row identifiers for data rows in a masterless table stored in a database, the masterless table being partitioned into multiple partitions; as shown in fig. 3, at least the following steps are included:
step 302, aiming at the target partition without the primary key table, determining a target data row to be marked in the target partition.
The non-primary key table refers to a table without primary keys designated in the data table, the table with primary keys can be positioned to the data rows through the primary keys, and the table without primary keys can be positioned to the data rows only through the data row identifications due to the fact that the table without primary keys does not have the primary keys.
The target partition may be any partition in the master-free table, and the target data row may be any data row in the target partition.
Step 304, generating a data row identifier of the target data row, where the data row identifier includes at least the unique partition description information of the target partition in the master-key-free table and the unique identifier of the target data row in the target partition.
The partition description information may refer to information recorded with partition characteristics. In one embodiment, the partition description information of the target partition includes: a partition ID of the target partition; or, the partition number of the target partition in the plurality of partitions.
The partition ID may be a globally unique ID in the database, such as "12645300". The partition number may be a partition rank of the target partition in the no-master key table, as shown in fig. 4, partition number 1 is ranked first in the no-master key table, so partition number 1,2 is ranked first in the no-master key table, so partition number is 2.
In one embodiment, the unique identification of the target row in the target partition comprises: self-incrementing sequence numbers in the target partition generated for the target row of data.
As shown in fig. 4, the self-increment of partition No. 2 generates serial numbers "AA01", "AA02", which are distributed in partition No. 2 as unique identifiers belonging to the second row of data lines and the third row of data lines, and which together with the partition serial numbers constitute the data line identifier "(2, aa01)" of the second row of data lines and the data line identifier "(2, aa02)" of the third row of data lines.
Furthermore, each partition of the master-key-free table is organized according to the structure of the LSM tree; wherein the self-increment is a rowkey column within the target partition.
Self-increment refers to a unique ID within a partition that is generated in an incremental manner, and rowkey columns in the LSM tree structure are sequences that are automatically generated by the database when storing data. The LSM tree structure is described in detail below with reference to fig. 5, and as shown in fig. 5, two data structures exist in the LSM tree structure: incremental data and baseline data. The incremental data is stored in the memory and used for storing the data which is updated recently. The baseline data, also known as an ordered set of key-value pairs, is the data structure of the LSM tree in disk. After the data is updated, the data is not directly etched into a disk, and is firstly stored in the memory to be incremental data. When the incremental data is accumulated to a certain threshold, the baseline data merged into the incremental data is carved into a disk. Each piece of baseline data is a collection of key-value pairs, the row keys are automatically generated by the LSM tree, and there is a corresponding row key for each row key-value pair, for example: the row key of the first row may be 1 and the row key of the second row may be 2.
Of course, the partition ID and rowkey columns in the actual case are not as simple as shown in FIG. 4. rowkey tends to shape one 64 bits and partition ID can also shape 64 bits. Some services compatible with the traditional database limit the length of the data row identifier to be at most 80 bits, at this time, when the data row identifier is generated, the requirement can be met by shortening the partition ID and the maximum bit number of the row identifier in the partition, and when the actually stored partition ID or the row identifier in the partition exceeds the bit number, an error is returned.
Because the partition description information is unique in the master-free key table, when the data row is inquired in the database, the partition in the master-free key table can be determined through the partition description information, and then further data row positioning is carried out.
In an embodiment, the method further comprises: acquiring a query request, wherein the query request comprises a data row identifier of a data row to be queried, and the data row to be queried is any data row or multiple data rows stored in the database; determining a partition corresponding to the data line to be queried according to the partition description information contained in the data line identifier of the data line to be queried; and reading the unique identifier of the data line to be inquired in the determined partition from the data line identifier of the data line to be inquired, and searching the data line to be inquired from the determined partition.
The query request is used for requesting to find a data line to be queried, and may be initiated in response to a query operation of a user, for example: the user inputs related query statements in the corresponding client, the query statements contain the data row identification of the data row to be queried, and the server corresponding to the database responds to the operation and initiates a query request aiming at the data row to be queried. Besides the data line identification, the query request may also include a user ID, a node ID of the distributed database, and the like, and this specification does not limit the specific content of the query request.
Taking the first row of data in fig. 4 as an example, assuming that the query request includes the data row identifier "(1, aa01)" of the data row to be queried, it can be determined that the partition corresponding to the data row to be queried is the partition "partition No. 1" by the partition number "1". Next, reading the unique identifier "AA01" of the data line to be queried in the "partition No. 1" from the data line identifier of the data line to be queried, and finding the first data line in the data line to be queried in the non-primary key table shown in fig. 4 from the "partition No. 1".
According to the embodiment, the partition corresponding to the data line to be queried is determined in advance through the partition description information in the data line identifier, and then the data line to be queried is further positioned in the partition corresponding to the data line to be queried, so that the partition semantics are prevented from being lost when the data line is queried, and the query efficiency is improved.
As described above, the generated data row identifier includes the unique partition description information of the target partition in at least the non-primary key table, so that when the database queries the data row using the data row identifier, the partition in which the data row to be queried is located can be determined through the partition description information, and then only the data row needs to be located in the determined partition without involving other partitions, which greatly improves the efficiency of data query. Besides the partition description information, the data row identification also comprises a unique identification of the data row in the target partition, so that the database can be positioned to the data row to be queried through the unique identification after the database is positioned to the partition where the data row to be queried is positioned.
In one embodiment, the database stores a mapping relationship between a master key table and partition description information, and the partition description information is globally unique in the database; the method further comprises the following steps: acquiring a partition exchange request, wherein the partition exchange request is used for requesting partition exchange of a first partition and a second partition which belong to different non-primary key tables; and in the mapping relation between the primary key-free table and the partitions, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
This embodiment is described in detail below with reference to fig. 6, where fig. 6 is a schematic diagram of a partition exchange provided by an exemplary embodiment. As shown in fig. 6, there are an unowned key table 601 and an unowned key table 602. The non-primary key table 601 is divided into a partition 603 and a partition 604, the partition 603 comprises a first data row of the non-primary key table 601, and the partition 604 comprises a second data row and a third data row of the non-primary key table 601; the non-primary key table 602 is divided into a partition 605 and a partition 606, the partition 605 including a first data row and a second data row of the non-primary key table 602, and the partition 606 including a third data row of the non-primary key table 602. Partition 603 corresponds to partition ID "A1", partition 604 corresponds to partition ID "A2", partition 605 corresponds to partition ID "B1", and partition 606 corresponds to partition ID "B1". At this time, the mapping relationship between the non-primary key table and the partition description information is "601- (A1, A2)", "602- (B1, B2)".
Assume that a partition swap request is obtained that requests a partition swap of partition 604 with partition 605. In the mapping relationship between the non-primary key table and the partition, the partition description information corresponding to the partition 604 and the partition description information corresponding to the partition 605 are exchanged to obtain "601- (A1, B1)", "602- (A2, B2)".
The partition description information in this embodiment is globally unique in the database, so that when partition exchange is performed, the exchange of the partition description information does not cause a conflict of data row identifiers, so that the database can support online partition exchange.
This specification also provides a query method, which is described in detail below with reference to fig. 7, where fig. 7 is a flowchart of a query method provided by an exemplary embodiment, the query method being used for querying data rows in a primary key-free table stored in a database, and the primary key-free table being divided into a plurality of partitions; as shown in fig. 7, at least the following steps are included:
step 702, obtaining a query request, where the query request includes a data row identifier of a data row to be queried, where the data row to be queried is any data row or multiple data rows stored in the database, and the data row identifier includes at least unique partition description information of a partition corresponding to the data row to be queried in the master key-free table and a unique identifier of the data row to be queried in the partition corresponding to the data row to be queried.
As described above, the partition description information of the partition corresponding to the data line to be queried may include: the partition ID of the partition corresponding to the data row to be inquired; or the partition sequence numbers of the partitions corresponding to the data row to be queried in the plurality of partitions.
As described above, the unique identifier of the data line to be queried in the partition corresponding to the data line to be queried is: and self-increment in the partition corresponding to the data row to be queried generates a sequence number aiming at the data row to be queried. Furthermore, each partition of the master key-free table is organized according to the structure of the LSM tree; the self-increment is a rowkey column in a partition corresponding to the data row to be queried.
As mentioned above, the query request is for requesting to find a data line to be queried, which may be initiated in response to a query operation by a user, for example: the user inputs related query statements in the corresponding client, the query statements contain the data row identification of the data row to be queried, and the server corresponding to the database responds to the operation and initiates a query request aiming at the data row to be queried. Besides the data line identification, the query request may also include a user ID, a node ID of the distributed database, and the like, and this specification does not limit the specific content of the query request.
Step 704, determining a partition corresponding to the data line to be queried according to the partition description information included in the data line identifier of the data line to be queried.
As described above, the database stores the mapping relationship between the master key table and the partition description information, and the partition description information is globally unique in the database; the method further comprises the following steps: acquiring a partition exchange request, wherein the partition exchange request is used for requesting partition exchange of a first partition and a second partition which belong to different non-primary key tables; and in the mapping relation between the non-primary key table and the partitions, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
Step 706, reading the unique identifier of the data line to be queried in the determined partition from the data line identifier of the data line to be queried, and finding the data line to be queried from the determined partition.
In the embodiment, the generated data row identifier contains the unique partition description information of the target partition at least in the non-primary key table, so that when the database queries the data row by using the data row identifier, the partition where the data row to be queried is located can be determined by the partition description information, and then the data row is located, thereby greatly improving the efficiency of data query. Besides the partition description information, the data row identification also comprises a unique identification of the data row in the target partition, so that the database can be positioned to the data row to be queried through the unique identification after the database is positioned to the partition where the data row to be queried is positioned.
The present specification further provides a partition exchange method, which is described in detail below with reference to fig. 8, where fig. 8 is a flowchart of a partition exchange method according to an exemplary embodiment, where the partition exchange method is used to perform partition exchange on partitions to be exchanged in different non-primary key tables stored in a database, each non-primary key table is divided into multiple partitions, each data row corresponds to a data row identifier, and the data row identifier includes globally unique partition description information of the partition to be exchanged in the database and a unique identifier of the data row in the partition to be exchanged; as shown in fig. 8, at least the following steps are included:
step 802, a partition exchange request is obtained, where the partition exchange request is used to request partition exchange between a first partition and a second partition that belong to different non-primary key tables.
As mentioned above, the partition description information of the partition to be exchanged may include a globally unique partition ID in the database.
As mentioned above, the unique identifier of the data row in the partition to be swapped includes: self-incrementing in the circuit-switched partition generates sequence numbers for rows of data. Furthermore, each partition of the master-key-free table is organized according to the structure of the LSM tree; wherein the self-increment is a rowkey column within the partition to be swapped.
Step 804, in the mapping relationship between the non-primary key table and the partition, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
As mentioned previously, the method further comprises: acquiring a query request, wherein the query request comprises a data row identifier of a data row to be queried, and the data row to be queried is any data row or multiple data rows stored in the database; determining a partition corresponding to the data line to be queried according to the partition description information contained in the data line identifier of the data line to be queried; and reading the unique identifier of the data line to be inquired in the determined partition from the data line identifier of the data line to be inquired, and searching the data line to be inquired from the determined partition.
The partition description information in this embodiment is globally unique, so the partition description information of the partitions in different non-primary key tables does not conflict, and therefore the data row identification in this embodiment can implement online partition exchange by exchanging the partition description information.
FIG. 9 is a schematic block diagram of an apparatus provided in an exemplary embodiment. Referring to fig. 9, at the hardware level, the apparatus includes a processor 902, an internal bus 904, a network interface 906, a memory 908, and a non-volatile memory 910, but may also include hardware required for other functions. One or more embodiments of the present description may be implemented in software, such as by the processor 902 reading a corresponding computer program from the non-volatile storage 910 into the memory 908 and then running. Of course, besides the software implementation, the one or more embodiments in this specification do not exclude other implementations, such as logic devices or combination of software and hardware, and so on, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or logic devices.
Fig. 10 is a block diagram of an apparatus for generating a data row identifier according to an exemplary embodiment, where the apparatus may be applied to the device shown in fig. 10 to implement the technical solution of this specification; the device is used for generating corresponding data row identification for data rows in a master-key-free table stored in a database, wherein the master-key-free table is divided into a plurality of partitions; the device comprises:
a first determining unit 1002, configured to determine, for a target partition without a primary key table, a target data row to be marked in the target partition;
a generating unit 1004, configured to generate a data row identifier of the target data row, where the data row identifier includes partition description information that is unique for the target partition at least in the masterless table and a unique identifier of the target data row in the target partition.
Optionally, the partition description information includes:
a partition ID of the target partition; or, the partition number of the target partition in the plurality of partitions.
Optionally, the unique identifier of the target row in the target partition includes: self-incrementing sequence numbers in the target partition generated for the target row of data.
Optionally, each partition of the master key-free table is organized according to the structure of the LSM tree; wherein the self-increment is a rowkey column within the target partition.
Optionally, the method further includes:
a first obtaining unit 1006, configured to obtain an inquiry request, where the inquiry request includes a data row identifier of a data row to be inquired, and the data row to be inquired is any data row or multiple data rows stored in the database;
a second determining unit 1008, configured to determine, according to the partition description information included in the data row identifier of the data row to be queried, a partition corresponding to the data row to be queried;
a reading unit 1010, configured to read, from the data line identifier of the data line to be queried, the unique identifier of the data line to be queried in the determined partition, and search the data line to be queried from the determined partition.
Optionally, the database stores a mapping relationship between a master key table and partition description information, and the partition description information is globally unique in the database; the method further comprises the following steps:
a second obtaining unit 1012, configured to obtain a partition swap request, where the partition swap request is used to request that a first partition and a second partition that belong to different non-primary key tables are to be subjected to partition swap;
the interchanging unit 1014 is configured to interchange the partition description information corresponding to the first partition with the partition description information corresponding to the second partition in the mapping relationship between the non-primary key table and the partition.
Fig. 11 is a block diagram of a query device according to an exemplary embodiment, where the query device may be applied to the apparatus shown in fig. 11 to implement the technical solution of the present specification; the device is used for inquiring data rows in a master key-free table stored in a database, wherein the master key-free table is divided into a plurality of partitions; the device includes:
an obtaining unit 1102, configured to obtain a query request, where the query request includes a data row identifier of a data row to be queried, the data row to be queried is any data row or multiple data rows stored in the database, and the data row identifier includes at least unique partition description information of a partition corresponding to the data row to be queried in the master-key-free table and a unique identifier of the data row to be queried in the partition corresponding to the data row to be queried;
a determining unit 1104, configured to determine, according to partition description information included in a data row identifier of the data row to be queried, a partition corresponding to the data row to be queried;
a reading unit 1106, configured to read, from the data line identifier of the data line to be queried, the unique identifier of the data line to be queried in the determined partition, and find the data line to be queried from the determined partition.
Optionally, the partition description information includes:
the partition ID of the partition corresponding to the data row to be inquired; or,
and the partition sequence numbers of the partitions corresponding to the data row to be queried in the plurality of partitions.
Optionally, the unique identifier of the data line to be queried in the partition corresponding to the data line to be queried includes: and self-increment in the partition corresponding to the data row to be queried generates a sequence number aiming at the data row to be queried.
Optionally, each partition of the master key-free table is organized according to the structure of the LSM tree; the self-increment is a rowkey column in a partition corresponding to the data row to be queried.
Optionally, the database stores a mapping relationship between a master key table and partition description information, and the partition description information is globally unique in the database; the method further comprises the following steps:
acquiring a partition exchange request, wherein the partition exchange request is used for requesting partition exchange of a first partition and a second partition which belong to different non-primary key tables;
and in the mapping relation between the primary key-free table and the partitions, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
Fig. 12 is a block diagram of a partition exchanging apparatus according to an exemplary embodiment, which may be applied to the device shown in fig. 12 to implement the technical solution of the present specification; the device is used for carrying out partition exchange on partitions to be exchanged in different master-key-free tables stored in a database, each master-key-free table is divided into a plurality of partitions, and the data row identification comprises globally unique partition description information of the partitions to be exchanged in the database and unique identification of data rows in the partitions to be exchanged; the device includes:
an obtaining unit 1202, configured to obtain a partition exchange request, where the partition exchange request is used to request that a first partition and a second partition that belong to different non-primary key tables are subjected to partition exchange;
a interchanging unit 1204, configured to interchange, in the mapping relationship between the non-primary key table and the partition, the partition description information corresponding to the first partition and the partition description information corresponding to the second partition.
Optionally, the partition description information includes:
a partition ID of the partition to be exchanged; or,
the partition sequence number of the partition to be exchanged in the plurality of partitions.
Optionally, the unique identifier of the data line in the partition to be exchanged includes: self-incrementing sequence numbers in the partition to be swapped are generated for rows of data in the partition to be swapped.
Optionally, each partition of the master key-free table is organized according to the structure of the LSM tree; wherein the self-increment is a rowkey column within the partition to be swapped.
Optionally, the method further includes:
acquiring a query request, wherein the query request comprises a data row identifier of a data row to be queried, and the data row to be queried is any data row or multiple data rows stored in the database;
determining a partition corresponding to the data line to be queried according to the partition description information contained in the data line identifier of the data line to be queried;
and reading the unique identifier of the data line to be inquired in the determined partition from the data line identifier of the data line to be inquired, and searching the data line to be inquired from the determined partition.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as ABEL (Advanced Boolean Expression Language), AHDL (alternate Hardware Description Language), traffic, CUPL (core universal Programming Language), HDCal, jhddl (Java Hardware Description Language), lava, lola, HDL, PALASM, rhyd (Hardware Description Language), and vhigh-Language (Hardware Description Language), which is currently used in most popular applications. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium that stores computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and embedded microcontrollers, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be conceived to be both a software module implementing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a server system. Of course, the present invention does not exclude that with future developments in computer technology, the computer implementing the functionality of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle mounted human interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device or a combination of any of these devices.
Although one or more embodiments of the present description provide method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-inventive means. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an actual apparatus or end product executes, it may execute sequentially or in parallel (e.g., parallel processors or multi-threaded environments, or even distributed data processing environments) according to the method shown in the embodiment or the figures. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, article, or apparatus that comprises the recited elements is not excluded. For example, if the terms first, second, etc. are used to denote names, they do not denote any particular order.
For convenience of description, the above devices are described as being divided into various modules by functions, which are described separately. Of course, when implementing one or more of the present description, the functions of each module may be implemented in one or more software and/or hardware, or a module implementing the same function may be implemented by a combination of multiple sub-modules or sub-units, etc. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both permanent and non-permanent, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
As will be appreciated by one skilled in the art, one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
One or more embodiments of the present description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the present specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the system embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for relevant points. In the description of the specification, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the specification. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
The above description is intended to be illustrative of one or more embodiments of the disclosure, and is not intended to limit the scope of one or more embodiments of the disclosure. Various modifications and alterations to one or more embodiments described herein will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of the present specification should be included in the scope of the claims.

Claims (13)

1. A generation method of data row identification is used for generating corresponding data row identification for data rows in a master key-free table stored in a database, wherein the master key-free table is divided into a plurality of partitions; the method comprises the following steps:
determining a target data row to be marked in the target partition aiming at the target partition without the primary key table;
and generating a data row identifier of the target data row, wherein the data row identifier comprises partition description information unique to the target partition at least in the primary key-free table and a unique identifier of the target data row in the target partition.
2. The method of claim 1, the partition description information comprising:
a partition ID of the target partition; or,
a partition number of the target partition in the plurality of partitions.
3. The method of claim 1, the unique identification of the target row in the target partition comprising: self-incrementing sequence numbers in the target partition generated for the target data row.
4. The method of claim 3, each partition of the masterless key table is organized in a structure of an LSM tree, respectively; wherein the self-increment is a rowkey column within the target partition.
5. The method of claim 1, further comprising:
acquiring a query request, wherein the query request comprises a data row identifier of a data row to be queried, and the data row to be queried is any data row or multiple data rows stored in the database;
determining a partition corresponding to the data line to be queried according to the partition description information contained in the data line identifier of the data line to be queried;
and reading the unique identifier of the data line to be inquired in the determined partition from the data line identifier of the data line to be inquired, and searching the data line to be inquired from the determined partition.
6. The method of claim 1, the database storing a mapping relationship between a master key table and partition description information, the partition description information being globally unique in the database; the method further comprises the following steps:
acquiring a partition exchange request, wherein the partition exchange request is used for requesting partition exchange of a first partition and a second partition which belong to different non-primary key tables;
and in the mapping relation between the primary key-free table and the partitions, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
7. A query method is used for querying data rows in a master-key-free table stored in a database, wherein the master-key-free table is divided into a plurality of partitions; the method comprises the following steps:
acquiring a query request, wherein the query request comprises a data row identifier of a data row to be queried, the data row to be queried is any data row or multiple data rows stored in the database, and the data row identifier comprises partition description information of a partition corresponding to the data row to be queried, the partition description information being unique at least in the non-master key table, and a unique identifier of the data row to be queried in a partition corresponding to the data row to be queried;
determining a partition corresponding to the data line to be queried according to the partition description information contained in the data line identifier of the data line to be queried;
and reading the unique identifier of the data line to be inquired in the determined partition from the data line identifier of the data line to be inquired, and searching the data line to be inquired from the determined partition.
8. A partition exchange method is used for carrying out partition exchange on partitions to be exchanged in different master-key-free tables stored in a database, each master-key-free table is divided into a plurality of partitions, each data row corresponds to a data row identifier, and the data row identifier comprises globally unique partition description information of the partitions to be exchanged in the database and unique identifiers of the data rows in the partitions to be exchanged; the method comprises the following steps:
acquiring a partition exchange request, wherein the partition exchange request is used for requesting partition exchange of a first partition and a second partition which belong to different non-primary key tables;
and in the mapping relation between the primary key-free table and the partitions, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
9. A data row identifier generating device is used for generating corresponding data row identifiers for data rows in a primary key-free table stored in a database, wherein the primary key-free table is divided into a plurality of partitions; the device comprises:
a first determination unit: determining a target data row to be marked in the target partition aiming at the target partition without the primary key table;
a generation unit: and generating a data row identifier of the target data row, wherein the data row identifier comprises partition description information unique to the target partition at least in the primary key-free table and a unique identifier of the target data row in the target partition.
10. A query device for querying rows of data in a masterless table stored in a database, said masterless table being divided into a plurality of partitions; the device comprises:
an acquisition unit: acquiring a query request, wherein the query request comprises a data row identifier of a data row to be queried, the data row to be queried is any data row or multiple data rows stored in the database, and the data row identifier comprises globally unique partition description information of a partition corresponding to the data row to be queried in the database and unique identifiers of the data row to be queried in the partition corresponding to the data row to be queried;
a determination unit: determining a partition corresponding to the data line to be queried according to the partition description information contained in the data line identifier of the data line to be queried;
a reading unit: and reading the unique identifier of the data line to be inquired in the determined partition from the data line identifier of the data line to be inquired, and searching the data line to be inquired from the determined partition.
11. A partition exchange device is used for carrying out partition exchange on partitions to be exchanged in different main key-free tables stored in a database, each main key-free table is divided into a plurality of partitions, each data row corresponds to a data row identifier, and the data row identifier comprises globally unique partition description information of the partitions to be exchanged in the database and unique identifiers of the data rows in the partitions to be exchanged; the device comprises:
an acquisition unit: acquiring a partition exchange request, wherein the partition exchange request is used for requesting partition exchange of a first partition and a second partition which belong to different non-primary key tables;
interchanging units: and in the mapping relation between the primary key-free table and the partitions, exchanging the partition description information corresponding to the first partition with the partition description information corresponding to the second partition.
12. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of any one of claims 1-8 by executing the executable instructions.
13. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, carry out the steps of the method according to any one of claims 1 to 8.
CN202211358911.2A 2022-11-01 2022-11-01 Data line identifier generation method and query and partition exchange method and device Pending CN115794813A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211358911.2A CN115794813A (en) 2022-11-01 2022-11-01 Data line identifier generation method and query and partition exchange method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211358911.2A CN115794813A (en) 2022-11-01 2022-11-01 Data line identifier generation method and query and partition exchange method and device

Publications (1)

Publication Number Publication Date
CN115794813A true CN115794813A (en) 2023-03-14

Family

ID=85434876

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211358911.2A Pending CN115794813A (en) 2022-11-01 2022-11-01 Data line identifier generation method and query and partition exchange method and device

Country Status (1)

Country Link
CN (1) CN115794813A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023202394A1 (en) * 2022-04-18 2023-10-26 北京奥星贝斯科技有限公司 Partition table creation method and apparatus, data writing method and apparatus for partition table, and data reading method and apparatus for partition table

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023202394A1 (en) * 2022-04-18 2023-10-26 北京奥星贝斯科技有限公司 Partition table creation method and apparatus, data writing method and apparatus for partition table, and data reading method and apparatus for partition table

Similar Documents

Publication Publication Date Title
CN106970936B (en) Data processing method and device and data query method and device
CN107526777B (en) Method and equipment for processing file based on version number
CN108205577B (en) Array construction method, array query method, device and electronic equipment
US7730099B2 (en) Storage and retrieval of richly typed hierarchical network models
CN108241715A (en) A kind of distributed data base major key generation method and device
CN110399359B (en) Data backtracking method, device and equipment
TWI709049B (en) Random walk, cluster-based random walk method, device and equipment
US20220414155A1 (en) Database management method and apparatus based on lookup table
CN114529417A (en) Method for executing transaction, block chain, main node and slave node
CN115794813A (en) Data line identifier generation method and query and partition exchange method and device
CN114840487A (en) Metadata management method and device for distributed file system
CN102521304A (en) Hash based clustered table storage method
CN114490674A (en) Partition table establishing method, partition table data writing method, partition table data reading method, partition table data writing device, partition table data reading device and partition table data reading device
CN116662019B (en) Request distribution method and device, storage medium and electronic device
CN116303625B (en) Data query method and device, storage medium and electronic equipment
US10901971B2 (en) Random walking and cluster-based random walking method, apparatus and device
CN110083602B (en) Method and device for data storage and data processing based on hive table
CN114238345A (en) Database processing and data query method and device
CN111008198A (en) Service data acquisition method and device, storage medium and electronic equipment
CN111309737A (en) List query method, device and equipment
CN111339117B (en) Data processing method, device and equipment
CN111143006A (en) Method and device for acquiring command help information
CN104133890B (en) A kind of large data processing method in high in the clouds and system
CN116126850A (en) Data storage method, data query method and related devices
CN116028504B (en) Data lake metadata management method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination