CN108073595B - A method and device for realizing data update and snapshot in OLAP database - Google Patents

A method and device for realizing data update and snapshot in OLAP database Download PDF

Info

Publication number
CN108073595B
CN108073595B CN201610991953.8A CN201610991953A CN108073595B CN 108073595 B CN108073595 B CN 108073595B CN 201610991953 A CN201610991953 A CN 201610991953A CN 108073595 B CN108073595 B CN 108073595B
Authority
CN
China
Prior art keywords
row
column
data table
snapshot
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201610991953.8A
Other languages
Chinese (zh)
Other versions
CN108073595A (en
Inventor
廖松博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201610991953.8A priority Critical patent/CN108073595B/en
Publication of CN108073595A publication Critical patent/CN108073595A/en
Application granted granted Critical
Publication of CN108073595B publication Critical patent/CN108073595B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/283Multi-dimensional databases or data warehouses, e.g. MOLAP or ROLAP

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种在OLAP数据库实现数据更新的方法及装置,该方法包括:在数据表中增加行标识列以及时间戳列,行标识列用于记录数据表中各行的行标识,时间戳列用于记录数据表中各行的修改时间;当接收到修改指令时,在数据表中确定待修改行;根据修改指令对待修改行进行修改并在待修改行的时间戳列写入当前修改时间,生成第一新增行;将第一新增行插入数据表中;当接收到读取数据指令时,根据读取数据指令在数据表中获得至少一个结果行,在至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将结果表中去除行标识列以及时间戳列的部分返回给用户。本发明还公开了一种在OLAP数据库实现数据快照的方法及装置。

Figure 201610991953

The invention discloses a method and a device for realizing data update in an OLAP database. The method includes: adding a row identification column and a timestamp column in a data table, the row identification column is used to record the row identification of each row in the data table, and the timestamp The column is used to record the modification time of each row in the data table; when a modification instruction is received, the row to be modified is determined in the data table; the row to be modified is modified according to the modification instruction and the current modification time is written in the timestamp column of the row to be modified , generate the first new row; insert the first new row into the data table; when receiving the read data command, obtain at least one result row in the data table according to the read data command, and fetch at least one result row The row with the latest modification time corresponding to each row identifier forms a result table, and the part of the result table that removes the row identifier column and the timestamp column is returned to the user. The invention also discloses a method and a device for realizing data snapshot in the OLAP database.

Figure 201610991953

Description

一种在OLAP数据库实现数据更新和快照的方法及装置A method and device for realizing data update and snapshot in OLAP database

技术领域technical field

本发明涉及数据库领域,具体涉及一种在OLAP数据库实现数据更新和快照的方法及装置。The invention relates to the field of databases, in particular to a method and device for implementing data update and snapshot in an OLAP database.

背景技术Background technique

在传统的软件开发中,单机数据库(例如Oracle数据库、SQL Server数据库等)在数据存储和数据计算中扮演着极其关键的作用,但传统单机数据库在存储和计算上无法实现横向扩展,即不能通过增加硬件的方式来存储、计算更多的数据,所以在处理海量数据时就捉襟见肘了。因此,出现了分布式的关系型数据仓库,OLAP(Online AnalyticalProcessing,联机分析处理)数据库是一种成熟的分布式关系型数据仓库的解决方案,但是OLAP数据库的特点是以读优化为主,不擅长修改,即只支持数据的插入和读取,不支持数据的修改更新,而在很多场景下,用户希望像传统数据库一样,可以对OLAP数据库里的表做单行或者多行数据的修改操作。In traditional software development, stand-alone databases (such as Oracle databases, SQL Server databases, etc.) play an extremely critical role in data storage and data computing, but traditional stand-alone databases cannot achieve horizontal expansion in storage and computing, that is, they cannot Adding hardware means to store and calculate more data, so it is stretched when dealing with massive data. Therefore, distributed relational data warehouses have emerged. OLAP (Online Analytical Processing) database is a mature solution for distributed relational data warehouses, but OLAP databases are characterized by read optimization, not It is good at modification, that is, it only supports data insertion and reading, but does not support data modification and update. In many scenarios, users want to be able to modify a single row or multiple rows of data in a table in an OLAP database, just like a traditional database.

另外,在很多业务场景下有这样的一个需求,用户希望得到数据库里某张表在之前某个时间点的状态,即快照,目的可能是为了将表的数据恢复到那个时间点,也可能是为了了解之前版本的信息或者是为了做一些版本对比,但是,目前在OLAP数据库中没有获得快照的功能。In addition, there is such a requirement in many business scenarios. Users want to get the status of a table in the database at a previous point in time, that is, a snapshot. The purpose may be to restore the data of the table to that point in time, or it may be In order to understand the information of the previous version or to do some version comparison, however, there is currently no function of obtaining snapshots in the OLAP database.

发明内容SUMMARY OF THE INVENTION

鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的在OLAP数据库实现数据更新和快照的方法及装置,本发明的技术方案如下:In view of the above-mentioned problems, the present invention is proposed in order to provide a method and device for realizing data update and snapshot in OLAP database that overcomes the above-mentioned problems or at least partially solves the above-mentioned problems. The technical scheme of the present invention is as follows:

一种在OLAP数据库实现数据更新的方法,所述方法包括:A method for implementing data update in an OLAP database, the method comprising:

在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;A row identification column and a timestamp column are added to the data table, the row identification column is used to record the row identification of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table;

当接收到修改指令时,在所述数据表中确定待修改行;When receiving the modification instruction, determine the row to be modified in the data table;

根据所述修改指令对所述待修改行进行修改并在所述待修改行的时间戳列写入当前修改时间,生成第一新增行;Modify the row to be modified according to the modification instruction and write the current modification time in the timestamp column of the row to be modified to generate a first new row;

将所述第一新增行插入所述数据表中;inserting the first new row into the data table;

当接收到读取数据指令时,根据所述读取数据指令在所述数据表中获得至少一个结果行,在所述至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将所述结果表中去除所述行标识列以及所述时间戳列的部分返回给用户。When a read data command is received, at least one result row is obtained in the data table according to the read data command, and a row with the latest modification time corresponding to each row identifier is taken from the at least one result row to form a composition A result table, returning the part of the result table with the row ID column and the timestamp column removed to the user.

相应的,所述方法还包括:Correspondingly, the method further includes:

当接收到增加指令时,根据所述增加指令生成第二新增行,在所述第二新增行的行标识列写入相应的行标识,在所述第二新增行的时间戳列写入当前修改时间;When an addition instruction is received, a second newly added row is generated according to the added instruction, the corresponding row identifier is written in the row identifier column of the second newly added row, and the timestamp column of the second newly added row is written in the row identifier column of the second added row. Write the current modification time;

将所述第二新增行插入所述数据表中。Insert the second new row into the data table.

相应的,所述在所述数据表中确定待修改行,包括:Correspondingly, determining the row to be modified in the data table includes:

根据所述修改指令在所述数据表中获得至少一个修改待选行,在所述至少一个修改待选行中取每个行标识对应的具有最新修改时间的行作为待修改行。Obtain at least one row to be selected for modification in the data table according to the modification instruction, and select a row with the latest modification time corresponding to each row identifier in the at least one row to be selected for modification as the row to be modified.

一种在OLAP数据库实现数据快照的方法,所述方法包括:A method for implementing data snapshots in an OLAP database, the method comprising:

在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;A row identification column and a timestamp column are added to the data table, the row identification column is used to record the row identification of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table;

接收读取快照指令,所述读取快照指令中包括一个时间点;receiving a read snapshot instruction, where the read snapshot instruction includes a time point;

在所述数据表中查找在所述时间戳列中的修改时间小于或等于所述时间点的行作为快照待选行;Searching in the data table for a row whose modification time in the timestamp column is less than or equal to the time point as a snapshot candidate row;

在所述快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,将所述快照表中去除所述行标识列以及所述时间戳列的部分返回给用户。In the snapshot candidate rows, a row with the latest modification time corresponding to each row identifier is taken to form a snapshot table, and the part of the snapshot table excluding the row identifier column and the timestamp column is returned to the user.

相应的,所述方法还包括:Correspondingly, the method further includes:

当在所述数据表中未查找到在所述时间戳列中的修改时间小于或等于所述时间点的行时,产生未查找到快照的提示。When a row whose modification time in the timestamp column is less than or equal to the time point is not found in the data table, a prompt that no snapshot is found is generated.

一种在OLAP数据库实现数据更新的装置,所述装置包括:A device for realizing data update in an OLAP database, the device comprising:

第一增加单元,用于在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;The first adding unit is used to add a row identifier column and a timestamp column in the data table, the row identifier column is used to record the row identifier of each row in the data table, and the timestamp column is used to record the data table The modification time of each row in ;

确定单元,用于当接收到修改指令时,在所述数据表中确定待修改行;a determining unit for determining the row to be modified in the data table when the modification instruction is received;

修改单元,用于根据所述修改指令对所述待修改行进行修改并在所述待修改行的时间戳列写入当前修改时间,生成第一新增行;a modification unit, configured to modify the row to be modified according to the modification instruction and write the current modification time in the timestamp column of the row to be modified to generate a first newly added row;

第一插入单元,用于将所述第一新增行插入所述数据表中;a first inserting unit for inserting the first newly added row into the data table;

读取单元,用于当接收到读取数据指令时,根据所述读取数据指令在所述数据表中获得至少一个结果行,在所述至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将所述结果表中去除所述行标识列以及所述时间戳列的部分返回给用户。The reading unit is configured to obtain at least one result row in the data table according to the read data instruction when receiving the read data instruction, and fetch the at least one result row corresponding to each row identifier with The row with the latest modification time constitutes a result table, and the part of the result table excluding the row ID column and the timestamp column is returned to the user.

相应的,所述装置还包括:Correspondingly, the device further includes:

第二增加单元,用于当接收到增加指令时,根据所述增加指令生成第二新增行,在所述第二新增行的行标识列写入相应的行标识,在所述第二新增行的时间戳列写入当前修改时间;The second adding unit is configured to generate a second newly added row according to the adding instruction when receiving the adding instruction, write the corresponding row identifier in the row identifier column of the second newly added row, and write the corresponding row identifier in the row identifier column of the second newly added row. The timestamp column of the new row is written to the current modification time;

第二插入单元,用于将所述第二新增行插入所述数据表中。The second inserting unit is used for inserting the second newly added row into the data table.

相应的,所述确定单元具体用于:Correspondingly, the determining unit is specifically used for:

根据所述修改指令在所述数据表中获得至少一个修改待选行,在所述至少一个修改待选行中取每个行标识对应的具有最新修改时间的行作为待修改行。Obtain at least one row to be selected for modification in the data table according to the modification instruction, and select a row with the latest modification time corresponding to each row identifier in the at least one row to be selected for modification as the row to be modified.

一种在OLAP数据库实现数据快照的装置,所述装置包括:A device for implementing data snapshots in an OLAP database, the device comprising:

增加单元,用于在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;an adding unit for adding a row ID column and a timestamp column in the data table, the row ID column is used to record the row ID of each row in the data table, and the timestamp column is used to record each row in the data table modification time;

接收单元,用于接收读取快照指令,所述读取快照指令中包括一个时间点;a receiving unit, configured to receive a read snapshot instruction, where the read snapshot instruction includes a time point;

查找单元,用于在所述数据表中查找在所述时间戳列中的修改时间小于或等于所述时间点的行作为快照待选行;a search unit, configured to search in the data table for a row whose modification time in the timestamp column is less than or equal to the time point as a snapshot candidate row;

快照单元,用于在所述快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,将所述快照表中去除所述行标识列以及所述时间戳列的部分返回给用户。A snapshot unit, configured to select a row with the latest modification time corresponding to each row identifier in the snapshot candidate row to form a snapshot table, and remove the row identifier column and the timestamp column from the snapshot table. returned to the user.

相应的,所述装置还包括:Correspondingly, the device further includes:

提示单元,用于当在所述数据表中未查找到在所述时间戳列中的修改时间小于或等于所述时间点的行时,产生未查找到快照的提示。The prompt unit is configured to generate a prompt that no snapshot is found when a row whose modification time in the timestamp column is less than or equal to the time point is not found in the data table.

借由上述技术方案,本发明提供的在OLAP数据库实现数据更新和快照的方法及装置,通过在数据表中记录各行的行标识以及修改时间,在需要修改数据时,对待修改行进行修改,且保持待修改行的行标识保持不变并在待修改行中记录最新的修改时间,当用户读取数据时,针对每个行标识返回具有最新修改时间的数据返回给用户,对于用户来说读取得到的都是修改后的数据,和数据已经实际进行了修改的效果相同,满足了在OLAP数据库中实现数据更新的需求。另外,当用户读取快照时,返回每一行标识小于或等于快照时间点且具有最新修改时间的数据返回给用户,从而实现了在OLAP数据库中读取快照的功能。By the above-mentioned technical scheme, the method and device for realizing data update and snapshot in the OLAP database provided by the present invention, by recording the row identifier and modification time of each row in the data table, when the data needs to be modified, the row to be modified is modified, and Keep the row ID of the row to be modified unchanged and record the latest modification time in the row to be modified. When the user reads the data, return the data with the latest modification time for each row ID and return it to the user, for the user to read What is obtained is the modified data, which has the same effect as the data has actually been modified, which satisfies the needs of realizing data update in the OLAP database. In addition, when the user reads the snapshot, the data whose row identifier is less than or equal to the snapshot time point and has the latest modification time is returned to the user, thereby realizing the function of reading the snapshot in the OLAP database.

上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solutions of the present invention, in order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand , the following specific embodiments of the present invention are given.

附图说明Description of drawings

通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are for the purpose of illustrating preferred embodiments only and are not to be considered limiting of the invention. Also, the same components are denoted by the same reference numerals throughout the drawings. In the attached image:

图1示出了本发明实施例中提供的在OLAP数据库实现数据更新的方法实施例的流程图;1 shows a flowchart of a method embodiment for implementing data update in an OLAP database provided in an embodiment of the present invention;

图2示出了本发明实施例中数据表的示意图;Fig. 2 shows the schematic diagram of the data table in the embodiment of the present invention;

图3示出了本发明实施例中一种对数据表进行修改的示意图;3 shows a schematic diagram of modifying a data table in an embodiment of the present invention;

图4示出了本发明实施例中另一种对数据表进行修改的示意图;FIG. 4 shows another schematic diagram of modifying the data table in an embodiment of the present invention;

图5示出了本发明实施例中对数据表进行增加的示意图;5 shows a schematic diagram of adding a data table in an embodiment of the present invention;

图6示出了本发明实施例中对数据表进行读取的示意图;6 shows a schematic diagram of reading a data table in an embodiment of the present invention;

图7示出了本发明实施例中提供的在OLAP数据库实现数据快照的方法实施例的流程图;FIG. 7 shows a flowchart of a method embodiment for implementing a data snapshot in an OLAP database provided in an embodiment of the present invention;

图8示出了本发明实施例中读取数据快照的示意图;FIG. 8 shows a schematic diagram of reading a data snapshot in an embodiment of the present invention;

图9示出了本发明实施例中提供的在OLAP数据库实现数据更新的装置实施例的示意图;9 shows a schematic diagram of an embodiment of an apparatus for implementing data update in an OLAP database provided in an embodiment of the present invention;

图10示出了本发明实施例中提供的在OLAP数据库实现数据快照的装置实施例的示意图。FIG. 10 shows a schematic diagram of an embodiment of an apparatus for implementing a data snapshot in an OLAP database according to an embodiment of the present invention.

具体实施方式Detailed ways

为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本发明实施例作进一步详细的说明。In order to make the above objects, features and advantages of the present invention more clearly understood, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and specific embodiments.

本发明的主要目的在于让用户可以像操作传统单机数据库一样,在基于Hadoop(一种分布式系统基础架构)的OLAP数据库上,对表数据进行单行或多行修改、更新操作,以克服OLAP数据库最大的缺陷;另外,本发明的目的还在于使用户在使用OLAP数据库时可以用很简单的方式得到任何表在任意时间点的快照。The main purpose of the present invention is to allow users to perform single-row or multiple-row modification and update operations on table data on an OLAP database based on Hadoop (a distributed system infrastructure) just like operating a traditional stand-alone database, so as to overcome the OLAP database. The biggest defect; in addition, the purpose of the present invention is to enable users to obtain snapshots of any table at any point in time in a very simple manner when using the OLAP database.

参见图1所示,示出了本发明实施例中提供的在OLAP数据库实现数据更新的方法实施例,可以包括以下步骤:Referring to FIG. 1 , a method embodiment for implementing data update in an OLAP database provided in an embodiment of the present invention is shown, which may include the following steps:

步骤101:在数据表中增加行标识列以及时间戳列,行标识列用于记录数据表中各行的行标识,时间戳列用于记录数据表中各行的修改时间。Step 101: Add a row ID column and a timestamp column to the data table, where the row ID column is used to record the row ID of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table.

首先在数据表中增加两个隐藏列:行标识列以及时间戳列,隐藏列即对于用户来说这两列是透明的,用户并不知道这两列的存在,其中,行标识列用于记录数据表中各行的行标识,时间戳列用于记录数据表中各行的修改时间。First, add two hidden columns to the data table: the row ID column and the timestamp column. The hidden column is transparent to the user, and the user does not know the existence of these two columns. Among them, the row ID column is used for Record the row ID of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table.

参见图2所示,为一种在数据表中增加行标识列以及时间戳列的示例,图2中左表为原始的数据表,在用户建立原始的数据表时可以增加行标识列以及时间戳列,生成图2中右表所示的更新后的数据表,可以看出原始的数据表中不同的数据行均具有不同的行标识,而时间戳列则记录了各行的修改时间。Referring to Figure 2, it is an example of adding a row ID column and a timestamp column in a data table. The left table in Figure 2 is the original data table, and the row ID column and time can be added when the user creates the original data table. Stamp the column to generate the updated data table shown in the right table in Figure 2. It can be seen that different data rows in the original data table have different row IDs, and the timestamp column records the modification time of each row.

步骤102:当接收到修改指令时,在数据表中确定待修改行。Step 102: When the modification instruction is received, determine the row to be modified in the data table.

在本发明一些可能的实现方式中,在数据表中确定待修改行的具体实现可以包括:In some possible implementations of the present invention, the specific implementation of determining the row to be modified in the data table may include:

根据修改指令在数据表中获得至少一个修改待选行,在至少一个修改待选行中取每个行标识对应的具有最新修改时间的行作为待修改行。Obtain at least one row to be modified in the data table according to the modification instruction, and select the row with the latest modification time corresponding to each row identifier in the at least one row to be modified as the row to be modified.

步骤103:根据修改指令对待修改行进行修改并在待修改行的时间戳列写入当前修改时间,生成第一新增行。Step 103: Modify the row to be modified according to the modification instruction and write the current modification time in the timestamp column of the row to be modified to generate a first newly added row.

步骤104:将第一新增行插入数据表中。Step 104: Insert the first newly added row into the data table.

在用户需要修改数据表中某一行或某些行时,可以向数据库发送修改指令,修改指令中包括了确定待修改行的条件。在本实施例中,第一新增行表示对待修改行进行修改后的数据行,待修改行可以为一个或多个,第一新增行也可以为一个或多个。When the user needs to modify a certain row or some rows in the data table, a modification instruction can be sent to the database, and the modification instruction includes the conditions for determining the row to be modified. In this embodiment, the first newly added row represents a data row after the row to be modified is modified, and there may be one or more rows to be modified, and there may also be one or more first newly added rows.

参见图3所示,例如需要将图2右表中所示的数据表中的“技术部”修改为“软件部”,则首先根据修改指令在图2右表所示的数据表中查找获得部门列中为“技术部”的行作为修改待选行,即将行标识为“01”和“02”的行确定为修改待选行,而此时数据表中行标识为“01”和“02”的行均只存在一行数据,则这两行数据即为这两个行标识对应的具有最新修改时间的行,被确定为待修改行,将待修改行根据修改指令进行修改后,行标识保持不变,在时间戳列写入当前修改时间,插入数据表,生成图3所示的数据表,这样数据表中同一行标识会存在多个修改时间不同的行。Referring to Fig. 3, for example, it is necessary to modify the "technical department" in the data table shown in the right table of Fig. 2 to "software department", then first, according to the modification instruction, look up the data table shown in the right table of Fig. 2 to obtain The row of "Technical Department" in the department column is used as the row to be selected for modification, that is, the rows with row identifiers "01" and "02" are determined as rows to be selected for modification, and at this time, the row identifiers in the data table are "01" and "02" ” has only one row of data, then the two rows of data are the rows with the latest modification time corresponding to the two row IDs, and are determined as the rows to be modified. After the rows to be modified are modified according to the modification instructions, the row IDs Keep it unchanged, write the current modification time in the timestamp column, insert it into the data table, and generate the data table shown in Figure 3, so that there will be multiple rows with different modification times in the same row ID in the data table.

参见图4所示,又例如在上述修改的基础上(即图3所示的数据表的基础上)将“张三”的年龄修改为“31”,则首先根据修改指令在图3所示的数据表中查找姓名列为“张三”的行,即将行标识为“01”的行确定为修改待选行,而此时行标识为“01”的行有两行数据,则需要在这两个修改待选行中选取该行标识对应的具有最新修改时间的行作为待修改行(即图3所示的数据表中的倒数第二行为此次修改的待修改行),将待修改行根据修改指令进行修改后,行标识保持不变,在时间戳列写入当前修改时间,插入数据表,生成图4所示的数据表。Referring to Fig. 4, for another example, on the basis of the above modification (that is, on the basis of the data table shown in Fig. 3), the age of "Zhang San" is modified to "31", then first according to the modification instruction shown in Fig. 3 Find the row whose name is listed as "Zhang San" in the data table of , that is, determine the row with the row ID "01" as the row to be selected for modification, and at this time, the row with the row ID "01" has two rows of data, you need to From the two rows to be modified, select the row with the latest modification time corresponding to the row ID as the row to be modified (that is, the penultimate row in the data table shown in FIG. 3 is the row to be modified this time), After the modified row is modified according to the modification instruction, the row ID remains unchanged, the current modification time is written in the timestamp column, and the data table is inserted to generate the data table shown in FIG. 4 .

另外,在本发明一些可能的实现方式中,还可以在数据表中增加数据行,增加数据行的实现方式可以包括:In addition, in some possible implementation manners of the present invention, data rows may also be added to the data table, and the implementation manners of adding data rows may include:

当接收到增加指令时,根据增加指令生成第二新增行,在第二新增行的行标识列写入相应的行标识,在第二新增行的时间戳列写入当前修改时间;When receiving the addition instruction, generate a second newly added row according to the addition instruction, write the corresponding row identifier in the row identifier column of the second newly added row, and write the current modification time in the timestamp column of the second newly added row;

将第二新增行插入数据表中。Insert the second new row into the data table.

在本实施例中,第二新增行为根据增加指令所生成的行,第二新增行可以为一个或多个。In this embodiment, the second newly added behavior is a line generated according to the addition instruction, and the second newly added line may be one or more.

参见图5所示,根据增加指令可以生成图5所示的数据表中的最后一行,在该行的行标识列写入新的行标识,在该行的时间戳列写入当前修改时间,将该行插入数据表,生成图5所示的数据表,完成在数据表中增加数据行。Referring to Fig. 5, the last row in the data table shown in Fig. 5 can be generated according to the adding instruction, a new row ID is written in the row ID column of the row, and the current modification time is written in the timestamp column of the row, Insert the row into the data table, generate the data table shown in Figure 5, and complete the addition of data rows in the data table.

步骤105:当接收到读取数据指令时,根据读取数据指令在数据表中获得至少一个结果行,在至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将结果表中去除行标识列以及时间戳列的部分返回给用户。Step 105: when receiving the read data command, obtain at least one result row in the data table according to the read data command, and take the row with the latest modification time corresponding to each row identifier in the at least one result row to form a result table, Returns the part of the result table with the row ID column and timestamp column removed to the user.

在用户需要读取数据表中的数据时,在所需要读取的数据中每一个行标识取具有最新修改时间的版本返回给用户,而对于用户来说行标识列以及时间戳列是透明的,则返回给用户的数据表是不包含行标识列以及时间戳列的,这样,对于用户来说读取到的都是修改后的数据,相当于已经进行了数据更新。When the user needs to read the data in the data table, the version with the latest modification time is returned to the user for each row ID in the data to be read, and the row ID column and the timestamp column are transparent to the user , the data table returned to the user does not contain the row ID column and the timestamp column, so that the user reads the modified data, which is equivalent to the data update.

参见图6所示,假设读取数据指令需要读取当前全部数据,则在图5所示的数据表中查找获得全部的行均作为结果行,每个行标识对应的具有最新修改时间的行组成结果表,即图5所示的数据表中的倒数第一、二、三、五行组成结果表,将结果表中的行标识列以及时间戳列去除生成如图6所示的数据表即为返回给用户的结果,这样用户得到的是每个行标识对应的最新数据。Referring to FIG. 6 , assuming that the read data command needs to read all current data, all rows obtained by searching in the data table shown in FIG. 5 are used as result rows, and each row identifies the corresponding row with the latest modification time. The result table is formed, that is, the penultimate first, second, third, and fifth rows in the data table shown in Figure 5 form the result table, and the row ID column and the timestamp column in the result table are removed to generate the data table shown in Figure 6, namely In order to return the result to the user, what the user gets is the latest data corresponding to each row ID.

另外,基于本实施例还可以实现在OLAP数据库中进行数据快照,实现数据快照的方式可以包括:In addition, based on this embodiment, it is also possible to perform a data snapshot in the OLAP database, and the way to realize the data snapshot may include:

接收读取快照指令,读取快照指令中包括一个时间点;Receive a read snapshot command, and the read snapshot command includes a time point;

在数据表中查找在时间戳列中的修改时间小于或等于时间点的行作为快照待选行;Find the row whose modification time in the timestamp column is less than or equal to the time point in the data table as the snapshot candidate row;

在快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,将快照表中去除行标识列以及时间戳列的部分返回给用户。A snapshot table is formed by selecting the row with the latest modification time corresponding to each row identifier in the snapshot candidate rows, and returning the part of the snapshot table with the row identifier column and the timestamp column removed to the user.

而当在数据表中未查找到在时间戳列中的修改时间小于或等于时间点的行时,产生未查找到快照的提示。However, when a row whose modification time in the timestamp column is less than or equal to the time point is not found in the data table, a prompt that the snapshot is not found is generated.

关于实现数据快照的相关说明可以参见后续实施例,在本实施例中暂不展开说明。For the relevant description about implementing the data snapshot, reference may be made to the subsequent embodiments, which will not be described in this embodiment for the time being.

这样,通过在数据表中记录各行的行标识以及修改时间,在需要修改数据时,对待修改行进行修改,且保持待修改行的行标识保持不变并在待修改行中记录最新的修改时间,当用户读取数据时,针对每个行标识返回具有最新修改时间的数据返回给用户,对于用户来说读取得到的都是修改后的数据,和数据已经实际进行了修改的效果相同,满足了在OLAP数据库中实现数据更新的需求。另外,当用户读取快照时,返回每一行标识小于或等于快照时间点且具有最新修改时间的数据返回给用户,从而实现了在OLAP数据库中读取快照的功能。In this way, by recording the row ID and modification time of each row in the data table, when data needs to be modified, the row to be modified is modified, the row ID of the row to be modified is kept unchanged, and the latest modification time is recorded in the row to be modified , when the user reads the data, the data with the latest modification time is returned to the user for each row identifier. For the user, what is read is the modified data, which has the same effect as the data has actually been modified. It satisfies the requirement of realizing data update in OLAP database. In addition, when the user reads the snapshot, the data whose row identifier is less than or equal to the snapshot time point and has the latest modification time is returned to the user, thereby realizing the function of reading the snapshot in the OLAP database.

参见图7所示,示出了本发明实施例中提供的在OLAP数据库实现数据快照的方法实施例,可以包括以下步骤:Referring to FIG. 7 , an embodiment of a method for implementing a data snapshot in an OLAP database provided in an embodiment of the present invention is shown, which may include the following steps:

步骤701:在数据表中增加行标识列以及时间戳列,行标识列用于记录数据表中各行的行标识,时间戳列用于记录数据表中各行的修改时间。Step 701: Add a row ID column and a timestamp column to the data table. The row ID column is used to record the row ID of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table.

本步骤的具体实现与上述实施例中的步骤101类似,相关说明可以参见上述实施例,在此不再赘述。The specific implementation of this step is similar to step 101 in the foregoing embodiment, and reference may be made to the foregoing embodiment for related descriptions, which will not be repeated here.

步骤702:接收读取快照指令,读取快照指令中包括一个时间点。Step 702: Receive an instruction to read the snapshot, and the instruction to read the snapshot includes a time point.

步骤703:在数据表中查找在时间戳列中的修改时间小于或等于时间点的行作为快照待选行。Step 703 : Find the row in the data table whose modification time in the timestamp column is less than or equal to the time point as a snapshot candidate row.

步骤704:在快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,将快照表中去除行标识列以及时间戳列的部分返回给用户。Step 704: From the rows to be selected in the snapshot, a row with the latest modification time corresponding to each row ID is taken to form a snapshot table, and the part of the snapshot table with the row ID column and the timestamp column removed is returned to the user.

在本发明的一些可能的实现方式中,当在数据表中未查找到在时间戳列中的修改时间小于或等于时间点的行时,产生未查找到快照的提示。In some possible implementations of the present invention, when a row whose modification time in the timestamp column is less than or equal to the time point is not found in the data table, a prompt that no snapshot is found is generated.

在用户需要读取数据表的快照时,通过读取快照指令给定一个时间点,首先根据数据表时间戳列中的修改时间获得小于或等于该时间点的至少一行作为快照待选行,快照待选行中可能存在具有同一行标识的多行数据,然后在快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,类似的,由于行标识列以及时间戳列对于用户是透明的,因此将快照表中去除行标识列以及时间戳列的部分返回给用户,通过这种方式,用户就得到了数据表在某个时间点的快照。When the user needs to read the snapshot of the data table, a time point is given by the read snapshot command. First, according to the modification time in the timestamp column of the data table, at least one row less than or equal to the time point is obtained as the snapshot candidate row. There may be multiple rows of data with the same row ID in the row to be selected, and then the row with the latest modification time corresponding to each row ID is taken from the row to be selected in the snapshot to form a snapshot table. It is transparent to the user, so the part of the snapshot table that removes the row ID column and the timestamp column is returned to the user. In this way, the user gets a snapshot of the data table at a certain point in time.

参见图8所示,假设读取快照指令中包括的时间点为“2016-10-0900:00:00”,首先在图8的左表中获得时间戳小于该时间点的行,则在图8的左表中去除最后两行的数据行作为快照待选行,在快照待选行中行标识为“01”和行标识为“02”的行均有两行,行标识为“03”的行有一行,则每个行标识均取具有最新修改时间的行组成快照表,在快照表中去除行标识列以及时间戳列,生成图8右表所示的数据表返回给用户,作为该时间点的快照。Referring to Fig. 8, assuming that the time point included in the read snapshot instruction is "2016-10-0900:00:00", first obtain the row whose timestamp is less than this time point in the left table of Fig. 8, then in Fig. In the left table of 8, the data rows of the last two rows are removed as the snapshot candidate rows. In the snapshot candidate rows, there are two rows with the row ID "01" and the row ID "02", and the row ID is "03". There is one row in the row, then each row ID is taken from the row with the latest modification time to form a snapshot table, the row ID column and the timestamp column are removed from the snapshot table, and the data table shown in the right table of Figure 8 is generated and returned to the user as the Snapshot of a point in time.

另外,基于本实施例还可以实现在OLAP数据库中进行数据更新,实现数据更新的方式可以包括:In addition, based on this embodiment, data update in the OLAP database can also be implemented, and the way of implementing the data update can include:

当接收到修改指令时,在数据表中确定待修改行;根据修改指令对待修改行进行修改并在待修改行的时间戳列写入当前修改时间,生成第一新增行;将第一新增行插入数据表中。其中,在数据表中确定待修改行的具体实现可以包括:根据修改指令在数据表中获得至少一个修改待选行,在至少一个修改待选行中取每个行标识对应的具有最新修改时间的行作为待修改行。When a modification instruction is received, the row to be modified is determined in the data table; the row to be modified is modified according to the modification instruction and the current modification time is written in the timestamp column of the row to be modified to generate the first new row; Insert additional rows into the data table. The specific implementation of determining the row to be modified in the data table may include: obtaining at least one row to be modified in the data table according to the modification instruction, and obtaining the latest modification time corresponding to each row identifier in the at least one row to be modified line as the line to be modified.

当接收到增加指令时,根据增加指令生成第二新增行,在第二新增行的行标识列写入相应的行标识,在第二新增行的时间戳列写入当前修改时间;将第二新增行插入数据表中。When receiving the addition instruction, generate a second newly added row according to the addition instruction, write the corresponding row identifier in the row identifier column of the second newly added row, and write the current modification time in the timestamp column of the second newly added row; Insert the second new row into the data table.

当接收到读取数据指令时,根据读取数据指令在数据表中获得至少一个结果行,在至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将结果表中去除行标识列以及时间戳列的部分返回给用户。When the read data command is received, at least one result row is obtained in the data table according to the read data command, the row with the latest modification time corresponding to each row ID is taken from the at least one result row to form a result table, and the result table The part that removes the row ID column and the timestamp column is returned to the user.

关于在OLAP数据库中进行数据更新的方法可以参见上述实施例的说明,在此不再赘述。For the method for updating data in the OLAP database, reference may be made to the description of the foregoing embodiment, which will not be repeated here.

这样,通过在数据表中记录各行的行标识以及修改时间,当用户读取快照时,返回每一行标识小于或等于快照时间点且具有最新修改时间的数据返回给用户,从而实现了在OLAP数据库中读取快照的功能。另外,在需要修改数据时,对待修改行进行修改,且保持待修改行的行标识保持不变并在待修改行中记录最新的修改时间,当用户读取数据时,针对每个行标识返回具有最新修改时间的数据返回给用户,对于用户来说读取得到的都是修改后的数据,和数据已经实际进行了修改的效果相同,满足了在OLAP数据库中实现数据更新的需求。In this way, by recording the row identifier and modification time of each row in the data table, when the user reads the snapshot, the data whose row identifier is less than or equal to the snapshot time point and has the latest modification time is returned to the user, thereby realizing the OLAP database. The ability to read snapshots in . In addition, when data needs to be modified, modify the row to be modified, keep the row ID of the row to be modified unchanged, and record the latest modification time in the row to be modified. When the user reads the data, it returns for each row ID. The data with the latest modification time is returned to the user, and the user can read the modified data, which has the same effect as the data has actually been modified, which satisfies the needs of realizing data update in the OLAP database.

参见图9所示,示出了本发明实施例中提供的在OLAP数据库实现数据更新的装置实施例,可以包括:Referring to FIG. 9 , an apparatus embodiment for implementing data update in an OLAP database provided in an embodiment of the present invention is shown, which may include:

第一增加单元901,用于在数据表中增加行标识列以及时间戳列,行标识列用于记录数据表中各行的行标识,时间戳列用于记录数据表中各行的修改时间。The first adding unit 901 is used to add a row ID column and a timestamp column in the data table, the row ID column is used to record the row ID of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table.

确定单元902,用于当接收到修改指令时,在数据表中确定待修改行。The determining unit 902 is configured to determine the row to be modified in the data table when the modification instruction is received.

在本发明的一些可能的实现方式中,确定单元可以具体用于:In some possible implementations of the present invention, the determining unit may be specifically used for:

根据修改指令在数据表中获得至少一个修改待选行,在至少一个修改待选行中取每个行标识对应的具有最新修改时间的行作为待修改行。Obtain at least one row to be modified in the data table according to the modification instruction, and select the row with the latest modification time corresponding to each row identifier in the at least one row to be modified as the row to be modified.

修改单元903,用于根据修改指令对待修改行进行修改并在待修改行的时间戳列写入当前修改时间,生成第一新增行。The modifying unit 903 is configured to modify the row to be modified according to the modification instruction and write the current modification time in the timestamp column of the row to be modified to generate a first newly added row.

第一插入单元904,用于将第一新增行插入数据表中。The first inserting unit 904 is used for inserting the first newly added row into the data table.

读取单元905,用于当接收到读取数据指令时,根据读取数据指令在数据表中获得至少一个结果行,在至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将结果表中去除行标识列以及时间戳列的部分返回给用户。The reading unit 905 is configured to obtain at least one result row in the data table according to the read data instruction when receiving the read data instruction, and fetch the row with the latest modification time corresponding to each row identifier in the at least one result row A result table is formed, and the part of the result table that removes the row ID column and the timestamp column is returned to the user.

在本发明的一些可能的实现方式中,本实施例还可以包括:In some possible implementations of the present invention, this embodiment may further include:

第二增加单元,用于当接收到增加指令时,根据增加指令生成第二新增行,在第二新增行的行标识列写入相应的行标识,在第二新增行的时间戳列写入当前修改时间;The second adding unit is configured to generate a second newly added row according to the adding instruction when receiving the adding instruction, write the corresponding row identifier in the row identifier column of the second newly added row, and write the corresponding row identifier in the row identifier column of the second newly added row, and the timestamp of the second newly added row column writes the current modification time;

第二插入单元,用于将第二新增行插入数据表中。The second inserting unit is used to insert the second newly added row into the data table.

所述在OLAP数据库实现数据更新的装置包括处理器和存储器,上述第一增加单元、确定单元、修改单元、第一插入单元和读取单元等均作为程序单元存储在存储器中,由处理器执行存储在存储器中的上述程序单元来实现相应的功能。The device for realizing data update in the OLAP database includes a processor and a memory, and the above-mentioned first adding unit, determining unit, modifying unit, first inserting unit and reading unit are all stored in the memory as program units, and are executed by the processor. The above-mentioned program units stored in the memory implement the corresponding functions.

处理器中包含内核,由内核去存储器中调取相应的程序单元。内核可以设置一个或以上,通过调整内核参数来在OLAP数据库实现数据更新。The processor contains a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can set one or more, and implement data update in the OLAP database by adjusting the kernel parameters.

存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM),存储器包括至少一个存储芯片。Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory, such as read only memory (ROM) or flash memory (flash RAM), the memory including at least one memory chip.

