Data storage method, query method and related equipment and storage medium

By adjusting the effective time of the storage object, the uniqueness of commodity prices at each time point or time period is ensured, multiple price problems during query in the existing technology are solved, and accurate storage and query of commodity prices are achieved.

CN112307017BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010972707.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-16
Publication Date
2024-10-18
Estimated Expiration
2040-09-16

Smart Images

  • Figure CN112307017B_ABST
    Figure CN112307017B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a data storage method and device, a query method and device, a computer storage medium and a computer device, wherein the storage method comprises: obtaining a storage object and a property of the storage object, wherein the property comprises a to-be-stored effective time of the storage object and first data, wherein the first data is represented as the value of the storage object within the to-be-stored effective time; obtaining the stored effective time of the property and second data, wherein the second data is represented as the value of the property within the stored effective time; determining whether to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data based on the to-be-stored effective time and the stored effective time; determining the target data to be stored based on the determination result; and storing the target data to be stored.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to data management technology, and in particular to a data storage method and device, a query method and device, a computer storage medium and a computer device. Background Art

[0002] In the scheme for storing massive data, there is a situation where the same type of data has different values ​​at different times. For example, in the application scenario of maintaining the commodity prices of e-commerce, the commodity prices may be different at different times. To facilitate the recording of these prices, the identification of the commodity, the identification of the merchant selling the commodity, the purchase or selling price of the commodity, and the effective time of each price are usually stored in the data storage device. Exemplarily, the data storage device can record the following corresponding relationships, and corresponding relationship 1 is: merchant 1, commodity A, September 1-5, 220 yuan. Corresponding relationship 1 means that merchant 1 sells commodity A at a price of 220 yuan during September 1-5. Corresponding relationship 2 is: merchant 2, commodity A, September 4-6, 210 yuan. Corresponding relationship 2 means that merchant 2 sells commodity A at a price of 210 yuan during September 4-6. Correspondence 3 is: Merchant 1, Commodity A, September 6, 200 yuan. Correspondence 3 means that Merchant 1 sells Commodity A at a price of 200 yuan on September 6. This is equivalent to storing the sales demand of each merchant for each commodity in different time periods in the data storage device. This storage method is too rough. Since the purchase price or selling price of different merchants in the same time period may be different, and the purchase or selling price of the same merchant at different times is also different, when querying the price of the commodity, it will cause multiple prices for the same commodity at a certain query time, resulting in the inability to obtain the accurate price. Moreover, this storage method has multiple prices when querying the price at a certain time point, and it is even more impossible to query the price of the commodity in a certain time period. It can be seen that a delicate storage method is urgently needed, which can at least solve the above problems. Summary of the invention

[0003] To solve the existing technical problems, the embodiments of the present application provide a data storage method and device, a query method and device, a computer storage medium and a computer device.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] The present application provides a data storage method, including:

[0006] Obtaining a storage object and an attribute of the storage object, wherein the attribute includes a storage effective time to be stored and first data of the storage object, wherein the first data is represented by a value of the storage object within the storage effective time;

[0007] Obtaining a stored effective time of the attribute and second data, wherein the second data is characterized by a value of the attribute within the stored effective time;

[0008] Determining whether to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data according to the effective time to be stored and the effective time already stored;

[0009] According to the determination result, the target data to be stored is determined;

[0010] The target data to be stored is stored.

[0011] In the above scheme, determining whether to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data based on the effective time to be stored and the stored effective time includes:

[0012] Determine whether the to-be-stored effective time and the stored effective time have an intersecting time point;

[0013] If it is determined that it exists, determining to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data;

[0014] Accordingly, determining the target data to be stored based on the determination result includes:

[0015] The adjusted effective time and the value of the storage object within the adjusted effective time are determined as the target data to be stored.

[0016] In the above scheme, when it is determined that the storage object exists, determining to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data includes:

[0017] The to-be-stored effective time and the stored effective time are both time periods; the time period includes the start time and the end time of the effective time;

[0018] If it is judged to exist,

[0019] Obtaining a first starting time and a first ending time of the effective time period to be stored;

[0020] Obtain a second starting time and a second ending time of the stored effective time period;

[0021] Obtain a first element set according to the first starting time, the first ending time, the second starting time, and the second ending time;

[0022] According to a judgment result that at least some elements in the first element set are new data or old data, determining to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data;

[0023] Among them, the elements in the first element set whose values ​​are the first starting moment or the first ending moment are new data, and the elements in the first element set whose values ​​are the second starting moment or the second ending moment are old data.

[0024] In the above scheme, obtaining the first element set according to the first starting time, the first ending time, the second starting time, and the second ending time includes:

[0025] The first starting time, the first ending time, the second starting time, and the second ending time are sorted in chronological order to obtain a first element set.

[0026] In the above scheme, the step of determining to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data based on the result of determining that at least some elements in the first element set are new data or old data includes:

[0027] In the case where the first element and the last element in the first element set are both new data, determining a time period formed by the first element and the last element as a new effective time of the storage object whose value is the first data;

[0028] In the case where the first element in the first element set is new data and the last element in the first element set is old data, the next element in the first element set other than the first element that is represented as new data is obtained, and the time period formed by the first element and the next element that is represented as new data is the new effective time of the storage object whose value is the first data; the time period formed by the element and the last element is the new effective time of the storage object whose value is the second data;

[0029] In the case where the first element and the last element in the first element set are both old data, the time period formed by the first element and the second element is the new effective time of the storage object whose value is the first target data; wherein the second data includes the first target data and the second target data, and the first target data is the value of the storage object in the stored effective time period corresponding to the first element; the time period formed by the second element and the next element represented as new data except the first and second elements in the first element set is the new effective time of the storage object whose value is the first data; the time period formed by the next element represented as new data and the last element is the new effective time of the storage object whose value is the second target data; wherein the second target data is the value of the storage object in the stored effective time period corresponding to the last element.

[0030] In the above solution, after determining to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data, the method further includes:

[0031] Obtaining a query time period for the storage object;

[0032] Determining the value of the storage object in the query time period based on the effective time period of the storage object under each value;

[0033] Output the value of the storage object during the query period.

[0034] In the above solution, before determining the value of the storage object in the query time period, the method further includes:

[0035] Determine whether there is an effective time that intersects with the query time period among the effective times of the storage object under various values;

[0036] If it is determined that the query time period exists, the query time period is divided into segments according to the effective time period intersecting with the query time period;

[0037] Obtaining the value of the storage object in each segment;

[0038] The values ​​of the storage object in each segment are output.

[0039] The present application provides a data query method, including:

[0040] Get the query time period for the storage object;

[0041] Obtaining each stored value of the storage object and the effective time under each value;

[0042] Determining the value of the storage object in the query time period based on the effective time of the storage object under each value;

[0043] Output the value of the storage object in the query time period.

[0044] In the above scheme, the effective time is a time period.

[0045] Determine whether there is an effective time period that intersects with the query time period among the effective time periods of the storage object under various values;

[0046] If it is determined that the query time period exists, the query time period is divided into segments according to the effective time period intersecting with the query time period;

[0047] Obtaining the value of the storage object in each segment;

[0048] The values ​​of the storage object in each segment are output.

[0049] The present application provides a data storage device, including:

[0050] A first obtaining unit is used to obtain a storage object and an attribute of the storage object, wherein the attribute includes a storage effective time to be stored and first data of the storage object, wherein the first data is represented by a value of the storage object within the storage effective time;

[0051] A second obtaining unit, configured to obtain a stored effective time of the attribute and second data, wherein the second data is represented by a value of the attribute within the stored effective time;

[0052] A first determining unit, configured to determine whether to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data according to the effective time to be stored and the stored effective time;

[0053] A second determining unit, used to determine target data to be stored according to the determination result;

[0054] The storage unit is used to store the target data to be stored.

[0055] In the above solution, the first determining unit is further used to:

[0056] Determine whether the to-be-stored effective time and the stored effective time have an intersecting time point;

[0057] If it is determined that it exists, determining to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data;

[0058] Correspondingly, the second determining unit is used to determine the adjusted effective time and the value of the storage object within the adjusted effective time as the target data to be stored.

[0059] The present application provides a data query device, including:

[0060] A first obtaining unit, used to obtain a query time period for a storage object;

[0061] A second obtaining unit, used to obtain each value of the stored object and the effective time under each value;

