WO2024098626A1 - 存储格式转换方法、系统、装置、电子设备及存储介质 - Google Patents

存储格式转换方法、系统、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2024098626A1
WO2024098626A1 PCT/CN2023/084271 CN2023084271W WO2024098626A1 WO 2024098626 A1 WO2024098626 A1 WO 2024098626A1 CN 2023084271 W CN2023084271 W CN 2023084271W WO 2024098626 A1 WO2024098626 A1 WO 2024098626A1
Authority
WO
WIPO (PCT)
Prior art keywords
column
data
storage page
storage
field
Prior art date
Application number
PCT/CN2023/084271
Other languages
English (en)
French (fr)
Inventor
刘科
Original Assignee
浪潮电子信息产业股份有限公司
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 浪潮电子信息产业股份有限公司 filed Critical 浪潮电子信息产业股份有限公司
Publication of WO2024098626A1 publication Critical patent/WO2024098626A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2291User-Defined Types; Storage management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/24569Query processing with adaptation to specific hardware, e.g. adapted for using GPUs or SSDs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/283Multi-dimensional databases or data warehouses, e.g. MOLAP or ROLAP
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of storage technology, and in particular to a storage format conversion method, system, device, electronic device and storage medium.
  • row storage mode Most traditional relational databases use row storage mode to store data.
  • row storage mode fields of different types and lengths are stored continuously in the same row, which is more suitable for OLTP (On-Line Transaction Processing) business.
  • OLTP On-Line Transaction Processing
  • the row storage mode needs to read all the data in a row and then extract the valid fields, which increases the IO reading overhead and field parsing overhead, and will cause large query delays when the amount of data is large. Therefore, in order to improve the OLAP performance of the database, the column storage mode is proposed. In the column storage mode, data is stored in columns.
  • variable-length data exists, and the length of each row is allowed to be different, and the length of the row cannot be predicted before calculation. Therefore, although this implementation method can obtain a higher data throughput, it cannot process variable-length data, which limits its applicable scenarios.
  • the present application provides a storage format conversion method, which is applied to a coprocessor, comprising:
  • the padding information including the first offset address and the column length of each data column in the column storage page, wherein each column field having the same field attribute constitutes a data column;
  • Feeds column store page data back to the main processor.
  • parsing the row storage page data according to the configuration information to obtain the column descriptor includes:
  • the configuration information is generated by the main processor based on the tuple descriptor corresponding to the row storage page data.
  • a tuple descriptor is created by a relational database while creating a data table of a row storage page type, and the tuple descriptor is used to describe the format information of each column field in the data table.
  • the data storage format of the row storage page data includes any one or more of the following:
  • the storage location of the data information itself the storage location of the metadata of the data information, and the storage location of the description information of the data information.
  • the padding information further includes the first offset address and field length of each variable-length column field, the maximum value and the minimum value of the fixed-length data column, and the column storage page is filled according to the padding information to generate column storage page data, including:
  • the first offset address and column length of each data column, and the maximum and minimum values of the fixed-length data column are filled into the column data index area of the column storage page.
  • filling a column storage page according to the filling information to generate column storage page data includes:
  • it also includes:
  • the filling alignment is performed according to the data storage format.
  • the following further includes:
  • the column descriptors are sorted according to the sorting mode of the sorted data column to obtain sorted column descriptors.
  • the coprocessor includes a first preset number of computing units and a first preset number of memories, each computing unit corresponds to a memory, and obtaining the row storage page data sent by the main processor includes:
  • the row storage page data is read from the memory corresponding to the current computing unit, and the row storage page data is sent to the memory by the main processor.
  • each computing unit includes a second preset number of execution channels, and reading from a memory corresponding to the current computing unit to obtain row storage page data includes:
  • the method further includes:
  • the second preset number of row storage page data is distributed to the second preset number of execution channels, so that each execution channel is used to perform the step of parsing the row storage page data to obtain the column descriptor.
  • feeding back column storage page data to a main processor includes:
  • Each column storage page is written back to the memory corresponding to the current computing unit, so that the main processor reads the data of each column storage page from each memory.
  • the method before feeding back the column storage page data to the main processor, the method further includes:
  • Each column field in the column storage page data is compressed according to a preset compression algorithm corresponding to each data column to obtain the compressed column storage page data.
  • compression processing is performed on each column field in the column storage page data according to a preset compression algorithm corresponding to each data column, including:
  • the data type of the column field in each data column is determined, and the corresponding preset compression algorithm is determined according to the data type, and the column fields in the column storage page data are compressed according to the preset compression algorithm.
  • the present application provides another storage format conversion method, which is applied to a main processor, comprising:
  • Configuration information about the row storage page data according to the tuple descriptor, the configuration information including format information of each column field in the row storage page data;
  • the process of the coprocessor converting row storage page data into column storage page data according to the configuration information includes:
  • the padding information including the first offset address and the column length of each data column in the column storage page, wherein each column field having the same field attribute constitutes a data column;
  • the column storage page is filled according to the filling information to generate column storage page data.
  • the present application also discloses a storage format conversion system, including a main processor and a coprocessor;
  • the main processor is used to send row storage page data and configuration information to the coprocessor, and obtain column storage page data fed back by the coprocessor;
  • the coprocessor is used to parse the row storage page data according to the configuration information to obtain a column descriptor, wherein the column descriptor includes a first offset address and a field length of each column field in the row storage page; obtain fill information about the column storage page according to the column descriptor, wherein the fill information includes a first offset address and a column length of each data column in the column storage page, wherein each column field having the same field attribute constitutes a data column; fill the column storage page according to the fill information to generate column storage page data.
  • the main processor is a CPU and the coprocessor is an FPGA.
  • the present application further discloses a storage format conversion device, which is applied to a coprocessor, comprising:
  • An acquisition module used to acquire row storage page data and configuration information sent by the main processor, wherein the configuration information includes format information of each column field in the row storage page;
  • a parsing module used to parse the row storage page data according to the configuration information to obtain a column descriptor, wherein the column descriptor includes the first offset address and field length of each column field in the row storage page;
  • a calculation module used for calculating and obtaining filling information about the column storage page according to the column descriptor, wherein the filling information includes the first offset address and the column length of each data column in the column storage page, wherein each column field having the same field attribute constitutes a data column;
  • a filling module used to fill the column storage page according to the filling information and generate column storage page data
  • the feedback module is used to feed back the column storage page data to the main processor.
  • the present application also discloses another storage format conversion device, which is applied to a main processor, comprising:
  • a first acquisition module is used to acquire row storage page data and a tuple descriptor corresponding to the row storage page data
  • a generating module used for generating configuration information about the row storage page data according to the tuple descriptor, wherein the configuration information includes format information of each column field in the row storage page data;
  • a sending module used for sending the row storage page data and the configuration information to the coprocessor, so that the coprocessor converts the row storage page data into the column storage page data according to the configuration information
  • a second acquisition module is used to acquire the column storage page data fed back by the coprocessor
  • the process of the coprocessor converting row storage page data into column storage page data according to the configuration information includes:
  • the padding information including the first offset address and the column length of each data column in the column storage page, wherein each column field having the same field attribute constitutes a data column;
  • the column storage page is filled according to the filling information to generate the number of column storage pages.
  • the present application further discloses an electronic device, comprising:
  • a processor is used to implement the steps of any of the above storage format conversion methods when executing a computer program.
  • the present application further discloses a non-volatile readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of any of the above storage format conversion methods are implemented.
  • the row storage page data is parsed in combination with the configuration information to obtain the offset address and field length of each column field in the row storage page data, and then the first offset address and field length of each data column in the column storage page are calculated, and the column storage page data corresponding to the row storage page data is generated, thereby realizing the conversion of the row-column storage format.
  • this implementation method takes into account the position information and field length of each column field, realizes the row-column storage format conversion that can support variable-length field data, and effectively improves the applicability of the row-column conversion method.
  • FIG1 is a schematic diagram of the structure of a storage format conversion system provided by the present application.
  • FIG2 is a schematic diagram of a flow chart of a storage format conversion method provided by the present application.
  • FIG3 is a flow chart of another storage format conversion method provided by the present application.
  • FIG4 is a schematic diagram of the structure of another storage format conversion system provided by the present application.
  • FIG5 is a schematic diagram of a storage format of a row storage page data provided by the present application.
  • FIG6 is a schematic diagram of a format of a configuration parameter code stream provided by the present application.
  • FIG7 is a schematic diagram of a data table corresponding to a row storage page data provided by the present application.
  • FIG8 is a schematic diagram of a tuple descriptor provided by the present application.
  • FIG9 is a schematic diagram of a configuration parameter code stream provided by the present application.
  • FIG10 is a schematic diagram of a row storage page data provided by the present application.
  • FIG11 is a schematic diagram of a column field parsing principle provided by the present application.
  • FIG12 is a schematic diagram of another tuple descriptor provided by the present application.
  • FIG13 is a schematic diagram of storing the tuple descriptor shown in FIG12 in a PostgreSQL database
  • FIG14 is a schematic diagram of a storage format of column storage page data provided by the present application.
  • FIG15 is a schematic diagram of a column storage page data without enabling sorting provided by the present application.
  • FIG16 is a schematic diagram of a column storage page data capable of enabling sorting provided by the present application.
  • FIG17 is a schematic diagram of the structure of a computing unit in an FPGA provided by the present application.
  • FIG18 is a schematic diagram of a workflow of a computing unit in an FPGA provided by the present application.
  • FIG19 is a schematic diagram of a workflow of an execution channel provided by the present application.
  • FIG20 is a schematic diagram of another column storage page enabling sorting provided by the present application.
  • FIG21 is a schematic diagram of another row storage page data provided by the present application.
  • FIG22 is a schematic diagram of a generation principle of a column descriptor provided by the present application.
  • FIG23 is a schematic diagram of a sorting principle of column descriptors provided by the present application.
  • FIG24 is a schematic diagram of a calculation principle of copy information in a column storage page provided by the present application.
  • FIG25 is a schematic diagram of an updating principle of a column descriptor provided by the present application.
  • FIG26 is a schematic diagram of a generation principle of column storage page data provided by the present application.
  • FIG27 is a schematic diagram of a flow chart of a storage format conversion device provided by the present application.
  • FIG28 is a schematic diagram of a flow chart of another storage format conversion device provided by the present application.
  • FIG29 is a schematic diagram of the structure of an electronic device provided in the present application.
  • the storage format conversion method provided in the present application is applied to a storage format conversion system.
  • Figure 1 is a schematic diagram of the structure of a storage format conversion system provided in the present application.
  • the storage format conversion system includes a main processor 100 and a coprocessor 200, which can perform collaborative processing to realize storage format conversion.
  • the main processor can be a CPU
  • the coprocessor can be an FPGA (Field Programmable Gate Array, a high-performance programmable logic device).
  • An embodiment of the present application provides a storage format conversion method.
  • FIG. 2 is a flow chart of a storage format conversion method provided in the present application.
  • the storage format conversion method is applied to a coprocessor and may include the following S101 to S105 .
  • S101 Acquire row storage page data and configuration information sent by a main processor, where the configuration information includes format information of each column field in the row storage page;
  • row storage page data refers to page data that stores data in a row storage format.
  • the corresponding column storage page data can be obtained, that is, page data that stores data in a column storage format.
  • the configuration information includes the format information of each column field in the row storage page.
  • the column field refers to the data information stored in the row storage page, which can be a fixed-length field or a variable-length field, such as a string, a number, a date, etc.
  • the format information includes but is not limited to the field length, field alignment, field type, etc. of each column field.
  • the storage format conversion method provided in the embodiment of the present application is applied to the coprocessor, and the row storage page data and configuration information are all sent by the main processor to the coprocessor. That is to say, when row-column storage format conversion is required, the main processor sends the row storage page data and its configuration information that need to be converted into row-column storage format to the coprocessor to perform the row-column storage format conversion operation, and the corresponding column storage page data can be obtained, thereby realizing the row-column storage format conversion.
  • S102 Parse the row storage page data according to the configuration information to obtain a column descriptor, where the column descriptor includes the first offset address and field length of each column field in the row storage page;
  • This step is intended to implement the parsing operation of the row storage page data and obtain the column descriptor corresponding to the row storage page data.
  • the column descriptor includes the first offset address and field length of each column field in the row storage page.
  • the first offset address is the first offset position of the corresponding column field in the row storage page;
  • the field length is the field length of the corresponding column field.
  • the field length of the fixed-length field is a fixed value, and the field length of the variable-length field is an indefinite value.
  • the column descriptor takes into account the first offset address and field length of each column field, which helps to realize the row-column storage format conversion that can support variable-length field data, and can effectively improve the applicability of the row-column conversion method.
  • the information contained in the column descriptor is not limited to this, and may also include other types of data information, which can be specifically set by technical personnel according to actual needs (such as storage format requirements of column storage pages), and this application does not limit this.
  • the above-mentioned parsing of the row storage page data according to the configuration information to obtain the column descriptor may include: determining the data storage format of the row storage page data; parsing the row storage page data according to the data storage format and the configuration information to obtain the column descriptor; wherein the configuration information is generated by the main processor based on the tuple descriptor corresponding to the row storage page data.
  • the embodiment of the present application provides a method for parsing row storage page data to obtain column descriptors.
  • the row storage page itself is preset with different storage formats, such as the storage location of the data information itself, the storage location of the metadata of the data information, the storage location of the description information of the data information, etc. Therefore, the row storage page data can be parsed in combination with the data storage format of the row storage page.
  • a tuple descriptor is also created to describe the field length, field alignment, field type and other format information of each column field in the data table. Therefore, the above configuration information can be generated based on the tuple descriptor, and thus, the configuration information can also include the above format information of each column field.
  • This step aims to realize the calculation of filling information in the column storage page.
  • the filling information is used to indicate the implementation method of storing each column field in the row storage page to the column storage page, mainly including the first offset address and column length of each data column in the column storage page, so that each column field in the row storage page can be stored in the column storage page according to this information, thereby realizing the conversion of row-column storage method.
  • the information contained in the filling information is not limited thereto, and may also include other types of data information, which may be specifically set by technical personnel according to actual needs (such as storage format requirements of column storage pages), and this application does not limit this.
  • the column descriptor corresponds to the row storage page, mainly including the first offset address and field length of each column field in the row storage page
  • the padding information corresponds to the column storage page, mainly including the first offset address and column length of each data column in the column storage page, wherein the data column is composed of column fields with the same field attributes (in other words, all column fields corresponding to the same key value in the row storage page data are called a data column), for example, all column fields with the field attribute of "salary" constitute a data column.
  • the first offset address and column length of each data column in the column storage page in the padding information can be calculated from the first offset address and field length of each column field in the column descriptor.
  • S104 Fill the column storage page according to the filling information to generate column storage page data
  • This step aims to implement the filling processing of the column storage page, obtain the column storage page corresponding to the row storage page, and thus realize the conversion of the row-column storage format.
  • the filling information includes the first offset address and column length of each data column in the column storage page.
  • each column field in the row storage page data can be directly copied to the column storage page according to the filling information, thereby generating the column storage page data.
  • the padding information may further include the first offset address and field length of each variable-length column field, and the maximum value and minimum value of the fixed-length data column.
  • the padding of the column storage page according to the padding information to generate the column storage page data may include the following steps:
  • the first offset address and column length of each data column, and the maximum and minimum values of the fixed-length data column are filled into the column data index area of the column storage page.
  • the embodiment of the present application provides an implementation method for filling a column storage page based on filling information.
  • the filling information may also include the first offset address and field length of each variable-length column field, and the maximum and minimum values of the fixed-length data column, wherein all column fields corresponding to the same key value in the row storage page data are called a data column, and each data column corresponds to a key value.
  • the data column corresponding to the key value is a variable-length data column
  • the data column corresponding to the key value is a fixed-length data column
  • the column storage page includes a field area, a variable-length field index area, and a column data index area, wherein the field area is used to store each column field in the row storage page data, and the field area can be filled according to the first offset address and column length of each data column in the column storage page; the variable-length field index area is used to store the first offset address and field length of each variable-length column field; the column data index area is used to store the first offset address and column length of each data column, and the maximum and minimum values of the fixed-length data column.
  • the field alignment method of the column field in the preset configuration information can also be combined to realize filling alignment.
  • This step aims to realize the feedback of the column storage page. After the row storage page is converted into a column storage page, it can be fed back to the main processor, and the main processor continues to perform corresponding business processing.
  • the storage format conversion method provided in the embodiment of the present application can effectively avoid the large consumption of the computing power resources of the main processor and ensure high work efficiency.
  • the row storage page data is parsed in combination with the configuration information to obtain the offset address and field length of each column field in the row storage page data, and then the first offset address and field length of each data column in the column storage page are calculated, and the column storage page data corresponding to the row storage page data is generated, thereby realizing the conversion of the row-column storage format.
  • this implementation method takes into account the position information and field length of each column field, realizes the row-column storage format conversion that can support variable-length field data, and effectively improves the applicability of the row-column conversion method.
  • the column descriptors are sorted according to the sorting mode of the sorted data column to obtain sorted column descriptors.
  • the storage format conversion method provided in the embodiment of the present application can further implement the sorting function of column data within a page. Specifically, after parsing the row storage page data to obtain the column descriptor, before calculating the fill information based on the column descriptor, the column descriptor can be sorted first, and the column data within the column storage page can be sorted by sorting the column descriptor.
  • the sorting enable information is obtained, and then the sorting data column is determined according to the sorting enable information, wherein the sorting enable information can be the key value information specified by the user, then the column data corresponding to the key value is the sorting data column, that is, the column data corresponding to the key value is sorted, for example, when the key value information specified by the user is "salary", it means that the various salary values in the "salary" column data are sorted from low to high or from high to low. Further, the column descriptors are sorted according to the sorting method of the sorting data column to obtain the sorted column descriptors.
  • the column descriptors are used to realize the calculation of the filling information in the column storage page, and the filling information is used to realize the data filling of the column storage page. Therefore, the filling information in the column storage page obtained by calculating the sorted column descriptors must also be the sorted filling information, and the column storage page data obtained based on the sorted filling information must also be the sorted column storage page data.
  • the implementation of the sorting function can effectively reduce the amount of data read and improve data reading efficiency. Specifically, after sorting the column data corresponding to a key value, if you want to query the target data with the key value within the specified range, you can directly determine the column number where the target data that meets the specified range is located, and start reading data directly from that column, without having to start reading data from the first column, that is, directly skipping the columns that do not meet the above specified range, thus effectively reducing the amount of data read and improving data reading efficiency.
  • the above-mentioned coprocessor may include a first preset number of computing units and a first preset number of memories, each computing unit corresponds to a memory, and the above-mentioned acquisition of row storage page data sent by the main processor may include: reading from the memory corresponding to the current computing unit to obtain the row storage page data, and the row storage page data is sent by the main processor to the memory.
  • the coprocessor may include a first preset number of computing units and a first preset number of memories, that is, the number of computing units and memories is equal, and one computing unit corresponds to one memory, wherein the memory is used to store the row storage page data sent by the main processor, and the computing unit is used to read the row storage page data from the corresponding memory and perform row-column conversion on it.
  • the specific value of the first preset number does not affect the implementation of the present technical solution, and can be set according to the actual characteristics of the coprocessor. This application does not limit this.
  • the first preset number can be set to 16. It can be understood that by setting multiple computing units in the coprocessor to realize parallel processing of multiple row storage page data, the storage format conversion efficiency can be greatly improved.
  • each computing unit includes a second preset number of execution channels
  • the above-mentioned reading from the memory corresponding to the current computing unit to obtain the row storage page data may include: reading from the memory corresponding to the current computing unit to obtain the second preset number of row storage page data;
  • a first preset number of computing units are provided in the coprocessor for realizing storage format conversion, and further, each computing unit may be provided with a second number of execution channels, and each computing unit may realize storage format conversion through its own execution channels. Therefore, when the current computing unit reads row storage page data from its corresponding memory, it may directly read the second preset number of row storage page data, thereby distributing each row storage page data to each execution channel in sequence, and each execution channel processes one row storage page data.
  • the specific value of the second preset number does not affect the implementation of the present technical solution, and can be set according to the actual characteristics of the coprocessor.
  • the present application does not limit this.
  • the second preset number can be set to 8.
  • a coprocessor is provided with a first preset number of computing units, each computing unit is provided with a second preset number of execution channels, and each execution channel processes a row storage page data. Therefore, a coprocessor can simultaneously process the first preset number * the second preset number of row storage page data, thereby realizing the parallel processing of multiple row storage page data, and further improving the storage format conversion efficiency.
  • the above-mentioned feeding back the column storage page data to the main processor may include: writing each column storage page back to the memory corresponding to the current computing unit, so that the main processor reads each column storage page data from each memory.
  • the embodiment of the present application provides a method for implementing feedback of column storage page data.
  • a first preset number of computing units are provided in the coprocessor, and each computing unit corresponds to a memory.
  • the main processor sends the row storage page data that needs to be converted from row to column to the memory for storage, and then the computing unit reads the row storage page data from its corresponding memory for row-column conversion.
  • the computing unit can write each column page storage data back to its corresponding memory for storage.
  • the main processor can read each column storage page data from each memory to obtain the data, thereby implementing feedback of the column storage page data.
  • the process may further include: compressing each column field in the column storage page data according to a preset compression algorithm corresponding to each data column to obtain the compressed column storage page data.
  • the storage format conversion method provided in the embodiment of the present application can further realize the compression processing function of the column fields in the column storage page to reduce the storage space occupied. Specifically, after completing the row-column storage format conversion to obtain the column storage page data, each column field in the column storage page data can be compressed to obtain the compressed column storage page data.
  • different compression methods can be used for different types of column fields. Therefore, when compressing column fields, the preset compression algorithm corresponding to each data column can be used. For example, for string type column fields, Huffman coding or LZ77 coding compression can be used; for floating point type column fields, run-length coding or a dedicated floating point compression algorithm can be used; for integer and date type column fields, difference coding compression can be used. It can be understood that using different compression methods for different types of column fields can achieve a higher compression ratio, thereby greatly reducing the storage space occupied.
  • An embodiment of the present application provides another storage format conversion method.
  • FIG. 3 is a flow chart of another storage format conversion method provided in the present application.
  • the storage format conversion method is applied to a main processor and may include the following S201 to S204 .
  • S202 Generate configuration information about the row storage page data according to the tuple descriptor, the configuration information including format information of each column field in the row storage page data;
  • S203 Sending the row storage page data and the configuration information to the coprocessor, so that the coprocessor converts the row storage page data into column storage page data according to the configuration information;
  • the process of the coprocessor converting row storage page data into column storage page data according to the configuration information includes: parsing the row storage page data according to the configuration information to obtain a column descriptor, the column descriptor including the first offset address and the field length of each column field in the row storage page; obtaining fill information about the column storage page according to the column descriptor, the fill information including the first offset address and the column length of each data column in the column storage page, wherein each column field with the same field attribute constitutes a data column; filling the column storage page according to the fill information to generate column storage page data.
  • the storage format conversion method provided in the embodiment of the present application is applied to the main processor, and the main processor and the coprocessor cooperate to perform storage format conversion.
  • the specific implementation process can refer to the above embodiments, and the embodiment of the present application will not be repeated here.
  • the storage format conversion method provided in the embodiment of the present application combined with the coprocessor to realize the conversion of row and column storage formats, can effectively avoid the large consumption of computing power resources of the main processor and ensure high work efficiency.
  • An embodiment of the present application provides a storage format conversion system.
  • the storage format conversion system may include a main processor 100 and a coprocessor 200, wherein:
  • the main processor 100 is used to send row storage page data and configuration information to the coprocessor 200, and obtain column storage page data fed back by the coprocessor 200;
  • the coprocessor 200 is used to parse the row storage page data according to the configuration information to obtain a column descriptor, where the column descriptor includes a first offset address and a field length of each column field in the row storage page; calculate and obtain fill information about the column storage page according to the column descriptor, where the fill information includes a first offset address and a column length of each data column in the column storage page, wherein each column field with the same field attribute constitutes a data column; fill the column storage page according to the fill information to generate column storage page data.
  • the storage format conversion system provided in the embodiment of the present application, combined with a coprocessor to realize the conversion of row-column storage formats, can effectively avoid the large consumption of computing power resources of the main processor and ensure high work efficiency.
  • the row storage page data is parsed in combination with the configuration information to obtain the offset address and field length of each column field in the row storage page data, and then the first offset address and field length of each data column in the column storage page are calculated, and the column storage page data corresponding to the row storage page data is generated, thereby realizing the conversion of the row-column storage format.
  • this implementation method takes into account the position information and field length of each column field, realizes the row-column storage format conversion that can support variable-length field data, and effectively improves the applicability of the row-column conversion method.
  • FIG. 4 is a schematic diagram of the structure of another storage format conversion system provided by the present application, in which the main processor is a CPU and the coprocessor is an FPGA.
  • the host side of the system is composed of a CPU, memory, and disk.
  • the FPGA is connected to the host through the PCIe bus as an acceleration card.
  • the FPGA is equipped with a high-speed HBM memory (High Bandwidth Memory, a high-bandwidth memory that uses memory stacking technology) to store data to be processed.
  • Multiple computing units are instantiated inside the FPGA to perform parallel data calculations.
  • the implementation process of the storage format conversion method may include:
  • the host CPU reads the database file data from the disk into the host memory
  • the host CPU reads the converted data from the FPGA's HBM memory into the host memory
  • the CPU obtains the converted data in column storage format.
  • variable-length field index variable-length field index area
  • the column data index is used to mark the first address offset and length of each data column in the memory block, and the maximum and minimum values of each data column are added to optimize data reading (column data index area).
  • the PostgreSQL database stores data in units of 8KB, and each 8KB memory block is called a page, that is, row storage page data.
  • Figure 5 is a schematic diagram of the storage format of a row storage page data provided by this application, and its storage rules are as follows:
  • a page stores several rows of data, and the number of rows stored in the page is marked at a fixed position on the page;
  • Each row of data is encapsulated as a tuple, in which the data of each field (including variable-length fields and fixed-length fields) is stored in sequence except for the header information;
  • the meta information of the tuple is stored toward the bottom of the page.
  • the meta information includes the offset and length of the tuple.
  • Each row tuple contains one or more columns, which can be fixed-length or variable-length.
  • PostgreSQL creates a corresponding tuple descriptor (corresponding to the tupDesc data structure in the source code) to describe the length, alignment, type, and other information of each column in the table.
  • tuple descriptor corresponding to the tupDesc data structure in the source code
  • the atlen field in the tuple descriptor is greater than 0, indicating the length of the corresponding column field
  • variable-length data the attlen field in the tuple descriptor is equal to -1, indicating that the corresponding column field is a variable-length field.
  • the length information of the variable-length field is placed at the head of the column data. The value is shifted right by one bit minus 1, which is the column length.
  • the atttype field indicates the field type of the column:
  • Common types include: integer, floating point, string, date, etc. (the values correspond to src/backend/catalog/pg_type_d.h in the source code).
  • the natts field indicates the total number of column fields in the tuple.
  • the purpose of configuring parameters for FPGA is to inform the FPGA of the format of each column field in the tuple in the row storage page.
  • the configuration parameters are converted from the PostgreSQL tuple descriptor, and can be composed of a continuous code stream by extracting the fields required for hardware parsing of the tuple.
  • the code stream format is shown in Figure 6, which is a schematic diagram of the format of a configuration parameter code stream provided by this application, wherein the 4 bytes at the head of the code stream represent the number of column fields in the tuple, and the subsequent 4 bytes store the sorting column index number (the index number is equal to -1 when sorting is not required), followed by the field type, field length, and field alignment of each column.
  • Figure 7 is a schematic diagram of a data table corresponding to a row storage page data provided by the present application, and the data table has a total of 5 rows of records.
  • ID and Age columns are integers (INT4)
  • Name and Position columns are strings (VARCHAR)
  • Salary column is a floating point number (FLOAT8).
  • the field type (atttype) corresponding to each column field is defined in the source code src/backend/catalog/pg_type_d.h as follows:
  • the natts field is equal to 5
  • the atttype, attalign, and attlen fields are as shown in Figure 8, which is a schematic diagram of a tuple descriptor provided by the present application.
  • the parsing parameter code stream generated according to the tuple descriptor is shown in Figure 9, which is a schematic diagram of a configuration parameter code stream provided by the present application, wherein columns 1, 3, and 5 are fixed-length types and can be used for sorting. If sorting is not required, the sorting index number is filled with -1.
  • FIG10 is a schematic diagram of a row storage page data provided by the present application, and the parsing process is as follows:
  • Bytes 12-13 of the page indicate the number of rows stored in the page. According to the parsing rules shown in FIG5 , the number of rows can be obtained to be 5;
  • each row of data is stored in sequence, and the data is encapsulated in the form of tuples.
  • the meta information value is 0x709fc8;
  • Bits 0-14 in the meta information represent the offset of the corresponding tuple within the page.
  • the tuple offset can be calculated to be 0x1fc8;
  • Bits 17-32 in the metadata represent the length of the corresponding tuple. It can be calculated that the original value of the tuple length is 56.
  • Figure 11 is a schematic diagram of a column field parsing principle provided by the present application, and the parsing process is: first, at the tuple offset 22 bytes, the offset position of the column field in the tuple is marked as 0x18, and the first column address offset is calculated to be 0x1fe0; then, the position of each field in the tuple is parsed according to attlen and attalign, and the meaning of each field is parsed according to atttype.
  • the fifth aspect is the row-column conversion format rules, which have the following characteristics:
  • variable-length field index contains the offset position and field length of each variable-length column field in the memory block
  • Figure 12 is a schematic diagram of another tuple descriptor provided by the present application, and its storage method in the PostgreSQL database is shown in Figure 13.
  • Figure 13 is a storage schematic diagram of the tuple descriptor shown in Figure 12 in the PostgreSQL database, wherein the data of each field is stored continuously in the memory; for fixed-length fields, the field data is directly stored, as shown in ⁇ in Figure 13; for variable-length fields, in addition to the content of the variable-length field itself, the length value of the field will also be stored in the header of the variable-length field, as shown in ⁇ in Figure 13.
  • FIG14 is a schematic diagram of a storage format of a column storage page data provided by the present application, wherein:
  • the data contents of the fixed-length field and the variable-length field are stored consecutively in the field data area, including: 1A ⁇ , 2A ⁇ , 3A ⁇ , 1B ⁇ , 2B ⁇ , 3B ⁇ , 1C ⁇ , 2C ⁇ , 3C ⁇ , 1D ⁇ , 2D ⁇ , 3D ⁇ , 1E ⁇ , 2E ⁇ , 3E ⁇ , and padding data is used to ensure the alignment of column data;
  • variable-length field index 1B*, 1B ⁇ , 2B*, 2B ⁇ , 3B*, 3B ⁇ , 1D*, 1D ⁇ , 2D*, 2D ⁇ , 3D*, 3D ⁇ ;
  • the offset (as shown in ⁇ in FIG. 14 ) and length (as shown in ⁇ in FIG. 14 ) of each data column in the memory block are stored in the column data index, including: A ⁇ , A ⁇ ; B ⁇ , B ⁇ ; C ⁇ , C ⁇ ; D ⁇ , D ⁇ ; E ⁇ , E ⁇ ;
  • the maximum and minimum values in the data column are recorded during the conversion process and stored in the column data index, including Amax, Amin; Cmax, Cmin; Emax, Emin.
  • the maximum and minimum values are not calculated and padding data is used for alignment and padding.
  • FIG15 is a schematic diagram of a column storage page data without enabling sorting provided by the present application
  • FIG16 is a schematic diagram of a column storage page data with enabling sorting provided by the present application.
  • FPGA is good at parallel and pipeline computing. For fixed algorithms, the use of dedicated hardware circuits can greatly improve computing efficiency.
  • FPGA design has the following characteristics:
  • the row-column conversion is performed in units of PostgreSQL pages.
  • the row-column parsing module performs parsing according to the storage format of the PostgreSQL page, and parses the position and length of each column field in the page.
  • the parsing result is encapsulated as a column descriptor structure.
  • the row-column parsing module can read 8 pages at a time and hand them over to 8 internal execution channels for parallel parsing.
  • the user can select a column as the primary key and sort the column descriptors according to the value of the primary key. After enabling the sorting function, the corresponding row data will be converted into rows and columns according to the result after the primary key sorting;
  • Each execution channel parses one page to match the processing speed of the read module and the write-back module.
  • Each execution channel may include a row and column parsing module, a sorting module, a calculation copy offset module, a field copy module, and a filling index module.
  • Ping-pong cache is used between each module to achieve pipeline operation between modules.
  • FIG. 17 is a schematic diagram of the structure of a computing unit in an FPGA provided by the present application.
  • Each computing unit in the FPGA includes seven modules: reading, row and column parsing, sorting, calculating copy offset, field copying, filling index, and writing back.
  • Ping-pong cache is used between each module to realize pipeline operation, wherein the sorting module is optional.
  • the workflow between modules is shown in FIG. 18, which is a schematic diagram of the workflow of a computing unit in an FPGA provided by the present application.
  • the specific work content of each module is as follows:
  • the read module is used to complete the reading of data from the external HBM memory to the internal RAM cache.
  • the data is read using a 512-bit bit width, reading 8 pages at a time, a total of 64KB of data, and passing it to the row and column parsing module through the ping-pong cache.
  • the row and column parsing module is used to obtain page data from the reading module, and obtains 8 pages at a time.
  • Each computing unit instantiates 8 execution channels inside, each channel uses a 64-bit bit width to read page data, and parses the offset and length of each column in the page in parallel according to the configuration parameters.
  • the output result of each channel is a column descriptor, which contains the position of each column data in the page, the field length, and the maximum and minimum values of the fixed-length data.
  • Figure 19 is a schematic diagram of the workflow of an execution channel provided by this application.
  • the sorting module is an optional function.
  • the column index number configured by the parsing parameter is greater than 0, the column descriptor is sorted according to the column corresponding to the index number. After the data in the page is sorted, it can be used to optimize the data reading operation during the OLAP query business.
  • Figure 20 is a schematic diagram of another column storage page with sorting enabled provided by this application, and its enabled sorting is sorting by salary. When performing an OLAP query on it and obtaining employee information with a salary greater than 15,000, the following optimized reading method can be used:
  • the copy offset calculation module completes the offset calculation of each area in each column storage page according to the parsed column descriptor.
  • the workflow is as follows:
  • Step 1 The initial offset value is 0;
  • Step 2 Align the offset value according to the field alignment value
  • Step 3 Accumulate the total length of each data column and update the maximum and minimum values
  • Step 4 Exit if it is the last column, otherwise jump to step 2.
  • Step 1 Starting from the end of the field data area, align the corresponding fields and use it as the offset of the variable-length field index in the page;
  • Step 2 Each variable-length field takes up 4 bytes, with the offset and length each taking up 2 bytes;
  • Step 3 Count the total length of the variable-length field and calculate the end address of the variable-length field index area.
  • Step 1 The end address of the variable-length field index area is aligned to 8 bytes and used as the column index start offset;
  • Step 2 Each column index occupies 32 bytes, the maximum and minimum values each occupy 8 bytes, the column offset and length each occupy 2 bytes, and the rest is padded for alignment.
  • the field copy module copies each column field to the corresponding position in sequence according to the column descriptor and the copy offset in (4), thereby completing the copy of the field data area in the column storage mode; and during the copying process, the offset field in the column descriptor is updated to the position in the column storage page.
  • the index information filling module fills the variable-length field index and column data index according to the copy offset and the updated column descriptor in (4).
  • the write-back module writes the converted column storage page data back to the HBM memory, where the data write-back uses a 512-bit bit width.
  • This example takes the parsing process of an execution channel as an example.
  • the implementation is as follows:
  • FIG21 is a schematic diagram of another row-storage page of data provided by the present application.
  • FIG. 22 is a schematic diagram of the generation principle of a column descriptor provided by the present application.
  • the first address offset of each column data in the column storage mode is calculated according to the column descriptor, and the main steps are: 1 counting the length of each data column; 2 aligning and storing each data column according to the alignment value, and updating the maximum and minimum values at the same time; 3 calculating the variable-length field index position; 4 calculating the starting offset and length of each column index; the calculation process is shown in FIG24, which is a schematic diagram of the calculation principle of copying information in a column storage page provided by the present application;
  • each field is copied from the row storage page to the column storage page.
  • the column descriptor is updated to the offset value of each field in the column storage page, as shown in FIG. 25 , which is a schematic diagram of the updating principle of a column descriptor provided by the present application;
  • FIG. 26 is a schematic diagram of the generation principle of a column storage page data provided by the present application.
  • the optional key value sorting function allows the converted data to be sorted by key value, which can reduce the reading of redundant data when executing OLAP business.
  • An embodiment of the present application provides a storage format conversion device.
  • FIG. 27 is a schematic diagram of the structure of a storage format conversion device provided by the present application.
  • the storage format conversion device can be applied to a coprocessor, including:
  • Acquisition module 1 used to acquire row storage page data and configuration information sent by the main processor, the configuration information including format information of each column field in the row storage page;
  • Parsing module 2 used to parse the row storage page data according to the configuration information to obtain a column descriptor, where the column descriptor includes the first offset address and field length of each column field in the row storage page;
  • a calculation module 3 is used to calculate and obtain filling information about the column storage page according to the column descriptor, where the filling information includes the first offset address and column length of each data column in the column storage page, wherein each column field with the same field attribute constitutes a data column;
  • Filling module 4 used to fill the column storage page according to the filling information to generate column storage page data
  • the feedback module 5 is used to feed back the column storage page data to the main processor.
  • the storage format conversion device provided in the embodiment of the present application, combined with the coprocessor to realize the conversion of the row-column storage format, can effectively avoid the large consumption of the computing power resources of the main processor and ensure high work efficiency.
  • the row storage page data is parsed in combination with the configuration information to obtain the offset address and field length of each column field in the row storage page data, and then the first offset address and field length of each data column in the column storage page are calculated, and the column storage page data corresponding to the row storage page data is generated, thereby realizing the conversion of the row-column storage format.
  • this implementation method takes into account the position information and field length of each column field, realizes the row-column storage format conversion that can support variable-length field data, and effectively improves the applicability of the row-column conversion method.
  • the above-mentioned parsing module 2 can be specifically used to determine the data storage format of the row storage page data; parse the row storage page data according to the data storage format and configuration information to obtain the column descriptor; wherein the configuration information is generated by the main processor based on the tuple descriptor corresponding to the row storage page data.
  • the above-mentioned filling information may also include the first offset address and field length of each variable-length column field, and the maximum and minimum values of the fixed-length data column.
  • the above-mentioned filling module 4 can be specifically used to fill each column field into the field area of the column storage page according to the first offset address and column length of each data column in the column storage page; fill the first offset address and field length of each variable-length column field into the variable-length field index area of the column storage page; fill the first offset address and column length of each data column, and the maximum and minimum values of the fixed-length data column into the column data index area of the column storage page.
  • the storage format conversion device may also include a sorting module, which is used to obtain sorting enable information after parsing the row storage page data and obtaining the column descriptor; determine the sorting data column according to the sorting enable information; sort the column descriptors according to the sorting method of the sorting data column to obtain the sorted column descriptors.
  • a sorting module which is used to obtain sorting enable information after parsing the row storage page data and obtaining the column descriptor; determine the sorting data column according to the sorting enable information; sort the column descriptors according to the sorting method of the sorting data column to obtain the sorted column descriptors.
  • the above-mentioned coprocessor may include a first preset number of computing units and a first preset number of memories, each computing unit corresponds to a memory, and the above-mentioned acquisition module 1 can be specifically used to read and obtain row storage page data from the memory corresponding to the current computing unit, and the row storage page data is sent by the main processor to the memory.
  • each computing unit may include a second preset number of execution channels, and the acquisition module 1 may be specifically configured to read and obtain a second preset number of row storage page data from a memory corresponding to the current computing unit;
  • the storage format conversion device may also include a distribution module for distributing a second preset number of row storage page data to a second preset number of execution channels after reading the row storage page data from the memory corresponding to the current computing unit, so as to utilize each execution channel to perform the step of parsing the row storage page data and obtaining a column descriptor.
  • a distribution module for distributing a second preset number of row storage page data to a second preset number of execution channels after reading the row storage page data from the memory corresponding to the current computing unit, so as to utilize each execution channel to perform the step of parsing the row storage page data and obtaining a column descriptor.
  • the feedback module 5 can be specifically used to write back each column storage page to the memory corresponding to the current computing unit, so that the main processor reads each column storage page data from each memory.
  • the storage format conversion device may also include a compression module, which is used to compress each column field in the column storage page data according to a preset compression algorithm corresponding to each data column before feeding the column storage page data back to the main processor to obtain the compressed column storage page data.
  • a compression module which is used to compress each column field in the column storage page data according to a preset compression algorithm corresponding to each data column before feeding the column storage page data back to the main processor to obtain the compressed column storage page data.
  • An embodiment of the present application provides another storage format conversion device.
  • FIG. 28 is a schematic diagram of the structure of another storage format conversion device provided by the present application.
  • the storage format conversion device can be applied to a main processor, including:
  • a generating module 7 used to generate configuration information about the row storage page data according to the tuple descriptor, the configuration information including format information of each column field in the row storage page data;
  • a sending module 8 used for sending the row storage page data and the configuration information to the coprocessor, so that the coprocessor converts the row storage page data into column storage page data according to the configuration information;
  • the second acquisition module 9 is used to acquire the column storage page data fed back by the coprocessor.
  • the storage format conversion device provided in the embodiment of the present application, combined with the coprocessor to realize the conversion of row and column storage formats, can effectively avoid the large consumption of computing power resources of the main processor and ensure high work efficiency.
  • An embodiment of the present application provides an electronic device.
  • FIG. 29 is a schematic diagram of the structure of an electronic device provided by the present application.
  • the electronic device may include:
  • a processor when used to execute a computer program, can implement the steps of any one of the above storage format conversion methods.
  • FIG29 it is a schematic diagram of the composition structure of an electronic device, which may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13.
  • the processor 10, the memory 11 and the communication interface 12 all communicate with each other through the communication bus 13.
  • the processor 10 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic devices, etc.
  • CPU central processing unit
  • application specific integrated circuit a digital signal processor
  • field programmable gate array a field programmable gate array or other programmable logic devices, etc.
  • the processor 10 may call a program stored in the memory 11. Specifically, the processor 10 may execute operations in an embodiment of the storage format conversion method.
  • the memory 11 is used to store one or more programs, which may include program codes, and the program codes include computer operation instructions.
  • the memory 11 at least stores programs for implementing the following functions:
  • the padding information including the first offset address and the column length of each data column in the column storage page, wherein each column field having the same field attribute constitutes a data column;
  • Configuration information about the row storage page data according to the tuple descriptor, the configuration information including format information of each column field in the row storage page data;
  • the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.
  • the memory 11 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.
  • the communication interface 12 may be an interface of a communication module, and is used to connect to other devices or systems.
  • FIG. 29 does not constitute a limitation on the electronic device in the embodiment of the present application.
  • the electronic device may include more or fewer components than those shown in FIG. 29, or combine certain components.
  • An embodiment of the present application provides a non-volatile readable storage medium.
  • the non-volatile readable storage medium provided in the embodiment of the present application stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned storage format conversion methods can be implemented.
  • the non-volatile readable storage medium may include: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
  • the steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two.
  • the software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种存储格式转换方法、系统、装置、电子设备及存储介质,应用于存储技术领域,方法应用于协处理器,包括获取主处理器发送的行存储页面数据与配置信息,配置信息包括行存储页面内各列字段的格式信息;根据配置信息对行存储页面数据进行解析获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,具有相同字段属性的各列字段组成一个数据列;根据填充信息对列存储页面进行填充,生成列存储页面数据;将列存储页面数据反馈至主处理器。可支持变长字段数据的行列存储格式转换,提高行列转换方法的适用性。