这样,通过在数据表中记录各行的行标识以及修改时间,在需要修改数据时,对待修改行进行修改,且保持待修改行的行标识保持不变并在待修改行中记录最新的修改时间,当用户读取数据时,针对每个行标识返回具有最新修改时间的数据返回给用户,对于用户来说读取得到的都是修改后的数据,和数据已经实际进行了修改的效果相同,满足了在OLAP数据库中实现数据更新的需求。In this way, by recording the row ID and modification time of each row in the data table, when data needs to be modified, the row to be modified is modified, the row ID of the row to be modified is kept unchanged, and the latest modification time is recorded in the row to be modified , when the user reads the data, the data with the latest modification time is returned to the user for each row identifier. For the user, what is read is the modified data, which has the same effect as the data has actually been modified. It satisfies the requirement of realizing data update in OLAP database.

参见图10所示,示出了本发明实施例中提供的在OLAP数据库实现数据快照的装置实施例,可以包括:Referring to FIG. 10 , an apparatus embodiment for implementing a data snapshot in an OLAP database provided in an embodiment of the present invention is shown, which may include:

增加单元1001,用于在数据表中增加行标识列以及时间戳列,行标识列用于记录数据表中各行的行标识,时间戳列用于记录数据表中各行的修改时间。The adding unit 1001 is used for adding a row ID column and a timestamp column in the data table, the row ID column is used to record the row ID of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table.