[0062] A determination unit, configured to determine a value of the storage object in a query time period based on the effective time of each value of the storage object;

[0063] An output unit is used to output the value of the storage object in the query time period.

[0064] In the above scheme, the effective time is a time period.

[0065] A determination unit, configured to determine whether there is an effective time period that intersects with the query time period among the effective time periods of the storage object under various values;

[0066] If it is determined that the query time period exists, the query time period is divided into segments according to the effective time period intersecting with the query time period;

[0067] Obtaining the value of the storage object in each segment;

[0068] The output unit is used to output the values ​​of the storage object in each segment.

[0069] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the program implements the steps of the aforementioned data storage method and / or the aforementioned data query method.

[0070] An embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned data storage method and / or the steps of the aforementioned data query method when executing the program.

[0071] The embodiments of the present application provide a data storage method and device, a query method and device, a computer storage medium and a computer device, wherein the storage method comprises: obtaining a storage object and a property of the storage object, wherein the property comprises a to-be-stored effective time of the storage object and first data, wherein the first data is represented as the value of the storage object within the to-be-stored effective time; obtaining the stored effective time of the property and second data, wherein the second data is represented as the value of the property within the stored effective time; determining whether to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data based on the to-be-stored effective time and the stored effective time; determining the target data to be stored based on the determination result; and storing the target data to be stored.

[0072] In an embodiment of the present application, based on the effective time to be stored and the stored effective time of the storage object, it is determined whether to adjust the effective time of the storage object whose storage object value is the first data and / or the effective time of the storage object whose storage object value is the second data; based on the determination result, the (target) data to be stored is determined and stored.

[0073] The data stored according to the solution provided in the embodiment of the present application realizes clear and accurate storage of the value of the storage object and the effective time of the value. Compared with the relatively rough storage method in the related art, the storage solution provided in the embodiment of the present application is more delicate in the storage of the value of the storage object and the effective time. Taking into account the situation encountered during the query, it is possible to solve the problems encountered by the storage method in the related art during the query. For example, when querying the value of the storage object, the accurate effective time information of the value can be provided, and the situation where the value of the storage object at the same effective time is not unique will not occur. When querying a certain effective time information of the storage object, it is possible to realize accurate query of the value of the storage object in the time period, which can avoid the problem of loss of interests caused by inaccurate acquisition of the value of the storage object within the effective time. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0075] Figure 1 Schematic diagram of the implementation process of the data storage method provided in the embodiment of the present application Figure 1 ;

[0076] Figure 2 Schematic diagram of the implementation process of the data storage method provided in the embodiment of the present application Figure 2 ;

[0077] Figure 3 Schematic diagram of the implementation process of the data storage method provided in the embodiment of the present application Figure 3 ;

[0078] Figure 4 Schematic diagram of the implementation process of the data query method provided in the embodiment of the present application Figure 1 ;

[0079] Figure 5 Schematic diagram of the implementation process of the data storage method provided in the embodiment of the present application Figure 4 ;

[0080] Figure 6 Schematic diagram of basic intersection and complex intersection provided in the embodiments of the present application;

[0081] Figure 7 Schematic diagram of the implementation process of the data storage method provided in the embodiment of the present application Figure 5 ;

[0082] Figure 8 Schematic diagram of the implementation process of the data query method provided in the embodiment of the present application Figure 2 ;

[0083] Fig. 9 A schematic diagram of the structure of a data storage device provided in an embodiment of the present application;

[0084] Fig.10 A schematic diagram of the structure of a data query device provided in an embodiment of the present application;

[0085] Fig.11 A schematic diagram of the hardware structure of a data storage and / or query device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0086] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other arbitrarily. The steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. In addition, although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.

[0087] Before introducing the technical solutions of the embodiments of the present application, the technical terms that may be used in the embodiments of the present application are first explained:

[0088] 1) Storage object: The stored object can be any storable object in a massive data storage device. For example, in a solution for storing commodity prices, the storage object is the commodity price.

[0089] 2) The attributes of the stored object can be used to identify the characteristics of the stored object, which is any reasonable attribute of the stored object. In the scheme of storing commodity prices, the attributes of the stored object include any of the following information: the value of the commodity price, the effective time of the commodity, the identification of the commodity, and the merchant identification. Among them, the commodity identification refers to the selling price or purchase price of the commodity price; the merchant identification refers to the merchant of which the commodity belongs.

[0090] 3) Effective time, the stored effective time point or time period. For example, in the solution of storing commodity prices, it can refer to the time when the commodity price takes a certain value, such as the time when the value of a certain commodity price is B is June 1-June 1.

[0091] The present application embodiment provides a data storage method, which is applied to a data storage device. Figure 1 As shown, the method includes:

[0092] S101: Obtain a storage object and its attributes, wherein the attributes include a storage effective time to be stored and first data of the storage object, wherein the first data is represented by a value of the storage object within the storage effective time;

[0093] In this step, it is necessary to know the objects and their attributes that need to be stored, such as which characteristics of the goods need to be stored, such as the price of the goods, and the attributes of the characteristics that need to be stored, such as the value of the goods price and the effective time information of the value. It can be understood that the maintenance personnel can maintain the information stored in the data storage device, such as adding, deleting, modifying, etc. When there is a maintenance demand, the maintenance personnel will input the storage objects and their attributes that they maintain this time into the data storage device, and the data storage device learns the storage objects and their attributes by receiving the content input by the maintenance personnel. Since the focus of the embodiment of the present application is on maintaining the data stored in the data storage device, such as adding or adding data, the maintenance operation of the maintenance personnel can be based on the maintenance operation generated to the data storage device, such as adding or adding operations, and inputting the expected operation such as adding content to the data storage device. The data storage device in the embodiment of the present application can be a system that only stores storage objects such as commodity prices, or a system that stores other storage objects such as travel destinations, or a system that stores different storage objects.

[0094] S102: Obtaining a stored effective time of the attribute and second data, wherein the second data is represented by a value of the attribute within the stored effective time;

[0095] In this step, the data storage device reads the stored effective time of the storage object that the maintenance personnel expects to maintain currently and the value of the storage object within the stored effective time from the information stored in the data storage device. It can be understood that if the stored effective time of the storage object and the value within the effective time are regarded as a record, the number of records stored may be one or more. That is, the stored effective time of the storage object and the number of second data read in this step may be one or more, which can be flexibly set according to the specific situation.

[0096] S103: Determine whether to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data according to the effective time to be stored and the stored effective time;

[0097] In this step, the data storage device determines whether to adjust the effective time of the storage object that the maintenance personnel expects to store as the first data and / or the effective time of the storage object that has been stored as the second data based on the to-be-stored and stored effective time of the storage object.

[0098] S104: Determine the target data to be stored according to the determination result;

[0099] S105: Storing the target data to be stored.

[0100] In S104 and S105, if it is determined that adjustment is required based on the effective time to be stored and the target effective time, the adjusted effective time and the value of the storage object within the adjusted effective time are determined as the target data to be stored. If it is determined that no adjustment is required, the effective time to be stored input into the data storage device by the maintenance personnel and the value of the storage object within the effective time to be stored, i.e., the first data, are regarded as the target data to be stored. The target data to be stored is stored.

[0101] The subject that executes S101 to S105 is a data storage device.

[0102] In the above S101 to S105, the data storage device can determine whether to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data according to the effective time to be stored and the effective time stored of the storage object; and determine the target data to be stored according to the result of whether to adjust, and store the target data to be stored. This is equivalent to a scheme for determining whether to adjust the effective time of the storage object according to the effective time to be stored and the effective time stored. The data stored according to this scheme can ensure that the value of the storage object of the attribute of the storage object to be stored is unique within a certain effective time, and there will be no situation where the value of the storage object at the same effective time is not unique. In this way, it can be avoided that the situation where the accurate value of the storage object cannot be obtained due to the existence of multiple values ​​of the same commodity at the same time point in subsequent queries. When querying the data stored using the above scheme, the accurate value of the storage object at a certain time point or time period can be obtained, and accurate query of the value of the storage object can be achieved. That is, at the application level, the value of the storage object and the effective time of the value stored by the above-mentioned solution can provide accurate effective time information of the value when querying the value of the storage object in the future; when querying the effective time information of a storage object, it is possible to accurately query the value of the storage object in the time period, and avoid the problem of loss of interests caused by inaccurate acquisition of the value of the storage object within the effective time. The storage method in the related art is relatively rough, and the storage solution provided in the embodiment of the present application is more delicate in the storage of the value of the storage object and the effective time. As mentioned above, the solution of the embodiment of the present application takes into account the situations encountered during the query, and can solve the problems encountered by the storage method in the related art during the query.