Description

存储格式转换方法、系统、装置、电子设备及存储介质
相关申请的交叉引用
本申请要求于2022年11月09日提交中国专利局,申请号为202211395237.5,申请名称为“存储格式转换方法、系统、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及存储技术领域,特别涉及一种存储格式转换方法、系统、装置、电子设备及存储介质。
背景技术
传统的关系型数据库大都采用行存储模式进行数据的存储,采用行存储模式,不同类型与长度的字段连续存储在同一行中,更适合OLTP(On-Line Transaction Processing,在线事务处理)业务,在队数据库进行增加、删除与修改操作时,能够获得较好的性能。然而,对于OLAP(On-Line Analytical Processing,在线分析处理)业务,在进行数据查询时,行存储模式下需要读取一行内所有数据,再提取有效字段,增加了IO读取的开销与字段解析的开销,在大数据量时会导致较大查询延迟。因此,为了提高数据库的OLAP性能,列存储模式被提出,在列存储模式中数据按列进行存储,在进行OLAP查询业务时,只需读取需要的列即可,减少了IO开销与行列解析开销。然而,列存模式虽然对OLAP业务有着更高的性能,但对于OLTP业务则性能较差。以数据的插入为例:由于数据的输入是按行输入的,列存储模式下,需要先对数据进行行列拆解后,再将数据追加到对应的列中,而行列拆解的过程会导致数据写入性能的下降。
为了兼顾数据库OLTP与OLAP性能,一些研究中采用行列混合的方式,在数据库进行OLTP业务时,数据按照行储存模式存储至磁盘;当数据库进行OLAP业务时,将行存储数据转换为列存储方式,存放在内存或磁盘中。为达到上该目的,需要先实现行列转换功能。相关技术中,行列转换操作大多依赖于CPU进行,在运行过程中需要消耗大量的CPU算力资源。另外,一些使用协处理器进行行列转换的方式,虽然可以大幅降低CPU的算力消耗,但方案中必须预知行的长度,且只能支持定长数据类型,无法支持变长数据类型。然而,大部分关系型数据库中,都存在变长数据,并且允许每一行的长度都不相同,无法在计算前预知行的长度。因此,该实现方法虽然可以获得较高的数据吞吐率,但无法处理变长数据,限制了其适用场景。
因此,如何实现可支持变长字段数据的行列存储格式转换,提高行列转换方法的适用性是本领域技术人员亟待解决的问题。
发明内容
本申请的目的是提供一种存储格式转换方法,该存储格式转换方法可以实现可支持变长字段数据的行列存储格式转换,提高行列转换方法的适用性;本申请的另一目的是提供另一种存储格式转换方法、存储格式转换系统、存储格式转换装置、电子设备及非易失性可读存储介质,均具有上述有益效果。
第一方面,本申请提供了一种存储格式转换方法,应用于协处理器,包括:
获取主处理器发送的行存储页面数据与配置信息,配置信息包括行存储页面内各列字段的格式信息;
根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;
根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;
根据填充信息对列存储页面进行填充,生成列存储页面数据;
将列存储页面数据反馈至主处理器。
在本发明一些实施例中,根据配置信息对行存储页面数据进行解析,获得列描述符,包括:
确定行存储页面数据的数据存储格式;
根据数据存储格式和配置信息对行存储页面数据进行解析,获得列描述符;
其中,配置信息由主处理器基于行存储页面数据对应的元组描述符生成。
在本发明一些实施例中,元组描述符为关系型数据库在创建行存储页面类型的数据表同时创建,元组描述符用于描述数据表中各列字段格式信息。
在本发明一些实施例中,行存储页面数据的数据存储格式包括以下任意一项或多项:
数据信息本身的存储位置、数据信息的元数据的存储位置、数据信息的描述信息的存储位置。
在本发明一些实施例中,填充信息还包括各变长列字段的首偏移地址和字段长度,定长数据列的最大值和最小值,根据填充信息对列存储页面进行填充,生成列存储页面数据,包括:
根据各数据列在列存储页面中的首偏移地址和列长度,将各列字段填充至列存储页面的字段区域;
将各变长列字段的首偏移地址和字段长度填充至列存储页面的变长字段索引区域;
将各数据列的首偏移地址和列长度、定长数据列的最大值和最小值填充至列存储页面的列数据索引区域。
在本发明一些实施例中,根据填充信息对列存储页面进行填充,生成列存储页面数据,包括:
确定列存储页面的数据存储格式;
按照数据存储格式将填充信息填充至列存储页面,生成列存储页面。
在本发明一些实施例中,还包括:
获取预设配置信息中列字段的字段对齐方式;
在填充过程中,按照数据存储格式进行填充对齐。
在本发明一些实施例中,对行存储页面数据进行解析,获得列描述符之后,还包括:
获取排序使能信息;
根据排序使能信息确定排序数据列;
根据排序数据列的排序方式对列描述符进行排序,获得排序后的列描述符。
在本发明一些实施例中,协处理器包括第一预设数量个计算单元和第一预设数量个存储器,每一计算单元对应于一个存储器,获取主处理器发送的行存储页面数据,包括:
从当前计算单元对应的存储器中读取获得行存储页面数据,行存储页面数据由主处理器发送至存储器。
在本发明一些实施例中,每一计算单元包括第二预设数量个执行通道,从当前计算单元对应的存储器中读取获得行存储页面数据,包括:
从当前计算单元对应的存储器中读取获得第二预设数量个行存储页面数据;
从当前计算单元对应的存储器中读取获得行存储页面数据之后,还包括:
将第二预设数量个行存储页面数据分发至第二预设数量个执行通道,以利用各执行通道执行对行存储页面数据进行解析,获得列描述符的步骤。
在本发明一些实施例中,将列存储页面数据反馈至主处理器,包括:
将各列存储页面回写至当前计算单元对应的存储器,以使主处理器从各存储器中读取获得各列存储页面数据。
在本发明一些实施例中,将列存储页面数据反馈至主处理器之前,还包括:
根据各数据列对应的预设压缩算法对列存储页面数据中的各列字段进行压缩处理,获得压缩处理后的列存储页面数据。
在本发明一些实施例中,根据各数据列对应的预设压缩算法对列存储页面数据中的各列字段进行压缩处理,包括:
确定各数据列中列字段的数据类型,并根据数据类型确定对应的预设压缩算法,并按照预设压缩算法对列存储页面数据中的各列字段进行压缩处理。
第二方面,本申请提供了另一种存储格式转换方法,应用于主处理器,包括:
获取行存储页面数据以及行存储页面数据对应的元组描述符;
根据元组描述符生成关于行存储页面数据的配置信息,配置信息包括行存储页面数据中各列字段的格式信息;
将行存储页面数据和配置信息发送至协处理器,以使协处理器根据配置信息将行存储页面数据转换为列存储页面数据;
获取协处理器反馈的列存储页面数据;
其中,协处理器根据配置信息将行存储页面数据转换为列存储页面数据的过程包括:
根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;
根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;
根据填充信息对列存储页面进行填充,生成列存储页面数据。
第三方面,本申请还公开了一种存储格式转换系统,包括主处理器和协处理器;
主处理器,用于发送行存储页面数据和配置信息至协处理器,并获取协处理器反馈的列存储页面数据;
协处理器,用于根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;根据填充信息对列存储页面进行填充,生成列存储页面数据。
在本发明一些实施例中,主处理器为CPU,协处理器为FPGA。
第四方面,本申请还公开了一种存储格式转换装置,应用于协处理器,包括:
获取模块,用于获取主处理器发送的行存储页面数据与配置信息,配置信息包括行存储页面内各列字段的格式信息;
解析模块,用于根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;
计算模块,用于根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;
填充模块,用于根据填充信息对列存储页面进行填充,生成列存储页面数据;
反馈模块,用于将列存储页面数据反馈至主处理器。
第五方面,本申请还公开了另一种存储格式转换装置,应用于主处理器,包括:
第一获取模块,用于获取行存储页面数据以及行存储页面数据对应的元组描述符;
生成模块,用于根据元组描述符生成关于行存储页面数据的配置信息,配置信息包括行存储页面数据中各列字段的格式信息;
发送模块,用于将行存储页面数据和配置信息发送至协处理器,以使协处理器根据配置信息将行存储页面数据转换为列存储页面数据;
第二获取模块,用于获取协处理器反馈的列存储页面数据;
其中,协处理器根据配置信息将行存储页面数据转换为列存储页面数据的过程包括:
根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;
根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;
根据填充信息对列存储页面进行填充,生成列存储页面数。
第六方面,本申请还公开了一种电子设备,包括:
存储器,用于存储计算机程序;
处理器,用于执行计算机程序时实现如上的任一种存储格式转换方法的步骤。
第七方面,本申请还公开了一种非易失性可读存储介质,非易失性可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现如上的任一种存储格式转换方法的步骤。
应用本申请所提供的技术方案,结合协处理器实现行列存储格式的转换,可以有效避免主处理器算力资源的大量消耗,保证较高的工作效率,同时,结合配置信息对行存储页面数据进行解析,得到行存储页面数据中各列字段的偏移地址和字段长度,进而计算获得各数据列在列存储页面中的首偏移地址和字段长度,并生成对应于该行存储页面数据的列存储页面数据,实现了行列存储格式的转换,可见,该种实现方式将各个列字段的位置信息和字段长度考虑在内,实现了可支持变长字段数据的行列存储格式转换,有效地提高了行列转换方法的适用性。
附图说明
为了更清楚地说明现有技术和本申请实施例中的技术方案,下面将对现有技术和本申请实施例描述中需要使用的附图作简要的介绍。当然,下面有关本申请实施例的附图描述的仅仅是本申请中的一部分实施例,对于本领域普通技术人员来说,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图,所获得的其他附图也属于本申请的保护范围。
图1为本申请所提供的一种存储格式转换系统的结构示意图;
图2为本申请所提供的一种存储格式转换方法的流程示意图;
图3为本申请所提供的另一种存储格式转换方法的流程示意图;
图4为本申请所提供的另一种存储格式转换系统的结构示意图;
图5为本申请所提供的一种行存储页面数据的存储格式示意图;
图6为本申请所提供的一种配置参数码流的格式示意图;
图7为本申请所提供的一种行存储页面数据对应的数据表的示意图;
图8为本申请所提供的一种元组描述符的示意图;
图9为本申请所提供的一种配置参数码流的示意图;
图10为本申请所提供的一种行存储页面数据的示意图;
图11为本申请所提供的一种列字段解析原理示意图;
图12为本申请所提供的另一种元组描述符的示意图;
图13为图12所示元组描述符在PostgreSQL数据库中的存储示意图;
图14为本申请所提供的一种列存储页面数据的存储格式示意图;
图15为本申请所提供的一种不使能排序的列存储页面数据的示意图;
图16为本申请所提供的一种使能排序的列存储页面数据的示意图;
图17为本申请所提供的一种FPGA中计算单元的结构示意图;
图18为本申请所提供的一种FPGA中计算单元的工作流程示意图;
图19为本申请所提供的一种执行通道的工作流程示意图;
图20为本申请所提供的另一种使能排序的列存储页面的示意图;
图21为本申请所提供的另一种行存储页面数据的示意图;
图22为本申请所提供的一种列描述符的生成原理示意图;
图23为本申请所提供的一种列描述符的排序原理示意图;
图24为本申请所提供的一种列存储页面中拷贝信息的计算原理示意图;
图25为本申请所提供的一种列描述符的更新原理示意图;
图26为本申请所提供的一种列存储页面数据的生成原理示意图;
图27为本申请所提供的一种存储格式转换装置的流程示意图;
图28为本申请所提供的另一种存储格式转换装置的流程示意图;
图29为本申请所提供的一种电子设备的结构示意图。
具体实施方式
本申请的核心是提供一种存储格式转换方法,该存储格式转换方法可以实现可支持变长字段数据的行列存储格式转换,提高行列转换方法的适用性;本申请的另一核心是提供另一种存储格式转换方法、存储格式转换系统、存储格式转换装置、电子设备及非易失性可读存储介质,均具有上述有益效果。
为了对本申请实施例中的技术方案进行更加清楚、完整地描述,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行介绍。显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
需要说明的是,本申请所提供的存储格式转换方法应用于存储格式转换系统,请参考图1,图1为本申请所提供的一种存储格式转换系统的结构示意图,该存储格式转换系统包括主处理器100和协处理器200,二者可以进行协同处理实现存储格式转换。在一种可能的实现方式中,主处理器可以为CPU,协处理器可以为FPGA(Field Programmable Gate Array,一种高性能可编程逻辑器件)。
本申请实施例提供了一种存储格式转换方法。
请参考图2,图2为本申请所提供的一种存储格式转换方法的流程示意图,该存储格式转换方法应用于协处理器,可以包括如下S101至S105。
S101:获取主处理器发送的行存储页面数据与配置信息,配置信息包括行存储页面内各列字段的格式信息;
本步骤旨在实现行存储页面数据和配置信息的获取。其中,行存储页面数据是指以行存储格式进行数据存储的页面数据,通过对该行存储页面数据进行行列转换,即可得到相应的列存储页面数据,也就是以列存储格式进行数据存储的页面数据。配置信息则包括有行存储页面内各列字段的格式信息,列字段是指行存储页面中所存储的数据信息,可以为定长字段也可以为变长字段,如字符串、数字、日期等;格式信息包括但不限于各列字段的字段长度、字段对齐方式、字段类型等。
需要说明的是,本申请实施例所提供的存储格式转换方法应用于协处理器,行存储页面数据和配置信息均是由主处理器发送至协处理器中的,也就是说,当需要进行行列存储格式转换时,主处理器将需要进行行列存储格式转换的行存储页面数据及其配置信息发送至协处理器执行行列存储格式转换操作,即可得到相应的列存储页面数据,从而实现行列存储格式转换。
S102:根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;
本步骤旨在实现行存储页面数据的解析操作,得到对应于该行存储页面数据的列描述符。其中,列描述符包括有各列字段在行存储页面中的首偏移地址和字段长度,首偏移地址即对应列字段在行存储页面中的第一个偏移位置;字段长度则为对应列字段的字段长度,定长字段的字段长度为定值,变长字段的字段长度为不定值。显然,列描述符将各个列字段的首偏移地址和字段长度考虑在内,有助于实现可支持变长字段数据的行列存储格式转换,可以有效提高行列转换方法的适用性。
当然,列描述符中所包含的信息并不仅限于此,还可以包括其他类型的数据信息,具体可以由技术人员根据实际需求(如列存储页面的存储格式需求)进行设定,本申请对此不做限定。
在一种可能的实现方式中,上述根据配置信息对行存储页面数据进行解析,获得列描述符,可以包括:确定行存储页面数据的数据存储格式;根据数据存储格式和配置信息对行存储页面数据进行解析,获得列描述符;其中,配置信息由主处理器基于行存储页面数据对应的元组描述符生成。
本申请实施例提供了一种对行存储页面数据进行解析获得列描述符的实现方法。具体而言,行存储页面本身预设有不同的存储格式,如预先设定有数据信息本身的存储位置、数据信息的元数据的存储位置、数据信息的描述信息的存储位置等,因此,可以结合行存储页面的数据存储格式对行存储页面数据进行解析。
可以理解的是,对于一般的关系型存储数据库(如PostgreSQL,一种开源的关系型数据库)而言,其在创建行存储页面类型的数据表时,会同时创建元组描述符,用于描述数据表中各个列字段的字段长度、字段对齐方式、字段类型等格式信息,因此,可以基于元组描述符生成上述配置信息,由此,配置信息中即可同样包含各列字段的上述各项格式信息。
S103:根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;
本步骤旨在实现列存储页面中填充信息的计算,该填充信息用于指示将行存储页面中的各列字段存储至列存储页面的实现方式,主要包括各数据列在列存储页面中的首偏移地址和列长度,以便于根据这些信息可以将行存储页面中的各列字段存储至列存储页面,从而实现行列存储方式的转换。
并且,类似于上述列描述符,填充信息中所包含的信息并不仅限于此,还可以包括其他类型的数据信息,具体可以由技术人员根据实际需求(如列存储页面的存储格式需求)进行设定,本申请对此不做限定。
可以理解的是,列描述符对应于行存储页面,主要包括各列字段在行存储页面中的首偏移地址和字段长度,填充信息则对应于列存储页面,主要包括各数据列在列存储页面中的首偏移地址和列长度,其中,数据列由具有相同字段属性的各列字段组成(换而言之,行存储页面数据中同一键值对应的所有列字段称为一个数据列),例如,所有字段属性为“薪资”的列字段组成一个数据列。需要说明的是,填充信息中各数据列在列存储页面中的首偏移地址和列长度,均可以由列描述符中各列字段的首偏移地址和字段长度计算获得。
S104:根据填充信息对列存储页面进行填充,生成列存储页面数据;
本步骤旨在实现列存储页面的填充处理,获得对应于行存储页面的列存储页面,从而实现行列存储格式的转换。如上,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,在此基础上,可以直接根据该填充信息将行存储页面数据中的各个列字段拷贝至列存储页面,从而生成列存储页面数据。
在一种可能的实现方式中,上述填充信息还可以包括各变长列字段的首偏移地址和字段长度,定长数据列的最大值和最小值,上述根据填充信息对列存储页面进行填充,生成列存储页面数据,可以包括如下步骤:
根据各数据列在列存储页面中的首偏移地址和列长度,将各列字段填充至列存储页面的字段区域;
将各变长列字段的首偏移地址和字段长度填充至列存储页面的变长字段索引区域;
将各数据列的首偏移地址和列长度、定长数据列的最大值和最小值填充至列存储页面的列数据索引区域。
本申请实施例提供了一种基于填充信息对列存储页面进行填充的实现方式。首先,除上述各数据列在列存储页面中的首偏移地址和列长度之外,填充信息还可以包括各变长列字段的首偏移地址和字段长度、定长数据列的最大值和最小值,其中,行存储页面数据中同一键值对应的所有列字段称为一个数据列,每个数据列对应于一个键值,如若一个键值对应的列字段为变长字段,那么,该键值对应的数据列为变长数据列,如若一个键值对应的列字段为定长字段,那么,该键值对应的数据列为定长数据列。进一步,列存储页面包括字段区域,变长字段索引区域以及列数据索引区域,其中,字段区域用于存储行存储页面数据中的各个列字段,根据各数据列在列存储页面中的首偏移地址和列长度填充至字段区域即可;变长字段索引区域用于存储各变长列字段的首偏移地址和字段长度;列数据索引区域用于存储各数据列的首偏移地址和列长度、定长数据列的最大值和最小值。其中,在进行数据填充时,参照列存储页面的数据存储格式实现即可,此外,还可以同时结合预设配置信息中列字段的字段对齐方式,实现填充对齐。
S105:将列存储页面数据反馈至主处理器。
本步骤旨在实现列存储页面的反馈,在将行存储页面转换为列存储页面之后,即可将其反馈给主处理器,由主处理器继续进行相应的业务处理。
可见,本申请实施例所提供的存储格式转换方法,结合协处理器实现行列存储格式的转换,可以有效避免主处理器算力资源的大量消耗,保证较高的工作效率,同时,结合配置信息对行存储页面数据进行解析,得到行存储页面数据中各列字段的偏移地址和字段长度,进而计算获得各数据列在列存储页面中的首偏移地址和字段长度,并生成对应于该行存储页面数据的列存储页面数据,实现了行列存储格式的转换,可见,该种实现方式将各个列字段的位置信息和字段长度考虑在内,实现了可支持变长字段数据的行列存储格式转换,有效地提高了行列转换方法的适用性。
在本申请的一个实施例中,上述对行存储页面数据进行解析,获得列描述符之后,还可以包括如下步骤:
获取排序使能信息;
根据排序使能信息确定排序数据列;
根据排序数据列的排序方式对列描述符进行排序,获得排序后的列描述符。
本申请实施例所提供的存储格式转换方法,还可以进一步实现页面内列数据的排序功能。具体而言,在对行存储页面数据进行解析,获得列描述符之后,基于该列描述符计算填充信息之前,可以先对该列描述符进行排序处理,通过对列描述符进行排序,实现列存储页面内列数据的排序。
在实现过程中,首先获得排序使能信息,进而根据该排序使能信息确定排序数据列,其中,排序使能信息可以为用户指定的键值信息,那么,该键值对应的列数据即为排序数据列,也就是对该键值对应的列数据进行排序,例如,当用户指定的键值信息为“薪资”时,说明是对“薪资”这一列数据中的各个薪资值进行由低到高的排序或者由高到低的排序。进一步,根据排序数据列的排序方式对列描述符进行排序,即可获得排序后的列描述符,可以理解的是,列描述符用于实现列存储页面中填充信息的计算,填充信息则用于实现列存储页面的数据填充,因此,利用排序后的列描述符计算获得的列存储页面中的填充信息,也必然为排序后的填充信息,基于该排序后的填充信息所获得的列存储页面数据,也必然为排序后的列存储页面数据。
可以理解的是,排序功能的实现可以有效减少数据读取量,提高数据读取效率。具体而言,当对某一键值对应的列数据进行排序之后,如若想要查询该键值在指定范围内的目标数据,则可以直接确定满足该指定范围的目标数据所在的列数,并直接从该列开始进行数据读取,而无需从第一列开始进行数据读取,也就是直接跳过了不满足上述指定范围的列,因此,有效地减少了数据读取量,提高了数据读取效率。
在本申请的一个实施例中,上述协处理器可以包括第一预设数量个计算单元和第一预设数量个存储器,每一计算单元对应于一个存储器,上述获取主处理器发送的行存储页面数据,可以包括:从当前计算单元对应的存储器中读取获得行存储页面数据,行存储页面数据由主处理器发送至存储器。
本申请实施例提供了一种获取行存储页面数据的实现方式。具体而言,协处理器可以包括第一预设数量个计算单元和第一预设数量个存储器,即计算单元和存储器的数量相等,且一个计算单元对应于一个存储器,其中,存储器用于存储主处理器发送的行存储页面数据,计算单元则用于从相应的存储器中读取行存储页面数据并对其进行行列转换。
需要说明的是,第一预设数量的具体取值并不影响本技术方案的实施,根据协处理器实际特性进行设定即可,本申请对此不做限定,例如,可以设置第一预设数量取值为16。可以理解的是,通过在协处理器中设置多个计算单元实现多个行存储页面数据的并行处理,可以大大提升存储格式转换效率。
在本申请的一个实施例中,每一计算单元包括第二预设数量个执行通道,上述从当前计算单元对应的存储器中读取获得行存储页面数据,可以包括:从当前计算单元对应的存储器中读取获得第二预设数量个行存储页面数据;
上述从当前计算单元对应的存储器中读取获得行存储页面数据之后,还可以包括:将第二预设数量个行存储页面数据分发至第二预设数量个执行通道,以利用各执行通道执行对行存储页面数据进行解析,获得列描述符的步骤。
如上,协处理器中设置有第一预设数量个计算单元,用于实现存储格式转换,进一步,每一个计算单元可以设置有第二数量个执行通道,每一个计算单元均可以通过自身的各个执行通道实现存储格式转换。因此,当前计算单元在从其对应的存储器中读取行存储页面数据时,可以直接读取第二预设数量个行存储页面数据,由此,即可将各个行存储页面数据依次分发至各个执行通道,并且,每一个执行通道处理一个行存储页面数据。
同样的,类似于上述第一预设数量,第二预设数量的具体取值并不影响本技术方案的实施,根据协处理器实际特性进行设定即可,本申请对此不做限定,例如,可以设置第二预设数量取值为8。在此基础上,一个协处理器设置有第一预设数量个计算单元,每一个计算单元设置有第二预设数量个执行通道,每一个执行通道处理一个行存储页面数据,由此,一个协处理器可以同时处理第一预设数量*第二预设数量个行存储页面数据,进而实现了多个行存储页面数据的并行处理,进一步提升了存储格式转换效率。
在本申请的一个实施例中,上述将列存储页面数据反馈至主处理器,可以包括:将各列存储页面回写至当前计算单元对应的存储器,以使主处理器从各存储器中读取获得各列存储页面数据。
本申请实施例提供了一种反馈列存储页面数据的实现方法。如上,协处理器中设置有第一预设数量个计算单元,且每一个计算单元对应一个存储器,在获取行存储页面数据时,主处理器将需要进行行列转换的行存储页面数据发送至存储器进行存储,然后由计算单元从自身对应的存储器中读取行存储页面数据进行行列转换,在此基础上,计算单元在执行完毕行列转换操作获得列存储页面数据之后,可以将各个列页面存储数据回写至自身对应的存储器中进行存储,由此,主处理器即可从各个存储器中读取获得各个列存储页面数据,从而实现列存储页面数据的反馈。
在本申请的一个实施例中,上述将列存储页面数据反馈至主处理器之前,还可以包括:根据各数据列对应的预设压缩算法对列存储页面数据中的各列字段进行压缩处理,获得压缩处理后的列存储页面数据。
本申请实施例所提供的存储格式转换方法,还可以进一步实现列存储页面内列字段的压缩处理功能,以减节省存储空间的占用。具体而言,在完成行列存储格式转换获得列存储页面数据之后,即可对列存储页面数据中的各个列字段进行压缩处理,获得压缩处理后的列存储页面数据。
其中,针对不同类型的列字段,还可以采用不同的压缩方式,因此,在进行列字段压缩处理时,可以采用各个数据列对应的预设压缩算法实现,例如,对于字符串类型的列字段,可以采用霍夫曼编码或LZ77编码的压缩方式;对于浮点数类型的列字段,可以采用游程编码或专用的浮点数压缩算法的压缩方式,对于整形及日期类型的列字段,则可以采用差值编码的压缩方式。可以理解的是,针对不同类型的列字段采用不同的压缩方式进行压缩处理,可以获得更高的压缩比,从而大大降低存储空间的占用。
本申请实施例提供了另一种存储格式转换方法。
请参考图3,图3为本申请所提供的另一种存储格式转换方法的流程示意图,该存储格式转换方法应用于主处理器,可以包括如下S201至S204。
S201:获取行存储页面数据以及行存储页面数据对应的元组描述符;
S202:根据元组描述符生成关于行存储页面数据的配置信息,配置信息包括行存储页面数据中各列字段的格式信息;
S203:将行存储页面数据和配置信息发送至协处理器,以使协处理器根据配置信息将行存储页面数据转换为列存储页面数据;
S204:获取协处理器反馈的列存储页面数据。
其中,协处理器根据配置信息将行存储页面数据转换为列存储页面数据的过程包括:根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;根据填充信息对列存储页面进行填充,生成列存储页面数据。
本申请实施例所提供的存储格式转换方法应用于主处理器,由主处理器与协处理器协同现存储格式转换,其具体实现流程参照上述各实施例即可,本申请实施例在此不再赘述。
需要说明的是,本申请实施例所提供的存储格式转换方法,结合协处理器实现行列存储格式的转换,可以有效避免主处理器算力资源的大量消耗,保证较高的工作效率。
本申请实施例提供了一种存储格式转换系统。
如图1所示,该存储格式转换系统可以包括主处理器100和协处理器200,其中:
主处理器100,用于发送行存储页面数据和配置信息至协处理器200,并获取协处理器200反馈的列存储页面数据;
协处理器200,用于根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;根据填充信息对列存储页面进行填充,生成列存储页面数据。
可见,本申请实施例所提供的存储格式转换系统,结合协处理器实现行列存储格式的转换,可以有效避免主处理器算力资源的大量消耗,保证较高的工作效率,同时,结合配置信息对行存储页面数据进行解析,得到行存储页面数据中各列字段的偏移地址和字段长度,进而计算获得各数据列在列存储页面中的首偏移地址和字段长度,并生成对应于该行存储页面数据的列存储页面数据,实现了行列存储格式的转换,可见,该种实现方式将各个列字段的位置信息和字段长度考虑在内,实现了可支持变长字段数据的行列存储格式转换,有效地提高了行列转换方法的适用性。
在此基础上,请参考图4,图4为本申请所提供的另一种存储格式转换系统的结构示意图,主处理器为CPU,协处理器为FPGA。
如图4所示,系统主机侧由CPU、内存、磁盘构成,FPGA作为加速卡通过PCIe总线与主机相连,FPGA内设有高速HBM内存(High Bandwidth Memory,一种利用存储器堆叠技术的高带宽内存),用于存放待处理数据,其内部例化了多个计算单元进行数据的并行计算。
以PostgreSQL数据库为例,基于上述存储格式转换系统,存储格式转换方法的实现流程可以包括:
1、主机侧CPU从磁盘中读取数据库文件数据到主机内存中;
2、将PostgreSQL中的行存储页面数据发送至FPGA的HBM内存中;
3、对FPGA进行参数配置;
4、FPGA内部例化有多个计算单元,每个计算单元用于完成行存储格式到列存储格式的转换;
5、将转换后的列存储页面数据回写到FPGA的HBM内存中;
6、主机侧CPU从FPGA的HBM内存中将转换后的数据读取到主机内存中;
7、CPU获取转换后的数据为列存储格式。
第一方面,由FPGA转换后的列存储格式如下:
(1)相同列的字段数据连续存放在字段数据区(字段区域);
(2)对于变长字段数据,通过变长字段索引表示变长字段数据在内存块中的偏移和长度(变长字段索引区域);
(3)通过列数据索引标记各个数据列在内存块中的首地址偏移与长度,同时添加每个数据列的最大值与最小值,用于优化数据读取(列数据索引区域)。
第二方面,PostgreSQL数据库以8KB为单位存放数据,每个8KB内存块称为一个页面,即行存储页面数据。请参考图5,图5为本申请所提供的一种行存储页面数据的存储格式示意图,其存储规则如下:
(1)一个页面中存放若干条行数据,页面固定位置标记页面内存放的行数;
(2)每个行数据封装为一个元组,元组内除头部信息外依次存放各个字段的数据(包括变长字段与定长字段);
(3)从页面的固定偏移位置开始,向页面底部方向存放元组的元信息,元信息中包含了元组的偏移和长度;
(4)从页面底部开始,向页面顶部方向依次存放元组。
其中,每一行元组中包含一到多个列字段,列字段有定长与不定长两种情况。在数据表创建时,PostgreSQL会创建相应的元组描述符(对应源码中的tupDesc数据结构),用于描述表中各个列的字段长度、字段对齐方式、字段类型等信息。在元组描述符中:
(1)attlen字段,表示该列的字段长度:
对于定长字段:元组描述符中的attlen字段大于0,表示对应列字段的长度;
对于变长数据:元组描述符中的attlen字段等于-1,表示对应列字段为变长字段,变长字段的长度信息放在列数据的头部,值右移一位减1,为列长度。
(2)attalign字段,表示该列的字段对齐方式:
列字段的对齐方式有1、2、4、8四种可能,列数据的存放地址,需要按照该对齐方式进行对齐。
(3)atttype字段,表示该列的字段类型:
常见类型有:整形、浮点数、字符串、日期等(数值对应源码中src/backend/catalog/pg_type_d.h)。
(4)natts字段,表示元组中一共有多少个列字段。
第三方面,可以支持对PostgreSQL原生格式解析的硬件加速,由硬件完成对原生格式的解析处理逻辑,因此,只需要从磁盘中读取数据库文件,将文件内容分块后传输到FPGA的HBM内存即可。
第四方面,对FPGA的参数配置:
对FPGA进行参数配置,旨在告知FPGA行存储页面内元组中各个列字段的格式。其中,配置参数由PostgreSQL元组描述符转换而来,可以通过提取硬件解析元组所需字段组成连续码流,码流格式如图6所示,图6为本申请所提供的一种配置参数码流的格式示意图,其中,码流头部4个字节表示元组中列字段的个数,后续4个字节存放排序列索引号(不需要排序时索引号等于-1),随后依次存放各个列的字段类型、字段长度、字段对齐方式。
基于以上四个方面,以下提供了一个举例:
例如,创建如图7所示的记录,图7为本申请所提供的一种行存储页面数据对应的数据表的示意图,该数据表共有5行记录。其中,ID和Age列为整形(INT4),Name和Position列为字符串(VARCHAR),Salary列为浮点数(FLOAT8),各个列字段所对应的字段类型(atttype),在源码中src/backend/catalog/pg_type_d.h定义如下:
#define INT4OID 23;
#define VARCHAROID 1043;
#define FLOAT8OID 701。
进一步,PostgreSQL数据库所生成的元组描述符中,natts字段等于5,atttype、attalign、attlen字段如图8所示,图8为本申请所提供的一种元组描述符的示意图,根据该元组描述符所生成的解析参数码流,如图9所示,图9为本申请所提供的一种配置参数码流的示意图,其中,1、3、5列为定长类型,可用于排序,如果无需进行排序,则填充排序索引号为-1。
假设,在PostgreSQL中,页面中的存储数据如图10所示,图10为本申请所提供的一种行存储页面数据的示意图,其解析过程为:
(1)页面第12-13字节,表示页面内存储的行数,按照图5所示解析规则可得出行数为5;
(2)页面在第24字节偏移开始,向页面底部方向,依次存放各个行的元信息;
(3)从页面底部开始向顶部方向,依次存放各个行数据,数据以元组的形式封装。
以第一个元组位置的解析为例:
(1)元信息值为0x709fc8;
(2)元信息中0-14比特,代表对应元组在页面内的偏移,可计算出元组偏移为0x1fc8;
(3)元信息中17-32比特,代表对应元组的长度,可计算出元组的长度原始值为56。
其中,第一个元组,各个列字段的解析过程可以如图11所示,图11为本申请所提供的一种列字段解析原理示意图,其解析过程为:首先,在元组偏移22字节处,标记了列字段在元组中的偏移位置为0x18,计算得出第1列地址偏移为0x1fe0;随后根据attlen、attalign解析出各个字段在元组中的位置,根据atttype解析出各个字段含义。
第五方面,行列转换格式规则,其特点如下:
(1)为了能够支持列字段的高效读取操作,在转换后的列存储格式中添加变长字段索引区域,变长字段索引中包含了每变长列字段在内存块中的偏移位置和字段长度;
(2)在转换后的存储格式中添加列数据索引区域,在列数据索引中,以固定4B长度标识经过行列转换后,各个数据列在内存中的首地址;
(3)在行列转换过程中,记录一列数据中的最大值与最小值(变长数据列除外),将最小值与最大值作为列的极限值存入列数据索引中,有基于此,当数据库进行OLAP查询时,筛选条件发现该列的极限值不满足条件,则直接跳过该内存块的读取,减少数据读取与计算操作;
(4)不同的列字段可能会有对齐方式的要求,在相邻的两列数据间,通过填充数据保障列字段在内存中的数据对齐。
基于此,实现行列格式转换的操作步骤如下:
假设,一个数据表中有A、B、C、D、E五个字段,创建该数据表时,各个元组描述符信息如图12所示,图12为本申请所提供的另一种元组描述符的示意图,其在PostgreSQL数据库中的存储方式,如图13所示,图13为图12所示元组描述符在PostgreSQL数据库中的存储示意图,其中,每个字段的数据在内存中连续存放;对于定长字段,直接存储该字段数据,如图13中★所示;对于变长字段,除了变长字段本身的内容外,还会在变长字段的头部存放该字段的长度值,如图13中☆所示。
在将图13所示元组描述符对应的行存储页面进行行列格式转换后,所获得的列存储页面数据的存储格式如图14所示,图14为本申请所提供的一种列存储页面数据的存储格式示意图,其中:
(1)定长字段与变长字段的数据内容(如图14中★所示)连续存放在字段数据区中,包含:1A★、2A★、3A★,1B★、2B★、3B★,1C★、2C★、3C★,1D★、2D★、3D★,1E★、2E★、3E★,使用填充数据保障列数据的对齐;
(2)变长字段的数据内容在内存中的偏移(如图14中*所示)与变长字段的数据内容的长度(如图14中☆所示),连续存放在变长字段索引中,包含:1B*、1B☆,2B*、2B☆,3B*、3B☆,1D*、1D☆,2D*、2D☆,3D*、3D☆;
(3)转换后各个数据列在内存块中的偏移(如图14中▲所示)与长度(如图14中△所示),存放在列数据索,包含:A▲、A△;B▲、B△;C▲、C△;D▲、D△;E▲、E△;
(4)对应定长数据列,在转换过程中会记录该数据列中的最大值与最小值,存放在列数据索引中,包含Amax、Amin;Cmax、Cmin;Emax、Emin,变长数据列不计算最大值与最小值,使用填充数据进行对齐填充。
基于以上第五方面,以下提供了一个举例:
以图7所示数据表为例,如若不使能排序,转换为列存储模式后,如图15所示,如若按照薪资(Salary)排序,转换为列存储模式后,如图16所示。其中,图15为本申请所提供的一种不使能排序的列存储页面数据的示意图,图16为本申请所提供的一种使能排序的列存储页面数据的示意图。
第六方面,FPGA的内部设计及工作流程:
FPGA擅长并行与流水计算,对于固定的算法,采用专用硬件电路可大幅提升运算效率。FPGA的设计有如下特点:
(1)在FPGA内部例化16个计算单元,每个计算单元分配一块独立的HBM内存,所有计算单元并行解析PostgreSQL页面数据,完成行存储到列存储的转换;
(2)以PostgreSQL页面为单位进行行列转换,行列解析模块根据PostgreSQL页面的存储格式进行解析,解析出每一列字段在页面内的位置和长度,解析结果封装为列描述符结构,行列解析模块可以一次读取8个页面,交由内部8个执行通道并行解析;
(3)解析得到列描述符后,用户可选择某一列为主键,将列描述符按照主键的值进行排序,使能排序功能后,相应的行数据会按照主键排序后的结果进行行列转换;
(4)在进行行列解析的过程中,统计每一列数据的总长度,每一列数据的最大值与最小值,其中,列长度统计信息用于计算各个数据列在列存储页面中的偏移;列数据的最大值与最小值用于填充列数据索引;
(5)每个计算单元内部,例化8个执行通道,每个通道解析一个页面,以匹配读取模块与回写模块的处理速度,每个执行通道均可以包括行列解析模块、排序模块、计算拷贝偏移模块、字段拷贝模块以及填充索引模块;
(6)每个模块间使用乒乓缓存,实现模块间的流水运行。
基于以上设计特点,请参考图17,图17为本申请所提供的一种FPGA中计算单元的结构示意图,FPGA中的每个计算单元均包含读取、行列解析、排序、计算拷贝偏移、字段拷贝、填充索引、回写七个模块,各个模块间使用乒乓缓存实现流水运行,其中排序模块为可选,模块之间的工作流程如图18所示,图18为本申请所提供的一种FPGA中计算单元的工作流程示意图,各个模块的具体工作内容如下:
(1)读取模块:
读取模块,用于完成数据从外部HBM内存到内部RAM缓存的读取,数据读取使用512bit位宽,一次读取8个页面,共64KB数据,通过乒乓缓存传递到行列解析模块。
(2)行列解析模块:
行列解析模块,用于从读取模块中获取页面数据,一次获取8个页面。每个计算单元内部例化8个执行通道,每个通道使用64bit位宽读取页面数据,并根据配置参数并行解析各个列在页面中的偏移与长度,并且,每个通道的输出结果为列描述符,列描述符包含各列数据在页面中的位置、字段长度,定长数据的最大值、最小值。其中,每个执行通道的工作流程如图19所示,图19为本申请所提供的一种执行通道的工作流程示意图。
(3)排序模块:
排序模块,为可选功能,当解析参数配置列索引号大于0时,将列描述符按照索引号对应的列进行排序,页面中的数据经过排序后,可用于优化OLAP查询业务时的数据读取操作。例如,如图20所示,图20为本申请所提供的另一种使能排序的列存储页面的示意图,其使能排序为按照薪资排序,当对其进行OLAP查询,获取薪资大于15000的员工信息时,可以采用如下优化读取方式:
①读取薪资列,计算后得知从第3列开始满足条件;
②由于列数据是有序排列的,因此后续的列数据,直接从列数据中第3列开始读取,跳过1、2列数据,从而减少数据的读取量。在数据量更大时,优化效果更为明显。
(4)计算拷贝偏移模块:
计算拷贝偏移模块,根据解析出的列描述符,完成各列存储页面中的各个区域的偏移量计算,工作流程如下:
①根据各个列字段的字段长度,统计各个数据列的总长度:
遍历列字段,累加获得列字段总长度。
②根据各个数据列的总长度和列字段对齐方式,分配各个列字段在字段数据区中的偏移,并记录最大值与最小值:
第一步:初始偏移值为0;
第二步:将偏移值按字段对齐值进行对齐;
第三步:累加各个数据列的总长度,更新最大值与最小值;
第四步:最后一个列则退出,否则跳转到第二步。
③计算变长字段索引在页面中的偏移与长度:
第一步:从字段数据区结尾开始,按对应字段对齐后,作为变长字段索引在页面中的偏移;
第二步:每个变长字段占用4个字节,偏移与长度各使用2个字节;
第三步:统计变长字段总长度,计算得到变长字段索引区的结束地址。
④计算列数据索引的偏移与长度:
第一步:变长字段索引区的结束地址,按照8字节对齐后,开始作为列索引起始偏移;
第二步:每个列索引固定占用32字节,最大值、最小值各占用8字节,列偏移与长度各占2字节,其余部分使用填充对齐。
(5)字段拷贝模块:
字段拷贝模块,根据列描述符与(4)中的拷贝偏移,将各个列字段依次拷贝到对应的位置,完成列存储模式下,字段数据区的拷贝;并且,在拷贝的过程中,更新列描述符中的偏移字段为在列存储页面中的位置。
(6)填充索引信息模块:
填充索引信息模块,根据(4)中的拷贝偏移与更新后的列描述符,填充变长字段索引与列数据索引。
(7)回写模块:
回写模块,将转换完成后的列存页面数据回写到HBM内存中,其中,数据回写使用512bit位宽。
基于以上第六方面,以下提供了一个举例,该举例以一个执行通道的解析过程为例,实现方式如下:
(1)假设读取模块获取一个页面数据如图21所示,图21为本申请所提供的另一种行存储页面数据的示意图;
(2)通过行列解析模块解析各个行的列字段,生成列描述符,记录各个列字段的偏移与长度,更新定长字段的最大值和最小值,如图22所示,图22为本申请所提供的一种列描述符的生成原理示意图;
(3)通过排序模块按照某个列字段对列描述符进行排序,由于列描述符中已经包含了各个列字段在页面中的偏移位置,因此可直接通过列描述符读取到数据,以薪资(Salary)排序为例,如图23所示,图23为本申请所提供的一种列描述符的排序原理示意图;
(4)通过偏移位置计算模块,根据列描述符计算在列存储模式下各个列数据的首地址偏移,主要步骤为:①统计各个数据列的长度;②根据对齐值,将各个数据列进行对齐存放,同时更新最大值最小值;③计算变长字段索引位置;④计算各个列索引的起始偏移和长度;其计算过程如图24所示,图24为本申请所提供的一种列存储页面中拷贝信息的计算原理示意图;
(5)通过字段拷贝模块,根据更新后的列描述符,从行存储页面中,将各个字段拷贝到列存储页面中,拷贝完成后,更新列描述符为各个字段在列存储页面中的偏移值,如图25所示,图25为本申请所提供的一种列描述符的更新原理示意图;
(6)通过填充索引信息模块,根据更新后的列描述符完成索引区域的填充,如图26所示,图26为本申请所提供的一种列存储页面数据的生成原理示意图。
显然,本申请实施例所提供的技术方案具有如下优势:
(1)针对PostgreSQL原生存储格式开发,可与PostgreSQL数据库进行无缝对接,无需中间层数据转换;
(2)支持不定长元组及变长字段;
(3)对变长字段的元信息进行重定位,将变长字段的元信息重新计算后进行集中存放,可以有效提高数据读取效率,更利于并行计算;
(4)在运算的过程中添加了统计信息,便于进行OLAP业务时,跳过不满足条件的数据块;
(5)可选的键值排序功能,使转换后的数据按照键值排序,可以在执行OLAP业务时减少冗余数据的读取。
本申请实施例提供了一种存储格式转换装置。
请参考图27,图27为本申请所提供的一种存储格式转换装置的结构示意图,该存储格式转换装置可应用于协处理器,包括:
获取模块1,用于获取主处理器发送的行存储页面数据与配置信息,配置信息包括行存储页面内各列字段的格式信息;
解析模块2,用于根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;
计算模块3,用于根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;
填充模块4,用于根据填充信息对列存储页面进行填充,生成列存储页面数据;
反馈模块5,用于将列存储页面数据反馈至主处理器。
可见,本申请实施例所提供的存储格式转换装置,结合协处理器实现行列存储格式的转换,可以有效避免主处理器算力资源的大量消耗,保证较高的工作效率,同时,结合配置信息对行存储页面数据进行解析,得到行存储页面数据中各列字段的偏移地址和字段长度,进而计算获得各数据列在列存储页面中的首偏移地址和字段长度,并生成对应于该行存储页面数据的列存储页面数据,实现了行列存储格式的转换,可见,该种实现方式将各个列字段的位置信息和字段长度考虑在内,实现了可支持变长字段数据的行列存储格式转换,有效地提高了行列转换方法的适用性。
在本申请的一个实施例中,上述解析模块2可具体用于确定行存储页面数据的数据存储格式;根据数据存储格式和配置信息对行存储页面数据进行解析,获得列描述符;其中,配置信息由主处理器基于行存储页面数据对应的元组描述符生成。
在本申请的一个实施例中,上述填充信息还可以包括各变长列字段的首偏移地址和字段长度,定长数据列的最大值和最小值,上述填充模块4可具体用于根据各数据列在列存储页面中的首偏移地址和列长度,将各列字段填充至列存储页面的字段区域;将各变长列字段的首偏移地址和字段长度填充至列存储页面的变长字段索引区域;将各数据列的首偏移地址和列长度、定长数据列的最大值和最小值填充至列存储页面的列数据索引区域。
在本申请的一个实施例中,该存储格式转换装置还可以包括排序模块,用于在上述对行存储页面数据进行解析,获得列描述符之后,获取排序使能信息;根据排序使能信息确定排序数据列;根据排序数据列的排序方式对列描述符进行排序,获得排序后的列描述符。
在本申请的一个实施例中,上述协处理器可以包括第一预设数量个计算单元和第一预设数量个存储器,每一计算单元对应于一个存储器,上述获取模块1可具体用于从当前计算单元对应的存储器中读取获得行存储页面数据,行存储页面数据由主处理器发送至存储器。
在本申请的一个实施例中,每一计算单元可以包括第二预设数量个执行通道,上述获取模块1可具体用于从当前计算单元对应的存储器中读取获得第二预设数量个行存储页面数据;
该存储格式转换装置还可以包括分发模块,用于在上述从当前计算单元对应的存储器中读取获得行存储页面数据之后,将第二预设数量个行存储页面数据分发至第二预设数量个执行通道,以利用各执行通道执行对行存储页面数据进行解析,获得列描述符的步骤。
在本申请的一个实施例中,上述反馈模块5可具体用于将各列存储页面回写至当前计算单元对应的存储器,以使主处理器从各存储器中读取获得各列存储页面数据。
在本申请的一个实施例中,该存储格式转换装置还可以包括压缩模块,用于在上述将列存储页面数据反馈至主处理器之前,根据各数据列对应的预设压缩算法对列存储页面数据中的各列字段进行压缩处理,获得压缩处理后的列存储页面数据。
对于本申请实施例提供的装置的介绍请参照上述方法实施例,本申请在此不做赘述。
本申请实施例提供了另一种存储格式转换装置。
请参考图28,图28为本申请所提供的另一种存储格式转换装置的结构示意图,该存储格式转换装置可应用于主处理器,包括:
第一获取模块6,用于获取行存储页面数据以及行存储页面数据对应的元组描述符;
生成模块7,用于根据元组描述符生成关于行存储页面数据的配置信息,配置信息包括行存储页面数据中各列字段的格式信息;
发送模块8,用于将行存储页面数据和配置信息发送至协处理器,以使协处理器根据配置信息将行存储页面数据转换为列存储页面数据;
第二获取模块9,用于获取协处理器反馈的列存储页面数据。
可见,本申请实施例所提供的存储格式转换装置,结合协处理器实现行列存储格式的转换,可以有效避免主处理器算力资源的大量消耗,保证较高的工作效率。
对于本申请实施例提供的装置的介绍请参照上述方法实施例,本申请在此不做赘述。
本申请实施例提供了一种电子设备。
请参考图29,图29为本申请所提供的一种电子设备的结构示意图,该电子设备可包括:
存储器,用于存储计算机程序;
处理器,用于执行计算机程序时可实现如上述任意一种存储格式转换方法的步骤。
如图29所示,为电子设备的组成结构示意图,电子设备可以包括:处理器10、存储器11、通信接口12和通信总线13。处理器10、存储器11、通信接口12均通过通信总线13完成相互间的通信。
在本申请实施例中,处理器10可以为中央处理器(Central Processing Unit,CPU)、特定应用集成电路、数字信号处理器、现场可编程门阵列或者其他可编程逻辑器件等。
处理器10可以调用存储器11中存储的程序,具体的,处理器10可以执行存储格式转换方法的实施例中的操作。
存储器11中用于存放一个或者一个以上程序,程序可以包括程序代码,程序代码包括计算机操作指令,在本申请实施例中,存储器11中至少存储有用于实现以下功能的程序:
获取主处理器发送的行存储页面数据与配置信息,配置信息包括行存储页面内各列字段的格式信息;
根据配置信息对行存储页面数据进行解析,获得列描述符,列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;
根据列描述符计算获得关于列存储页面的填充信息,填充信息包括各数据列在列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各列字段组成一个数据列;
根据填充信息对列存储页面进行填充,生成列存储页面数据;
将列存储页面数据反馈至主处理器;
或者,
获取行存储页面数据以及行存储页面数据对应的元组描述符;
根据元组描述符生成关于行存储页面数据的配置信息,配置信息包括行存储页面数据中各列字段的格式信息;
将行存储页面数据和配置信息发送至协处理器,以使协处理器根据配置信息将行存储页面数据转换为列存储页面数据;
获取协处理器反馈的列存储页面数据。
在一种可能的实现方式中,存储器11可包括存储程序区和存储数据区,其中,存储程序区可存储操作系统,以及至少一个功能所需的应用程序等;存储数据区可存储使用过程中所创建的数据。
此外,存储器11可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件或其他易失性固态存储器件。
通信接口12可以为通信模块的接口,用于与其他设备或者系统连接。
当然,需要说明的是,图29所示的结构并不构成对本申请实施例中电子设备的限定,在实际应用中电子设备可以包括比图29所示的更多或更少的部件,或者组合某些部件。
本申请实施例提供了一种非易失性可读存储介质。
本申请实施例所提供的非易失性可读存储介质上存储有计算机程序,计算机程序被处理器执行时可实现如上述任意一种存储格式转换方法的步骤。
该非易失性可读存储介质可以包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
对于本申请实施例提供的非易失性可读存储介质的介绍请参照上述方法实施例,本申请在此不做赘述。
说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。
专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM或技术领域内所公知的任意其它形式的存储介质中。
以上对本申请所提供的技术方案进行了详细介绍。本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想。应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以对本申请进行若干改进和修饰,这些改进和修饰也落入本申请的保护范围内。