接收单元1002,用于接收读取快照指令,读取快照指令中包括一个时间点。The receiving unit 1002 is configured to receive a read snapshot instruction, where the read snapshot instruction includes a time point.

查找单元1003,用于在数据表中查找在时间戳列中的修改时间小于或等于时间点的行作为快照待选行。The search unit 1003 is configured to search the data table for a row whose modification time in the timestamp column is less than or equal to the time point as a snapshot candidate row.

快照单元1004,用于在快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,将快照表中去除行标识列以及时间戳列的部分返回给用户。The snapshot unit 1004 is configured to select a row with the latest modification time corresponding to each row identifier in the snapshot candidate rows to form a snapshot table, and return the part of the snapshot table with the row identifier column and the timestamp column removed to the user.

在本发明一些可能的实现方式中,本实施例还可以包括:In some possible implementations of the present invention, this embodiment may further include:

提示单元,用于当在数据表中未查找到在时间戳列中的修改时间小于或等于时间点的行时,产生未查找到快照的提示。The prompt unit is used to generate a prompt that a snapshot is not found when a row whose modification time in the timestamp column is less than or equal to the time point is not found in the data table.

所述在OLAP数据库实现数据快照的装置包括处理器和存储器,上述增加单元、接收单元、查找单元和快照单元等均作为程序单元存储在存储器中,由处理器执行存储在存储器中的上述程序单元来实现相应的功能。The described device for realizing data snapshot in the OLAP database includes a processor and a memory, and the above-mentioned increasing unit, receiving unit, search unit and snapshot unit etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory. to achieve the corresponding function.