[0103] In some embodiments, Figure 2 As shown, S103 can also be implemented by the following solution:

[0104] S1041: Determine whether there is an intersecting time point between the to-be-stored effective time and the stored effective time;

[0105] If it is determined to exist, execute S1042;

[0106] If it is determined that the address does not exist, execute S1044;

[0107] S1042: Determine to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data, and continue to execute S1043;

[0108] S1043: storing the adjusted effective time and the value of the storage object within the adjusted effective time, and the storage process ends;

[0109] S1044: storing the storage object's effective time to be stored and the value of the storage object within the effective time to be stored, that is, the first data, and the process ends;

[0110] In this step, if S1041 determines that it does not exist, the effective time is not adjusted. That is, no adjustment is required, and the effective time to be stored of the storage object input by the maintenance personnel to the data storage device and the value of the storage object within the effective time to be stored - the first data can be directly stored in the data storage device, and the process ends.

[0111] In the above-mentioned S1041 to S1043, based on the judgment result of whether there is an intersecting time point between the effective time to be stored and the effective time, the process of adjusting or not adjusting the effective time is determined, which can ensure the accuracy of the determination.

[0112] In practical applications, the effective time (including the effective time to be stored and the stored effective time) can be a discrete time point or a continuous time period. The time information can be in seconds, minutes, hours, days, months, and years. If the unit is days, the discrete time points can be specific dates, such as June 1st and June 2nd. The time period refers to a number of consecutive days, such as June 1st to June 3rd, June 4th to June 10th, etc. The effective time in the embodiment of the present application is preferably a time period.

[0113] In the case where the to-be-stored effective time and the stored effective time are time periods, the time period includes the start time and the end time of the effective time, such as the time period shown as June 4 to June 10, which starts at June 4 and ends at June 10. In the case where the number of stored effective time periods is at least one, the number of the start time and the end time of each stored effective time period may be one or more, depending on the specific situation.

[0114] In some embodiments, when the to-be-stored effective time and the stored effective time are time periods, such as Figure 3 As shown, S1042 can be implemented by the following scheme:

[0115] When it is determined that the to-be-stored effective time and the stored effective time have an intersecting time point, the method further includes:

[0116] S301: Obtain a first starting time and a first ending time of the effective time period to be stored;

[0117] S302: Obtain a second start time and a second end time of the stored effective time period;

[0118] There is no strict order between S301 and S302, and they can be performed simultaneously. The starting moment of the effective time period to be stored is regarded as the first starting moment, and the ending moment is regarded as the first ending moment. The starting moment of the stored effective time period is regarded as the second starting moment, and the ending moment is regarded as the second ending moment. It can be understood that in actual applications, the maintenance personnel expect to store the effective time period in a manner of one effective time period per effective time period each time. In one maintenance operation, the effective time period to be stored is a time period, and the first starting moment and the first ending moment are a time point. The number of stored effective time periods stored in the data storage device is usually multiple, each stored effective time period has a starting moment and an ending moment, and multiple stored effective time periods have multiple starting moments and ending moments.

[0119] S303: Obtain a first element set according to the first starting time, the first ending time, the second starting time, and the second ending time;

[0120] This step is equivalent to the step of constructing the first element set. Sort the first starting moment, the first ending moment, the second starting moment, and the second ending moment in chronological order to obtain the first element set. That is, the first element set is obtained by sorting the first and second starting moments and the first and second ending moments in chronological order. The first element set includes multiple elements (the first element, the second element...the Nth element), N is a positive integer greater than or equal to 4, and the value of each element is the aforementioned several moment values.

[0121] S304: Determine to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data based on the judgment result that at least some elements in the first element set are new data or old data; wherein, the elements in the first element set whose values ​​are the first starting time or the first ending time are new data, and the elements in the first element set whose values ​​are the second starting time or the second ending time are old data.

[0122] In the above-mentioned S301 to S304, the first element set is constructed using the start time and end time of the effective time period to be stored and the effective time period that has been stored, and the effective time of the storage object is adjusted according to the judgment result that at least part of the elements in the first element set are new data or old data, so as to ensure the accuracy of the adjustment of the effective time. The data stored by using this adjustment scheme can ensure that the attribute of the storage object expected to be stored is unique within a certain effective time, and the value of the storage object at the same effective time will not be non-unique. In this way, it is possible to avoid the situation where multiple values ​​are queried when querying the value of the storage object within a certain time.

[0123] In some embodiments, taking the stored effective time to be stored as an example, a scheme for adjusting the effective time, that is, determining the scheme for adjusting the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data according to the judgment result that at least some elements in the first element set are new data or old data, may include the following three situations according to the judgment result of whether the first element and the last element in the first element set are new data or old data:

[0124] In the first case, when the first element and the last element in the first element set are both new data, the time period formed by the first element and the last element is determined as the new effective time of the attribute whose value is the first data.

[0125] In the first case, it is equivalent to adjusting the time to be stored and the time already stored to a new effective time.

[0126] In the second case, when the first element in the first element set is new data and the last element is old data, the next element in the first element set other than the first element that represents new data is obtained, and the time period formed by the first element and the element is the new effective time of the attribute whose value is the first data; the time period formed by the element and the last element is the new effective time of the attribute whose value is the second data.

[0127] In the second case, it is equivalent to adjusting the time to be stored and the time already stored to two new effective times.

[0128] In the third case, when the first element and the last element in the first element set are both old data, the time period formed by the first element and the second element is the new effective time of the storage object whose value is the second data (the first new effective time of the second data); the time period formed by the second element and the next element represented as new data except the first and second elements in the first element set is the new effective time of the storage object whose value is the first data; the time period formed by the next element represented as new data and the last element is the new effective time of the storage object whose value is the second data (the second new effective time of the second data).

[0129] In the third case, it is equivalent to adjusting the to-be-stored time and the stored time to three new effective times; the three new effective times include two new effective times when the storage object takes the second data as the value and one new effective time when the storage object takes the first data as the value. In this case, if the value of the storage object in the stored effective time period corresponding to the first element is the first target data, and the value of the storage object in the stored effective time period corresponding to the last element is the second target data, then the time period composed of the first element and the second element is the new effective time of the storage object taking the first target data as the value; the time period composed of the next element represented as new data and the last element is the new effective time of the storage object taking the second target data as the value.

[0130] The above describes three solutions for adjusting the stored effective time and the time to be stored. For this situation, please refer to the subsequent description of the basic intersection and complex intersection. The repetition will not be repeated.

[0131] In the third case, illustratively, when there are two stored effective time periods, such as time period 1 and time period 2, the value of the storage object in time period 1 is A, and the value of the storage object in time period 2 is B. If the value of the first element is the start time or end time of time period 1, then the effective time period corresponding to the first element is time period 1, and the first target data is the value of the storage object in time period 1, that is, A. If the value of the last element is the start time or end time of time period 2, then the effective time period corresponding to the last element is time period 2, and the second target data is the value of the storage object in time period 2, that is, B.

[0132] The above scheme is a scheme for storing data provided by the embodiment of the present application. After the data is stored, specifically, Figure 4 As shown, the method also includes:

[0133] S401: Obtaining a query time period for the storage object;

[0134] S402: Obtaining each stored value of the storage object and the effective time under each value;

[0135] S403: Determine the value of the storage object in the query time period based on the effective time of each value of the storage object;

[0136] S404: Output the value of the storage object in the query time period.

[0137] Since the storage object is stored according to the time information based on the value of the storage object, when querying a certain effective time information of the storage object, the query of the value within a certain time period can be realized, and the accurate query of the value within a certain time period can be realized. The problem of loss of interests caused by inaccurate acquisition of the value of the storage object within the effective time can be avoided, and the accurate query of the commodity price within the time period can be realized. Due to the adoption of the above-mentioned storage scheme, it can be guaranteed that the value of the storage object of the attribute of the storage object expected to be stored is unique within a certain effective time, and the situation that the value of the storage object at the same effective time is not unique will not occur. Therefore, in the query process of executing S401 to S404, the above beneficial effects can be obtained.