Claims (20)

  1. 一种存储格式转换方法,其特征在于,应用于协处理器,包括:
    获取主处理器发送的行存储页面数据与配置信息,所述配置信息包括所述行存储页面内各列字段的格式信息;
    根据所述配置信息对所述行存储页面数据进行解析,获得列描述符,所述列描述符包括各所述列字段在行存储页面中的首偏移地址和字段长度;
    根据所述列描述符计算获得关于列存储页面的填充信息,所述填充信息包括各数据列在所述列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各所述列字段组成一个数据列;
    根据所述填充信息对所述列存储页面进行填充,生成列存储页面数据;
    将所述列存储页面数据反馈至所述主处理器。
  2. 根据权利要求1所述的存储格式转换方法,其特征在于,所述根据所述配置信息对所述行存储页面数据进行解析,获得列描述符,包括:
    确定所述行存储页面数据的数据存储格式;
    根据所述数据存储格式和所述配置信息对所述行存储页面数据进行解析,获得所述列描述符;
    其中,所述配置信息由所述主处理器基于所述行存储页面数据对应的元组描述符生成。
  3. 根据权利要求2所述的存储格式转换方法,其特征在于,所述元组描述符为关系型数据库在创建所述行存储页面类型的数据表同时创建,所述元组描述符用于描述所述数据表中各列字段格式信息。
  4. 根据权利要求2所述的存储格式转换方法,其特征在于,所述行存储页面数据的数据存储格式包括以下任意一项或多项:
    数据信息本身的存储位置、数据信息的元数据的存储位置、数据信息的描述信息的存储位置。
  5. 根据权利要求1所述的存储格式转换方法,其特征在于,所述填充信息还包括各变长列字段的首偏移地址和字段长度,定长数据列的最大值和最小值,所述根据所述填充信息对所述列存储页面进行填充,生成列存储页面数据,包括:
    根据各所述数据列在所述列存储页面中的首偏移地址和列长度,将各所述列字段填充至所述列存储页面的字段区域;
    将各所述变长列字段的首偏移地址和字段长度填充至所述列存储页面的变长字段索引区域;
    将各所述数据列的首偏移地址和列长度、所述定长数据列的最大值和最小值填充至所述列存储页面的列数据索引区域。
  6. 根据权利要求1所述的存储格式转换方法,其特征在于,所述根据所述填充信息对所述列存储页面进行填充,生成列存储页面数据,包括:
    确定所述列存储页面的数据存储格式;
    按照所述数据存储格式将所述填充信息填充至所述列存储页面,生成所述列存储页面。
  7. 根据权利要求6所述的存储格式转换方法,其特征在于,还包括:
    获取预设配置信息中列字段的字段对齐方式;
    在填充过程中,按照所述数据存储格式进行填充对齐。
  8. 根据权利要求1所述的存储格式转换方法,其特征在于,所述对所述行存储页面数据进行解析,获得列描述符之后,还包括:
    获取排序使能信息;
    根据所述排序使能信息确定排序数据列;
    根据所述排序数据列的排序方式对所述列描述符进行排序,获得排序后的列描述符。
  9. 根据权利要求1所述的存储格式转换方法,其特征在于,所述协处理器包括第一预设数量个计算单元和所述第一预设数量个存储器,每一所述计算单元对应于一个所述存储器,所述获取主处理器发送的行存储页面数据,包括:
    从当前计算单元对应的存储器中读取获得所述行存储页面数据,所述行存储页面数据由所述主处理器发送至所述存储器。
  10. 根据权利要求9所述的存储格式转换方法,其特征在于,每一所述计算单元包括第二预设数量个执行通道,所述从当前计算单元对应的存储器中读取获得所述行存储页面数据,包括:
    从所述当前计算单元对应的存储器中读取获得所述第二预设数量个行存储页面数据;
    所述从当前计算单元对应的存储器中读取获得所述行存储页面数据之后,还包括:
    将所述第二预设数量个行存储页面数据分发至所述第二预设数量个执行通道,以利用各所述执行通道执行所述对所述行存储页面数据进行解析,获得列描述符的步骤。
  11. 根据权利要求10所述的存储格式转换方法,其特征在于,所述将所述列存储页面数据反馈至所述主处理器,包括:
    将各所述列存储页面回写至所述当前计算单元对应的存储器,以使所述主处理器从各所述存储器中读取获得各所述列存储页面数据。
  12. 根据权利要求1至11任一项所述的存储格式转换方法,其特征在于,所述将所述列存储页面数据反馈至所述主处理器之前,还包括:
    根据各数据列对应的预设压缩算法对所述列存储页面数据中的各列字段进行压缩处理,获得压缩处理后的列存储页面数据。
  13. 根据权利要求12所述的存储格式转换方法,其特征在于,所述根据各数据列对应的预设压缩算法对所述列存储页面数据中的各列字段进行压缩处理,包括:
    确定各数据列中列字段的数据类型,并根据所述数据类型确定对应的预设压缩算法,并按照所述预设压缩算法对所述列存储页面数据中的各列字段进行压缩处理。
  14. 一种存储格式转换方法,其特征在于,应用于主处理器,包括:
    获取行存储页面数据以及所述行存储页面数据对应的元组描述符;
    根据所述元组描述符生成关于所述行存储页面数据的配置信息,所述配置信息包括所述行存储页面数据中各列字段的格式信息;
    将所述行存储页面数据和所述配置信息发送至协处理器,以使所述协处理器根据所述配置信息将所述行存储页面数据转换为列存储页面数据;
    获取所述协处理器反馈的所述列存储页面数据;
    其中,所述协处理器根据所述配置信息将所述行存储页面数据转换为列存储页面数据的过程包括:
    根据所述配置信息对所述行存储页面数据进行解析,获得列描述符,所述列描述符包括各所述列字段在行存储页面中的首偏移地址和字段长度;
    根据所述列描述符计算获得关于列存储页面的填充信息,所述填充信息包括各数据列在所述列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各所述列字段组成一个数据列;
    根据所述填充信息对所述列存储页面进行填充,生成列存储页面数据。
  15. 一种存储格式转换系统,其特征在于,包括主处理器和协处理器;
    所述主处理器,用于发送行存储页面数据和配置信息至所述协处理器,并获取所述协处理器反馈的列存储页面数据;
    所述协处理器,用于根据所述配置信息对所述行存储页面数据进行解析,获得列描述符,所述列描述符包括各列字段在行存储页面中的首偏移地址和字段长度;根据所述列描述符计算获得关于列存储页面的填充信息,所述填充信息包括各数据列在所述列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各所述列字段组成一个数据列;根据所述填充信息对所述列存储页面进行填充,生成所述列存储页面数据。
  16. 根据权利要求15所述的存储格式转换系统,其特征在于,所述主处理器为CPU,所述协处理器为FPGA。
  17. 一种存储格式转换装置,其特征在于,应用于协处理器,包括:
    获取模块,用于获取主处理器发送的行存储页面数据与配置信息,所述配置信息包括所述行存储页面内各列字段的格式信息;
    解析模块,用于根据所述配置信息对所述行存储页面数据进行解析,获得列描述符,所述列描述符包括各所述列字段在行存储页面中的首偏移地址和字段长度;
    计算模块,用于根据所述列描述符计算获得关于列存储页面的填充信息,所述填充信息包括各数据列在所述列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各所述列字段组成一个数据列;
    填充模块,用于根据所述填充信息对所述列存储页面进行填充,生成列存储页面数据;
    反馈模块,用于将所述列存储页面数据反馈至所述主处理器。
  18. 一种存储格式转换装置,其特征在于,应用于主处理器,包括:
    第一获取模块,用于获取行存储页面数据以及所述行存储页面数据对应的元组描述符;
    生成模块,用于根据所述元组描述符生成关于所述行存储页面数据的配置信息,所述配置信息包括所述行存储页面数据中各列字段的格式信息;
    发送模块,用于将所述行存储页面数据和所述配置信息发送至协处理器,以使所述协处理器根据所述配置信息将所述行存储页面数据转换为列存储页面数据;
    第二获取模块,用于获取所述协处理器反馈的所述列存储页面数据;
    其中,所述协处理器根据所述配置信息将所述行存储页面数据转换为列存储页面数据的过程包括:
    根据所述配置信息对所述行存储页面数据进行解析,获得列描述符,所述列描述符包括各所述列字段在行存储页面中的首偏移地址和字段长度;
    根据所述列描述符计算获得关于列存储页面的填充信息,所述填充信息包括各数据列在所述列存储页面中的首偏移地址和列长度,其中,具有相同字段属性的各所述列字段组成一个数据列;
    根据所述填充信息对所述列存储页面进行填充,生成列存储页面数。
  19. 一种电子设备,其特征在于,包括:
    存储器,用于存储计算机程序;
    处理器,用于执行所述计算机程序时实现如权利要求1至13任一项所述的存储格式转换方法的步骤或者如权利要求14所述的存储格式转换方法的步骤。
  20. 一种非易失性可读存储介质,其特征在于,所述非易失性可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至13任一项所述的存储格式转换方法的步骤或者如权利要求14所述的存储格式转换方法的步骤。