处理器中包含内核,由内核去存储器中调取相应的程序单元。内核可以设置一个或以上,通过调整内核参数来在OLAP数据库实现数据快照。The processor includes a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can set one or more, and implement data snapshots in the OLAP database by adjusting the kernel parameters.

存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM),存储器包括至少一个存储芯片。Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory, such as read only memory (ROM) or flash memory (flash RAM), the memory including at least one memory chip.

这样,通过在数据表中记录各行的行标识以及修改时间,当用户读取快照时,返回每一行标识小于或等于快照时间点且具有最新修改时间的数据返回给用户,从而实现了在OLAP数据库中读取快照的功能。另外,在需要修改数据时,对待修改行进行修改,且保持待修改行的行标识保持不变并在待修改行中记录最新的修改时间,当用户读取数据时,针对每个行标识返回具有最新修改时间的数据返回给用户,对于用户来说读取得到的都是修改后的数据,和数据已经实际进行了修改的效果相同,满足了在OLAP数据库中实现数据更新的需求。In this way, by recording the row identifier and modification time of each row in the data table, when the user reads the snapshot, the data whose row identifier is less than or equal to the snapshot time point and has the latest modification time is returned to the user, thus realizing the OLAP database. The ability to read snapshots in . In addition, when data needs to be modified, modify the row to be modified, keep the row ID of the row to be modified unchanged, and record the latest modification time in the row to be modified. When the user reads the data, it returns for each row ID. The data with the latest modification time is returned to the user. For the user, what the user can read is the modified data, which has the same effect as the data has actually been modified, which satisfies the needs of realizing data update in the OLAP database.