[0138] In some embodiments, before determining the value of the storage object in the query time period, the method further includes: determining whether there is an effective time that intersects with the query time period among the effective times of the storage object under each value; if it is determined that there is, segmenting the query time period according to the effective time period that intersects with the query time period; obtaining the value of the storage object in each segment; and outputting the value of the storage object in each segment. That is, if the query time period intersects with the effective time period stored in the data storage device, the query time period is segmented to obtain each segment, and the value of the query time period in each segment is regarded as the expected output value and output, so as to achieve accurate output / query of the value of the storage object in the query time period. Outputting the value of the storage object in each segment can achieve refined output of the value in the query time period.

[0139] The embodiments of the present application are further described in detail below in conjunction with the accompanying drawings and specific application scenarios.

[0140] In this application scenario, the data storage device is used to store the purchase price of goods as an example for explanation, that is, the storage object is the price of goods, which can be the purchase price of goods. Before introducing the use of the solution in the embodiment of this application to store the purchase price of goods, the following problems exist in the use of related technologies to store the purchase price of goods:

[0141] When using related technologies to store commodity purchase prices (referred to as commodity prices), there is an overlap in the effective time of commodity prices. If you query the price of a commodity at a certain point in time, multiple prices will be queried, and the accurate price at that point in time cannot be obtained. Since it is impossible to obtain the accurate price at each point in time, it is naturally impossible to query the price of the commodity in a certain period of time. The storage in the related technology may have overlapping effective times for commodity prices, so it may not be possible to accurately query the commodity price according to the time when the price actually takes effect. In short, the storage method of commodity prices in the related technology is relatively rough, which is not conducive to query and has low query efficiency. The above problems in the related technology can be solved in this application scenario. Please see the following instructions for details.

[0142] In actual applications, considering that different merchants may have different purchase prices for the same commodity, and the same merchant may have different purchase prices for the same commodity in different time periods, in this application scenario, the standard price and the special price are stored separately according to whether the commodity is purchased at a standard price or a special price. Among them, the standard price is a price set to stabilize the market, and the special price is a purchase price that is lower than the standard price and can be obtained by some merchants with certain purchase channels. In specific implementation, when storing the standard price or the special price, the price and its effective time can be recorded in the form of an entry, such as recording the corresponding relationship between sku_id (commodity identifier), merchant identifier, commodity price (storage object), commodity price value, and the effective time period of the price (the purchase price within the time period is the value of the commodity price in the record). In this application scenario, it is preferred that the effective time information in each record is a time period.

[0143] When there is a need, such as adding a purchase price of a certain commodity to a merchant, the maintenance personnel can input information such as the commodity ID, merchant ID, commodity price (storage object), the value of the commodity price, and the effective time of the value into the (data storage) device. The data storage device receives the input of the maintenance personnel, and learns the price of the commodity that is expected to be added to the data storage device through the commodity price, and learns the price of the commodity expected to be added through the information of the value of the commodity price (the reported price); and learns the effective time information of the reported price through the effective time information of the commodity price (S501). It can be understood that for the convenience of maintenance, it is expected that the price value of the commodity stored in the data storage device is unique within a certain time period. In the case of learning the price of the commodity that needs to be added to the data storage device, it is necessary to first ensure that after the above information expected to be added to the device is added to the device, there will be no situation where the same commodity of the same merchant has two or more prices within the same effective time period.

[0144] To avoid this situation, follow Figure 5 In layman's terms, Figure 5 In the process shown, when the device receives the above information input by the maintenance personnel, the stored effective time of each commodity price is read, and it is determined whether the expected effective time information (effective time information to be stored) of the expected added price (submitted price) and / or the read stored effective time need to be split or adjusted (S502). If the determination is no, it means that the data storage device does not store a record characterized as the value of the commodity price within the effective time to be stored as the submitted price, and the submitted price and the effective time of the submitted price are directly stored in the data storage device. The submitted price, the effective time of the submitted price, the commodity identifier, and the merchant identifier can also be recorded as one entry for storage.

[0145] In specific implementation, when it is determined that there is an intersecting time point between the to-be-stored effective time of the submitted price and the stored effective time, it is determined that splitting or adjustment is required, and the splitting or adjustment logic is called to split or adjust the effective time (S503), and the split effective time information, product identification, merchant identification, and the value of the product within the split effective time are recorded in the form of entries. If there is no intersecting time point, the submitted price and the effective time of the submitted price are directly stored in the data storage device; or the submitted price, the effective time of the submitted price, the product identification, and the merchant identification are recorded as an entry and stored. In this application scenario, in order to facilitate the operation and query of the maintenance personnel, the recorded entry information can be stored in the price life cycle table (S504). Later, when you want to query the information such as the price of the product and / or the effective time of the product at a certain price, you can directly query it in the price life cycle table.

[0146] It can be understood that in the price life cycle table, a flag bit can be set for each record, and the flag bit is used to identify whether the effective time recorded in the record is valid. If it is valid, the flag bit can be set to 1, and if it is invalid, the flag bit can be set to 0, and vice versa. To a certain extent, the invalid effective time of a record means that the record is also invalid. The significance of setting the flag bit is to avoid querying invalid records, and to make the content of the record consistent with the actual usage requirements. The price life cycle table can be stored in a dedicated price library or a standard price library. In specific implementation, two types of price life cycle tables can be provided, one type is used to record the effective time of the proposed price as a dedicated price, and the other type is used to record the effective time of the proposed price as a standard price. The price life cycle table used to record the effective time of the proposed price as a dedicated price is stored in the dedicated price library, and the price life cycle table used to record the effective time of the proposed price as a dedicated price is stored in the standard price library. If the type of the price submitted is the standard price, it is equivalent to storing the relevant information indicating that the submitted price is the standard price (the specific value of the price, the effective time, the commodity identification, the merchant identification, etc.) in the standard price library (S505). If the type of the price submitted is the special price, it is equivalent to storing the relevant information indicating that the submitted price is the special price in the special price library (S505). It can be understood that in this application scenario, the effective time of the special price of the commodity and the effective time of the standard price are stored separately in the form of vertical sub-library and sub-table, that is, the corresponding library (standard price library and special price library) is used to store the effective time of the special price and the standard price respectively. There are usually multiple entries stored in each library, and the stored entries can be stored in the form of horizontal sub-library and sub-table, that is, the entries in each library are stored one by one to facilitate the maintenance of the stored data. In addition, the maintenance personnel can also record each maintenance operation in the data storage device, such as recording the addition operation and the query operation, and make an operation record flow table. Exemplarily, the current maintenance operation, such as adding operation, operation time and other information, is recorded in the operation record flow table.

[0147] In this application scenario, assuming that both the effective time of the submitted price and the stored effective time are time periods, for the effective time information of the submitted price to be stored, if there is a time point in the data storage device where the stored effective time information intersects with the effective time information, then the intersection between the effective time of the submitted price and the stored effective time has the following four situations:

[0148] like Figure 6 As shown in the left content of , since the stored effective time information is the data already stored in the data storage device, it can be regarded as old data, and the effective time of the submitted price is the new time expected to be added to the data storage device, which can be regarded as new data.

[0149] The first type is that the intersection of the new and old data is located in the front part of the new data. For example, the new data is from June 1st to June 12th, and the old data is from May 21st to June 5th. The intersection of the two is from June 1st to June 5th, which is within the first part of the new data from June 1st to June 12th.

[0150] The second type is that the intersection of the new and old data is located in the latter part of the new data. For example, the new data is from May 29 to June 6, and the old data is from June 1 to June 9. The intersection of the two is June 1 to June 6, which is the latter part of the new data from May 29 to June 6.

[0151] The third type is that the new data covers part of the old data; for example, the new data is from June 6th to June 9th, and the old data is from June 1st to June 22nd. The intersection of the two is June 6th to June 9th, and June 1st to June 9th of the old data is covered by the new data.

[0152] The fourth type is that the new data covers all the old data; for example, the new data is from May 29th to June 22nd, and the old data is from June 1st to June 5th. The intersection of the two is June 1st to June 5th, and the old data from June 1st to June 5th is covered by the new data.

[0153] The above are several intersection situations between a single or single stored effective time and the effective time of the submitted price, which can be regarded as basic intersection situations. In the case of basic intersection, the first case mentioned above is used as an example to illustrate how to split or adjust the time of a single old data and new data. The commodity price of the old data is regarded as price 1, and the commodity price of the new data is price 2. In this case, the maintenance personnel expect that the price from May 21st to June 1st will still be maintained as the old price - price 1, and the price from June 2nd to June 12th will be the new price - price 2.

