WO2017071525A1 - Data storage method and apparatus and data query method and apparatus - Google Patents

Data storage method and apparatus and data query method and apparatus Download PDF

Info

Publication number
WO2017071525A1
WO2017071525A1 PCT/CN2016/102764 CN2016102764W WO2017071525A1 WO 2017071525 A1 WO2017071525 A1 WO 2017071525A1 CN 2016102764 W CN2016102764 W CN 2016102764W WO 2017071525 A1 WO2017071525 A1 WO 2017071525A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
indicator
data storage
storage location
indicator data
Prior art date
Application number
PCT/CN2016/102764
Other languages
French (fr)
Chinese (zh)
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 WO2017071525A1 publication Critical patent/WO2017071525A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • 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
    • 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/284Relational databases

Definitions

  • the present application relates to the field of databases, and in particular, to a data storage method, apparatus, and data query method and apparatus.
  • Data stored in a relational database data analysis system usually has many indicators to provide different combinations of dimensional indicators for different customers. In many cases, it is also necessary to import indicator data of other system statistics into the data analysis system for comprehensive analysis. Taking advertisement monitoring as an example, data analysis systems usually have data monitoring indicators such as exposure, click, and click rate, which are also called data indicators. When you need to analyze the relationship between cost and exposure or click and order volume, you need to import indicators such as order quantity, and then perform query statistics to facilitate correlation analysis.
  • the data analysis system in the prior art introduces storage and query support of dynamic indicators.
  • Table 1 the data recorded in the data analysis system is as shown in Table 1.
  • Table 2 the definition of the indicator is added first, as shown in Table 2.
  • the scheme overcomes the query implementation problem of adding dynamic indicators, it can dynamically complete the data analysis work without predicting the number of indicators.
  • the above scheme first stores the data. The query is converted to column storage. This query step will become slower and the query efficiency will gradually decrease.
  • the embodiment of the present application provides a data storage method, apparatus, and data query method and apparatus, so as to at least solve the technical problem of low efficiency of index data query in the prior art.
  • a data storage method including: adding, in a metadata table, an indicator definition of the indicator data; and in the indicator data storage table, retrieving a data storage location of the unstored data, where The data storage location includes a column in the indicator data storage table is empty; establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location; storing the indicator data to the association In the storage location.
  • establishing a mapping relationship between the indicator definition and the retrieved data storage location includes: obtaining an identifier of the retrieved data storage location; and querying, from the metadata table, a data table of a mapping relationship column corresponding to the indicator definition And storing an identifier of the retrieved data storage location into the data table to establish a mapping relationship between the data storage location and the indicator definition, and using the data storage location as the associated storage location.
  • the method before querying the empty column preset in the indicator data storage table stored in the column, the method further includes: setting N columns of empty columns in the indicator data storage table, and using the empty column as the The data storage location, where 0 ⁇ N ⁇ Max, the Max is a maximum value supported by a database storing index data; and the indicator data storage table is set in the database as column storage.
  • the method further includes deleting, when the deletion instruction for deleting the indicator data is deleted, the indicator definition indicated by the deletion instruction in the metadata table and the indicator data in the indicator data storage table a mapping relationship; the metadata in the metadata table that records the indicator definition indicated by the deletion instruction is marked as redundant.
  • the method further includes: acquiring a data type of the indicator data; acquiring a data storage type supported by the associated storage location; Determining, by the data type of the indicator data and the data storage type supported by the associated storage location, an associated storage location that matches a data type of the indicator data; storing the indicator data to a data type of the indicator data Match the associated storage location.
  • a data query method including: receiving a query instruction for querying indicator data; determining an indicator definition indicated by the query instruction from a metadata table, determining the The mapping relationship between the indicator indicated by the query instruction and the indicator data in the indicator data storage table is used; and the indicator data indicated by the query instruction is queried from the indicator data storage table by using the mapping relationship.
  • a data storage apparatus including: an adding unit, configured to add an indicator definition of the indicator data in the metadata table; and a retrieval unit, configured to be in the indicator data storage table , Retrieving a data storage location of the unstored data, wherein the data storage location includes a column in the indicator data storage table is empty; and an establishing unit, configured to establish a mapping relationship between the indicator definition and the data storage location, Obtaining an associated storage location; and importing unit for storing the indicator data in the associated storage location.
  • the establishing unit includes: an obtaining module, configured to acquire an identifier of the retrieved data storage location; and a query module, configured to query data of the mapping relationship column corresponding to the indicator definition from the metadata table a table; a writing module, configured to store an identifier of the retrieved data storage location into the data table to establish a mapping relationship between the data storage location and the indicator definition, and use the data storage location as the association storage location.
  • the apparatus further includes: a first setting unit, configured to set an N column of empty columns in the indicator data storage table, and use the empty column as the data before retrieving a data storage location of the unstored data a storage location, where 0 ⁇ N ⁇ Max, the Max is a maximum value supported by a database storing index data; and a second setting unit configured to set the indicator data storage table in the database as a column storage.
  • a first setting unit configured to set an N column of empty columns in the indicator data storage table, and use the empty column as the data before retrieving a data storage location of the unstored data a storage location, where 0 ⁇ N ⁇ Max, the Max is a maximum value supported by a database storing index data
  • a second setting unit configured to set the indicator data storage table in the database as a column storage.
  • the device further includes: a deleting unit, configured to delete the indicator definition indicated by the deletion instruction in the metadata table and the indicator data storage table when receiving the deletion instruction for deleting the indicator data a mapping relationship of the indicator data in the marking unit, configured to mark metadata in the metadata table that records the indicator definition indicated by the deletion instruction as redundant.
  • a deleting unit configured to delete the indicator definition indicated by the deletion instruction in the metadata table and the indicator data storage table when receiving the deletion instruction for deleting the indicator data a mapping relationship of the indicator data in the marking unit, configured to mark metadata in the metadata table that records the indicator definition indicated by the deletion instruction as redundant.
  • the device further includes: a first acquiring unit, configured to acquire a data type of the indicator data; and a second acquiring unit, configured to acquire a data storage type supported by the associated storage location; And determining, according to the data type of the indicator data and the data storage type supported by the associated storage location, an associated storage location that matches a data type of the indicator data, and a storage unit configured to use the indicator The data is stored to an associated storage location that matches the data type of the indicator data.
  • a data query apparatus including: a receiving unit, configured to receive a query instruction for querying indicator data; and a second determining unit, configured to determine, from the metadata table Determining, by the query instruction, the index definition, the mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table; and the query unit, configured to use the mapping relationship from the indicator data storage table Querying indicator data indicated by the query instruction.
  • the indicator definition of the indicator data is added; in the indicator data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes the column in the indicator data storage table is empty Establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location; storing the indicator data in the associated storage location, reducing the IO performance overhead of converting the row storage indicator into the column storage, and improving the query efficiency, The technical problem of low efficiency of index data query in the prior art is solved.
  • FIG. 1 is a flow chart of a data storage method according to an embodiment of the present application.
  • FIG. 2 is a flowchart of a data query method according to an embodiment of the present application.
  • FIG. 3 is a schematic diagram of a data storage device in accordance with an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a data query device in accordance with an embodiment of the present application.
  • a method embodiment of a data storage method is provided. It should be noted that the steps illustrated in the flowchart of the accompanying drawings may be performed in a computer system such as a set of computer executable instructions, and Although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein.
  • FIG. 1 is a flowchart of a data storage method according to an embodiment of the present application. As shown in FIG. 1, the method includes the following steps:
  • step S102 an indicator definition of the indicator data is added in the metadata table.
  • the metadata table is a data table for recording indicator metadata, and the identifier of the indicator may be recorded on the metadata table. Metadata such as name, data type, etc.
  • the indicator definition of the indicator data is added to the metadata table, which may include adding the identifier, name, data type, and the like of the indicator data for querying and storing. Data (for example: data type for data storage format verification).
  • Step S104 in the indicator data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes the column in the indicator data storage table being empty.
  • Step S106 establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location.
  • the indicator data storage table is a data table in which statistical data of various indicators are recorded.
  • the indicator data storage table may be set to be column storage, or may be set to row storage, that is, the indicator data is stored in a data column or stored in a row, and each column represents statistical data of an indicator in different dimensions, and is in the indicator.
  • the data storage table is preset with a data storage location where the indicator data is not stored, such as a blank line or an empty column, so that after the indicator data is imported, the indicator data is imported into a data storage location of the preset unstored indicator data.
  • step S108 the indicator data is stored in the associated storage location.
  • the import location of the indicator data is determined as the associated storage location. Therefore, the acquired indicator data can be imported into the associated storage location mapped by the above established mapping relationship. .
  • the data storage location in which the indicator data is not stored is preset in the indicator data storage table for importing the indicator data, so that the imported indicator data and the original indicator data in the data analysis system are in the same indicator data storage table.
  • the row storage metrics need not be converted into column storage, which reduces the IO performance overhead of the row storage metrics into column storage, and improves the query efficiency.
  • the indicator definition of the indicator data is added; in the indicator data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes the column in the indicator data storage table is empty Establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location; storing the indicator data in the associated storage location, and eliminating the need to convert the row storage indicator into column storage when performing the indicator data query, reducing The row storage index is converted into the IO performance overhead of the column storage, which improves the query efficiency and solves the technical problem of low efficiency of index data query in the prior art.
  • the method before querying the empty column preset in the indicator data storage table stored in the column, the method further includes: setting an N column empty column in the indicator data storage table, and using the empty column as the data The storage location, where 0 ⁇ N ⁇ Max, Max is the maximum value supported by the database storing the indicator data; the indicator data storage table is set in the database as the column storage.
  • N columns of empty columns are set in the indicator data storage table stored in advance in the data analysis system, wherein N can be arbitrarily selected from 0 to Max. Each empty column can be added with a corresponding identifier for indicating Corresponding empty or empty lines. If the indicator data storage table is set to column storage, each column represents statistics of an indicator in different dimensions, as shown in Table 4; if the indicator data storage table is set to row storage, each row represents one item The statistics of the indicators in different dimensions.
  • establishing a mapping relationship between the indicator definition and the retrieved data storage location includes: obtaining an identifier of the retrieved data storage location; and querying the data table of the mapping relationship column corresponding to the indicator definition from the metadata table The identifier of the retrieved data storage location is stored in the data table to establish a mapping relationship between the data storage location and the indicator definition, and the data storage location is used as the associated storage location.
  • each data storage location in the preset indicator data storage table is provided with a corresponding identifier, such as “preset 1”... “preset N” shown in Table 4, and the indicator data is imported.
  • the identifier is obtained, and then the identifier is written into the data table of the mapping relationship column corresponding to the imported indicator in the metadata table to establish an empty column and an imported The mapping relationship between indicators.
  • the principle of using blank lines as the data storage location is the same as that of the empty column, and will not be described here.
  • the indicators whose names are “Order” and “Cost” are imported indicators, and the identifiers of the empty columns corresponding to the above indicators in the mapping relationship column are “Preset 1” and “ Preset 2", when the indicator data is imported into Table 4, there is a mapping relationship between the above indicators in Table 5 and their indicator data.
  • the method further includes: deleting a mapping relationship between the indicator definition indicated by the deletion instruction in the metadata table and the indicator data in the indicator data storage table when receiving the deletion instruction for deleting the indicator data
  • the metadata defined by the indicator indicated by the record deletion instruction in the metadata table is marked as redundant.
  • the mapping relationship between the indicator definition indicated by the deletion instruction and the indicator data is deleted, and the metadata defined by the indicator recorded in the metadata table is marked as redundant. In this way, the data analysis system will delete it when it is idle.
  • the method before the storing the indicator data in the associated storage location, the method further includes: acquiring a data type of the indicator data; acquiring a data storage type supported by the associated storage location; and a data type according to the indicator data. And the data storage type supported by the associated storage location, determining an associated storage location that matches the data type of the indicator data; storing the indicator data to an associated storage location that matches the data type of the indicator data.
  • data can be stored to a storage location that matches its data type.
  • a method embodiment of a data query method there is also provided a method embodiment of a data query method, and it should be noted that the steps shown in the flowchart of the drawing may be executed in a computer system such as a set of computer executable instructions, and Although the logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein.
  • the data query method in the embodiment of the present application may be queried based on the indicator data stored and imported by the data storage method in the embodiment of the present application, that is, the data query method in the embodiment of the present application may be used to query the data in the embodiment of the present application.
  • the storage method stores and imports the indicator data.
  • the data query method in this embodiment of the present application includes:
  • Step S202 receiving a query instruction for querying indicator data.
  • Step S204 Determine an indicator definition indicated by the query instruction from the metadata table, and determine a mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table.
  • Step S206 querying, by using the mapping relationship, the indicator data indicated by the query instruction from the indicator data storage table.
  • the imported indicator data and the original indicator data are stored in the indicator data storage table.
  • the reference finger After receiving the query instruction for querying the indicator data, combining the metadata table and the indicator data storage table, the reference finger The corresponding indicator data is directly queried in the standard data storage table.
  • the data storage location is preset in the indicator data storage table for importing the indicator data, so that the imported indicator data and the original indicator data in the data analysis system are in the same indicator data storage table, and the indicator data is performed.
  • the embodiment of the present application further provides a data storage device, which can be used to execute the data storage method of the embodiment of the present application.
  • the device includes: an adding unit 301, a retrieving unit 303, an establishing unit 305, and Import unit 307.
  • the adding unit 301 is configured to add an indicator definition of the indicator data in the metadata table.
  • the metadata table is a data table for recording indicator metadata, and metadata such as an identifier, a name, and a data type of the indicator may be recorded on the metadata table.
  • the indicator definition of the indicator data is added to the metadata table, which may include adding the identifier, name, data type, and the like of the indicator data for querying and storing.
  • Data for example: data type for data storage format verification).
  • the retrieval unit 303 is configured to retrieve, in the indicator data storage table, a data storage location of the unstored data, wherein the data storage location includes a column in the indicator data storage table that is empty.
  • the establishing unit 305 is configured to establish a mapping relationship between the indicator definition and the data storage location to obtain an associated storage location.
  • the indicator data storage table is a data table in which statistical data of various indicators are recorded.
  • the indicator The data storage table can be set to column storage or set to row storage, that is, the indicator data is stored in a data column or stored in a row, and each column represents statistical data of an indicator in different dimensions, and is preset in the indicator data storage table.
  • the data storage location of the indicator data such as a blank line, is stored, so that after the indicator data is imported, the indicator data is imported into a data storage location of the preset unstored indicator data.
  • the import unit 307 is configured to store the indicator data in an associated storage location.
  • the import location of the indicator data is determined as the associated storage location. Therefore, the acquired indicator data can be imported into the associated storage location mapped by the above established mapping relationship. .
  • the data storage location in which the indicator data is not stored is preset in the indicator data storage table for importing the indicator data, so that the imported indicator data and the original indicator data in the data analysis system are in the same indicator data storage table.
  • the row storage metrics need not be converted into column storage, which reduces the IO performance overhead of the row storage metrics into column storage, and improves the query efficiency.
  • the indicator definition of the indicator data is added; in the indicator data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes the column in the indicator data storage table is empty Establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location; storing the indicator data in the associated storage location, and eliminating the need to convert the row storage indicator into column storage when performing the indicator data query, reducing The row storage index is converted into the IO performance overhead of the column storage, which improves the query efficiency and solves the technical problem of low efficiency of index data query in the prior art.
  • the apparatus further includes: a first setting unit, configured to set an N column empty column in the indicator data storage table, and use an empty column or a blank line as a data storage location for retrieving data that is not stored.
  • the data storage location where 0 ⁇ N ⁇ Max, Max is the maximum value supported by the database storing the indicator data; and the second setting unit is configured to set the indicator data storage table in the database as the column storage.
  • N columns of empty columns are set in the indicator data storage table stored in advance in the data analysis system, wherein N can be arbitrarily selected from 0 to Max. Each empty column can be added with a corresponding identifier to indicate the corresponding empty column. If the indicator data storage table is set to column storage, each column represents statistics of an indicator in different dimensions, as shown in Table 4; if the indicator data storage table is set to row storage, each row represents one item The statistics of the indicators in different dimensions.
  • the establishing unit includes: an obtaining module, configured to obtain an identifier of the retrieved data storage location; and a query module, configured to query, from the metadata table, a data table of the mapping relationship column corresponding to the index definition;
  • the writing module is configured to store the identifier of the retrieved data storage location into the data table to establish a mapping relationship between the data storage location and the indicator definition, and use the data storage location as the associated storage location.
  • each data storage location in the preset indicator data storage table is set corresponding thereto
  • the identifier as shown in Table 4, "Preset 1" ... "Preset N”, in the process of importing the indicator data, if the empty column of the index data is determined, the identifier is obtained, and then the identifier is written.
  • the data table of the mapping relationship column corresponding to the imported indicator in the metadata table a mapping relationship between the empty column and the imported indicator is established.
  • the principle of using blank lines as the data storage location is the same as that of the empty column, and will not be described here.
  • the indicators whose names are “Order” and “Cost” are imported indicators, and the identifiers of the empty columns corresponding to the above indicators in the mapping relationship column are “Preset 1” and “ Preset 2", when the indicator data is imported into Table 4, there is a mapping relationship between the above indicators in Table 5 and their indicator data.
  • the device further includes: a deleting unit, configured to delete the indicator definition and the indicator data storage table indicated by the deletion instruction in the metadata table when receiving the deletion instruction for deleting the indicator data A mapping relationship of the indicator data; the marking unit is configured to mark the metadata defined by the indicator indicated by the record deletion instruction in the metadata table as redundant.
  • the mapping relationship between the indicator definition indicated by the deletion instruction and the indicator data is deleted, and the metadata defined by the indicator recorded in the metadata table is marked as redundant. In this way, the data analysis system will delete it when it is idle.
  • the foregoing apparatus further includes: a first acquiring unit, configured to acquire a data type of the indicator data; and a second acquiring unit, configured to acquire a data storage type supported by the associated storage location; And determining, according to the data type of the indicator data and the data storage type supported by the associated storage location, an associated storage location that matches the data type of the indicator data; and a storage unit configured to store the indicator data to the data type of the indicator data Match the associated storage location.
  • the data storage device of the embodiment of the present application may further include: a metadata storage unit, configured to add a definition of the indicator, establish a mapping relationship between the indicator and the preset table column, and store other metadata information, and use Query and storage (for example: data type for data storage format check); and data unit for updating a column of data or a cell data (including new data or updated data) in the indicator data storage table, and deleting the indicator data Stores a column of data or a cell of data in a table and supports batch operations to improve operational performance and transaction support.
  • the metadata storage unit is equivalent to the adding unit and the establishing unit in the embodiment of the present application, and the data unit is equivalent to the searching unit, the import unit, the deleting unit, the marking unit, and the like.
  • the data storage device includes a processor and a memory, and the adding unit 301, the retrieving unit 303, the establishing unit 305, the importing unit 307, and the like are each stored as a program unit in a memory, and the program unit stored in the memory is executed by the processor.
  • the processor contains a kernel, and the kernel removes the corresponding program unit from the memory.
  • the kernel can be set to one or more, and the indicator data can be imported by adjusting the kernel parameters.
  • the memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory (flash RAM), the memory including at least one Memory chip.
  • RAM random access memory
  • ROM read only memory
  • flash RAM flash memory
  • the present application also provides an embodiment of a computer program product, when executed on a data processing device, adapted to perform a program code that initializes a method step of: adding an indicator definition of the indicator data in the metadata table; In the data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes a column in the indicator data storage table is empty; and a mapping relationship between the indicator definition and the retrieved data storage location is established to obtain an associated storage location; Store metric data in an associated storage location.
  • the embodiment of the present application further provides a data query device, which can be used to perform the data query method of the embodiment of the present application.
  • the device includes: a receiving unit 401, a second determining unit 403, and a query unit. 405.
  • the receiving unit 401 is configured to receive a query instruction for querying the indicator data.
  • the second determining unit 403 is configured to determine, from the metadata table, the indicator definition indicated by the query instruction, and determine a mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table.
  • the query unit 405 is configured to query the indicator data indicated by the query instruction from the indicator data storage table by using the mapping relationship.
  • the imported indicator data and the original indicator data are stored in the indicator data storage table.
  • the data storage location is preset in the indicator data storage table for importing the indicator data, so that the imported indicator data and the original indicator data in the data analysis system are in the same indicator data storage table, and the indicator data is performed.
  • the data querying device includes a processor and a memory, and the receiving unit 401, the second determining unit 403, the query unit 405, and the like are all stored as a program unit in a memory, and the program unit stored in the memory is executed by the processor.
  • the processor contains a kernel, and the kernel removes the corresponding program unit from the memory.
  • the kernel can set one or more and query the indicator data by adjusting the kernel parameters.
  • the memory may include non-persistent memory, random access memory (RAM) and/or in a computer readable medium. Or a form of non-volatile memory, such as a read only memory (ROM) or a flash memory (flash RAM), the memory including at least one memory chip.
  • RAM random access memory
  • flash RAM flash memory
  • the present application also provides an embodiment of a computer program product, when executed on a data processing device, adapted to perform program code initialization having the following method steps: receiving a query instruction for querying indicator data, from a metadata table Determining the indicator definition indicated by the query instruction, determining a mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table, and using the mapping relationship to query the indicator data indicated by the query instruction from the indicator data storage table.
  • the disclosed technical contents may be implemented in other manners.
  • the device embodiments described above are only schematic.
  • the division of the unit may be a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • a computer readable storage medium A number of instructions are included to cause a computer device (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application.
  • the foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .

Abstract

A data storage method and apparatus and a data query method and apparatus. The data storage method comprises: in a metadata table, adding an index definition of index data (S102); in an index data storage table, retrieving a data storage position of unstored data (S104), wherein the data storage position includes a column in the index data storage table being empty; establishing a mapping relationship between the index definition and the retrieved data storage position, so as to obtain an associated storage position (S106); and storing the index data in the associated storage position (S108). The method and apparatus solve the technical problem that the query efficiency of index data is low in the prior art.

Description

数据存储方法、装置和数据查询方法、装置Data storage method, device and data query method and device 技术领域Technical field
本申请涉及数据库领域,具体而言,涉及一种数据存储方法、装置和数据查询方法、装置。The present application relates to the field of databases, and in particular, to a data storage method, apparatus, and data query method and apparatus.
背景技术Background technique
在关系型数据库数据分析系统中存储的数据,通常会有很多指标,为不同的客户提供不同的维度指标组合分析。很多情况下,还需要向数据分析系统中导入其他系统统计的指标数据,以便于进行综合分析。以广告监测为例,数据分析系统中通常会有曝光、点击、点击率等数据监测指标,也称为数据指标。当需要分析成本与曝光或者点击与订单量之间的关系,则需要导入如订单量等指标,然后进行查询统计,以便于进行关联分析。Data stored in a relational database data analysis system usually has many indicators to provide different combinations of dimensional indicators for different customers. In many cases, it is also necessary to import indicator data of other system statistics into the data analysis system for comprehensive analysis. Taking advertisement monitoring as an example, data analysis systems usually have data monitoring indicators such as exposure, click, and click rate, which are also called data indicators. When you need to analyze the relationship between cost and exposure or click and order volume, you need to import indicators such as order quantity, and then perform query statistics to facilitate correlation analysis.
由于导入的指标与分析的需求有关,不同的客户需求也不相同,因此,待导入的指标是不可预知的。为了达到分析效果,现有技术中数据分析系统会引入动态指标的存储和查询支持。还以广告监测的数据分析为例,数据分析系统中记录的数据如表1所示,当需要导入“成本”和“订单”的指标时,先添加该指标的定义,如表2所示,再生成动态指标数据表,如表3。Since the imported indicators are related to the needs of the analysis, different customer needs are different, so the indicators to be imported are unpredictable. In order to achieve the analysis effect, the data analysis system in the prior art introduces storage and query support of dynamic indicators. Taking the data analysis of advertisement monitoring as an example, the data recorded in the data analysis system is as shown in Table 1. When the indicators of “cost” and “order” need to be imported, the definition of the indicator is added first, as shown in Table 2. Regenerate the dynamic indicator data table, as shown in Table 3.
表1Table 1
维度IDDimension ID 曝光exposure 点击Click 点击率Click rate
11 100100 33 3.00%3.00%
...      
表2Table 2
指标IDIndicator ID 名称name
11 成本cost
22 订单Order
...  
表3table 3
维度IDDimension ID 指标值Index value 指标IDIndicator ID
11 100100 11
22 11 22
...    
当查询指标数据时,其查询语句如下:When querying indicator data, its query statement is as follows:
Figure PCTCN2016102764-appb-000001
Figure PCTCN2016102764-appb-000001
由此得出,在导入指标之后,查询原指标和导入的指标数据的过程中,需要先将行存储指标转为列存储,通过指标关系与原指标联合查询。该方案虽然克服了动态指标添加的查询实现问题,能够在无法预知指标数量的情况下,动态完成数据分析工作,但是,随着时间的积累,数据量的上升,上述方案中“先将行存储指标转化为列存储”这一查询步骤将变得缓慢,查询效率逐渐下降。Therefore, after importing the indicator, in the process of querying the original indicator and the imported indicator data, it is necessary to first convert the row storage indicator into a column storage, and jointly query the original indicator by the indicator relationship. Although the scheme overcomes the query implementation problem of adding dynamic indicators, it can dynamically complete the data analysis work without predicting the number of indicators. However, as time accumulates and the amount of data increases, the above scheme first stores the data. The query is converted to column storage. This query step will become slower and the query efficiency will gradually decrease.
针对上述的问题,目前尚未提出有效的解决方案。 In response to the above problems, no effective solution has been proposed yet.
发明内容Summary of the invention
本申请实施例提供了一种数据存储方法、装置和数据查询方法、装置,以至少解决现有技术中指标数据查询效率低的技术问题。The embodiment of the present application provides a data storage method, apparatus, and data query method and apparatus, so as to at least solve the technical problem of low efficiency of index data query in the prior art.
根据本申请实施例的一个方面,提供了一种数据存储方法,包括:在元数据表中,添加指标数据的指标定义;在指标数据存储表中,检索未存储数据的数据存储位置,其中,所述数据存储位置包含所述指标数据存储表中的列为空;建立所述指标定义与检索到的数据存储位置的映射关系,以得到关联存储位置;将所述指标数据存储到所述关联存储位置中。According to an aspect of the embodiments of the present application, a data storage method is provided, including: adding, in a metadata table, an indicator definition of the indicator data; and in the indicator data storage table, retrieving a data storage location of the unstored data, where The data storage location includes a column in the indicator data storage table is empty; establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location; storing the indicator data to the association In the storage location.
进一步地,建立所述指标定义与检索到的数据存储位置的映射关系包括:获取检索到的数据存储位置的标识;从所述元数据表中查询所述指标定义对应的映射关系列的数据表格;将检索到的数据存储位置的标识存储到所述数据表格中以建立所述数据存储位置与所述指标定义的映射关系,将所述数据存储位置作为所述关联存储位置。Further, establishing a mapping relationship between the indicator definition and the retrieved data storage location includes: obtaining an identifier of the retrieved data storage location; and querying, from the metadata table, a data table of a mapping relationship column corresponding to the indicator definition And storing an identifier of the retrieved data storage location into the data table to establish a mapping relationship between the data storage location and the indicator definition, and using the data storage location as the associated storage location.
进一步地,在查询在设置为列存储的指标数据存储表中预先设置的空列之前,所述方法还包括:在所述指标数据存储表中设置N列空列,将所述空列作为所述数据存储位置,其中,0<N≤Max,所述Max为存储指标数据的数据库所支持的最大值;在所述数据库中设置所述指标数据存储表为列存储。Further, before querying the empty column preset in the indicator data storage table stored in the column, the method further includes: setting N columns of empty columns in the indicator data storage table, and using the empty column as the The data storage location, where 0 < N ≤ Max, the Max is a maximum value supported by a database storing index data; and the indicator data storage table is set in the database as column storage.
进一步地,所述方法还包括:在接收到用于删除指标数据的删除指令时,删除所述元数据表中所述删除指令所指示的指标定义与所述指标数据存储表中的指标数据的映射关系;将所述元数据表中记录所述删除指令所指示的指标定义的元数据标记为冗余。Further, the method further includes deleting, when the deletion instruction for deleting the indicator data is deleted, the indicator definition indicated by the deletion instruction in the metadata table and the indicator data in the indicator data storage table a mapping relationship; the metadata in the metadata table that records the indicator definition indicated by the deletion instruction is marked as redundant.
进一步地,在将所述指标数据存储到所述关联存储位置中之前,所述方法还包括:获取所述指标数据的数据类型;获取所述关联存储位置所支持的数据存储类型;根据所述指标数据的数据类型和所述关联存储位置所支持的数据存储类型,确定与所述指标数据的数据类型相匹配的关联存储位置;将所述指标数据存储到与所述指标数据的数据类型相匹配的关联存储位置上。Further, before storing the indicator data in the associated storage location, the method further includes: acquiring a data type of the indicator data; acquiring a data storage type supported by the associated storage location; Determining, by the data type of the indicator data and the data storage type supported by the associated storage location, an associated storage location that matches a data type of the indicator data; storing the indicator data to a data type of the indicator data Match the associated storage location.
根据本申请实施例的另一方面,还提供了一种数据查询方法,包括:接收用于查询指标数据的查询指令;从元数据表中确定所述查询指令所指示的指标定义,确定所述查询指令所指示的指标定义与指标数据存储表中的指标数据的映射关系;利用所述映射关系从所述指标数据存储表中查询所述查询指令所指示的指标数据。According to another aspect of the embodiments of the present application, a data query method is further provided, including: receiving a query instruction for querying indicator data; determining an indicator definition indicated by the query instruction from a metadata table, determining the The mapping relationship between the indicator indicated by the query instruction and the indicator data in the indicator data storage table is used; and the indicator data indicated by the query instruction is queried from the indicator data storage table by using the mapping relationship.
根据本申请实施例的另一方面,还提供了一种数据存储装置,包括:添加单元,用于在元数据表中,添加指标数据的指标定义;检索单元,用于在指标数据存储表中, 检索未存储数据的数据存储位置,其中,所述数据存储位置包含所述指标数据存储表中的列为空;建立单元,用于建立所述指标定义与所述数据存储位置的映射关系,以得到关联存储位置;以及导入单元,用于将所述指标数据存储到所述关联存储位置中。According to another aspect of the embodiments of the present application, a data storage apparatus is further provided, including: an adding unit, configured to add an indicator definition of the indicator data in the metadata table; and a retrieval unit, configured to be in the indicator data storage table , Retrieving a data storage location of the unstored data, wherein the data storage location includes a column in the indicator data storage table is empty; and an establishing unit, configured to establish a mapping relationship between the indicator definition and the data storage location, Obtaining an associated storage location; and importing unit for storing the indicator data in the associated storage location.
进一步地,所述建立单元包括:获取模块,用于获取所述检索到的数据存储位置的标识;查询模块,用于从所述元数据表中查询所述指标定义对应的映射关系列的数据表格;写入模块,用于将检索到的数据存储位置的标识存储到所述数据表格中以建立所述数据存储位置与所述指标定义的映射关系,将所述数据存储位置作为所述关联存储位置。Further, the establishing unit includes: an obtaining module, configured to acquire an identifier of the retrieved data storage location; and a query module, configured to query data of the mapping relationship column corresponding to the indicator definition from the metadata table a table; a writing module, configured to store an identifier of the retrieved data storage location into the data table to establish a mapping relationship between the data storage location and the indicator definition, and use the data storage location as the association storage location.
进一步地,所述装置还包括:第一设置单元,用于在检索未存储数据的数据存储位置之前,在所述指标数据存储表中设置N列空列,将所述空列作为所述数据存储位置,其中,0<N≤Max,所述Max为存储指标数据的数据库所支持的最大值;第二设置单元,用于在所述数据库中设置所述指标数据存储表为列存储。Further, the apparatus further includes: a first setting unit, configured to set an N column of empty columns in the indicator data storage table, and use the empty column as the data before retrieving a data storage location of the unstored data a storage location, where 0<N≤Max, the Max is a maximum value supported by a database storing index data; and a second setting unit configured to set the indicator data storage table in the database as a column storage.
进一步地,所述装置还包括:删除单元,用于在接收到用于删除指标数据的删除指令时,删除所述元数据表中所述删除指令所指示的指标定义与所述指标数据存储表中的指标数据的映射关系;标记单元,用于将所述元数据表中记录所述删除指令所指示的指标定义的元数据标记为冗余。Further, the device further includes: a deleting unit, configured to delete the indicator definition indicated by the deletion instruction in the metadata table and the indicator data storage table when receiving the deletion instruction for deleting the indicator data a mapping relationship of the indicator data in the marking unit, configured to mark metadata in the metadata table that records the indicator definition indicated by the deletion instruction as redundant.
进一步地,所述装置还包括:第一获取单元,用于获取所述指标数据的数据类型;第二获取单元,用于获取所述关联存储位置所支持的数据存储类型;第一确定单元,用于根据所述指标数据的数据类型和所述关联存储位置所支持的数据存储类型,第一确定与所述指标数据的数据类型相匹配的关联存储位置;存储单元,用于将所述指标数据存储到与所述指标数据的数据类型相匹配的关联存储位置上。Further, the device further includes: a first acquiring unit, configured to acquire a data type of the indicator data; and a second acquiring unit, configured to acquire a data storage type supported by the associated storage location; And determining, according to the data type of the indicator data and the data storage type supported by the associated storage location, an associated storage location that matches a data type of the indicator data, and a storage unit configured to use the indicator The data is stored to an associated storage location that matches the data type of the indicator data.
根据本申请实施例的另一方面,还提供了一种数据查询装置,包括:接收单元,用于接收用于查询指标数据的查询指令;第二确定单元,用于从元数据表中确定所述查询指令所指示的指标定义,确定所述查询指令所指示的指标定义与指标数据存储表中的指标数据的映射关系;查询单元,用于利用所述映射关系从所述指标数据存储表中查询所述查询指令所指示的指标数据。According to another aspect of the embodiments of the present application, a data query apparatus is provided, including: a receiving unit, configured to receive a query instruction for querying indicator data; and a second determining unit, configured to determine, from the metadata table Determining, by the query instruction, the index definition, the mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table; and the query unit, configured to use the mapping relationship from the indicator data storage table Querying indicator data indicated by the query instruction.
根据本申请实施例,在元数据表中,添加指标数据的指标定义;在指标数据存储表中,检索未存储数据的数据存储位置,其中,数据存储位置包含指标数据存储表中的列为空;建立指标定义与检索到的数据存储位置的映射关系,以得到关联存储位置;将指标数据存储到关联存储位置中,减少了行存储指标转化为列存储的IO性能开销,提高了查询效率,解决了现有技术中指标数据查询效率低的技术问题。 According to the embodiment of the present application, in the metadata table, the indicator definition of the indicator data is added; in the indicator data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes the column in the indicator data storage table is empty Establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location; storing the indicator data in the associated storage location, reducing the IO performance overhead of converting the row storage indicator into the column storage, and improving the query efficiency, The technical problem of low efficiency of index data query in the prior art is solved.
附图说明DRAWINGS
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the present application, and are intended to be a part of this application. In the drawing:
图1是根据本申请实施例的数据存储方法的流程图;1 is a flow chart of a data storage method according to an embodiment of the present application;
图2是根据本申请实施例的数据查询方法的流程图;2 is a flowchart of a data query method according to an embodiment of the present application;
图3是根据本申请实施例的数据存储装置的示意图;3 is a schematic diagram of a data storage device in accordance with an embodiment of the present application;
图4是根据本申请实施例的数据查询装置的示意图。4 is a schematic diagram of a data query device in accordance with an embodiment of the present application.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present application. It is an embodiment of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope shall fall within the scope of the application.
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or order. It is to be understood that the data so used may be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "comprises" and "comprises" and "the" and "the" are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or device that comprises a series of steps or units is not necessarily limited to Those steps or units may include other steps or units not explicitly listed or inherent to such processes, methods, products or devices.
根据本申请实施例,提供了一种数据存储方法的方法实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。According to an embodiment of the present application, a method embodiment of a data storage method is provided. It should be noted that the steps illustrated in the flowchart of the accompanying drawings may be performed in a computer system such as a set of computer executable instructions, and Although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein.
图1是根据本申请实施例的数据存储方法的流程图,如图1所示,该方法包括如下步骤:FIG. 1 is a flowchart of a data storage method according to an embodiment of the present application. As shown in FIG. 1, the method includes the following steps:
步骤S102,在元数据表中,添加指标数据的指标定义。In step S102, an indicator definition of the indicator data is added in the metadata table.
其中,元数据表为记录指标元数据的数据表,该元数据表上可以记载指标的标识、 名称、数据类型等元数据。本实施例中,在需要向数据分析系统中导入指标时,先在元数据表中添加该指标数据的指标定义,可以包括添加该指标数据的标识、名称、数据类型等用于查询和存储的数据(例如:数据类型用于数据存储格式校验)。The metadata table is a data table for recording indicator metadata, and the identifier of the indicator may be recorded on the metadata table. Metadata such as name, data type, etc. In this embodiment, when the indicator needs to be imported into the data analysis system, the indicator definition of the indicator data is added to the metadata table, which may include adding the identifier, name, data type, and the like of the indicator data for querying and storing. Data (for example: data type for data storage format verification).
步骤S104,在指标数据存储表中,检索未存储数据的数据存储位置,其中,数据存储位置包含指标数据存储表中的列为空。Step S104, in the indicator data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes the column in the indicator data storage table being empty.
步骤S106,建立指标定义与检索到的数据存储位置的映射关系,以得到关联存储位置。Step S106, establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location.
指标数据存储表为记录有各项指标的统计数据的数据表。本申请实施例中,指标数据存储表可以设置为列存储,也可以设置为行存储,即指标数据按数据列存储或者行存储,每一列表示一项指标在不同维度的统计数据,并在指标数据存储表中预先设置未存储指标数据的数据存储位置,例如空行或者空列,以便于在导入指标数据后,将指标数据导入到预先设置的未存储指标数据的数据存储位置中。The indicator data storage table is a data table in which statistical data of various indicators are recorded. In the embodiment of the present application, the indicator data storage table may be set to be column storage, or may be set to row storage, that is, the indicator data is stored in a data column or stored in a row, and each column represents statistical data of an indicator in different dimensions, and is in the indicator. The data storage table is preset with a data storage location where the indicator data is not stored, such as a blank line or an empty column, so that after the indicator data is imported, the indicator data is imported into a data storage location of the preset unstored indicator data.
步骤S108,将指标数据存储到关联存储位置中。In step S108, the indicator data is stored in the associated storage location.
在建立指标定义与检索到的数据存储位置的映射关系之后,即确定指标数据的导入位置,作为关联存储位置,因此,可以将获取的指标数据导入到上述建立映射关系所映射的关联存储位置中。由于本申请实施例在指标数据存储表中预先设置了未存储指标数据的数据存储位置用于导入指标数据,使得导入后的指标数据与数据分析系统中原有的指标数据在同一指标数据存储表中,在进行指标数据查询时,无需将行存储指标转化为列存储,减少了行存储指标转化为列存储的IO性能开销,提高了查询效率。After the mapping relationship between the indicator definition and the retrieved data storage location is established, the import location of the indicator data is determined as the associated storage location. Therefore, the acquired indicator data can be imported into the associated storage location mapped by the above established mapping relationship. . In the embodiment of the present application, the data storage location in which the indicator data is not stored is preset in the indicator data storage table for importing the indicator data, so that the imported indicator data and the original indicator data in the data analysis system are in the same indicator data storage table. When the indicator data is queried, the row storage metrics need not be converted into column storage, which reduces the IO performance overhead of the row storage metrics into column storage, and improves the query efficiency.
根据本申请实施例,在元数据表中,添加指标数据的指标定义;在指标数据存储表中,检索未存储数据的数据存储位置,其中,数据存储位置包含指标数据存储表中的列为空;建立指标定义与检索到的数据存储位置的映射关系,以得到关联存储位置;将指标数据存储到关联存储位置中,在进行指标数据查询时,无需将行存储指标转化为列存储,减少了行存储指标转化为列存储的IO性能开销,提高了查询效率,解决了现有技术中指标数据查询效率低的技术问题。According to the embodiment of the present application, in the metadata table, the indicator definition of the indicator data is added; in the indicator data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes the column in the indicator data storage table is empty Establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location; storing the indicator data in the associated storage location, and eliminating the need to convert the row storage indicator into column storage when performing the indicator data query, reducing The row storage index is converted into the IO performance overhead of the column storage, which improves the query efficiency and solves the technical problem of low efficiency of index data query in the prior art.
作为一种可选的实施方式,在查询在设置为列存储的指标数据存储表中预先设置的空列之前,方法还包括:在指标数据存储表中设置N列空列,将空列作为数据存储位置,其中,0<N≤Max,Max为存储指标数据的数据库所支持的最大值;在数据库中设置指标数据存储表为列存储。As an optional implementation manner, before querying the empty column preset in the indicator data storage table stored in the column, the method further includes: setting an N column empty column in the indicator data storage table, and using the empty column as the data The storage location, where 0 < N ≤ Max, Max is the maximum value supported by the database storing the indicator data; the indicator data storage table is set in the database as the column storage.
本申请实施例中,在数据分析系统中预先存储的指标数据存储表中设置N列空列,其中,N可以从0到Max中任意选择。每一空列可以添加一个对应的标识,用于表示 相应的空列或者空行。如果,将该指标数据存储表设置为列存储,则每一列表示一项指标在不同维度的统计数据,如表4所示;如果该指标数据存储表设置为行存储,则每一行表示一项指标在不同维度的统计数据。In the embodiment of the present application, N columns of empty columns are set in the indicator data storage table stored in advance in the data analysis system, wherein N can be arbitrarily selected from 0 to Max. Each empty column can be added with a corresponding identifier for indicating Corresponding empty or empty lines. If the indicator data storage table is set to column storage, each column represents statistics of an indicator in different dimensions, as shown in Table 4; if the indicator data storage table is set to row storage, each row represents one item The statistics of the indicators in different dimensions.
表4Table 4
维度IDDimension ID 曝光exposure 点击Click 点击率Click rate 预置1Preset 1 ... 预置NPreset N
             
             
作为一种可选的实施方式,建立指标定义与检索到的数据存储位置的映射关系包括:获取检索到的数据存储位置的标识;从元数据表中查询指标定义对应的映射关系列的数据表格;将检索到的数据存储位置的标识存储到数据表格中以建立数据存储位置与指标定义的映射关系,将数据存储位置作为关联存储位置。As an optional implementation manner, establishing a mapping relationship between the indicator definition and the retrieved data storage location includes: obtaining an identifier of the retrieved data storage location; and querying the data table of the mapping relationship column corresponding to the indicator definition from the metadata table The identifier of the retrieved data storage location is stored in the data table to establish a mapping relationship between the data storage location and the indicator definition, and the data storage location is used as the associated storage location.
本申请实施例中,在预置的指标数据存储表中每一数据存储位置设置有与其对应的标识,如表4所示的“预置1”……“预置N”,在导入指标数据过程中,如果确定了导入指标数据的空列,则获取其标识,然后将该标识写入到元数据表中该导入的指标对应的映射关系列的数据表格中,以建立空列与导入的指标之间的映射关系。以空行作为数据存储位置与空列的原理相同,这里不做赘述。In the embodiment of the present application, each data storage location in the preset indicator data storage table is provided with a corresponding identifier, such as “preset 1”... “preset N” shown in Table 4, and the indicator data is imported. During the process, if an empty column of the imported indicator data is determined, the identifier is obtained, and then the identifier is written into the data table of the mapping relationship column corresponding to the imported indicator in the metadata table to establish an empty column and an imported The mapping relationship between indicators. The principle of using blank lines as the data storage location is the same as that of the empty column, and will not be described here.
表5table 5
Figure PCTCN2016102764-appb-000002
Figure PCTCN2016102764-appb-000002
如表4、表5所示,其中,名称为“订单”和“成本”的指标为导入的指标,其中,映射关系列中上述指标对应的空列的标识依次为“预置1”和“预置2”,当将指标数据导入到表4之后,则表5中的上述指标与其指标数据之间存在映射关系。 As shown in Table 4 and Table 5, the indicators whose names are “Order” and “Cost” are imported indicators, and the identifiers of the empty columns corresponding to the above indicators in the mapping relationship column are “Preset 1” and “ Preset 2", when the indicator data is imported into Table 4, there is a mapping relationship between the above indicators in Table 5 and their indicator data.
作为一种可选的实施方式,方法还包括:在接收到用于删除指标数据的删除指令时,删除元数据表中删除指令所指示的指标定义与指标数据存储表中的指标数据的映射关系;将元数据表中记录删除指令所指示的指标定义的元数据标记为冗余。As an optional implementation manner, the method further includes: deleting a mapping relationship between the indicator definition indicated by the deletion instruction in the metadata table and the indicator data in the indicator data storage table when receiving the deletion instruction for deleting the indicator data The metadata defined by the indicator indicated by the record deletion instruction in the metadata table is marked as redundant.
本申请实施例中,当需要删除某个指标数据时,先将删除指令所指示的指标定义与指标数据的映射关系删除,并将元数据表中记录的该指标定义的元数据标记为冗余,这样,数据分析系统在空闲时就会将其删除。In the embodiment of the present application, when a certain indicator data needs to be deleted, the mapping relationship between the indicator definition indicated by the deletion instruction and the indicator data is deleted, and the metadata defined by the indicator recorded in the metadata table is marked as redundant. In this way, the data analysis system will delete it when it is idle.
需要说明的是,本申请实施例中,各示例中的数据仅以广告监测数据为例,本领域技术人员在阅读本申请的说明书之后,可以知晓,本申请实施例的技术方案可以用于各种多指标的数据存储和查询,本申请实施例并没有不当限定。It should be noted that, in the embodiment of the present application, the data in each example is only used as an example of the advertisement monitoring data. After reading the specification of the present application, those skilled in the art may know that the technical solutions of the embodiments of the present application may be used for each The data storage and query of multiple indicators are not unduly limited in the embodiment of the present application.
作为一种可选的实施方式,在将指标数据存储到关联存储位置中之前,上述方法还包括:获取指标数据的数据类型;获取关联存储位置所支持的数据存储类型;根据指标数据的数据类型和关联存储位置所支持的数据存储类型,确定与指标数据的数据类型相匹配的关联存储位置;将指标数据存储到与指标数据的数据类型相匹配的关联存储位置上。这样,通过本发明实施例,可以将数据存储到与其数据类型相匹配的存储位置上。As an optional implementation manner, before the storing the indicator data in the associated storage location, the method further includes: acquiring a data type of the indicator data; acquiring a data storage type supported by the associated storage location; and a data type according to the indicator data. And the data storage type supported by the associated storage location, determining an associated storage location that matches the data type of the indicator data; storing the indicator data to an associated storage location that matches the data type of the indicator data. Thus, with embodiments of the present invention, data can be stored to a storage location that matches its data type.
根据本申请实施例,还提供了一种数据查询方法的方法实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。本申请实施例的数据查询方法可以是基于本申请实施例的数据存储方法所存储和导入的指标数据进行查询,也即是本申请实施例的数据查询方法可以用于查询本申请实施例的数据存储方法存储和导入的指标数据。According to an embodiment of the present application, there is also provided a method embodiment of a data query method, and it should be noted that the steps shown in the flowchart of the drawing may be executed in a computer system such as a set of computer executable instructions, and Although the logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein. The data query method in the embodiment of the present application may be queried based on the indicator data stored and imported by the data storage method in the embodiment of the present application, that is, the data query method in the embodiment of the present application may be used to query the data in the embodiment of the present application. The storage method stores and imports the indicator data.
如图2所示,本申请实施例的数据查询方法包括:As shown in FIG. 2, the data query method in this embodiment of the present application includes:
步骤S202,接收用于查询指标数据的查询指令。Step S202, receiving a query instruction for querying indicator data.
步骤S204,从元数据表中确定查询指令所指示的指标定义,确定查询指令所指示的指标定义与指标数据存储表中的指标数据的映射关系。Step S204: Determine an indicator definition indicated by the query instruction from the metadata table, and determine a mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table.
步骤S206,利用映射关系从指标数据存储表中查询查询指令所指示的指标数据。Step S206, querying, by using the mapping relationship, the indicator data indicated by the query instruction from the indicator data storage table.
在采用本申请实施例的数据存储方法导入指标数据(具体参见本申请实施例的数据存储方法的描述)之后,导入的指标数据与原有的指标数据均存储在指标数据存储表中。After the indicator data is imported by using the data storage method of the embodiment of the present application (refer to the description of the data storage method in the embodiment of the present application), the imported indicator data and the original indicator data are stored in the indicator data storage table.
在接收到查询指标数据的查询指令之后,结合元数据表和指标数据存储表,从指 标数据存储表中直接查询相应的指标数据。由于本申请实施例在指标数据存储表中预先设置了数据存储位置用于导入指标数据,使得导入后的指标数据与数据分析系统中原有的指标数据在同一指标数据存储表中,在进行指标数据查询时,无需将行存储指标转化为列存储,减少了行存储指标转化为列存储的IO性能开销,提高了查询效率。After receiving the query instruction for querying the indicator data, combining the metadata table and the indicator data storage table, the reference finger The corresponding indicator data is directly queried in the standard data storage table. In the embodiment of the present application, the data storage location is preset in the indicator data storage table for importing the indicator data, so that the imported indicator data and the original indicator data in the data analysis system are in the same indicator data storage table, and the indicator data is performed. When querying, there is no need to convert row storage metrics into column storage, which reduces the IO performance overhead of row storage metrics converted into column storage and improves query efficiency.
例如,以上述表4、表5为例,在进行指标数据查询时,查询语句如下:For example, taking Table 4 and Table 5 above as examples, when querying indicator data, the query statement is as follows:
Figure PCTCN2016102764-appb-000003
Figure PCTCN2016102764-appb-000003
由此得出,本申请实施例的指标数据查询过程中,只需要到元数据表中查询指标所在的列,直接进行分组查询,性能得到了极大提升。Therefore, in the index data query process of the embodiment of the present application, only the column in which the index is queried in the metadata table is needed, and the group query is directly performed, and the performance is greatly improved.
本申请实施例还提供了一种数据存储装置,该装置可以用于执行本申请实施例的数据存储方法,如图3所示,该装置包括:添加单元301、检索单元303,建立单元305和导入单元307。The embodiment of the present application further provides a data storage device, which can be used to execute the data storage method of the embodiment of the present application. As shown in FIG. 3, the device includes: an adding unit 301, a retrieving unit 303, an establishing unit 305, and Import unit 307.
添加单元301用于在元数据表中,添加指标数据的指标定义。The adding unit 301 is configured to add an indicator definition of the indicator data in the metadata table.
其中,元数据表为记录指标元数据的数据表,该元数据表上可以记载指标的标识、名称、数据类型等元数据。本实施例中,在需要向数据分析系统中导入指标时,先在元数据表中添加该指标数据的指标定义,可以包括添加该指标数据的标识、名称、数据类型等用于查询和存储的数据(例如:数据类型用于数据存储格式校验)。The metadata table is a data table for recording indicator metadata, and metadata such as an identifier, a name, and a data type of the indicator may be recorded on the metadata table. In this embodiment, when the indicator needs to be imported into the data analysis system, the indicator definition of the indicator data is added to the metadata table, which may include adding the identifier, name, data type, and the like of the indicator data for querying and storing. Data (for example: data type for data storage format verification).
检索单元303用于在指标数据存储表中,检索未存储数据的数据存储位置,其中,数据存储位置包含指标数据存储表中的列为空。The retrieval unit 303 is configured to retrieve, in the indicator data storage table, a data storage location of the unstored data, wherein the data storage location includes a column in the indicator data storage table that is empty.
建立单元305用于建立指标定义与数据存储位置的映射关系,以得到关联存储位置。The establishing unit 305 is configured to establish a mapping relationship between the indicator definition and the data storage location to obtain an associated storage location.
指标数据存储表为记录有各项指标的统计数据的数据表。本申请实施例中,指标 数据存储表可以设置为列存储,也可以设置为行存储,即指标数据按数据列存储或者行存储,每一列表示一项指标在不同维度的统计数据,并在指标数据存储表中预先设置未存储指标数据的数据存储位置,例如空行,以便于在导入指标数据后,将指标数据导入到预先设置的未存储指标数据的数据存储位置中。The indicator data storage table is a data table in which statistical data of various indicators are recorded. In the embodiment of the present application, the indicator The data storage table can be set to column storage or set to row storage, that is, the indicator data is stored in a data column or stored in a row, and each column represents statistical data of an indicator in different dimensions, and is preset in the indicator data storage table. The data storage location of the indicator data, such as a blank line, is stored, so that after the indicator data is imported, the indicator data is imported into a data storage location of the preset unstored indicator data.
导入单元307用于将指标数据存储到关联存储位置中。The import unit 307 is configured to store the indicator data in an associated storage location.
在建立指标定义与检索到的数据存储位置的映射关系之后,即确定指标数据的导入位置,作为关联存储位置,因此,可以将获取的指标数据导入到上述建立映射关系所映射的关联存储位置中。由于本申请实施例在指标数据存储表中预先设置了未存储指标数据的数据存储位置用于导入指标数据,使得导入后的指标数据与数据分析系统中原有的指标数据在同一指标数据存储表中,在进行指标数据查询时,无需将行存储指标转化为列存储,减少了行存储指标转化为列存储的IO性能开销,提高了查询效率。After the mapping relationship between the indicator definition and the retrieved data storage location is established, the import location of the indicator data is determined as the associated storage location. Therefore, the acquired indicator data can be imported into the associated storage location mapped by the above established mapping relationship. . In the embodiment of the present application, the data storage location in which the indicator data is not stored is preset in the indicator data storage table for importing the indicator data, so that the imported indicator data and the original indicator data in the data analysis system are in the same indicator data storage table. When the indicator data is queried, the row storage metrics need not be converted into column storage, which reduces the IO performance overhead of the row storage metrics into column storage, and improves the query efficiency.
根据本申请实施例,在元数据表中,添加指标数据的指标定义;在指标数据存储表中,检索未存储数据的数据存储位置,其中,数据存储位置包含指标数据存储表中的列为空;建立指标定义与检索到的数据存储位置的映射关系,以得到关联存储位置;将指标数据存储到关联存储位置中,在进行指标数据查询时,无需将行存储指标转化为列存储,减少了行存储指标转化为列存储的IO性能开销,提高了查询效率,解决了现有技术中指标数据查询效率低的技术问题。According to the embodiment of the present application, in the metadata table, the indicator definition of the indicator data is added; in the indicator data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes the column in the indicator data storage table is empty Establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location; storing the indicator data in the associated storage location, and eliminating the need to convert the row storage indicator into column storage when performing the indicator data query, reducing The row storage index is converted into the IO performance overhead of the column storage, which improves the query efficiency and solves the technical problem of low efficiency of index data query in the prior art.
作为一种可选的实施方式,装置还包括:第一设置单元,用于在检索未存储数据的数据存储位置之前,在指标数据存储表中设置N列空列,将空列或者空行作为数据存储位置,其中,0<N≤Max,Max为存储指标数据的数据库所支持的最大值;第二设置单元,用于在数据库中设置指标数据存储表为列存储。As an optional implementation manner, the apparatus further includes: a first setting unit, configured to set an N column empty column in the indicator data storage table, and use an empty column or a blank line as a data storage location for retrieving data that is not stored. The data storage location, where 0<N≤Max, Max is the maximum value supported by the database storing the indicator data; and the second setting unit is configured to set the indicator data storage table in the database as the column storage.
本申请实施例中,在数据分析系统中预先存储的指标数据存储表中设置N列空列,其中,N可以从0到Max中任意选择。每一空列可以添加一个对应的标识,用于表示相应的空列。如果,将该指标数据存储表设置为列存储,则每一列表示一项指标在不同维度的统计数据,如表4所示;如果该指标数据存储表设置为行存储,则每一行表示一项指标在不同维度的统计数据。In the embodiment of the present application, N columns of empty columns are set in the indicator data storage table stored in advance in the data analysis system, wherein N can be arbitrarily selected from 0 to Max. Each empty column can be added with a corresponding identifier to indicate the corresponding empty column. If the indicator data storage table is set to column storage, each column represents statistics of an indicator in different dimensions, as shown in Table 4; if the indicator data storage table is set to row storage, each row represents one item The statistics of the indicators in different dimensions.
作为一种可选的实施方式,建立单元包括:获取模块,用于获取检索到的数据存储位置的标识;查询模块,用于从元数据表中查询指标定义对应的映射关系列的数据表格;写入模块,用于将检索到的数据存储位置的标识存储到数据表格中以建立数据存储位置与指标定义的映射关系,将数据存储位置作为关联存储位置。As an optional implementation manner, the establishing unit includes: an obtaining module, configured to obtain an identifier of the retrieved data storage location; and a query module, configured to query, from the metadata table, a data table of the mapping relationship column corresponding to the index definition; The writing module is configured to store the identifier of the retrieved data storage location into the data table to establish a mapping relationship between the data storage location and the indicator definition, and use the data storage location as the associated storage location.
本申请实施例中,在预置的指标数据存储表中每一数据存储位置设置有与其对应 的标识,如表4所示的“预置1”……“预置N”,在导入指标数据过程中,如果确定了导入指标数据的空列,则获取其标识,然后将该标识写入到元数据表中该导入的指标对应的映射关系列的数据表格中,以建立空列与导入的指标之间的映射关系。以空行作为数据存储位置与空列的原理相同,这里不做赘述。In the embodiment of the present application, each data storage location in the preset indicator data storage table is set corresponding thereto The identifier, as shown in Table 4, "Preset 1" ... "Preset N", in the process of importing the indicator data, if the empty column of the index data is determined, the identifier is obtained, and then the identifier is written. In the data table of the mapping relationship column corresponding to the imported indicator in the metadata table, a mapping relationship between the empty column and the imported indicator is established. The principle of using blank lines as the data storage location is the same as that of the empty column, and will not be described here.
如表4、表5所示,其中,名称为“订单”和“成本”的指标为导入的指标,其中,映射关系列中上述指标对应的空列的标识依次为“预置1”和“预置2”,当将指标数据导入到表4之后,则表5中的上述指标与其指标数据之间存在映射关系。As shown in Table 4 and Table 5, the indicators whose names are “Order” and “Cost” are imported indicators, and the identifiers of the empty columns corresponding to the above indicators in the mapping relationship column are “Preset 1” and “ Preset 2", when the indicator data is imported into Table 4, there is a mapping relationship between the above indicators in Table 5 and their indicator data.
作为一种可选的实施方式,装置还包括:删除单元,用于在接收到用于删除指标数据的删除指令时,删除元数据表中删除指令所指示的指标定义与指标数据存储表中的指标数据的映射关系;标记单元,用于将元数据表中记录删除指令所指示的指标定义的元数据标记为冗余。As an optional implementation manner, the device further includes: a deleting unit, configured to delete the indicator definition and the indicator data storage table indicated by the deletion instruction in the metadata table when receiving the deletion instruction for deleting the indicator data A mapping relationship of the indicator data; the marking unit is configured to mark the metadata defined by the indicator indicated by the record deletion instruction in the metadata table as redundant.
本申请实施例中,当需要删除某个指标数据时,先将删除指令所指示的指标定义与指标数据的映射关系删除,并将元数据表中记录的该指标定义的元数据标记为冗余,这样,数据分析系统在空闲时就会将其删除。In the embodiment of the present application, when a certain indicator data needs to be deleted, the mapping relationship between the indicator definition indicated by the deletion instruction and the indicator data is deleted, and the metadata defined by the indicator recorded in the metadata table is marked as redundant. In this way, the data analysis system will delete it when it is idle.
作为一种可选的实施方式,上述装置还包括:第一获取单元,用于获取指标数据的数据类型;第二获取单元,用于获取关联存储位置所支持的数据存储类型;第一确定单元,用于根据指标数据的数据类型和关联存储位置所支持的数据存储类型,确定与指标数据的数据类型相匹配的关联存储位置;存储单元,用于将指标数据存储到与指标数据的数据类型相匹配的关联存储位置上。As an optional implementation manner, the foregoing apparatus further includes: a first acquiring unit, configured to acquire a data type of the indicator data; and a second acquiring unit, configured to acquire a data storage type supported by the associated storage location; And determining, according to the data type of the indicator data and the data storage type supported by the associated storage location, an associated storage location that matches the data type of the indicator data; and a storage unit configured to store the indicator data to the data type of the indicator data Match the associated storage location.
需要说明的是本申请实施例的数据存储装置还可以包括:元数据存储单元,用于添加指标的定义,建立指标与预置表列之间的映射关系,以及存储其它元数据信息,用于查询和存储(例如:数据类型用于数据存储格式校验);以及数据单元,用于更新指标数据存储表中的一列数据或者一个单元格数据(包括新增数据或更新数据),删除指标数据存储表中的一列数据或者一个单元格数据,并支持批量操作,以提升操作性能,还具有事务支持。其中,元数据存储单元相当于本申请实施例中的添加单元、建立单元,数据单元相当于检索单元、导入单元、删除单元、标记单元等。It should be noted that the data storage device of the embodiment of the present application may further include: a metadata storage unit, configured to add a definition of the indicator, establish a mapping relationship between the indicator and the preset table column, and store other metadata information, and use Query and storage (for example: data type for data storage format check); and data unit for updating a column of data or a cell data (including new data or updated data) in the indicator data storage table, and deleting the indicator data Stores a column of data or a cell of data in a table and supports batch operations to improve operational performance and transaction support. The metadata storage unit is equivalent to the adding unit and the establishing unit in the embodiment of the present application, and the data unit is equivalent to the searching unit, the import unit, the deleting unit, the marking unit, and the like.
所述数据存储装置包括处理器和存储器,上述添加单元301、检索单元303,建立单元305和导入单元307等均作为程序单元存储在存储器中,由处理器执行存储在存储器中的上述程序单元。The data storage device includes a processor and a memory, and the adding unit 301, the retrieving unit 303, the establishing unit 305, the importing unit 307, and the like are each stored as a program unit in a memory, and the program unit stored in the memory is executed by the processor.
处理器中包含内核,由内核去存储器中调取相应的程序单元。内核可以设置一个或以上,通过调整内核参数来导入指标数据。 The processor contains a kernel, and the kernel removes the corresponding program unit from the memory. The kernel can be set to one or more, and the indicator data can be imported by adjusting the kernel parameters.
存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM),存储器包括至少一个存储芯片。The memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory (flash RAM), the memory including at least one Memory chip.
本申请还提供了一种计算机程序产品的实施例,当在数据处理设备上执行时,适于执行初始化有如下方法步骤的程序代码:在元数据表中,添加指标数据的指标定义;在指标数据存储表中,检索未存储数据的数据存储位置,其中,数据存储位置包含指标数据存储表中的列为空;建立指标定义与检索到的数据存储位置的映射关系,以得到关联存储位置;将指标数据存储到关联存储位置中。The present application also provides an embodiment of a computer program product, when executed on a data processing device, adapted to perform a program code that initializes a method step of: adding an indicator definition of the indicator data in the metadata table; In the data storage table, the data storage location of the unstored data is retrieved, wherein the data storage location includes a column in the indicator data storage table is empty; and a mapping relationship between the indicator definition and the retrieved data storage location is established to obtain an associated storage location; Store metric data in an associated storage location.
本申请实施例还提供了一种数据查询装置,该装置可以用于执行本申请实施例的数据查询方法,如图4所示,该装置包括:接收单元401、第二确定单元403和查询单元405。The embodiment of the present application further provides a data query device, which can be used to perform the data query method of the embodiment of the present application. As shown in FIG. 4, the device includes: a receiving unit 401, a second determining unit 403, and a query unit. 405.
接收单元401用于接收用于查询指标数据的查询指令。The receiving unit 401 is configured to receive a query instruction for querying the indicator data.
第二确定单元403用于从元数据表中确定查询指令所指示的指标定义,确定查询指令所指示的指标定义与指标数据存储表中的指标数据的映射关系。The second determining unit 403 is configured to determine, from the metadata table, the indicator definition indicated by the query instruction, and determine a mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table.
查询单元405用于利用映射关系从指标数据存储表中查询查询指令所指示的指标数据。The query unit 405 is configured to query the indicator data indicated by the query instruction from the indicator data storage table by using the mapping relationship.
在采用本申请实施例的数据存储方法导入指标数据(具体参见本申请实施例的数据存储方法的描述)之后,导入的指标数据与原有的指标数据均存储在指标数据存储表中。After the indicator data is imported by using the data storage method of the embodiment of the present application (refer to the description of the data storage method in the embodiment of the present application), the imported indicator data and the original indicator data are stored in the indicator data storage table.
在接收到查询指标数据的查询指令之后,结合元数据表和指标数据存储表,从指标数据存储表中直接查询相应的指标数据。由于本申请实施例在指标数据存储表中预先设置了数据存储位置用于导入指标数据,使得导入后的指标数据与数据分析系统中原有的指标数据在同一指标数据存储表中,在进行指标数据查询时,无需将行存储指标转化为列存储,减少了行存储指标转化为列存储的IO性能开销,提高了查询效率。After receiving the query instruction for querying the indicator data, combining the metadata table and the indicator data storage table, directly querying the corresponding indicator data from the indicator data storage table. In the embodiment of the present application, the data storage location is preset in the indicator data storage table for importing the indicator data, so that the imported indicator data and the original indicator data in the data analysis system are in the same indicator data storage table, and the indicator data is performed. When querying, there is no need to convert row storage metrics into column storage, which reduces the IO performance overhead of row storage metrics converted into column storage and improves query efficiency.
所述数据查询装置包括处理器和存储器,上述接收单元401、第二确定单元403和查询单元405等均作为程序单元存储在存储器中,由处理器执行存储在存储器中的上述程序单元。The data querying device includes a processor and a memory, and the receiving unit 401, the second determining unit 403, the query unit 405, and the like are all stored as a program unit in a memory, and the program unit stored in the memory is executed by the processor.
处理器中包含内核,由内核去存储器中调取相应的程序单元。内核可以设置一个或以上,通过调整内核参数来查询指标数据。The processor contains a kernel, and the kernel removes the corresponding program unit from the memory. The kernel can set one or more and query the indicator data by adjusting the kernel parameters.
存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/ 或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM),存储器包括至少一个存储芯片。The memory may include non-persistent memory, random access memory (RAM) and/or in a computer readable medium. Or a form of non-volatile memory, such as a read only memory (ROM) or a flash memory (flash RAM), the memory including at least one memory chip.
本申请还提供了一种计算机程序产品的实施例,当在数据处理设备上执行时,适于执行初始化有如下方法步骤的程序代码:接收用于查询指标数据的查询指令,从元数据表中确定查询指令所指示的指标定义,确定查询指令所指示的指标定义与指标数据存储表中的指标数据的映射关系,利用映射关系从指标数据存储表中查询查询指令所指示的指标数据。The present application also provides an embodiment of a computer program product, when executed on a data processing device, adapted to perform program code initialization having the following method steps: receiving a query instruction for querying indicator data, from a metadata table Determining the indicator definition indicated by the query instruction, determining a mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table, and using the mapping relationship to query the indicator data indicated by the query instruction from the indicator data storage table.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments of the present application are merely for the description, and do not represent the advantages and disadvantages of the embodiments.
在本申请的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments of the present application, the descriptions of the various embodiments are different, and the parts that are not detailed in a certain embodiment can be referred to the related descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的技术内容,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,可以为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed technical contents may be implemented in other manners. The device embodiments described above are only schematic. For example, the division of the unit may be a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。 The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application, in essence or the contribution to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium. A number of instructions are included to cause a computer device (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .
以上所述仅是本申请的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。 The above description is only a preferred embodiment of the present application, and it should be noted that those skilled in the art can also make several improvements and retouchings without departing from the principles of the present application. It should be considered as the scope of protection of this application.

Claims (12)

  1. 一种数据存储方法,其中,包括:A data storage method, comprising:
    在元数据表中,添加指标数据的指标定义;In the metadata table, add the indicator definition of the indicator data;
    在指标数据存储表中,检索未存储数据的数据存储位置,其中,所述数据存储位置包含所述指标数据存储表中的列为空;Retrieving, in the indicator data storage table, a data storage location of the unstored data, wherein the data storage location includes a column in the indicator data storage table that is empty;
    建立所述指标定义与检索到的数据存储位置的映射关系,以得到关联存储位置;Establishing a mapping relationship between the indicator definition and the retrieved data storage location to obtain an associated storage location;
    将所述指标数据存储到所述关联存储位置中。The indicator data is stored in the associated storage location.
  2. 根据权利要求1所述的方法,其中,建立所述指标定义与检索到的数据存储位置的映射关系包括:The method of claim 1, wherein establishing a mapping relationship between the indicator definition and the retrieved data storage location comprises:
    获取检索到的数据存储位置的标识;Obtaining an identifier of the retrieved data storage location;
    从所述元数据表中查询所述指标定义对应的映射关系列的数据表格;Querying, from the metadata table, a data table of a mapping relationship column corresponding to the indicator definition;
    将检索到的数据存储位置的标识存储到所述数据表格中以建立所述数据存储位置与所述指标定义的映射关系,将所述数据存储位置作为所述关联存储位置。And storing an identifier of the retrieved data storage location into the data table to establish a mapping relationship between the data storage location and the indicator definition, and using the data storage location as the associated storage location.
  3. 根据权利要求1所述的方法,其中,在检索未存储数据的数据存储位置之前,所述方法还包括:The method of claim 1 wherein prior to retrieving the data storage location where the data is not stored, the method further comprises:
    在所述指标数据存储表中设置N列空列,将所述空列作为所述数据存储位置,其中,0<N≤Max,所述Max为存储指标数据的数据库所支持的最大值;Setting N columns of empty columns in the indicator data storage table, and using the empty columns as the data storage location, where 0<N≤Max, the Max is a maximum value supported by a database storing index data;
    在所述数据库中设置所述指标数据存储表为列存储。The indicator data storage table is set in the database as a column storage.
  4. 根据权利要求1所述的方法,其中,所述方法还包括:The method of claim 1 wherein the method further comprises:
    在接收到用于删除指标数据的删除指令时,删除所述元数据表中所述删除指令所指示的指标定义与所述指标数据存储表中的指标数据的映射关系;And when the deletion instruction for deleting the indicator data is received, deleting a mapping relationship between the indicator definition indicated by the deletion instruction in the metadata table and the indicator data in the indicator data storage table;
    将所述元数据表中记录所述删除指令所指示的指标定义的元数据标记为冗余。The metadata in the metadata table in which the indicator definition indicated by the deletion instruction is recorded is marked as redundant.
  5. 根据权利要求1所述的方法,其中,在将所述指标数据存储到所述关联存储位置中之前,所述方法还包括:The method of claim 1 wherein before the storing the indicator data in the associated storage location, the method further comprises:
    获取所述指标数据的数据类型; Obtaining a data type of the indicator data;
    获取所述关联存储位置所支持的数据存储类型;Obtaining a data storage type supported by the associated storage location;
    根据所述指标数据的数据类型和所述关联存储位置所支持的数据存储类型,确定与所述指标数据的数据类型相匹配的关联存储位置;Determining an associated storage location that matches a data type of the indicator data according to a data type of the indicator data and a data storage type supported by the associated storage location;
    将所述指标数据存储到与所述指标数据的数据类型相匹配的关联存储位置上。The indicator data is stored in an associated storage location that matches the data type of the indicator data.
  6. 一种数据查询方法,其中,包括:A data query method, including:
    接收用于查询指标数据的查询指令;Receiving a query instruction for querying indicator data;
    从元数据表中确定所述查询指令所指示的指标定义,确定所述查询指令所指示的指标定义与指标数据存储表中的指标数据的映射关系;Determining, from the metadata table, the indicator definition indicated by the query instruction, determining a mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table;
    利用所述映射关系从所述指标数据存储表中查询所述查询指令所指示的指标数据。The indicator data indicated by the query instruction is queried from the indicator data storage table by using the mapping relationship.
  7. 一种数据存储装置,其中,包括:A data storage device, comprising:
    添加单元,用于在元数据表中,添加指标数据的指标定义;Add a unit for adding a metric definition of the indicator data in the metadata table;
    检索单元,用于在指标数据存储表中,检索未存储数据的数据存储位置,其中,所述数据存储位置包含所述指标数据存储表中的列为空;a retrieval unit, configured to retrieve, in the indicator data storage table, a data storage location of the unstored data, wherein the data storage location includes a column in the indicator data storage table that is empty;
    建立单元,用于建立所述指标定义与所述数据存储位置的映射关系,以得到关联存储位置;以及Establishing a unit, configured to establish a mapping relationship between the indicator definition and the data storage location to obtain an associated storage location;
    导入单元,用于将所述指标数据存储到所述关联存储位置中。And an importing unit, configured to store the indicator data into the associated storage location.
  8. 根据权利要求7所述的装置,其中,所述建立单元包括:The apparatus of claim 7, wherein the establishing unit comprises:
    获取模块,用于获取检索到的数据存储位置的标识;An obtaining module, configured to obtain an identifier of the retrieved data storage location;
    查询模块,用于从所述元数据表中查询所述指标定义对应的映射关系列的数据表格;a query module, configured to query, from the metadata table, a data table of a mapping relationship column corresponding to the indicator definition;
    写入模块,用于将检索到的数据存储位置的标识存储到所述数据表格中以建立所述数据存储位置与所述指标定义的映射关系,将所述数据存储位置作为所述关联存储位置。a writing module, configured to store an identifier of the retrieved data storage location into the data table to establish a mapping relationship between the data storage location and the indicator definition, and use the data storage location as the associated storage location .
  9. 根据权利要求7所述的装置,其中,所述装置还包括:The apparatus of claim 7 wherein said apparatus further comprises:
    第一设置单元,用于在检索未存储数据的数据存储位置之前,在所述指标数据存储表中设置N列空列,将所述空列作为所述数据存储位置,其中,0<N≤Max, 所述Max为存储指标数据的数据库所支持的最大值;a first setting unit, configured to set an N column of empty columns in the indicator data storage table before using the data storage location of the unstored data, and use the empty column as the data storage location, where 0<N≤ Max, The Max is a maximum value supported by a database storing indicator data;
    第二设置单元,用于在所述数据库中设置所述指标数据存储表为列存储。And a second setting unit, configured to set the indicator data storage table in the database as a column storage.
  10. 根据权利要求7所述的装置,其中,所述装置还包括:The apparatus of claim 7 wherein said apparatus further comprises:
    删除单元,用于在接收到用于删除指标数据的删除指令时,删除所述元数据表中所述删除指令所指示的指标定义与所述指标数据存储表中的指标数据的映射关系;a deleting unit, configured to delete a mapping relationship between the indicator definition indicated by the deletion instruction in the metadata table and the indicator data in the indicator data storage table when receiving the deletion instruction for deleting the indicator data;
    标记单元,用于将所述元数据表中记录所述删除指令所指示的指标定义的元数据标记为冗余。a marking unit, configured to mark metadata in the metadata table that records the indicator definition indicated by the deletion instruction as redundant.
  11. 根据权利要求7所述的装置,其中,所述装置还包括:The apparatus of claim 7 wherein said apparatus further comprises:
    第一获取单元,用于在将所述指标数据存储到所述关联存储位置中之前,获取所述指标数据的数据类型;a first acquiring unit, configured to acquire a data type of the indicator data before storing the indicator data in the associated storage location;
    第二获取单元,用于获取所述关联存储位置所支持的数据存储类型;a second acquiring unit, configured to acquire a data storage type supported by the associated storage location;
    第一确定单元,用于根据所述指标数据的数据类型和所述关联存储位置所支持的数据存储类型,确定与所述指标数据的数据类型相匹配的关联存储位置;a first determining unit, configured to determine, according to a data type of the indicator data and a data storage type supported by the associated storage location, an associated storage location that matches a data type of the indicator data;
    存储单元,用于将所述指标数据存储到与所述指标数据的数据类型相匹配的关联存储位置上。And a storage unit, configured to store the indicator data to an associated storage location that matches a data type of the indicator data.
  12. 一种数据查询装置,其中,包括:A data query device, comprising:
    接收单元,用于接收用于查询指标数据的查询指令;a receiving unit, configured to receive a query instruction for querying indicator data;
    第二确定单元,用于从元数据表中确定所述查询指令所指示的指标定义,确定所述查询指令所指示的指标定义与指标数据存储表中的指标数据的映射关系;a second determining unit, configured to determine, from the metadata table, the indicator definition indicated by the query instruction, and determine a mapping relationship between the indicator definition indicated by the query instruction and the indicator data in the indicator data storage table;
    查询单元,用于利用所述映射关系从所述指标数据存储表中查询所述查询指令所指示的指标数据。 And a query unit, configured to query, from the indicator data storage table, the indicator data indicated by the query instruction by using the mapping relationship.
PCT/CN2016/102764 2015-10-30 2016-10-20 Data storage method and apparatus and data query method and apparatus WO2017071525A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510729753.0A CN106649368A (en) 2015-10-30 2015-10-30 Data storage method and device and data query method and device
CN201510729753.0 2015-10-30

Publications (1)

Publication Number Publication Date
WO2017071525A1 true WO2017071525A1 (en) 2017-05-04

Family

ID=58629833

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/102764 WO2017071525A1 (en) 2015-10-30 2016-10-20 Data storage method and apparatus and data query method and apparatus

Country Status (2)

Country Link
CN (1) CN106649368A (en)
WO (1) WO2017071525A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111291037A (en) * 2018-11-22 2020-06-16 中国移动通信集团重庆有限公司 Data storage and query method, device, equipment and computer storage medium
CN113422796A (en) * 2021-05-06 2021-09-21 北京沃东天骏信息技术有限公司 Information processing method and device and storage medium
CN113535734A (en) * 2021-07-26 2021-10-22 安徽容知日新科技股份有限公司 Data storage method, data query method and computing device

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108021618B (en) * 2017-11-13 2020-10-16 北京天元创新科技有限公司 Data query method and system
CN108829897A (en) * 2018-07-03 2018-11-16 沈文策 Date storage method and data-storage system
CN112860696A (en) * 2021-02-07 2021-05-28 中国邮政储蓄银行股份有限公司 Data query method and device and data query model

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101320388A (en) * 2008-07-18 2008-12-10 金蝶软件(中国)有限公司 Method and apparatus for filtering documents according to documents state
US7689631B2 (en) * 2005-05-31 2010-03-30 Sap, Ag Method for utilizing audience-specific metadata
CN104376042A (en) * 2014-10-11 2015-02-25 武汉天量数据技术有限公司 Method and system for acquiring test questions from test question database
CN104850565A (en) * 2014-02-19 2015-08-19 北京京东尚科信息技术有限公司 Metadata management method based on K-V storage system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7689631B2 (en) * 2005-05-31 2010-03-30 Sap, Ag Method for utilizing audience-specific metadata
CN101320388A (en) * 2008-07-18 2008-12-10 金蝶软件(中国)有限公司 Method and apparatus for filtering documents according to documents state
CN104850565A (en) * 2014-02-19 2015-08-19 北京京东尚科信息技术有限公司 Metadata management method based on K-V storage system
CN104376042A (en) * 2014-10-11 2015-02-25 武汉天量数据技术有限公司 Method and system for acquiring test questions from test question database

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111291037A (en) * 2018-11-22 2020-06-16 中国移动通信集团重庆有限公司 Data storage and query method, device, equipment and computer storage medium
CN113422796A (en) * 2021-05-06 2021-09-21 北京沃东天骏信息技术有限公司 Information processing method and device and storage medium
CN113535734A (en) * 2021-07-26 2021-10-22 安徽容知日新科技股份有限公司 Data storage method, data query method and computing device
CN113535734B (en) * 2021-07-26 2023-07-07 安徽容知日新科技股份有限公司 Data storage method, data query method and computing device

Also Published As

Publication number Publication date
CN106649368A (en) 2017-05-10

Similar Documents

Publication Publication Date Title
WO2017071525A1 (en) Data storage method and apparatus and data query method and apparatus
US10747762B2 (en) Automatic generation of sub-queries
CN107016001B (en) Data query method and device
US8862566B2 (en) Systems and methods for intelligent parallel searching
JP6434154B2 (en) Identifying join relationships based on transaction access patterns
US9940360B2 (en) Streaming optimized data processing
CN107301214B (en) Data migration method and device in HIVE and terminal equipment
JP2007506191A5 (en)
US9600559B2 (en) Data processing for database aggregation operation
US10235400B2 (en) Database keying with encoded filter attributes
US11567999B2 (en) Using a B-tree to store graph information in a database
CN106033455B (en) Method and equipment for processing user operation information
JPWO2019168599A5 (en)
CN107735781B (en) Method and device for storing query result and computing equipment
CN106933903B (en) Storage method and device applied to distributed storage
CN115858471A (en) Service data change recording method, device, computer equipment and medium
TWI547888B (en) A method of recording user information and a search method and a server
US20170004537A1 (en) Methods and apparatus to estimate a number of actual mobile devices
CN114564501A (en) Database data storage and query methods, devices, equipment and medium
CN112632115A (en) BI-based data query method and system
CN114185890B (en) Database retrieval method and device, storage medium and electronic equipment
CN107861956B (en) Method and device for inquiring data record of bayonet passing vehicle
CN108241679B (en) Data processing method and device
CN111581220A (en) Storage and retrieval method, device, equipment and storage medium for time series data
CN112131215A (en) Bottom-up database information acquisition method and device

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: 16858960

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16858960

Country of ref document: EP

Kind code of ref document: A1