本申请还提供了一种计算机程序产品,当在数据处理设备上执行时,适于执行初始化有如下方法步骤的程序代码:The present application also provides a computer program product that, when executed on a data processing device, is adapted to execute program code initialized with the following method steps:

在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;A row identification column and a timestamp column are added to the data table, the row identification column is used to record the row identification of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table;

当接收到修改指令时,在所述数据表中确定待修改行;When receiving the modification instruction, determine the row to be modified in the data table;

根据所述修改指令对所述待修改行进行修改并在所述待修改行的时间戳列写入当前修改时间,生成第一新增行;Modify the row to be modified according to the modification instruction and write the current modification time in the timestamp column of the row to be modified to generate a first new row;

将所述第一新增行插入所述数据表中;inserting the first new row into the data table;

当接收到读取数据指令时,根据所述读取数据指令在所述数据表中获得至少一个结果行,在所述至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将所述结果表中去除所述行标识列以及所述时间戳列的部分返回给用户。When a read data command is received, at least one result row is obtained in the data table according to the read data command, and a row with the latest modification time corresponding to each row identifier is taken from the at least one result row to form a composition A result table, returning the part of the result table with the row ID column and the timestamp column removed to the user.

本申请还提供了另一种计算机程序产品,当在数据处理设备上执行时,适于执行初始化有如下方法步骤的程序代码:The present application also provides another computer program product that, when executed on a data processing device, is adapted to execute program code initialized with the following method steps:

在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;A row identification column and a timestamp column are added to the data table, the row identification column is used to record the row identification of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table;

接收读取快照指令,所述读取快照指令中包括一个时间点;receiving a read snapshot instruction, where the read snapshot instruction includes a time point;

在所述数据表中查找在所述时间戳列中的修改时间小于或等于所述时间点的行作为快照待选行;Searching in the data table for a row whose modification time in the timestamp column is less than or equal to the time point as a snapshot candidate row;

在所述快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,将所述快照表中去除所述行标识列以及所述时间戳列的部分返回给用户。In the snapshot candidate rows, a row with the latest modification time corresponding to each row identifier is taken to form a snapshot table, and the part of the snapshot table excluding the row identifier column and the timestamp column is returned to the user.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.

存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。存储器是计算机可读介质的示例。Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory in the form of, for example, read only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.

计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-permanent, removable and non-removable media, and storage of information may be implemented by any method or technology. Information may be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Flash Memory or other memory technology, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, excludes transitory computer-readable media, such as modulated data signals and carrier waves.

以上仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above are merely examples of the present application, and are not intended to limit the present application. Various modifications and variations of this application are possible for those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included within the scope of the claims of this application.

Claims (10)

1.一种在OLAP数据库实现数据更新的方法,其特征在于,所述方法包括:1. a method for realizing data update in OLAP database, is characterized in that, described method comprises: 在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;所述行标识列以及所述时间戳列为隐藏列;A row ID column and a timestamp column are added to the data table, the row ID column is used to record the row ID of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table; The row identifier column and the timestamp column are hidden columns; 当接收到修改指令时,在所述数据表中确定待修改行;When receiving the modification instruction, determine the row to be modified in the data table; 根据所述修改指令对所述待修改行进行修改并在所述待修改行的时间戳列写入当前修改时间,生成第一新增行;Modify the row to be modified according to the modification instruction and write the current modification time in the timestamp column of the row to be modified to generate a first new row; 将所述第一新增行插入所述数据表中;inserting the first new row into the data table; 当接收到读取数据指令时,根据所述读取数据指令在所述数据表中获得至少一个结果行,在所述至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将所述结果表中去除所述行标识列以及所述时间戳列的部分返回给用户。When a read data command is received, at least one result row is obtained in the data table according to the read data command, and a row with the latest modification time corresponding to each row identifier is taken from the at least one result row to form a composition A result table, returning the part of the result table with the row ID column and the timestamp column removed to the user. 2.根据权利要求1所述的方法,其特征在于,所述方法还包括:2. The method according to claim 1, wherein the method further comprises: 当接收到增加指令时,根据所述增加指令生成第二新增行,在所述第二新增行的行标识列写入相应的行标识,在所述第二新增行的时间戳列写入当前修改时间;When an addition instruction is received, a second newly added row is generated according to the added instruction, the corresponding row identifier is written in the row identifier column of the second newly added row, and the timestamp column of the second newly added row is written in the row identifier column of the second added row. Write the current modification time; 将所述第二新增行插入所述数据表中。Insert the second new row into the data table. 3.根据权利要求1所述的方法,其特征在于,所述在所述数据表中确定待修改行,包括:3. The method according to claim 1, wherein the determining the row to be modified in the data table comprises: 根据所述修改指令在所述数据表中获得至少一个修改待选行,在所述至少一个修改待选行中取每个行标识对应的具有最新修改时间的行作为待修改行。Obtain at least one row to be selected for modification in the data table according to the modification instruction, and select a row with the latest modification time corresponding to each row identifier in the at least one row to be selected for modification as the row to be modified. 4.一种在OLAP数据库实现数据快照的方法,其特征在于,所述方法包括:4. a method for realizing data snapshot in OLAP database, is characterized in that, described method comprises: 在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;所述行标识列以及所述时间戳列为隐藏列;A row ID column and a timestamp column are added to the data table, the row ID column is used to record the row ID of each row in the data table, and the timestamp column is used to record the modification time of each row in the data table; The row identifier column and the timestamp column are hidden columns; 接收读取快照指令,所述读取快照指令中包括一个时间点;receiving a read snapshot instruction, where the read snapshot instruction includes a time point; 在所述数据表中查找在所述时间戳列中的修改时间小于或等于所述时间点的行作为快照待选行;Searching in the data table for a row whose modification time in the timestamp column is less than or equal to the time point as a snapshot candidate row; 在所述快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,将所述快照表中去除所述行标识列以及所述时间戳列的部分返回给用户。In the snapshot candidate rows, a row with the latest modification time corresponding to each row identifier is taken to form a snapshot table, and the part of the snapshot table excluding the row identifier column and the timestamp column is returned to the user. 5.根据权利要求4所述的方法,其特征在于,所述方法还包括:5. The method according to claim 4, wherein the method further comprises: 当在所述数据表中未查找到在所述时间戳列中的修改时间小于或等于所述时间点的行时,产生未查找到快照的提示。When a row whose modification time in the timestamp column is less than or equal to the time point is not found in the data table, a prompt that no snapshot is found is generated. 6.一种在OLAP数据库实现数据更新的装置,其特征在于,所述装置包括:6. A device for realizing data update in OLAP database, wherein the device comprises: 第一增加单元,用于在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;所述行标识列以及所述时间戳列为隐藏列;The first adding unit is used to add a row identifier column and a timestamp column in the data table, the row identifier column is used to record the row identifier of each row in the data table, and the timestamp column is used to record the data table The modification time of each row in ; the row identification column and the timestamp column are hidden columns; 确定单元,用于当接收到修改指令时,在所述数据表中确定待修改行;a determining unit for determining the row to be modified in the data table when the modification instruction is received; 修改单元,用于根据所述修改指令对所述待修改行进行修改并在所述待修改行的时间戳列写入当前修改时间,生成第一新增行;a modification unit, configured to modify the row to be modified according to the modification instruction and write the current modification time in the timestamp column of the row to be modified to generate a first newly added row; 第一插入单元,用于将所述第一新增行插入所述数据表中;a first inserting unit for inserting the first newly added row into the data table; 读取单元,用于当接收到读取数据指令时,根据所述读取数据指令在所述数据表中获得至少一个结果行,在所述至少一个结果行中取每个行标识对应的具有最新修改时间的行组成结果表,将所述结果表中去除所述行标识列以及所述时间戳列的部分返回给用户。The reading unit is configured to obtain at least one result row in the data table according to the read data instruction when receiving the read data instruction, and fetch the at least one result row corresponding to each row identifier with The row with the latest modification time constitutes a result table, and the part of the result table excluding the row ID column and the timestamp column is returned to the user. 7.根据权利要求6所述的装置,其特征在于,所述装置还包括:7. The apparatus of claim 6, wherein the apparatus further comprises: 第二增加单元,用于当接收到增加指令时,根据所述增加指令生成第二新增行,在所述第二新增行的行标识列写入相应的行标识,在所述第二新增行的时间戳列写入当前修改时间;The second adding unit is configured to generate a second newly added row according to the adding instruction when receiving the adding instruction, write the corresponding row identifier in the row identifier column of the second newly added row, and write the corresponding row identifier in the row identifier column of the second newly added row. The timestamp column of the new row is written to the current modification time; 第二插入单元,用于将所述第二新增行插入所述数据表中。The second inserting unit is used for inserting the second newly added row into the data table. 8.根据权利要求6所述的装置,其特征在于,所述确定单元具体用于:8. The apparatus according to claim 6, wherein the determining unit is specifically configured to: 根据所述修改指令在所述数据表中获得至少一个修改待选行,在所述至少一个修改待选行中取每个行标识对应的具有最新修改时间的行作为待修改行。Obtain at least one row to be selected for modification in the data table according to the modification instruction, and select a row with the latest modification time corresponding to each row identifier in the at least one row to be selected for modification as the row to be modified. 9.一种在OLAP数据库实现数据快照的装置,其特征在于,所述装置包括:9. A device for realizing data snapshot in an OLAP database, wherein the device comprises: 增加单元,用于在数据表中增加行标识列以及时间戳列,所述行标识列用于记录所述数据表中各行的行标识,所述时间戳列用于记录所述数据表中各行的修改时间;所述行标识列以及所述时间戳列为隐藏列;an adding unit for adding a row ID column and a timestamp column in the data table, the row ID column is used to record the row ID of each row in the data table, and the timestamp column is used to record each row in the data table The modification time of ; the row identification column and the timestamp column are hidden columns; 接收单元,用于接收读取快照指令,所述读取快照指令中包括一个时间点;a receiving unit, configured to receive a read snapshot instruction, where the read snapshot instruction includes a time point; 查找单元,用于在所述数据表中查找在所述时间戳列中的修改时间小于或等于所述时间点的行作为快照待选行;a search unit, configured to search in the data table for a row whose modification time in the timestamp column is less than or equal to the time point as a snapshot candidate row; 快照单元,用于在所述快照待选行中取每个行标识对应的具有最新修改时间的行组成快照表,将所述快照表中去除所述行标识列以及所述时间戳列的部分返回给用户。A snapshot unit, configured to select a row with the latest modification time corresponding to each row identifier in the snapshot to-be-selected row to form a snapshot table, and remove the row identifier column and the timestamp column from the snapshot table returned to the user. 10.根据权利要求9所述的装置,其特征在于,所述装置还包括:10. The apparatus of claim 9, wherein the apparatus further comprises: 提示单元,用于当在所述数据表中未查找到在所述时间戳列中的修改时间小于或等于所述时间点的行时,产生未查找到快照的提示。The prompt unit is configured to generate a prompt that no snapshot is found when a row whose modification time in the timestamp column is less than or equal to the time point is not found in the data table.
CN201610991953.8A 2016-11-10 2016-11-10 A method and device for realizing data update and snapshot in OLAP database Expired - Fee Related CN108073595B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610991953.8A CN108073595B (en) 2016-11-10 2016-11-10 A method and device for realizing data update and snapshot in OLAP database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610991953.8A CN108073595B (en) 2016-11-10 2016-11-10 A method and device for realizing data update and snapshot in OLAP database