[0154] In practical applications, considering that there should not be two or more prices on the same day, the records in the database should use a half-open and half-closed form to record the effective time, such as the effective time of the old price-price 1 is [May 21, June 1). The effective time of the new price-price 2 is [June 1, June 12). This is equivalent to splitting the stored effective time and the effective time to be stored into two (time) intervals, interval 1 is [May 21, June 1), interval 2 is [June 1, June 12). Among them, the price of the product in interval 1 is the old price, and the price of the product in interval 2 is the new price. For the splitting of the second to fourth basic intersection situations mentioned above, please refer to the splitting of the first basic intersection situation. In the case of the second basic intersection, it is split into two (time) intervals, interval 1 is [May 29, June 6), interval 2 is [June 6, June 9). Among them, the product in interval 1 is the new price, and the product in interval 2 is the old price. In the case of the third basic intersection, it is split into three (time) intervals, interval 1 is [June 1, June 6), interval 2 is [June 6, June 9), interval 3 is [June 9, June 22). Among them, the goods in intervals 1 and 3 are the old prices, and the goods in interval 2 are the new prices. In the case of the fourth basic intersection, it is split into one (time) interval, interval 1 is [May 29, June 22), and the prices of goods in this interval are the new prices. It can be seen that for these four basic intersection situations, it can be split into a maximum of 3 intervals and a minimum of 1 interval. Figure 6 As shown, in the second to fourth basic intersection cases, the basis can be divided into 2 intervals, 3 intervals and 1 interval.

[0155] In actual applications, among the stored effective time information, there are usually two or more stored effective time information that intersect with the effective time information of the submitted price. Figure 6 As shown in the right content of , take the case where the data storage device has stored 2 or 2 pieces of stored effective time information that intersects with the effective time information of the submitted price, that is, for the new data, there are two old data that intersect with it, and the intersection situation has the following four situations:

[0156] Case 1: The intersection of the new data and each old data is part of the new data; Figure 6 The first and second complex intersection situations are shown in FIG.

[0157] In the first complex intersection case, the old data 1 is May 21-June 5, the old data 2 is June 10-June 22, and the new data is June 1-12. The intersection of old data 1 and the new data is June 1-5, and the intersection of old data 2 and the new data is June 10-6.12.

[0158] In the second complex intersection situation, the old data 1 is May 21-June 5, the old data 2 is June 10-June 12, and the new data is June 1-12. The intersection of the old data 1 and the new data is June 1-5, and the intersection of the old data 2 and the new data is June 10-6.12.

[0159] Scenario 2: The new data overwrites all the old data; Figure 6 The third complex intersection is shown in FIG. In the third complex intersection, the old data 1 is from May 21 to June 5, the old data 2 is from June 6 to June 7, and the new data is from June 1 to June 12. The new data will completely cover the old data.

[0160] Scenario 3: New data overwrites part of the old data; Figure 6 The fourth and fifth complex intersection situations.

[0161] In the fourth complex intersection situation, the old data 1 is May 21-June 5, the old data 2 is June 6-June 7, and the new data is June 1-12. The intersection of the new data and the old data 1 is June 1-5, and the intersection of the new data and the old data 2 is June 6-June 7, which is equivalent to the new data covering all of the old data 2 and the latter part of the old data 1, June 1-June 5.

[0162] In the fifth complex intersection situation, the old data 1 is June 1-June 5, the old data 2 is June 1-June 9, and the new data is May 29-June 6. The intersection of the new data and the old data 1 is June 1-5, and the intersection of the new data and the old data 2 is June 1-June 6, which is equivalent to the new data covering all of the old data 1 and the first part of the old data 2, June 1-June 6.

[0163] In the case of complex intersection, the first complex intersection case mentioned above is used as an example to illustrate how to split the two old data and new data in time. The commodity price of old data 1 is regarded as price 1, the commodity price of old data 2 is regarded as price 2, and the commodity price of new data is regarded as price 3. In this case, the maintenance personnel expect that the price from May 21st to June 1st will still be maintained as the old price - price 1, the price from June 2nd to June 12th will be the new price - price 3; and the price from June 13th to June 22nd will be the old price - price 2. Among them, price 1 and price 2 can be regarded as the first target data and the second target data mentioned above.

[0164] In actual applications, a half-open and half-closed form is used to record the effective time. For example, the effective time of the old price - Price 1 is [May 21, June 1). The effective time of the new price - Price 3 is [June 1, June 12). For example, the effective time of the old price - Price 2 is [June 12, June 22). This is equivalent to splitting the stored effective time and the effective time to be stored into three (time) intervals. Interval 1 is [May 21, June 1), interval 2 is [June 1, June 12), and interval 3 is [June 12, June 22). For the splitting of the remaining complex intersection situations, please refer to the splitting of the first complex intersection situation. The detailed process will not be repeated. Therefore, for these complex intersection situations, it can be split into a maximum of 3 intervals and a minimum of 1 interval. Figure 6 As shown, in the second to fifth complex intersection cases, the basis can be split into 3 intervals, 1 interval, 2 intervals and 2 intervals.

[0165] It can be understood that the aforementioned calling of splitting or adjusting logic for splitting can be regarded as splitting or adjusting the effective time according to the aforementioned several basic intersection situations or complex intersection situations. If each intersection situation is regarded as a splitting or adjusting logic, one of the splitting logics can be called in a maintenance operation such as an adding operation to split or adjust the effective time.

[0166] Combine the following Figure 7 As shown, taking the first basic intersection situation as an example, the new data is from June 1st to 12th, and the old data is from May 21st to June 5th, to illustrate how to split the interval at the technical level.

[0167] The data storage device identifies the start time (start time 1: June 1) and end time (end time 1: June 12) of the new data. The data storage device identifies the start time (start time 2: May 21) and end time (end time 2: June 5) of the old data. Sort all the identified start times and end times in chronological order to obtain the first element set. Exemplarily, the first element set includes N elements, where N is the number of all start times and all end times. The first element set = {element 1, element 2...element N}. In this application scenario, N = 4, element 1 = May 21 (start time 2); element 1 = June 1 (start time 1); element 3 = June 5 (end time 3); element 4 = June 12 (end time 1). The first element set is regarded as a TreeMap. In the TreeMap, element-by-element search can be performed in a tree structure.

[0168] The data storage device determines whether the first element (element 1) in the TreeMap is new data or old data. In this application scenario, element 1 = May 21, which is old data, then this element and the second element in the TreeMap (element 2: June 1) constitute interval 1, that is, interval 1 is [May 21, June 1). Search for the next new data in the elements in the TreeMap other than elements 1 and 2. For example, if element 4 = June 12, then element 2 and the next new data found (June 12) constitute interval 2, that is, interval 2 is [June 1, June 12]. Determine whether the last element in the TreeMap (element 4 = June 12) is new data or old data. If it is new data, the effective time information is obtained after the aforementioned interval 1 and interval 2 are split as the final effective intervals of the new data and the old data, that is, at this time, the effective intervals of the new data and the old data are split into 2 intervals. Then the price of the goods in interval 1 [May 21, June 1) is still the old price (the purchase price from May 21 to June 5 is price 1), and the price of the goods in interval 2 [June 1, June 12) is the new price - the reported price. The product identifier, merchant identifier, interval 1 and its price value, interval 2 and its price value are recorded in the price life cycle table. If the last element in the TreeMap (element 4 = June 12) is old data, the next new data found (June 12) and the last element need to form interval 3, that is, the new data and the old data are split into 3 intervals at this time. It can be understood that the aforementioned splitting of new data and old data is actually the process of adjusting the stored effective time and the effective time to be stored. This adjustment scheme can ensure that the price of the goods in each effective time in the stored data is unique, and there is no situation of multiple values, which can facilitate subsequent queries.

[0169] The following takes the first complex intersection situation mentioned above as an example. The old data 1 is from May 21 to June 5, the old data 2 is from June 10 to June 22, and the new data is from June 1 to 12. The old and new data are split, that is, the stored effective time and the effective time to be stored are adjusted.