PCT/CN2023/084271 2022-11-09 2023-03-28 存储格式转换方法、系统、装置、电子设备及存储介质 WO2024098626A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211395237.5 2022-11-09
CN202211395237.5A CN115438114B (zh) 2022-11-09 2022-11-09 存储格式转换方法、系统、装置、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2024098626A1 true WO2024098626A1 (zh) 2024-05-16

Family

ID=84252567

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/084271 WO2024098626A1 (zh) 2022-11-09 2023-03-28 存储格式转换方法、系统、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN115438114B (zh)
WO (1) WO2024098626A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115438114B (zh) * 2022-11-09 2023-03-24 浪潮电子信息产业股份有限公司 存储格式转换方法、系统、装置、电子设备及存储介质
CN116302178B (zh) * 2023-02-23 2023-10-20 合肥申威睿思信息科技有限公司 一种列存数据的加速处理方法和装置

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120173515A1 (en) * 2010-12-30 2012-07-05 Chanho Jeong Processing Database Queries Using Format Conversion
CN102999519A (zh) * 2011-09-15 2013-03-27 上海盛付通电子商务有限公司 一种数据库的读写方法及系统
US20160147801A1 (en) * 2014-11-25 2016-05-26 David Wein Optimized rollover processes to accommodate a change in value identifier bit size and related system reload processes
US20170109398A1 (en) * 2015-09-25 2017-04-20 Mongodb, Inc. Systems and methods for data conversion and comparison
CN106874437A (zh) * 2017-02-04 2017-06-20 中国人民大学 面向数据库一体机的内存数据仓库行列存储转换实现方法
CN108875077A (zh) * 2018-07-10 2018-11-23 上海达梦数据库有限公司 数据库的列存储方法、装置、服务器及存储介质
CN110109910A (zh) * 2018-01-08 2019-08-09 广东神马搜索科技有限公司 数据处理方法及系统、电子设备和计算机可读存储介质
CN110309233A (zh) * 2018-03-28 2019-10-08 腾讯科技(深圳)有限公司 数据存储的方法、装置、服务器和存储介质
CN110990402A (zh) * 2019-11-26 2020-04-10 中科驭数(北京)科技有限公司 由行存储到列存储的格式转化方法、查询方法及装置
JP2020098479A (ja) * 2018-12-18 2020-06-25 株式会社日立製作所 カラムストアデータベースシステム及びデータベース処理高速化方法
CN114647635A (zh) * 2022-03-31 2022-06-21 苏州浪潮智能科技有限公司 数据处理系统
CN115438114A (zh) * 2022-11-09 2022-12-06 浪潮电子信息产业股份有限公司 存储格式转换方法、系统、装置、电子设备及存储介质

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10817512B2 (en) * 2016-04-01 2020-10-27 Arista Networks, Inc. Standing queries in memory
CN109542889B (zh) * 2018-10-11 2023-07-21 平安科技(深圳)有限公司 流式数据列存储方法、装置、设备和存储介质
CN114327244A (zh) * 2020-09-30 2022-04-12 华为技术有限公司 数据迁移的方法、装置、处理器和计算设备

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120173515A1 (en) * 2010-12-30 2012-07-05 Chanho Jeong Processing Database Queries Using Format Conversion
CN102999519A (zh) * 2011-09-15 2013-03-27 上海盛付通电子商务有限公司 一种数据库的读写方法及系统
US20160147801A1 (en) * 2014-11-25 2016-05-26 David Wein Optimized rollover processes to accommodate a change in value identifier bit size and related system reload processes
US20170109398A1 (en) * 2015-09-25 2017-04-20 Mongodb, Inc. Systems and methods for data conversion and comparison
CN106874437A (zh) * 2017-02-04 2017-06-20 中国人民大学 面向数据库一体机的内存数据仓库行列存储转换实现方法
CN110109910A (zh) * 2018-01-08 2019-08-09 广东神马搜索科技有限公司 数据处理方法及系统、电子设备和计算机可读存储介质
CN110309233A (zh) * 2018-03-28 2019-10-08 腾讯科技(深圳)有限公司 数据存储的方法、装置、服务器和存储介质
CN108875077A (zh) * 2018-07-10 2018-11-23 上海达梦数据库有限公司 数据库的列存储方法、装置、服务器及存储介质
JP2020098479A (ja) * 2018-12-18 2020-06-25 株式会社日立製作所 カラムストアデータベースシステム及びデータベース処理高速化方法
CN110990402A (zh) * 2019-11-26 2020-04-10 中科驭数(北京)科技有限公司 由行存储到列存储的格式转化方法、查询方法及装置
CN114647635A (zh) * 2022-03-31 2022-06-21 苏州浪潮智能科技有限公司 数据处理系统
CN115438114A (zh) * 2022-11-09 2022-12-06 浪潮电子信息产业股份有限公司 存储格式转换方法、系统、装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN115438114B (zh) 2023-03-24
CN115438114A (zh) 2022-12-06