Publications (2)

Publication Number Publication Date
CN108073595A CN108073595A (en) 2018-05-25
CN108073595B true CN108073595B (en) 2020-09-18

Family

ID=62154766

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610991953.8A Expired - Fee Related CN108073595B (en) 2016-11-10 2016-11-10 A method and device for realizing data update and snapshot in OLAP database

Country Status (1)

Country Link
CN (1) CN108073595B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109388646B (en) * 2018-10-16 2021-03-02 新华三大数据技术有限公司 Data processing method and device
CN111475517B (en) * 2020-03-06 2024-02-20 平安科技(深圳)有限公司 Data updating method, device, computer equipment and storage medium
CN111797108A (en) * 2020-07-17 2020-10-20 西安数据如金信息科技有限公司 A method and device for updating an analysis database
CN115544048B (en) * 2022-11-29 2023-03-21 福建慧政通信息科技有限公司 Method and terminal for monitoring data change
CN119088807A (en) * 2024-11-07 2024-12-06 杭州新中大科技股份有限公司 Business data report updating method, device, equipment and storage medium
CN119226362B (en) * 2024-12-02 2025-07-15 天津南大通用数据技术股份有限公司 Data processing method, apparatus, device, medium, and program product

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1349089A2 (en) * 2002-03-19 2003-10-01 Network Appliance, Inc. System and method for managing a plurality of snapshots of a file system
CN101064630A (en) * 2006-04-24 2007-10-31 华为技术有限公司 Data synchronization method and system
CN102663117A (en) * 2012-04-18 2012-09-12 中国人民大学 OLAP (On Line Analytical Processing) inquiry processing method facing database and Hadoop mixing platform

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7953749B2 (en) * 2004-05-11 2011-05-31 Oracel International Corporation Providing the timing of the last committed change to a row in a database table

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1349089A2 (en) * 2002-03-19 2003-10-01 Network Appliance, Inc. System and method for managing a plurality of snapshots of a file system
CN101064630A (en) * 2006-04-24 2007-10-31 华为技术有限公司 Data synchronization method and system
CN102663117A (en) * 2012-04-18 2012-09-12 中国人民大学 OLAP (On Line Analytical Processing) inquiry processing method facing database and Hadoop mixing platform

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于近邻传播聚类分析的医生处方数据研究;钟会玲;《中国优秀硕士学位论文全文数据库医药卫生科技辑》;20160615(第6期);正文第17页 *