[0170] The data storage device identifies the start time (start time 1: June 1) and end time (end time 1: June 12) of the new data. The data storage device identifies the start time (start time 2: May 21; and start time 3: June 10) and end time (end time 2: June 5; and end time 3: June 22) of the old data. Sort all the identified start times and end times in chronological order to obtain the first element set. Exemplarily, in this application scenario, N=6, element 1=May 21; element 1=June 1; element 3=June 5; element 4=June 10; element 5=June 12; element 6=June 22. The first element set is regarded as a TreeMap. In the TreeMap, element by element can be searched in a tree structure.

[0171] The data storage device determines whether the first element (element 1) in the TreeMap is new data or old data. In this application scenario, element 1 = May 21, which is old data, then this element and the second element in the TreeMap (element 2: June 1) form interval 1, that is, interval 1 is [May 21, June 1). Find the next new data in the elements in the TreeMap other than elements 1 and 2. For example, if element 5 = June 12, then element 2 and the next new data found (element 5) form interval 2, that is, interval 2 is [June 1, June 12]. Determine whether the last element in the TreeMap (element 6 = June 22) is new data or old data. If it is old data, the next new data found (June 12) and the last element need to form interval 3, that is, interval 3 is [June 12, June 22). That is, at this time, the new data and the old data are split into 3 intervals. Then the price of the goods in interval 1 [May 21, June 1) is still the old price 1 (the price corresponding to the old data 1), the price of the goods in interval 2 [June 1, June 12) is the new price minus the reported price, and the price of the goods in interval 3 [June 12, June 22) is the old price 3 minus (the price corresponding to the old data 2). The product ID, merchant ID, each interval 1, and the value of the product price in each interval are recorded in the price life cycle table.

[0172] In the price life cycle table, the entry originally stored that reflects the old price 1 and its effective time [May 21, June 5) is set to an invalid flag such as 0. The entry originally stored that reflects the old price 3 and its effective time [June 10, June 22) is set to an invalid flag such as 0. The storage scheme in the embodiment of the present application is equivalent to the need to add effective time and price value to the data storage device, and it is necessary to readjust these effective times according to the effective time to be added and the stored effective time that has an intersection with the effective time to be added, so that the prices of the goods stored in the library at the same time point or time period are unique.

[0173] It can be understood that the aforementioned splitting of the new data (effective time period of the commodity price to be stored) and the old data that intersects with the new data (effective time period of the stored commodity price that intersects with the effective time period to be stored) is actually a process of re-adjusting the stored effective time and the effective time to be stored. This adjustment scheme can ensure that the price of the commodity within each effective time in the stored data is unique, and there are no multiple values, which can facilitate subsequent queries.

[0174] The above is a data storage solution. After the above data is stored in the data storage device, the maintenance personnel can query the data stored in the data storage device at any time, such as querying the price of the product, and further querying the effective time of the product price. Figure 8 As shown, the query process is: the maintenance personnel generates a query operation, inputs the commodity identification to be queried, the attribute is the commodity price and the time period to be queried into the data storage device, and obtains the purchase price of the commodity in the time period to be queried through the commodity identification, commodity price and the time period to be queried. The data storage device receives the data input by the maintenance personnel, searches for all prices of the commodity from the price life cycle table, and searches for the effective time of each price. If the effective time of the found price is regarded as the stored effective time, it is determined from the found stored effective time information whether there is an effective time that intersects with the time period to be queried. If it is determined that it does not exist, it means that the data storage device does not store the price information in the time period to be queried, and outputs a prompt message. The prompt message is used to remind the maintenance personnel that there is no price record in the time period to be queried and the price information has not been queried.

[0175] From the stored effective time information found, if it is determined that there is an effective time that intersects with the time period to be queried, the time period to be queried is divided into segments. Assume that the time period to be queried is May 25-June 15, that is, the maintenance personnel expect to obtain the purchase price of the product from May 25 to June 15. Assume that the purchase price of [June 1, June 10) is stored as price 1 for the product, and the purchase price of [June 10, June 22) is stored as price 2, then there are two stored effective time periods that intersect with the time period to be queried (June 1-10 and June 10-June 22). Since the data storage device does not store the price of the product from May 25 to May 31, the data storage device regards [May 25, June 1) as the first segment obtained by segmenting the query time period, and outputs a prompt message for the first segment. The prompt message is used to remind the maintenance personnel that there is no price record and no price information is found in the [May 25, June 1) time period. The remaining query time periods [June 1, June 15) in the query time period except the [May 25, June 1) time period are processed one by one with the intersecting stored effective time periods as follows: See Figure 8 As shown, identify the start time (June 1) and end time (June 9) of the first intersecting stored effective time period, and record the start time and end time as the basic data set. Identify the start time and end time of the remaining time period to be queried [June 1, June 15), and determine whether the start time of the remaining time period to be queried is less than the (minimum) effective start time (i.e., the start time) of the basic data set. If less than, use the minimum effective start time as the effective start time of the remaining time period to be queried. If greater than or equal to, use the start time of the remaining time period to be queried as the effective start time of the remaining time period to be queried. Determine whether the end time of the remaining time period to be queried is less than the (maximum) effective end time (i.e., the end time) in the basic data set. If less than, use the end time of the remaining time period to be queried as the effective end time of the remaining time period to be queried. If greater than or equal to, use the maximum effective end time in the basic data set as the effective end time of the remaining time period to be queried.

[0176] If the start time and end time of the stored effective time period (start time: June 1st; and end time June 9th) are used as the basic data set, then through the above scheme, the effective start time of the remaining time period to be queried is June 1st, and the effective end time is June 10th. If the start time and end time of the stored effective time period (start time: June 10th; and end time June 22nd) are used as the basic data set, then through the above scheme, the effective start time of the remaining time period to be queried is June 10th, and the effective end time is June 15th. For the operation of querying the commodity price in the query time period [May 25th, June 15th) by the maintenance personnel, the data storage device outputs that there is no price record in the time period [May 25th, June 1st), the commodity price of [June 1st, June 10th) is price 1, and the commodity price of [June 10th, June 15th) is price 2, so as to give the query result of the current query operation of the maintenance personnel. This is equivalent to dividing the time period to be queried into three segments: segment 1 is [May 25, June 1), segment 2 is [June 1, June 10), and segment 3 is [June 10, June 15).

[0177] In this application scenario, the effective time information when the commodity price takes a certain value can also be queried. The maintenance personnel can input the value of the commodity price to be queried into the data storage device. The data storage device reads the time information corresponding to the value from the price life cycle table and outputs the read information. According to the data stored in the above scheme, when querying the effective time information when the commodity price takes a certain value, the data storage device can output the accurate effective time information of the value to the maintenance personnel.

[0178] As known from the foregoing, the storage scheme of the embodiment of the present application determines the data to be stored (target data to be stored) by determining whether to adjust the effective time of the commodity price, and stores the target data to be stored. According to the data stored in this scheme, it can be ensured that there will be no overlapping of the effective time of the commodity price, and each price of the commodity is unique within a certain effective time, and there will be no situation where the value of the commodity price at the same effective time is not unique. The commodity price stored in the embodiment of the present application can ensure that no matter when querying the effective time information of the commodity price when the value is a certain numerical value, or querying the value of the commodity price at a certain effective time, the information to be queried can be accurately obtained, and the information to be queried can be avoided from querying errors. Not only can the accurate query of the commodity price at a certain time be realized, but also the accurate query of the commodity price at a certain time can be realized, which greatly improves the query efficiency and alleviates the storage pressure of the database. If the effective time when the queryable commodity price takes a certain value is regarded as a queryable dimension, and the value of the queryable commodity price at a certain effective time is regarded as another queryable dimension, then the query scheme of the embodiment of the present application provides a scheme for querying data in multiple dimensions, and accurate query information can be obtained regardless of which dimension is queried. Compared with the single query scheme in the related art that can only query the price at a certain point in time, the scheme in the embodiment of the present application is equivalent to expanding the query dimension, allowing maintenance personnel to query the required data from multiple dimensions, which is convenient for users. In addition, compared with the scheme in the related art that queries the price at a certain point in time and outputs the price after sorting, in addition to querying the price at a time point, the embodiment of the present application can also query the price within the time period without sorting, thereby improving the query efficiency.

