WO2020135737A1 - 分区管理、数据存储和查询方法及装置、设备、介质 - Google Patents
分区管理、数据存储和查询方法及装置、设备、介质 Download PDFInfo
- Publication number
- WO2020135737A1 WO2020135737A1 PCT/CN2019/129277 CN2019129277W WO2020135737A1 WO 2020135737 A1 WO2020135737 A1 WO 2020135737A1 CN 2019129277 W CN2019129277 W CN 2019129277W WO 2020135737 A1 WO2020135737 A1 WO 2020135737A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- partition
- data
- partition information
- time interval
- specified value
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
Definitions
- This application relates to the field of database technology, and in particular to a method, device, device, and medium for partition management, data storage, and query.
- a distributed database such as HBase is the product of a combination of database technology and network technology.
- a distributed database can include multiple partitions for distributed storage and load balancing, and data can be stored in the partitions.
- partitions are created uniformly, and the partition numbers of all partitions are divided at the time of creation.
- the partition number is the serial number of the corresponding partition.
- all partition numbers are divided according to the total number of partitions. For example, there are 32 partitions.
- the partition number includes 0 to 31.
- the data obtained in a period of time may be distributed and stored in many partitions.
- the data in all the partitions needs to be searched, resulting in low search efficiency.
- this application provides a partition management, data storage and query method and device, equipment, and media.
- the created partitions are divided according to time intervals.
- data query only the partition corresponding to the time interval needs to be searched, which is helpful to improve the search. effectiveness.
- a first aspect of the present application provides a partition management method, including: when a partition needs to be created, determine the number N of first partitions required to store data in a first time interval T1; the smaller time endpoint of T1 is later than Current time t0; create the N first partitions in the database, and record the T1 corresponding to the partition information of the first partition in a preset partition information table.
- a second aspect of the present application provides a data storage method, including: acquiring a time stamp in first data to be stored; determining at least one corresponding to a time interval matching the time stamp from a preset partition information table Fourth partition information; the partition information table records the partition information of the created partition in the database and the corresponding time interval; the second partition for storing the first data is determined according to the fourth partition information, and The first data is stored in the second partition of the database.
- a third aspect of the present application provides a data query method, including: acquiring query conditions required for querying second data; determining at least one target time interval T4 satisfying the query conditions from a preset partition information table, and determining The fifth partition information corresponding to the T4 in the partition information table; the partition information table records the partition information of the created partition in the database and the corresponding time interval; from the database corresponds to the fifth partition information Query the second data in the partition.
- a fourth aspect of the present application provides a partition management device, including: a quantity determination module for determining the number N of first partitions required to store data in a first time interval T1 when a partition needs to be created; The smaller time endpoint is later than the current time t0; the partition creation module is used to create the N first partitions in the database, and record the T1 corresponding to the partition information of the first partition in a preset partition Information table.
- a fifth aspect of the present application provides a data storage device, including: a time stamp acquisition module for acquiring a time stamp in first data to be stored; a first information determination module for determining from a preset partition information table Output at least one fourth partition information corresponding to the time interval matching the time stamp; the partition information table records the partition information of the created partition in the database and the corresponding time interval; the data storage module is used to The fourth partition information determines a second partition for storing the first data, and stores the first data in the second partition of the database.
- a sixth aspect of the present application provides a data query device, including: a condition acquisition module for acquiring query conditions required for querying second data; a second information determination module for determining satisfaction from a preset partition information table At least one target time interval T4 of the query condition, and determine the fifth partition information corresponding to T4 in the partition information table; the partition information table records the partition information of the created partition in the database and the corresponding time interval A data query module for querying the second data from the partition of the database corresponding to the fifth partition information.
- a seventh aspect of the present application provides an electronic device, including a processor and a memory; the memory stores a program that can be called by the processor; wherein, when the processor executes the program, the implementation is as described in the foregoing embodiment Partition management method, data storage method, or data query method.
- An eighth aspect of the present application provides a machine-readable storage medium on which a program is stored.
- a partition management method, a data storage method, or a data query method as described in the foregoing embodiment is implemented.
- FIG. 1 is a schematic flowchart of a partition management method according to an embodiment of the present application
- FIG. 2 is a structural block diagram of a partition management device according to an embodiment of the present application.
- FIG. 3 is a schematic flowchart of a data storage method according to an embodiment of the present application.
- FIG. 4 is a structural block diagram of a data storage device according to an embodiment of the present application.
- FIG. 5 is a schematic flowchart of a data query method according to an embodiment of the present application.
- FIG. 6 is a structural block diagram of a data query device according to an embodiment of the present application.
- FIG. 7 is a structural block diagram of an electronic device according to an embodiment of the present application.
- first, second, third, etc. may be used in this application to describe various devices, this information should not be limited to these terms. These terms are only used to distinguish devices of the same type from each other.
- the first device may also be referred to as the second device, and similarly, the second device may also be referred to as the first device.
- the word "if” as used herein may be interpreted as "when” or “when” or “in response to a determination”.
- HBase HadoopDatabase is a high-reliability, high-performance, column-oriented, and scalable distributed storage system. HBase technology can be used to build large-scale structured storage clusters on physical machines.
- the first aspect of the present application provides a partition management method.
- the following describes the partition management method of the embodiment of the present application in more detail, but it should not be limited to this.
- a partition management method according to an embodiment of the present application is shown, including the following steps:
- S200 Create the N first partitions in the database, and record the T1 corresponding to the partition information of the first partition in a preset partition information table.
- the partition management method of the embodiment of the present application may be applied to electronic devices, and the electronic devices may be computer devices and the like.
- the database is a distributed database, including but not limited to HBase.
- the partition created by the electronic device may be on the electronic device or on other devices, as long as it is in the database.
- the electronic device may be a physical machine where the partition service node HregionServer in the HBase cluster is located, or a physical machine where the management node Hmaster is located.
- HRegionServer can serve multiple partition regions; HMaster manages the load balancing of HRegionServer and adjusts the distribution of partitions.
- step S100 when a partition needs to be created, the number N of first partitions required to store data in the first time interval T1 is determined.
- One way to determine that a partition needs to be created is, for example, when a first instruction to create a first partition is received, it is determined that the first partition needs to be created.
- the first instruction may be triggered regularly in the electronic device, and it is triggered every other time, for example, the first instruction may be triggered every other month (the interval may also be a day or a few days, etc., the specific time is not limited) . In this way, you can periodically create new partitions for new data.
- the first command may also be input from outside, and the specific is not limited.
- the N may be a fixed value, that is, the number of first partitions created each time is the same; or, the N may be variable, and the number of first partitions created each time may be determined according to needs. It can be understood that N is greater than or equal to 1.
- step S200 when the partition is created for the first time, a set number of partitions can be created to meet the data storage needs within a certain period of time; when the partition is subsequently created, it can be determined according to the amount of data stored in the created partition in the database N, of course, the way of determining N is not limited to this.
- the N first partitions are created in the database, and the T1 and the partition information of the first partition are recorded in a preset partition information table correspondingly.
- Each first partition has corresponding partition information.
- the partition information of the first partition may include, for example, the start row position information and the end row position information of the first partition in the database.
- the partition information can be found in the database corresponding to the first partition.
- the partition information of the N first partitions created this time corresponds to T1. If the N of the first partition created each time is different, the partition information of the first partition corresponding to T1 of the first partition created each time is also different.
- the size of each first partition may be the same or of course different.
- the smaller time endpoint of T1 is later than the current time t0, which can be the time of the system clock of the device when the first partition needs to be created, thus it can be stated that any time in T1 is a future time.
- the first partition created is used to store data obtained in the future.
- the data can be obtained from many data sources, such as KafKa, Flume, Twitter, ZeroMQ, Kinesis, TCP sockets and other data sources, of course, other data sources, as long as the data has a time stamp.
- the data is time-series data, that is, data having a time column and recorded in chronological order. In this way, when storing data in the first partition, a matching time interval can be found according to the time stamp in the data, so that the first partition for storing the data can be determined according to the partition information corresponding to the matching time interval.
- T1 corresponds to the partition information of the N first partitions currently created in the partition information table, so that when you need to find the data in the first partition, you can first determine T1 in the partition information table, according to the found T1
- the corresponding partition information finds the first partition in the database, and then finds the required data from the first partition.
- the created partitions are divided according to time intervals.
- the time interval is recorded in the partition information table corresponding to the partition information of the partition required to store the data in the time interval; when the data is subsequently stored, the data within a period of time can be stored collectively in several time intervals.
- partitions when querying data, it is not necessary to search for data within a period of time in all partitions, only need to find the partition corresponding to the time interval, which can reduce the amount of data to be searched, which is conducive to improving search efficiency.
- partition management method In addition, in the related partition management method, once a partition is created, a new partition cannot be dynamically created subsequently. As a result, after a certain amount of data is stored in the partition, it can only be split through the partition, that is, a partition is split into multiple Partitioning to increase the number of partitions.
- partitioning brings pressure on HBase services and affects application usage. At the same time, as partitions are split, more partitions need to be searched during data query, which causes a greater burden on the query.
- a new partition may be created according to the number of partitions required to store data in a period of time in the future.
- partitions can be created dynamically as needed, without partition splitting to increase partitions, thereby reducing the pressure on HBase services, and avoiding the problem of large search burden caused by too many partitions.
- the above partition management method may be executed by a partition management device.
- the partition management device 100 includes two modules: a number determination module 101 and a partition creation module 102.
- the quantity determination module 101 is used to perform the above step S100
- the partition creation module 102 is used to perform the above step S200.
- step S100 determining the number N of first partitions required to store data in the first time interval T1 includes the following steps:
- S101 Determine the first partition information corresponding to the second time interval T2 from the partition information table, and the larger time endpoint of T2 is not later than the t0;
- S103 Determine the number of the first partition according to the total amount of data and the set storage capacity of a single partition.
- step S101 first partition information corresponding to one or more second time intervals earlier than the current time may be found from the partition information table.
- the larger time endpoint of T2 and the smaller time endpoint of T1 may be two adjacent times, for example, the larger time endpoint of T2 is 10:10 on December 6, 2018 10 Seconds, and the smaller time endpoint of T1 is 10:10:11 on December 6, 2018; or, the larger time endpoint of T2 and the smaller time endpoint of T1 may be the same, of course, in order to avoid the range of the time interval There is overlap, and the time interval may be a half-open half-closed interval, for example, T1 and T2 are both left-open and right-closed intervals.
- step S101 the total amount of data stored in the partition corresponding to the first partition information corresponding to T2 can be reflected in the amount of data that needs to be stored per unit time, and thus can be used to evaluate the amount of data that needs to be stored in T1.
- the number of first partitions to be created can be determined.
- T2 may include multiple time intervals, so that there are multiple first partition information. Of course, T2 may also include only one time interval.
- the ratio of the duration of T2 and T1 can be calculated first, and then the total data stored in the partition corresponding to all the determined first partition information and the The ratio of the duration ratio determines the ratio as the amount of data to be stored in T1, so that the number of the first partition can be determined; if the duration of T2 is as large as the duration of T1, all partitions corresponding to the first partition information The total amount of stored data is determined as the amount of data to be stored in T1, so that the number of the first partition can be determined.
- step S103 the number of the first partition can be calculated from the total amount of data and the storage capacity of a single partition, which can be calculated through a simple division operation.
- the storage capacity of a single partition is, for example, 20GB.
- the 20GB is a reasonable amount of data stored in a partition in HBase.
- the actual amount of data that can be stored in a partition can exceed 20GB.
- the storage capacity of a single partition is not limited, and can be determined according to the actual situation.
- the number of partitions required is determined by the number of servers, and is generally an integer multiple of the server.
- the total amount of data required to be stored cannot be predetermined, and the amount of data may be more or less.
- the amount of data that can be stored in a single partition is small, which increases the burden of HBase services; while the total amount of data to be stored is large and the server.
- the number is small, there are too few partitions, and the amount of data that can be stored in a single partition is too large, which is inconvenient for querying and using data.
- partitions can be created over time, and the number of partitions required in the future can be estimated based on the amount of data stored in existing partitions, and new partitions can be flexibly created in HBase, so that flexibility and Expandability is higher.
- determining the number of the first partition according to the total amount of data and the set storage volume of a single partition includes the following steps: calculating the total data and the set storage of the single partition The ratio of the quantity; round up the ratio, and determine the value obtained by the rounding as the number of the first partition.
- the method further includes the following steps:
- S400 Delete a partition corresponding to the second partition information in the database, and delete an entry in the partition information table where the second partition information is located.
- one way to determine that the partition needs to be deleted is, for example, when a second instruction indicating the deletion of the partition is received, it is determined that the partition needs to be deleted.
- the second instruction may be triggered periodically in the electronic device, and the instruction may be triggered at intervals, for example, the second instruction may be triggered every month (the interval may also be a day or a few days, etc., the specific time is not limited ). In this way, you can periodically delete the partition you want to delete.
- the second instruction can also be triggered externally, which is not limited in detail.
- the set effective duration can be two years, then t1 is the time two years before the current time t0, that is, two years is the validity period of the data, and the partition corresponding to the second partition information stores the data two years ago, which is useful It is not big enough, you can delete these invalid data. For example, if t0 is 10:10:11 on December 6, 2018, data and partitions earlier than 10:10:11 on December 6, 2016 can be deleted.
- the set effective duration can be determined according to needs.
- step S400 the partition corresponding to the second partition information in the database is deleted, the data on the partition is also deleted, and at the same time, the entry where the second partition information is located in the partition information table is deleted to avoid partition information There are too many entries in the table.
- partitions that store data earlier than the current time and set a valid duration can be deleted, so that each partition has a lifetime, and the partition will be deleted when the partition exceeds the lifetime, thereby achieving premature deletion Of invalid data and the purpose of freeing up storage space.
- the method further includes the following steps:
- a method for determining whether to delete a partition is determined, for example, when a third instruction indicating whether to delete a partition is received, it is determined whether to delete the partition.
- the third instruction may be triggered regularly in the electronic device, and the instruction may be triggered at intervals, for example, the third instruction may be triggered every month (the interval may also be a day or a few days, etc., the specific time is not limited ). In this way, you can periodically check whether you need to delete the partition.
- the third command can also be triggered externally, which is not limited.
- the amount of data stored in the database can be limited, and when the set data amount is exceeded, the partition corresponding to the earliest time interval is deleted to free up storage space so that the amount of data stored in the database does not exceed the set data Data, so as to avoid the problem that new data cannot be stored due to the large amount of data stored in the database.
- the second aspect of the present application provides a data storage method.
- the data storage method according to an embodiment of the present application will be described in more detail below, but it should not be limited thereto.
- a data storage method according to an embodiment of the present application is shown, including the following steps:
- T100 Obtain the time stamp in the first data to be stored
- T200 Determine at least one fourth partition information corresponding to the time interval matching the time stamp from the preset partition information table; the partition information table records the partition information of the created partition in the database and the corresponding Time interval
- T300 Determine a second partition for storing the first data according to the fourth partition information, and store the first data in the second partition of the database.
- the data storage method of the embodiment of the present application can also be applied to electronic devices.
- the related content of the electronic device please refer to the content in the partition management method of the foregoing embodiment, which will not be repeated here.
- the first data carries a time stamp
- the first data may be time-series data, which is not limited in detail.
- the time stamp in the first data is, for example, the time when the event associated with the first data occurs, and the data source carries the time stamp in the first data.
- step T200 the time interval in the partition information table may be traversed to determine whether the time stamp matches the traversed time interval. If it matches, the partition information corresponding to the traversed time interval is the fourth partition information.
- Determine whether the timestamp matches the traversed time interval for example: compare the timestamp with the smaller time endpoint of the time interval and the larger time endpoint, if the timestamp is greater than or equal to the smaller time endpoint and less than or equal to the larger time endpoint , It is determined that the time stamp matches the traversed time interval.
- the partition information table records the partition information of the created partition in the database and the corresponding time interval, which can be implemented based on the partition management method of the foregoing embodiment.
- the second partition required for storing the first data can be determined according to the determined fourth partition information, and the specific method for determining the second partition may depend on the amount of the determined fourth partition information.
- the primary key may include a timestamp and a unique identifier of the first data.
- the timestamp of different data may be the same, but the unique identifier can make the primary key of the data in the database unique, and the unique identifier can be randomly generated.
- Each partition has corresponding partition information.
- the partition information can include the start row position information and the end row position information of the partition in the database.
- the specific is not limited, as long as the corresponding partition can be found in the database according to the partition information .
- the partition information table records the partition information of the created partition in the database and the corresponding time interval.
- the data within a period of time can be stored in the partitions corresponding to several time intervals; when querying the data, it is not necessary to search for the data within a period of time in all the partitions, only the partition corresponding to the corresponding time interval That is, the amount of data needed to be searched can be reduced, thereby improving search efficiency.
- the above data storage method may be executed by a data storage device.
- the data storage device 200 includes three modules: a time stamp acquisition module 201, a first information determination module 202, and a data storage module 203.
- the time stamp acquisition module 201 is used to perform the above step T100
- the first information determination module 202 is used to perform the above step T200
- the data storage module 203 is used to perform the above step T300.
- step T300 determining the second partition for storing the first data according to the fourth partition information includes:
- T301 When a piece of fourth partition information is determined, determine the partition corresponding to the fourth partition information as the second partition;
- T302 When at least two fourth partition information is determined, one fourth partition information is selected from all fourth partition information, and the partition corresponding to the selected fourth partition information is determined as the second partition.
- a random selection method may be adopted, or the fourth partition information corresponding to the partition with the least stored data may be selected, which is not limited.
- the data storage method in the embodiment of the present application can be implemented on the basis of the aforementioned partition management method in the embodiment of the present application. After the partition for storing data is initially created and the partition information table is recorded, the data can be stored. Over time, new partitions can be continuously created and premature partitions can be deleted to ensure sustainable data storage.
- a third aspect of the present application provides a data query method.
- the data query method in the embodiments of the present application will be described in more detail below, but it should not be limited to this.
- a data query method according to an embodiment of the present application is shown, including the following steps:
- U200 Determine at least one target time interval T4 satisfying the query condition from the preset partition information table, and determine the fifth partition information corresponding to the T4 in the partition information table; the partition information table records The partition information and corresponding time interval of the created partition in the database;
- U300 query the second data from a partition of the database corresponding to the fifth partition information.
- the data query method of the embodiment of the present application can also be applied to electronic devices.
- the related content of the electronic device please refer to the content in the partition management method of the foregoing embodiment, which will not be repeated here.
- the query condition may be externally input, and the specific format and content of the query condition are not limited, as long as the required target time interval can be found.
- step U200 at least one T4 satisfying the query condition is determined from the partition information table according to the query conditions. Since the partition information table records the partition information of the created partition in the database and the corresponding time interval, it is determined At T4, the fifth partition information corresponding to T4 can be determined.
- the fifth partition information may include one or more, and each fifth partition information corresponds to a different partition.
- Each partition has corresponding partition information.
- the partition information can include the start row position information and the end row position information of the partition in the database.
- the specific is not limited, as long as the corresponding partition can be found in the database according to the partition information .
- step U300 after determining the partition required for querying the second data, the second data can be queried from the partition of the database corresponding to the fifth partition information.
- the partition information table records the partition information of the created partition in the database and the corresponding time interval.
- the above data query method may be executed by a data query device.
- the data query device 300 includes three modules: a condition acquisition module 301, a second information determination module 302, and a data query module 303.
- the condition acquisition module 301 is used to perform the above step U100
- the second information determination module 302 is used to perform the above step U200
- the data query module 303 is used to perform the above step U300.
- the query condition includes a first specified value and a second specified value, the first specified value is less than the second specified value;
- step U300 querying the second data from the partition of the database corresponding to the fifth partition information includes the following steps:
- U301 Traverse the data in the partition corresponding to the fifth partition information, and determine whether the timestamp in the traversed data is greater than or equal to the first specified value and less than or equal to the second specified value;
- the partitions that may have the required data are determined. After the partitions to be searched are determined, the required time can be accurately found from these partitions according to the query conditions.
- the second data in the segment realizes the secondary filtering of the data.
- the query condition includes a first specified value and a second specified value, the first specified value is less than the second specified value;
- step U200 determining at least one target time interval T4 satisfying the query condition from the preset partition information table includes the following steps:
- U202 For the traversed time interval, when the first specified value is greater than or equal to the minimum time stamp of the time interval and less than or equal to the maximum time stamp of the time interval, or when the second specified value is greater than or equal to the minimum time stamp of the time interval and Less than or equal to the maximum time stamp of the time interval, or when the first specified value is less than the minimum time stamp of the time interval and the second specified value is greater than the maximum time stamp of the time interval, the time interval is determined as the T4.
- the above query method can ensure that all or part of the time range between the first specified value and the second specified value of the search condition is queried, and also avoid too many time intervals from being queried, thereby ensuring the search Full rate and query speed.
- the smaller time endpoint is 20180715181001.100
- the larger time endpoint is 20180715184001.100
- the first specified value is 20180715180501.100
- the second specified value is 20180715183501.100
- 20180715183501.100 is greater than the smaller time endpoint and Less than the larger time endpoint, so the time interval is T4.
- the data query method in the embodiment of the present application may be implemented based on the foregoing partition management method and data storage method in the embodiment of the present application.
- the partition for storing data is initially created, the partition information table is recorded, and the data is stored. After that, you can use the above method for data query.
- a fourth aspect of the present application provides a partition management device.
- the partition management device 100 includes:
- the quantity determination module 101 is used to determine the number N of the first partitions needed to store data in the first time interval T1 when a partition needs to be created; the smaller time endpoint of T1 is later than the current time t0;
- the partition creation module 102 is configured to create the N first partitions in the database, and record the T1 in the preset partition information table corresponding to the partition information of the first partition.
- the quantity determination module includes:
- the historical information determining unit is configured to determine the first partition information corresponding to the second time interval T2 from the partition information table, and the larger time endpoint of T2 is not later than the t0;
- a data total amount determining unit which determines the total amount of data stored in the partition corresponding to the first partition information in the database
- the number determining unit is used to determine the number of the first partition according to the total amount of data and the set storage capacity of a single partition.
- the quantity determination unit includes:
- a first calculation subunit used to calculate the ratio of the total amount of data to the set storage capacity of a single partition
- the second calculation subunit is used to round up the ratio, and determine the rounded value as the number of the first partition.
- the device further includes:
- the expiration information determination module is used to determine at least one second partition information corresponding to the third time interval T3 from the partition information table when the partition needs to be deleted, the larger time endpoint of T3 is earlier than the specified time t1, The t1 is set earlier than the t0 for an effective duration;
- the first deletion module is configured to delete a partition corresponding to the second partition information in the database, and delete an entry where the second partition information is located in the partition information table.
- the device further includes:
- the deletion judgment module is used to judge whether the amount of data stored in the database exceeds the set amount of data when it is necessary to determine whether to delete the partition;
- the second deletion module is used to determine at least one third partition information recorded in the partition information table from the partition information table at the earliest, and delete the partition corresponding to the third partition information in the database And delete the entry where the third partition information is located in the partition information table.
- a fifth aspect of the present application provides a data storage device.
- the data storage device 200 includes:
- a time stamp obtaining module 201 configured to obtain a time stamp in the first data to be stored
- the first information determination module 202 is configured to determine at least one fourth partition information corresponding to the time interval matching the time stamp from a preset partition information table; the partition information table records that the database has been created Partition information and corresponding time interval of the partition;
- the data storage module 203 is configured to determine a second partition for storing the first data according to the fourth partition information, and store the first data in the second partition of the database.
- the data storage module includes:
- a first determining unit configured to determine the partition corresponding to the fourth partition information as the second partition when determining the fourth partition information
- the second determining unit is configured to select one fourth partition information from all fourth partition information when determining at least two fourth partition information, and determine the partition corresponding to the selected fourth partition information as the first Two partitions.
- a sixth aspect of the present application provides a data query device.
- the data query device 300 includes:
- the condition acquisition module 301 is used to acquire query conditions required for querying the second data
- the second information determining module 302 is configured to determine at least one target time interval T4 satisfying the query condition from the preset partition information table, and determine fifth partition information corresponding to the T4 in the partition information table;
- the partition information table records the partition information of the created partition in the database and the corresponding time interval;
- the data query module 303 is configured to query the second data from the partition of the database corresponding to the fifth partition information.
- the query condition includes a first specified value and a second specified value, the first specified value is less than the second specified value;
- the data query module includes:
- a traversal search unit used to traverse the data in the partition corresponding to the fifth partition information, and determine whether the timestamp in the traversed data is greater than or equal to the first specified value and less than or equal to the second specified value;
- the data determining unit is configured to determine the traversed data as the second data if it is.
- the query condition includes a first specified value and a second specified value, the first specified value is less than the second specified value;
- the second information determination module includes:
- a time interval traversing unit used to traverse the time interval in the partition information table
- Time interval determination unit for the traversed time interval, when the first specified value is greater than or equal to the minimum time stamp of the time interval and less than or equal to the maximum time stamp of the time interval, or when the second specified value is greater than or equal to the time interval.
- the minimum time stamp of and less than or equal to the maximum time stamp of the time interval, or when the first specified value is less than the minimum time stamp of the time interval and the second specified value is greater than the maximum time stamp of the time interval is determined as The T4.
- the relevant part can be referred to the description of the method embodiment.
- the device embodiments described above are only schematic, wherein 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.
- the present application also provides an electronic device, including a processor and a memory; the memory stores a program that can be called by the processor; wherein, when the processor executes the program, the partition as described in the foregoing embodiment is implemented Management method, data storage method, or data query method.
- FIG. 7 is a hardware structure diagram of the electronic device where the partition management device 10 is shown according to an exemplary embodiment of the present application, except for the processor 510 and memory shown in FIG. 7.
- the electronic device where the apparatus 10 is located may generally include other hardware according to the actual function of the electronic device, which will not be repeated here.
- the present application also provides a machine-readable storage medium on which a program is stored, and when the program is executed by a processor, a partition management method, a data storage method, or a data query method as described in any one of the foregoing embodiments is implemented .
- This application may take the form of a computer program product implemented on one or more storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing program code.
- Machine-readable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology.
- the information may be computer readable instructions, data structures, modules of programs, or other data.
- machine-readable 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 technologies, CD-ROM, digital versatile disk (DVD), or other optical storage , Magnetic tape cassette, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media, can be used to store information that can be accessed by computing devices.
- PRAM phase change memory
- SRAM static random access memory
- DRAM dynamic random access memory
- RAM random access memory
- ROM read-only Memory
- EEPROM electrically erasable programmable read-only memory
- flash memory or other memory technologies
- CD-ROM compact disc-read-only memory
- DVD digital versatile disk
- Magnetic tape cassette magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media, can be used to store information that can be accessed by computing devices.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
Claims (22)
- 一种分区管理方法,包括:在需创建分区时,确定在第一时间区间T1内存储数据所需的第一分区的数量N;所述T1的较小时间端点晚于当前时间t0;在数据库中创建所述N个第一分区,并将所述T1与所述第一分区的分区信息对应地记录在预设的分区信息表中。
- 如权利要求1所述的分区管理方法,其特征在于,确定在所述第一时间区间T1内存储数据所需的所述第一分区的数量N,包括:从所述分区信息表中确定出第二时间区间T2对应的第一分区信息,所述T2的较大时间端点不晚于所述t0;确定所述数据库中与所述第一分区信息对应的分区所存储的数据总量;依据所述数据总量及设定的单个分区存储量确定所述第一分区的数量。
- 如权利要求2所述的分区管理方法,其特征在于,依据所述数据总量及所述设定的单个分区存储量确定所述第一分区的数量,包括:计算所述数据总量与所述设定的单个分区存储量的比值;对所述比值进行向上取整,将取整所得值确定为所述第一分区的数量。
- 如权利要求1所述的分区管理方法,其特征在于,该方法进一步包括:在需删除分区时,从所述分区信息表中确定出至少一个第三时间区间T3对应的第二分区信息,所述T3的较大时间端点早于指定时间t1,所述t1比所述t0早设定有效时长;删除所述数据库中与所述第二分区信息对应的分区,并删除所述分区信息表中的所述第二分区信息所在表项。
- 如权利要求1所述的分区管理方法,其特征在于,该方法进一步包括:在需判断是否删除分区时,判断所述数据库中已存储的数据量是否超过设定数据量;若所述数据库中已存储的数据量超过所述设定数据量,从所述分区信息表中确定出至少一个最早记录至所述分区信息表中的第三分区信息,删除所述数据库中与所述第三分区信息对应的分区,并删除所述分区信息表中的所述第三分区信息所在表项。
- 一种数据存储方法,包括:获取待存储的第一数据中的时间戳;从预设的分区信息表中确定出与所述时间戳匹配的时间区间所对应的至少一个第 四分区信息;所述分区信息表中记录有数据库中已创建分区的分区信息及对应的时间区间;依据所述第四分区信息确定用于存储所述第一数据的第二分区,并将所述第一数据存储至所述数据库的第二分区中。
- 如权利要求6所述的数据存储方法,其特征在于,依据所述第四分区信息确定用于存储所述第一数据的第二分区,包括:当确定出一个第四分区信息时,将所述第四分区信息对应的分区确定为所述第二分区;当确定出至少两个第四分区信息时,从所有第四分区信息中选取出一个第四分区信息,将选取出的第四分区信息对应的分区确定为所述第二分区。
- 一种数据查询方法,包括:获取查询第二数据所需的查询条件;从预设的分区信息表中确定出满足所述查询条件的至少一个目标时间区间T4,并确定分区信息表中与所述T4对应的第五分区信息;所述分区信息表中记录有数据库中已创建分区的分区信息及对应的时间区间;从所述数据库的与所述第五分区信息对应的分区中查询所述第二数据。
- 如权利要求8所述的数据查询方法,其特征在于,所述查询条件包括第一指定值和第二指定值,所述第一指定值小于所述第二指定值;从所述数据库的与所述第五分区信息对应的分区中查询所述第二数据,包括:遍历所述第五分区信息对应的分区中的数据,判断遍历到的数据中的时间戳是否大于等于所述第一指定值且小于等于所述第二指定值;若所述遍历到的数据中的时间戳大于等于所述第一指定值且小于等于所述第二指定值,则确定所述遍历到的数据为所述第二数据。
- 如权利要求8所述的数据查询方法,其特征在于,所述查询条件包括所述第一指定值和所述第二指定值,所述第一指定值小于所述第二指定值;从预设的分区信息表中确定出满足所述查询条件的至少一个所述目标时间区间T4,包括:遍历所述分区信息表中的时间区间;针对遍历到的所述时间区间,当所述第一指定值大于等于该时间区间的最小时间戳且小于等于该时间区间的最大时间戳,或者当所述第二指定值大于等于该时间区间的最小时间戳且小于等于该时间区间的最大时间戳,或者当所述第一指定值小于该时间区间 的最小时间戳且所述第二指定值大于该时间区间的最大时间戳时,将该时间区间确定为所述T4。
- 一种分区管理装置,包括:数量确定模块,用于在需创建分区时,确定在第一时间区间T1内存储数据所需的第一分区的数量N;所述T1的较小时间端点晚于当前时间t0;分区创建模块,用于在数据库中创建所述N个第一分区,并将所述T1与所述第一分区的分区信息对应地记录在预设的分区信息表中。
- 如权利要求11所述的分区管理装置,其特征在于,所述数量确定模块,包括:历史信息确定单元,用于从所述分区信息表中确定出第二时间区间T2对应的第一分区信息,所述T2的较大时间端点不晚于所述t0;数据总量确定单元,确定所述数据库中与所述第一分区信息对应的分区所存储的数据总量;数量确定单元,用于依据所述数据总量及设定的单个分区存储量确定所述第一分区的数量。
- 如权利要求12所述的分区管理装置,其特征在于,所述数量确定单元,包括:第一计算子单元,用于计算所述数据总量与所述设定的单个分区存储量的比值;第二计算子单元,用于对所述比值进行向上取整,将取整所得值确定为所述第一分区的数量。
- 如权利要求11所述的分区管理装置,其特征在于,该装置还包括:过期信息确定模块,用于在需删除分区时,从所述分区信息表中确定出至少一个第三时间区间T3对应的第二分区信息,所述T3的较大时间端点早于指定时间t1,所述t1比所述t0早设定有效时长;第一删除模块,用于删除所述数据库中与所述第二分区信息对应的分区,并删除所述分区信息表中的所述第二分区信息所在表项。
- 如权利要求11所述的分区管理装置,其特征在于,该装置还包括:删除判断模块,用于在需判断是否删除分区时,判断所述数据库中已存储的数据量是否超过设定数据量;第二删除模块,用于若所述数据库中已存储的数据量超过设定数据量,从所述分区信息表中确定出至少一个最早记录至所述分区信息表中的第三分区信息,删除所述数据库中与所述第三分区信息对应的分区,并删除所述分区信息表中的所述第三分区信息所在表项。
- 一种数据存储装置,包括:时间戳获取模块,用于获取待存储的第一数据中的时间戳;第一信息确定模块,用于从预设的分区信息表中确定出与所述时间戳匹配的时间区间所对应的至少一个第四分区信息;所述分区信息表中记录有数据库中已创建分区的分区信息及对应的时间区间;数据存储模块,用于依据所述第四分区信息确定用于存储所述第一数据的第二分区,并将所述第一数据存储至所述数据库的第二分区中。
- 如权利要求16所述的数据存储装置,其特征在于,所述数据存储模块,包括:第一确定单元,用于当确定出一个第四分区信息时,将所述第四分区信息对应的分区确定为所述第二分区;第二确定单元,用于当确定出至少两个第四分区信息时,从所有第四分区信息中选取出一个第四分区信息,将选取出的第四分区信息对应的分区确定为所述第二分区。
- 一种数据查询装置,包括:条件获取模块,用于获取查询第二数据所需的查询条件;第二信息确定模块,用于从预设的分区信息表中确定出满足所述查询条件的至少一个目标时间区间T4,并确定分区信息表中与所述T4对应的第五分区信息;所述分区信息表中记录有数据库中已创建分区的分区信息及对应的时间区间;数据查询模块,用于从所述数据库的与所述第五分区信息对应的分区中查询所述第二数据。
- 如权利要求18所述的数据查询装置,其特征在于,所述查询条件包括第一指定值和第二指定值,所述第一指定值小于所述第二指定值;所述数据查询模块,包括:遍历查找单元,用于遍历所述第五分区信息对应的分区中的数据,判断遍历到的数据中的时间戳是否大于等于所述第一指定值且小于等于所述第二指定值;数据确定单元,用于若所述遍历到的数据中的时间戳大于等于所述第一指定值且小于等于所述第二指定值,则确定所述遍历到的数据为所述第二数据。
- 如权利要求18所述的数据查询装置,其特征在于,所述查询条件包括所述第一指定值和所述第二指定值,所述第一指定值小于所述第二指定值;所述第二信息确定模块,包括:时间区间遍历单元,用于遍历所述分区信息表中的时间区间;时间区间确定单元,用于针对遍历到的所述时间区间,当所述第一指定值大于等于 该时间区间的最小时间戳且小于等于该时间区间的最大时间戳,或者当所述第二指定值大于等于该时间区间的最小时间戳且小于等于该时间区间的最大时间戳,或者当所述第一指定值小于该时间区间的最小时间戳且第二指定值大于该时间区间的最大时间戳时,将该时间区间确定为所述T4。
- 一种电子设备,其特征在于,包括处理器及存储器;所述存储器存储有可被处理器调用的程序;其中,所述处理器执行所述程序时,实现如权利要求1-5中任意一项所述的分区管理方法、权利要求6或7所述的数据存储方法、或权利要求8-10中任意一项所述的数据查询方法。
- 一种机器可读存储介质,其特征在于,其上存储有程序,该程序被处理器执行时,实现如权利要求1-5中任意一项所述的分区管理方法、权利要求6或7所述的数据存储方法、或权利要求8-10中任意一项所述的数据查询方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811628668.5A CN111382197B (zh) | 2018-12-28 | 2018-12-28 | 分区管理、数据存储和查询方法及装置、设备、介质 |
| CN201811628668.5 | 2018-12-28 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020135737A1 true WO2020135737A1 (zh) | 2020-07-02 |
Family
ID=71127771
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/129277 Ceased WO2020135737A1 (zh) | 2018-12-28 | 2019-12-27 | 分区管理、数据存储和查询方法及装置、设备、介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN111382197B (zh) |
| WO (1) | WO2020135737A1 (zh) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113590675A (zh) * | 2021-06-29 | 2021-11-02 | 阿里巴巴新加坡控股有限公司 | 数据存储、查询、管理方法、装置、设备、系统及程序 |
| CN116627990A (zh) * | 2023-06-16 | 2023-08-22 | 中国银行股份有限公司 | 数据库表处理方法、装置、设备和存储介质 |
| CN119513206A (zh) * | 2025-01-13 | 2025-02-25 | 中电科金仓(北京)科技股份有限公司 | 数据库中数据的范围分区方法、介质、产品及设备 |
| WO2025202763A1 (zh) * | 2024-03-27 | 2025-10-02 | 云智能资产控股(新加坡)私人股份有限公司 | 文件处理方法、计算设备、存储介质及程序产品 |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113297135B (zh) * | 2021-02-10 | 2025-04-04 | 阿里巴巴集团控股有限公司 | 数据处理方法以及装置 |
| CN119166679A (zh) * | 2024-09-06 | 2024-12-20 | 北京奥星贝斯科技有限公司 | 应用于分区分裂过程中的数据查询方法及装置、电子设备 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20080172526A1 (en) * | 2007-01-11 | 2008-07-17 | Akshat Verma | Method and System for Placement of Logical Data Stores to Minimize Request Response Time |
| CN105573889A (zh) * | 2015-12-15 | 2016-05-11 | 上海仪电(集团)有限公司 | 虚拟机监控数据的存取方法及装置 |
| CN106407191A (zh) * | 2015-07-27 | 2017-02-15 | 中国移动通信集团公司 | 一种数据处理方法及服务器 |
| CN107861989A (zh) * | 2017-10-17 | 2018-03-30 | 平安科技(深圳)有限公司 | 数据的分区存储方法、装置、计算机设备及存储介质 |
Family Cites Families (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7734615B2 (en) * | 2005-05-26 | 2010-06-08 | International Business Machines Corporation | Performance data for query optimization of database partitions |
| US20080228783A1 (en) * | 2007-03-14 | 2008-09-18 | Dawn Moffat | Data Partitioning Systems |
| US20090198736A1 (en) * | 2008-01-31 | 2009-08-06 | Jinmei Shen | Time-Based Multiple Data Partitioning |
| CN102063490B (zh) * | 2010-12-20 | 2012-12-19 | 大唐移动通信设备有限公司 | 一种数据库分区方法和分区装置 |
| US10108690B1 (en) * | 2013-06-06 | 2018-10-23 | Amazon Technologies, Inc. | Rolling subpartition management |
| CN105446991B (zh) * | 2014-07-07 | 2018-10-30 | 阿里巴巴集团控股有限公司 | 数据存储方法、查询方法及设备 |
| CN105868071A (zh) * | 2016-03-23 | 2016-08-17 | 乐视网信息技术(北京)股份有限公司 | 监测数据的处理方法及装置 |
| CN107657058A (zh) * | 2017-10-19 | 2018-02-02 | 上海大汉三通数据通信有限公司 | 一种数据的查询方法及相关装置 |
| CN108197267B (zh) * | 2018-01-02 | 2021-04-27 | 武汉斗鱼网络科技有限公司 | 数据库分区表的扩展分析方法、装置及终端设备 |
-
2018
- 2018-12-28 CN CN201811628668.5A patent/CN111382197B/zh active Active
-
2019
- 2019-12-27 WO PCT/CN2019/129277 patent/WO2020135737A1/zh not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20080172526A1 (en) * | 2007-01-11 | 2008-07-17 | Akshat Verma | Method and System for Placement of Logical Data Stores to Minimize Request Response Time |
| CN106407191A (zh) * | 2015-07-27 | 2017-02-15 | 中国移动通信集团公司 | 一种数据处理方法及服务器 |
| CN105573889A (zh) * | 2015-12-15 | 2016-05-11 | 上海仪电(集团)有限公司 | 虚拟机监控数据的存取方法及装置 |
| CN107861989A (zh) * | 2017-10-17 | 2018-03-30 | 平安科技(深圳)有限公司 | 数据的分区存储方法、装置、计算机设备及存储介质 |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113590675A (zh) * | 2021-06-29 | 2021-11-02 | 阿里巴巴新加坡控股有限公司 | 数据存储、查询、管理方法、装置、设备、系统及程序 |
| CN116627990A (zh) * | 2023-06-16 | 2023-08-22 | 中国银行股份有限公司 | 数据库表处理方法、装置、设备和存储介质 |
| WO2025202763A1 (zh) * | 2024-03-27 | 2025-10-02 | 云智能资产控股(新加坡)私人股份有限公司 | 文件处理方法、计算设备、存储介质及程序产品 |
| CN119513206A (zh) * | 2025-01-13 | 2025-02-25 | 中电科金仓(北京)科技股份有限公司 | 数据库中数据的范围分区方法、介质、产品及设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111382197B (zh) | 2023-10-27 |
| CN111382197A (zh) | 2020-07-07 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020135737A1 (zh) | 分区管理、数据存储和查询方法及装置、设备、介质 | |
| US10459898B2 (en) | Configurable-capacity time-series tables | |
| US10762108B2 (en) | Query dispatching system and method | |
| CN107807796B (zh) | 一种基于超融合存储系统的数据分层方法、终端及系统 | |
| EP3944556B1 (en) | Block data storage method and apparatus, and block data access method and apparatus | |
| CN106648446A (zh) | 一种用于时序数据的存储方法、装置及电子设备 | |
| US10552460B2 (en) | Sensor data management apparatus, sensor data management method, and computer program product | |
| CN108196787B (zh) | 集群存储系统的配额管理方法以及集群存储系统 | |
| US20190087437A1 (en) | Scheduling database compaction in ip drives | |
| US11057465B2 (en) | Time-based data placement in a distributed storage system | |
| CN113946552B (zh) | 数据处理方法及电子装置 | |
| CN109299115A (zh) | 一种数据存储方法、装置、服务器及存储介质 | |
| CN114090577A (zh) | 时序数据的存储、读取方法及装置 | |
| CN111125171A (zh) | 一种监测数据存取方法、装置、设备及可读存储介质 | |
| CN112632058A (zh) | 轨迹确定方法、装置及设备、存储介质 | |
| CN107894942B (zh) | 数据表访问量的监控方法和装置 | |
| CN115687525B (zh) | 客户名单的同步方法以及装置、处理器 | |
| WO2016184199A1 (zh) | 一种文件管理的方法、设备和系统 | |
| CN117539392A (zh) | 一种磁带库数据处理方法及系统、电子设备、存储介质 | |
| CN105718485B (zh) | 一种将数据录入数据库的方法及装置 | |
| CN111177077A (zh) | 数据存储及数据查询方法、装置、设备、介质 | |
| CN111190949B (zh) | 数据存储及处理方法、装置、设备、介质 | |
| CN107819804B (zh) | 云端储存设备系统及决定其架构的高速缓存中数据的方法 | |
| US20150006832A1 (en) | Vsam data set tier management | |
| CN106326139A (zh) | 一种音/视频数据文件循环存储方法及系统 |
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: 19904715 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: 19904715 Country of ref document: EP Kind code of ref document: A1 |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19904715 Country of ref document: EP Kind code of ref document: A1 |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 04.02.2022) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19904715 Country of ref document: EP Kind code of ref document: A1 |