Also Published As

Publication number Publication date
CN108073595A (en) 2018-05-25

Similar Documents

Publication Publication Date Title
CN108073595B (en) A method and device for realizing data update and snapshot in OLAP database
JP7410919B2 (en) Generation, access, and display of lineage metadata
CN106484906B (en) Distributed object storage system flash-back method and device
JP6697392B2 (en) Transparent discovery of semi-structured data schema
EP3238097B1 (en) Identifying join relationships based on transactional access patterns
CN107590207B (en) Data synchronization method and device and electronic equipment
CN107977396B (en) A kind of updating method and table data updating device of data table of KeyValue database
WO2015106711A1 (en) Method and device for constructing nosql database index for semi-structured data
CN112181902B (en) Database storage method and device and electronic equipment
CN106933823B (en) Data synchronization method and device
CN107391544B (en) Column storage data processing method, device, device and computer storage medium
US11983226B2 (en) Real-time crawling
CN117520349A (en) Index table creation method, data query method and device
CN115455035A (en) Data query model construction method and computer-readable storage medium
CN110019507B (en) Data synchronization method and device
CN108073596B (en) Data deletion method and device for OLAP database
CN108228604B (en) Model construction method based on memory object, information query method and device
Singh NoSQL: A new horizon in big data
CN111125087A (en) Data storage method and device
CN112860912A (en) Method and device for updating knowledge graph
CN108121719B (en) Method and device for realizing data extraction conversion loading ETL
CN110795421A (en) Method for preventing dirty data from being generated
Han The application of nosql database in air quality monitoring
CN113468231A (en) User group size estimation method and device, electronic equipment and readable storage medium
WO2017007867A1 (en) Sharing usage of resources with interested users

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100080 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Applicant after: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

Address before: 100086 Cuigong Hotel, 76 Zhichun Road, Shuangyushu District, Haidian District, Beijing

Applicant before: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20200918