[0179] In an embodiment of the present application, a data storage method is provided for data with an effective time period, such as commodity prices, which can expand the data query dimension and improve the query efficiency. Storing data according to this method can at least ensure: 1) that there is no intersection between the effective time of the newly added commodity price and the stored commodity price; 2) when querying data with the effective time as the query condition, the stored effective time that intersects with the query condition is processed as the basic data set, and the query result is given (please refer to the above-mentioned relevant instructions for details), and the query is accurate and efficient.

[0180] From the above scheme, it can be seen that in the data storage scheme, the effective time of the commodity price value is determined based on the effective time to be stored and the stored effective time, that is, the split scheme. The data stored according to this scheme can ensure that the value of the expected commodity price within a certain effective time is unique, and there will be no situation where the price is not unique at the same effective time. In the subsequent query scheme, the accurate price of the commodity price at a certain time point or time period can be obtained, and the accurate query of the commodity price can be realized. Moreover, the commodity price is output in a segmented scheme, which realizes the refined output of the commodity price within the time period to be queried.

[0181] From the application level, the embodiments of the present application have at least the following advantages:

[0182] 1) In the business layer, the present invention vertically divides the standard price and the special price into different databases and tables, and reasonably designs the storage layer.

[0183] 2) The idea of ​​splitting or adjusting the effective time to be stored and the stored effective time that has an intersection with the effective time to be stored is introduced. This design method transfers the time cost of querying prices to the time consumed for each storage and submission of prices. In the solution of splitting or adjusting the effective time, multi-threading is used. For example, each thread is responsible for searching an element in the TreeMap, which can shorten the search time.

[0184] 3) When querying the price of a product within a certain period of time, the search time is greatly shortened and the output of the search results is accelerated. It can better support the maintenance of massive prices and has a longer-term use significance.

[0185] 4) In the splitting or adjusting effective time scheme, the splitting or adjustment logic can be called in a multi-threaded manner, such as each thread is responsible for calling a splitting or adjustment logic, so as to better utilize the characteristics of distributed services and make the system more scalable.

[0186] 5) For data with effective time periods, such as commodity prices, a data storage method is provided that can expand the data query dimension and improve query efficiency. The storage solution can ensure that the effective time of the newly added commodity prices and the stored commodity prices do not overlap. In the query solution, when the effective time is used as the query condition for data query, the stored effective time that intersects with the query condition is processed as the basic data set, and the query result is given, and the query is accurate and efficient.

[0187] The present application also provides a data query method, such as Figure 4 As shown, the method includes:

[0188] S401: Obtaining a query time period for a storage object;

[0189] S402: Obtaining each stored value of the storage object and the effective time under each value;

[0190] S403: Determine the value of the storage object in the query time period based on the effective time of each value of the storage object;

[0191] S404: Output the value of the storage object in the query time period.

[0192] In the above scheme, since the data is stored according to the attribute values ​​in time periods, the query of the attribute values ​​in a certain time period (s) can be realized in S401 to S404, and the accurate query of the attribute values ​​in a certain time period can be realized.

[0193] In some embodiments, the effective time is a time period.

[0194] Determine whether there is an effective time period that intersects with the query time period in the effective time periods of the storage object under each value; if it is determined that there is, divide the query time period into segments according to the effective time periods that intersect with the query time period; obtain the value of the storage object in each segment; and output the value of the storage object in each segment. Outputting the value of the storage object in each segment can achieve accurate and refined output of the value of the storage object within the query time period.

[0195] For the specific implementation process of the data query method here, please refer to the above related instructions, and the repeated process will not be repeated.

[0196] The present application provides an embodiment of a data storage device, such as Fig. 9 As shown, it includes: a first obtaining unit 1001, a second obtaining unit 1002, a first determining unit 1003 and a second determining unit 1004, and a storage unit 1005; wherein,

[0197] The first obtaining unit 1001 is used to obtain a storage object and an attribute of the storage object, wherein the attribute includes a storage effective time to be stored and first data of the storage object, wherein the first data is represented by a value of the storage object within the storage effective time;

[0198] A second obtaining unit 1002 is used to obtain the stored effective time of the attribute and second data, wherein the second data is represented by the value of the attribute within the stored effective time;

[0199] A first determining unit 1003 is used to determine whether to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data according to the effective time to be stored and the stored effective time;

[0200] The second determining unit 1004 is used to determine the target data to be stored according to the determination result;

[0201] The storage unit 1005 is used to store the target data to be stored.

[0202] In some embodiments, the first determining unit 1003 is used to determine whether there is an intersecting time point between the effective time to be stored and the stored effective time; if it is determined that there is an intersecting time point, determine to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data;

[0203] The second determining unit 1004 is configured to determine the adjusted effective time and the value of the storage object within the adjusted effective time as the target data to be stored.

[0204] In some embodiments, the effective time to be stored and the stored effective time are both time periods; the time period includes the start time and the end time of the effective time; the first determination unit 1003 is used to obtain the first start time and the first end time of the effective time period to be stored when it is determined to exist; obtain the second start time and the second end time of the stored effective time period; obtain the first element set based on the first start time, the first end time, the second start time and the second end time; based on the judgment result that at least some elements in the first element set are new data or old data, determine to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data; wherein, the elements in the first element set whose values ​​are the first start time or the first end time are new data, and the elements in the first element set whose values ​​are the second start time or the second end time are old data.

[0205] In some embodiments, the first determining unit 1003 is used to sort the first start time, the first end time, the second start time and the second end time in chronological order to obtain a first element set.

[0206] In some embodiments, the first determining unit 1003 is used to determine, when the first element and the last element in the first element set are both new data, that the time period formed by the first element and the last element is the new effective time of the storage object whose value is the first data;

[0207] In the case where the first element in the first element set is new data and the last element is old data, obtaining the next element in the first element set other than the first element that is represented as new data, the first element and the time period formed by the element are the new effective time of the storage object whose value is the first data; the time period formed by the element and the last element are the new effective time of the storage object whose value is the second data;

[0208] In the case where the first element and the last element in the first element set are both old data, the time period formed by the first element and the second element is the new effective time of the storage object whose value is the first target data; wherein the second data includes the first target data and the second target data, and the first target data is the value of the storage object in the stored effective time period corresponding to the first element; the time period formed by the second element and the next element represented as new data except the first and second elements in the first element set is the new effective time of the storage object whose value is the first data; the time period formed by the next element represented as new data and the last element is the new effective time of the storage object whose value is the second target data; wherein the second target data is the value of the storage object in the stored effective time period corresponding to the last element.

[0209] In some embodiments, the device further comprises a query unit, configured to:

[0210] Obtaining a query time period for the storage object;

[0211] Determining the value of the storage object in the query time period based on the effective time period of the storage object under each value;

[0212] An output unit is used to output the value of the storage object during the query period.

[0213] In some embodiments, the query unit is used to:

[0214] Determine whether there is an effective time that intersects with the query time period among the effective times of the storage object under various values;

[0215] If it is determined that the query time period exists, the query time period is divided into segments according to the effective time period intersecting with the query time period;

[0216] Obtaining the value of the storage object in each segment;

[0217] The output unit is used to output the values ​​of the storage object in each segment.

[0218] It can be understood that the first obtaining unit 1001, the second obtaining unit 1002, the first determining unit 1003, the second determining unit 1004, and the query unit in the device can be implemented by a central processing unit (CPU, Central Processing Unit), a digital signal processor (DSP, Digital Signal Processor), a microcontroller unit (MCU, Microcontroller Unit) or a field-programmable gate array (FPGA, Field-Programmable Gate Array) of a data storage device in actual applications. The storage unit 1005 can be implemented by a memory.

[0219] The present application also provides a data query device, such as Fig.10 As shown, it includes: a first obtaining unit 1101, a second obtaining unit 1102, a determining unit 1103, and an output unit 1104; wherein,

[0220] A first obtaining unit 1101 is used to obtain a query time period for a storage object;

[0221] The second obtaining unit 1102 is used to obtain each stored value of the storage object and the effective time under each value;

[0222] A determining unit 1103, configured to determine a value of the storage object in a query time period based on the effective time of each value of the storage object;

[0223] The output unit 1104 is used to output the value of the storage object in the query time period.

[0224] In some embodiments, the second obtaining unit 1102 is used to:

[0225] Determine whether there is an effective time period that intersects with the query time period among the effective time periods of the storage object under various values;

[0226] If it is determined that the query time period exists, the query time period is divided into segments according to the effective time period intersecting with the query time period;

[0227] Obtaining the value of the storage object in each segment;

[0228] The output unit 1104 is used to output the value of the attribute in each segment.