Similar Documents

Publication Publication Date Title
WO2024098626A1 (zh) 存储格式转换方法、系统、装置、电子设备及存储介质
US11036799B2 (en) Low RAM space, high-throughput persistent key value store using secondary memory
US11080277B2 (en) Data set compression within a database system
JP4907600B2 (ja) 繰り返し値を有するテーブルのブロック圧縮
US8255398B2 (en) Compression of sorted value indexes using common prefixes
US8126855B2 (en) Compression of tables based on occurrence of values
EP2443564B1 (en) Data compression for reducing storage requirements in a database system
Wu Notes on design and implementation of compressed bit vectors
CN104462141B (zh) 一种数据存储与查询的方法、系统及存储引擎装置
US20170300510A1 (en) Ozip compression and decompression
CN101894115A (zh) 电子文档的图像数据处理方法及其装置
WO2024103599A1 (zh) 一种数据查询方法、系统、装置、设备及非易失性可读存储介质
US20140085115A1 (en) Data compression using dictionary encoding
CN111723059B (zh) 一种数据压缩方法、装置、终端设备及存储介质
CN114647635B (zh) 数据处理系统
CN102880615A (zh) 一种数据存储方法和装置
CN108475508B (zh) 音频数据和保存在块处理存储系统中的数据的简化
WO2022037015A1 (zh) 一种基于持久性内存的列式存储方法、装置及设备
WO2023082902A1 (zh) 索引的创建方法、计算设备及存储介质
Slechta et al. Optimizing query execution for variable-aligned length compression of bitmap indices
Yiannis et al. Compression techniques for fast external sorting
WO2024066753A1 (zh) 压缩数据的方法和相关装置
WO2024046132A1 (zh) 一种数据存储方法及相关装置
US11507499B2 (en) System and method for facilitating mitigation of read/write amplification in data compression
WO2016194159A1 (ja) 計算機、データベース管理方法、データベース管理システム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23887330

Country of ref document: EP

Kind code of ref document: A1