[0229] It should be noted that the data storage and query device of the embodiment of the present application, since the principle of solving the problem by the data storage and query device is similar to that of the aforementioned data storage and query method, the implementation process and implementation principle of the data storage and query device can be referred to the description of the implementation process and implementation principle of the aforementioned data storage and query method, and the repeated parts will not be repeated.

[0230] The present application also provides a computer-readable storage medium having a computer program stored thereon, wherein the program is at least used to execute when executed by a processor Figures 1 to 8 The steps of any of the methods shown. The computer readable storage medium may be a memory. The memory may be Fig.11 The memory 62 is shown.

[0231] Fig.11 Schematic diagram of the hardware structure of the data storage device and / or query device of the embodiment of the present application, such as Fig.11 As shown, the terminal includes: a communication component 63 for data transmission, at least one processor 61, and a memory 62 for storing a computer program that can be run on the processor 61. The various components in the terminal are coupled together through a bus system 64. It can be understood that the bus system 64 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 64 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Fig.11 Various buses are labeled as bus system 64.

[0232] Wherein, when the processor 61 executes the computer program, at least Figures 1 to 8 Any of the steps of the method shown.

[0233] It can be understood that the memory 62 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 62 described in the embodiments of the present application is intended to include, but is not limited to, these and any other suitable types of memory.

[0234] The method disclosed in the above embodiment of the present application can be applied to the processor 61, or implemented by the processor 61. The processor 61 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 61 or the instruction in the form of software. The above processor 61 can be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 61 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 62, and the processor 61 reads the information in the memory 62 and completes the steps of the above method in combination with its hardware.

[0235] In an exemplary embodiment, the data storage device and / or data query device may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), FPGA, general purpose processor, controller, MCU, microprocessor, or other electronic components to execute the aforementioned data storage and / or query method.

[0236] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0237] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0238] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0239] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.

[0240] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0241] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0242] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0243] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.

[0244] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data storage method, characterized in that: include: Obtaining a storage object and attributes of the storage object, wherein the attributes include a storage effective time to be stored and first data of the storage object, wherein the first data is represented by a value of the storage object within the storage effective time; Obtaining a stored effective time of the attribute and second data, wherein the second data is characterized by a value of the attribute within the stored effective time; Determine whether the to-be-stored effective time and the stored effective time have an intersecting time point; wherein the to-be-stored effective time and the stored effective time are both time periods; the time period includes the start time and the end time of the effective time; If it is judged to exist, Obtaining a first starting time and a first ending time of the effective time period to be stored; Obtain a second starting time and a second ending time of the stored effective time period; Obtain a first element set according to the first starting time, the first ending time, the second starting time, and the second ending time; According to the judgment result that at least some elements in the first element set are new data or old data, determine to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data; wherein the elements in the first element set whose values ​​are the first starting time or the first ending time are new data, and the elements in the first element set whose values ​​are the second starting time or the second ending time are old data; According to the determination result, the target data to be stored is determined; The target data to be stored is stored.

2. The method according to claim 1, characterized in that Determining the target data to be stored based on the determination result includes: The adjusted effective time and the value of the storage object within the adjusted effective time are determined as the target data to be stored.

3. The method according to claim 1, characterized in that The obtaining of a first element set according to the first starting time, the first ending time, the second starting time, and the second ending time comprises: The first starting time, the first ending time, the second starting time, and the second ending time are sorted in chronological order to obtain a first element set.

4. The method according to claim 1 or 3, characterized in that: The step of determining, based on a result of determining whether at least some elements in the first element set are new data or old data, to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data comprises: In the case where the first element and the last element in the first element set are both new data, determining a time period formed by the first element and the last element as a new effective time of the storage object whose value is the first data; In the case where the first element in the first element set is new data and the last element in the first element set is old data, the next element in the first element set other than the first element that is represented as new data is obtained, and the time period formed by the first element and the next element that is represented as new data is the new effective time of the storage object whose value is the first data; the time period formed by the element and the last element is the new effective time of the storage object whose value is the second data; In the case where the first element and the last element in the first element set are both old data, the time period formed by the first element and the second element is the new effective time of the storage object whose value is the first target data; wherein the second data includes the first target data and the second target data, and the first target data is the value of the storage object in the stored effective time period corresponding to the first element; the time period formed by the second element and the next element represented as new data except the first and second elements in the first element set is the new effective time of the storage object whose value is the first data; the time period formed by the next element represented as new data and the last element is the new effective time of the storage object whose value is the second target data; wherein the second target data is the value of the storage object in the stored effective time period corresponding to the last element.

5. The method according to any one of claims 2 to 3, characterized in that: After determining to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data, the method further includes: Obtaining a query time period for the storage object; Determining the value of the storage object in the query time period based on the effective time period of the storage object under each value; Output the value of the storage object in the query time period.

6. The method according to claim 5, characterized in that Before determining the value of the storage object in the query time period, the method further includes: Determine whether there is an effective time that intersects with the query time period among the effective times of the storage object under various values; If it is determined that the query time period exists, the query time period is divided into segments according to the effective time period intersecting with the query time period; Obtaining the value of the storage object in each segment; The values ​​of the storage object in each segment are output.

7. A data query method, characterized in that: include: Obtaining a query time period for a storage object; wherein the storage object is stored according to the method of claim 1; Obtaining each stored value of the storage object and the effective time under each value; Determining the value of the storage object in the query time period based on the effective time of the storage object under each value; Output the value of the storage object in the query time period.

8. The method according to claim 7, characterized in that The effective time is a time period. Determine whether there is an effective time period that intersects with the query time period among the effective time periods of the storage object under various values; If it is determined that the query time period exists, the query time period is divided into segments according to the effective time period intersecting with the query time period; Obtaining the value of the storage object in each segment; The values ​​of the storage object in each segment are output.

9. A data storage device, characterized in that: include: A first obtaining unit is used to obtain a storage object and an attribute of the storage object, wherein the attribute includes a storage effective time to be stored and first data of the storage object, wherein the first data is represented by a value of the storage object within the storage effective time; A second obtaining unit, configured to obtain a stored effective time of the attribute and second data, wherein the second data is represented by a value of the attribute within the stored effective time; A first determination unit is used to determine whether there is an intersecting time point between the effective time to be stored and the stored effective time; if it is determined that there is an intersecting time point, obtain the first starting time and the first ending time of the effective time period to be stored; obtain the second starting time and the second ending time of the stored effective time period; obtain a first element set based on the first starting time, the first ending time, the second starting time and the second ending time; according to the judgment result that at least some elements in the first element set are new data or old data, determine to adjust the effective time of the storage object to be stored as the first data and / or the effective time of the storage object stored as the second data; wherein, the elements in the first element set whose values ​​are the first starting time or the first ending time are new data, and the elements in the first element set whose values ​​are the second starting time or the second ending time are old data; wherein, the effective time to be stored and the stored effective time are both time periods; and the time period includes the starting time and the ending time of the effective time; A second determining unit, used to determine target data to be stored according to the determination result; The storage unit is used to store the target data to be stored.

10. The device according to claim 9, characterized in that The second determining unit is further configured to determine the adjusted effective time and the value of the storage object within the adjusted effective time as the target data to be stored.

11. A data query device, characterized in that: include: A first obtaining unit, configured to obtain a query time period for a storage object; wherein the storage object is stored according to the method of claim 1; A second obtaining unit, used to obtain each value of the stored object and the effective time under each value; A determination unit, configured to determine a value of the storage object in a query time period based on the effective time of each value of the storage object; An output unit is used to output the value of the storage object in the query time period.

12. The device according to claim 11, characterized in that The effective time is a time period. A determination unit, configured to determine whether there is an effective time period that intersects with the query time period among the effective time periods of the storage object under various values; If it is determined that the query time period exists, the query time period is divided into segments according to the effective time period intersecting with the query time period; Obtaining the value of the storage object in each segment; The output unit is used to output the values ​​of the storage object in each segment.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the program implements the steps of the data storage method described in any one of claims 1 to 6 and / or the data query method described in any one of claims 7 to 8.

14. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the data storage method described in any one of claims 1 to 6 and / or the data query method described in any one of claims 7 to 8 are implemented.

Citation Information

Patent Citations

  • Method and device for storing data and method and device for querying data

    CN110704507A

  • Database index storage based on temporal data

    US10445306B1