A method and device for storing freight rate data
By building data structures of data blocks and hierarchical blocks, and searching based on the release time and version identification of freight data, the problem of low freight data query efficiency in traditional methods is solved, and the calculation speed and user experience are improved.
Patent Information
- Application Number
- CN202210343528.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-02
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2042-04-02
AI Technical Summary
The traditional freight data storage method has insufficient query efficiency and calculation time, resulting in poor user experience, especially when the amount of freight data is large, the query efficiency is low and the calculation time is long.
By obtaining freight data and its release time, we build a data structure corresponding to the logical primary key, including data blocks and hierarchical blocks, store freight data in the data block, and determine the starting version identification and correspondence based on the release time, and store it in In the hierarchy block, so that subsequent precise searches are made based on the starting version identification and correspondence relationship.
The search range is narrowed, query efficiency is improved, calculation time is shortened, and user experience is improved.
Smart Images

Figure CN114691693B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method for storing freight rate data and related devices. Background Art
[0002] Freight data refers to the air transportation fees that an airline should charge for transporting a shipment from the origin airport to the destination airport, such as air fares, etc. Freight data needs to be retained in the database for a long period of time, such as 2 years, due to the needs of ticket refund and ticket change functions.
[0003] As time goes by, freight rate data will generate a huge amount of text files. In traditional freight rate calculation systems, text databases or relational databases are usually used to store data. When calculating freight rates, it is necessary to first query the corresponding freight rate data. The large amount of data leads to low query efficiency, which in turn leads to long calculation time and poor user experience. Summary of the invention
[0004] In response to the above problems, the present application provides a freight rate data storage method and related devices, which are used to improve query efficiency, reduce calculation time, and improve user experience.
[0005] Based on this, the embodiments of the present application disclose the following technical solutions:
[0006] In one aspect, an embodiment of the present application provides a method for storing freight rate data, the method comprising:
[0007] Obtain target freight rate data and the release time of the target freight rate data;
[0008] If the logical primary key of the target freight rate data is not stored in the database, construct a data structure corresponding to the logical primary key, wherein the data structure includes a data block and a hierarchical block;
[0009] storing the target freight rate data in the data block;
[0010] Determine the starting version identifier of the target freight rate data according to the release time;
[0011] Establishing a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block;
[0012] The starting version identifier of the target freight rate data and the target corresponding relationship are stored in the hierarchical block.
[0013] On the other hand, an embodiment of the present application provides a freight rate data storage device, the device comprising: an acquisition unit, a construction unit, a first storage unit, a determination unit, an establishment unit, and a second storage unit;
[0014] The acquisition unit is used to acquire the target freight rate data and the release time of the target freight rate data;
[0015] The construction unit is used to construct a data structure corresponding to the logical primary key if the logical primary key of the target freight rate data is not stored in the database, and the data structure includes a data block and a hierarchical block;
[0016] The first storage unit is used to store the target freight rate data in the data block;
[0017] The determining unit is used to determine the starting version identifier of the target freight rate data according to the release time;
[0018] The establishing unit is used to establish a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block;
[0019] The second storage unit is used to store the starting version identifier of the target freight rate data and the target corresponding relationship in the hierarchical block.
[0020] On the other hand, the present application provides a computer device, the device comprising a processor and a memory:
[0021] The memory is used to store program code and transmit the program code to the processor;
[0022] The processor is used to execute the method described in the above aspects according to the instructions in the program code.
[0023] On the other hand, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method described in the above aspects.
[0024] On the other hand, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method described in the above aspects.
[0025] The advantages of the above technical solution of this application are:
[0026] After obtaining the target freight rate data and the release time of the target freight rate data, if the logical primary key of the target freight rate data is not stored in the database, a new operation is performed on the target freight rate data to construct a data structure corresponding to the logical primary key. The target freight rate data is stored in the data block included in the data structure so that the corresponding freight rate data can be taken out from the data block when searching later. The starting version identifier of the target freight rate data is determined according to the release time, and a target corresponding relationship between the starting version identifier and the storage position of the target freight rate data in the data block is established, and the starting version identifier and the target corresponding relationship are stored in the hierarchical block. Thus, the freight rate data with the same logical primary key are stored in the same data structure, and the starting version identifier is added to the freight rate data and stored in the hierarchical block. Even if the freight rate data will generate a large number of text files, when searching, it can be based on the starting version identifier and the target corresponding relationship, first match the storage location of the required freight rate data from the hierarchical block, and then make an accurate call, instead of searching in all the stored data, which narrows the search scope, improves the query efficiency, and thus shortens the calculation time and improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0028] Figure 1 A flowchart of a method for storing freight rate data provided in an embodiment of the present application;
[0029] Figure 2 A schematic diagram of a data structure is provided for this application;
[0030] Figure 3 A schematic diagram of a data switching structure provided in an embodiment of the present application;
[0031] Figure 4 A schematic diagram of a freight rate data storage device provided in an embodiment of the present application;
[0032] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0034] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0035] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0036] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0037] The fare data includes many data items, such as fare, effective time and deadline, etc. Among them, the effective time and deadline are usually compared with the passenger's travel time. Only when the effective time of a fare data record is earlier than or equal to the travel time and the deadline is later than or equal to the travel time, the fare data record can be used in the fare calculation process. Therefore, after the fare data is released, other attributes except the deadline cannot be changed. If you need to modify a record, you must publish a new record with the same logical primary key. After the update, there will be 3 records in the database, the first one is the original old record, the second one is the record with the deadline of the old record modified, and the third one is the new record. These 3 data will be divided into 2 groups according to the release time, that is, one group of the first data and one group of the second and third data, that is, two historical levels are generated.
[0038] As time goes by, freight rate data will generate a large amount of historical levels. In related technologies, text databases or relational databases are used to store data. In text databases, freight rate data at different historical levels correspond to different text files. Due to the large number of text files, it not only affects system maintenance, but also greatly affects the efficiency of freight rate data access. In relational databases, querying freight rate data at different historical levels requires time comparison, and data access efficiency is low.
[0039] Based on this, the embodiment of the present application provides a data storage method. After obtaining the target freight rate data and the release time of the target freight rate data, if the logical primary key of the target freight rate data is not stored in the database, the target freight rate data is added, and the data structure corresponding to the logical primary key is constructed. The target freight rate data is stored in the data block included in the data structure, so that the corresponding freight rate data can be taken out from the data block when searching later. The starting version identifier of the target freight rate data is determined according to the release time, and the target corresponding relationship between the starting version identifier and the storage position of the target freight rate data in the data block is established, and the starting version identifier and the target corresponding relationship are stored in the hierarchical block. Thus, the freight rate data with the same logical primary key are stored in the same data structure, and the starting version identifier is added to the freight rate data and stored in the hierarchical block. Even if the freight rate data will generate a large number of text files, when searching, it can be based on the starting version identifier and the target corresponding relationship, first match the storage location of the required freight rate data from the hierarchical block, and then make an accurate call, instead of searching in all the stored data, which narrows the search range, improves the query efficiency, and thus shortens the calculation time and improves the user experience.
[0040] Combine the following Figure 1 , a method for storing freight rate data provided by an embodiment of the present application is introduced. Figure 1 , this figure is a flowchart of a freight rate data storage method provided in an embodiment of the present application, and the method may include S101-S106.
[0041] S101: Obtain target freight rate data and the release time of the target freight rate data.
[0042] The target freight rate data is a piece of data in the freight rate data. The release time is the time when the target data is released after being entered into the freight rate system. After the freight rate data is released, the freight rate data becomes available in the freight rate system (or production database).
[0043] Based on the above, we can know that the characteristic of freight rate data is that after it is released, other attributes except the deadline cannot be changed, that is, it cannot be modified or deleted. As shown in Table 1:
[0044] Table 1
[0045] fare Effective time Deadline Data A-1 1000 January 2, 2020 Max (infinity) Data A-2 1000 January 2, 2020 October 1, 2020 Data A-3 1500 October 2, 2020 Max (infinity)
[0046] For data A, on January 1, 2020 (release time), the first data A, data A-1, was added, with a fare of 1000, a corresponding effective time of January 2, 2020, and an expiration time of infinity. If you want to modify the fare of data A on October 1, 2020 (release time), two data will be added, data A-2 and data A-3. At this time, 3 records are obtained, namely the original old record, the record with the expiration time of the old record modified, and the new record. These 3 data will be stored in 2 groups according to the release time, that is, data A-1 in one group and data A-2 and data A-3 in another group, that is, 2 historical levels are generated.
[0047] Therefore, due to the above characteristics of freight rate data, as time goes by, freight rate data will generate massive historical levels, and the data stored in the freight rate system will increase.
[0048] S102: If the logical primary key of the target freight rate data is not stored in the database, construct a data structure corresponding to the logical primary key.
[0049] It should be noted that the operations on the freight rate data include: adding operation, deleting operation, querying operation and modifying operation, and the embodiments corresponding to S101-S106 mainly illustrate the adding operation.
[0050] For the new operation, the target freight rate data has no other historical layers before it is added, or the target freight rate data is a "new" data type. To determine whether the target freight rate data requires a new operation, it can be determined based on whether the logical primary key of the target freight rate data is stored in the database.
[0051] Among them, the logical primary key is that the freight rate system allows multiple records in a data type to have the same logical primary key, but the effective time and deadline time intervals of these data records must not overlap.
[0052] If the logical primary key of the target freight rate data is not stored in the database, a data structure corresponding to the logical primary key is constructed. Freight rate data with the same logical primary key are stored in the same data structure, and the data structure can store complex data structures of the NoSQL database. The data structure includes data blocks and hierarchical blocks, such as Figure 2 As shown. Figure 2 In the example, the data structure (BusinessBlock) 200 includes a data block (DataBlock) 210 and a slice block (SliceBlock) 220 .
[0053] S103: Store the target freight rate data in a data block.
[0054] Data blocks are used to store data objects, such as freight rate data itself.
[0055] Continue with Figure 2 For example, see Figure 2 The data block contains a pointer (bos) to the first address of the data object storage area. The first address of the data object storage area can also be called the offset within the block. All data objects are written into this storage area in sequence, and data objects will not be written repeatedly.
[0056] The data object includes the starting version identifier (dataVersionFrom) and the ending version identifier (dataVersionTo). Data items such as fare (Fare) and rule (Rule) are inherited from the data object. When the freight rate data is stored in the database, dataVertionTo is set to the default maximum value Max (such as 9999999999).
[0057] S104: Determine the starting version identifier of the target freight rate data according to the release time.
[0058] It should be noted that since there are multiple historical levels of freight rate data, different historical levels have the same logical primary key and can be distinguished by version identification.
[0059] For new operations, the starting version of the target freight rate data determined by the release time is marked as the first version, that is, it represents the first historical level, such as 1, and the subsequent historical levels are represented by 2, 3, etc. Figure 2 , dataVersionFrom can be 1, and dataVertionTo can be 9999999999.
[0060] S105: Establishing a target corresponding relationship between the initial version identifier of the target freight rate data and the storage position of the target freight rate data in the data block.
[0061] The storage position of the target freight rate data in the data block can be known through S103, and the initial version identifier of the target freight rate data can be known through S104, so a corresponding relationship between the two, ie, a target corresponding relationship, can be established.
[0062] S106: storing the initial version identifier and the target corresponding relationship of the target freight rate data in the hierarchical block.
[0063] The hierarchical block is used to store the starting version identifier and target correspondence of the target freight rate data.
[0064] Continue to see Figure 2, the layer block (SliceBlock) 220 includes a layer object (SliceObject) 221 corresponding to each freight rate data, and the layer object (SliceObject) 221 includes the starting version identifier (dataVersionFrom) of the freight rate data and a first address pointer (bos) pointing to the pointer storage area of the data object (BusinessObject) 211. All the pointers of the freight rate data corresponding to the same starting version identifier of the data object will be written in sequence. It should be noted that what is stored in the layer block 220 is the pointer of the data object 211 rather than the object itself, so it will not cause duplicate data storage.
[0065] It can be seen from the above technical solution that after obtaining the target freight rate data and the release time of the target freight rate data, if the logical primary key of the target freight rate data is not stored in the database, the target freight rate data is added, and the data structure corresponding to the logical primary key is constructed. The target freight rate data is stored in the data block included in the data structure, so that the corresponding freight rate data can be taken out from the data block when searching later. The starting version identifier of the target freight rate data is determined according to the release time, and the target corresponding relationship between the starting version identifier and the storage position of the target freight rate data in the data block is established, and the starting version identifier and the target corresponding relationship are stored in the hierarchical block. Thus, the freight rate data with the same logical primary key are stored in the same data structure, and the starting version identifier is added to the freight rate data and stored in the hierarchical block. Even if the freight rate data will generate a large number of text files, when searching, it can be based on the starting version identifier and the target corresponding relationship, first match the storage location of the required freight rate data from the hierarchical block, and then make an accurate call, instead of searching in all the stored data, which narrows the search range, improves the query efficiency, and thus shortens the calculation time and improves the user experience.
[0066] As a possible implementation method, the search operation of freight rate data is described below through S107-S110.
[0067] S107: Obtain a query request.
[0068] The query request includes travel time and a logical primary key, wherein the travel time is the actual travel time of the user and is the basis for refund and change of ticket.
[0069] S108: Searching for the hierarchical blocks included in the data structure corresponding to the logical primary key.
[0070] Based on the above, the freight rate data corresponding to the same logical primary key are all stored in the same data structure, and the freight rate data itself is stored in the data block, and the version identification and corresponding relationship of the freight rate data are stored in the hierarchical block.
[0071] S109: In the hierarchical block, determine the target release time that is closest to the travel time in time and before the travel time; based on the corresponding relationship between the starting version identifier corresponding to the target release time, determine the target storage position of the freight rate data corresponding to the starting version identifier corresponding to the target release time in the data block.
[0072] It is understandable that a hierarchical block may store data of multiple historical levels, and different starting version identifiers correspond to different historical levels with different release times. The one closest to the travel time has two release times, one before the travel time and one after the travel time. The query request requires the one before the travel time.
[0073] The corresponding starting version identifier is determined according to the target release time, so that the target storage position of the freight rate data corresponding to the starting version identifier in the data block can be determined according to the starting version identifier and the corresponding relationship between the starting version identifier and the storage position of the freight rate data in the data block.
[0074] S110: Retrieving the freight rate data required by the query request from the storage block according to the target storage location.
[0075] It can be seen from the above technical solution that the freight data with the same logical primary key are stored in the same data structure, the freight data itself is stored in the data block included in the data structure, and the starting version identifier and the target correspondence relationship of the freight data are stored in the hierarchical block. When a query request is obtained, the hierarchical block to be queried is determined according to the logical primary key included in the query request, and the storage location of the required freight data is determined from the hierarchical block based on the travel time included in the query request, and then the required freight data is retrieved. Therefore, under the premise of retaining all freight data, compared with searching for the required data in the massive freight data itself, searching based on the logical primary key and version identifier narrows the search scope, improves query efficiency, and thus shortens the calculation time and improves the user experience.
[0076] As a possible implementation method, the operation of deleting the freight rate data is described below through S201-S203.
[0077] S201: If a deletion request for target freight rate data is obtained, a data structure corresponding to the target freight rate data is determined according to a logical primary key of the target freight rate data.
[0078] It should be noted that the target freight rate data that can be deleted is data that has been stored in the database, that is, the logical primary key of the target freight rate data has been stored in the database, and the data structure corresponding to the target freight rate data can be determined based on the logical primary key.
[0079] S202: Determine the start version identifier of the target freight rate data in the data block included in the data structure corresponding to the target freight rate data.
[0080] S203: modifying the end version identifier of the target freight rate data based on the start version identifier of the target freight rate data.
[0081] As can be seen from the above, the deadline of the freight rate data can be modified, or in other words, the corresponding deadline version identifier can be modified, thereby indicating that the freight rate data has been deleted and is no longer used for query and calculation. In other words, in this application, the deletion operation of the freight rate data is a soft deletion. Among them, the freight rate data cannot be physically deleted after it is released, and it is necessary to mark the freight rate data as deleted in a certain way. This operation is called soft deletion.
[0082] As a possible implementation method, if the starting version identifier is 1 and the ending version identifier is 999999999, 1 can be added to the starting version identifier and the ending version identifier can be changed to 2, thereby marking the freight rate data as being in a deleted state.
[0083] It can be seen from the above technical solution that after obtaining the deletion request corresponding to the target freight rate data, the data structure of the target freight rate data is determined according to the logical primary key, so that the starting version identifier of the target freight rate data is determined in the data block where the target freight rate data is stored, and the ending version identifier of the target freight rate data is modified based on the starting version identifier, thereby completing the soft deletion of the target freight rate data. In addition, all freight rate data are saved in the database.
[0084] As a possible implementation method, the modification operation of the freight rate data is described below through S301-S307.
[0085] S301: If the logical primary key of the target freight rate data is stored in the database, determine the target data structure corresponding to the logical primary key.
[0086] For modification operations, the target freight rate data has other historical levels before modification, and can only be modified based on the stored historical levels. To determine whether the target freight rate data needs to be modified, it can be determined based on whether the logical primary key of the target freight rate data is stored in the database.
[0087] If the logical primary key of the target freight rate data is stored in the database, it means that this operation is a modification operation, and the target data structure corresponding to the logical primary key is determined.
[0088] S302: In the hierarchical block of the target data structure, determine the historical freight rate data that is closest in time to the target freight rate data according to the release time, and the historical starting version identifier corresponding to the historical freight rate data.
[0089] As mentioned above, if you want to modify the freight rate data, two historical levels and three data will be generated, namely the original old record, the record with the cut-off time of the old record modified, and the new record. Therefore, it is necessary to determine the old record with the target freight rate data in the hierarchical block of the target data structure.
[0090] Specifically, in the hierarchical blocks of the target data structure, all freight rate data have the same logical primary key as the target freight rate data, and have one or more historical levels. Different historical levels correspond to different release times. Therefore, according to the release time, the historical freight rate data that is closest to the target freight rate data in time can be found in multiple historical levels, that is, the original old record. For example, if the version identifier of the freight rate data is continuously increasing, it can be said that the historical freight rate data of the previous version of the target freight rate data is found. After finding the historical freight rate data, determine the historical starting version identifier corresponding to the historical freight rate data.
[0091] It should be noted that the target freight rate data is a new record, the historical freight rate data that is closest to the target freight rate data in time is the original old record, and the modified freight rate data is a record with the cut-off time of the old record modified, which are explained below respectively.
[0092] S303: In the data block of the target data structure, modify the end version identifier of the historical freight rate data according to the historical start version identifier.
[0093] That is, the old records are soft deleted. For the relevant details, please refer to the embodiments corresponding to S201-S203, which will not be described in detail here.
[0094] S304: Store the target freight rate data and the modified freight rate data into a data block of the target data structure.
[0095] The modified freight rate data is the historical freight rate data with the cut-off time data item modified, that is, the record with the cut-off time of the old record modified.
[0096] S305: Determine the starting version identifier of the target freight rate data according to the release time, and determine the starting version identifier of the modified freight rate data according to the release time.
[0097] As can be seen from the above, different release times correspond to different historical levels of freight rate data, so the starting version identifier of the target freight rate data can be determined according to the release time. For example, if the version identifier of the freight rate data is continuously increasing, 1 can be added to the historical starting version to determine the starting version identifier of the target freight rate data. Similarly, the starting version identifier of the modified freight rate data can be determined according to the release time. As a possible implementation method, the starting version identifier of the modified freight rate data can be the same as the starting version identifier of the target freight rate data.
[0098] S306: establishing a first target correspondence between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block of the target data structure, and establishing a second target correspondence between the starting version identifier of the modified freight rate data and the storage position of the modified freight rate data in the data block of the target data structure.
[0099] Through S304, the storage locations of the target freight rate data and the modified freight rate data in the target data structure can be known, and through S305, the starting version identifier of the target freight rate data and the starting version identifier of the modified freight rate data can be known, so the first target corresponding relationship and the second target corresponding relationship can be established.
[0100] S307: storing the starting version identifier of the target freight rate data, the first target corresponding relationship, the starting version identifier of the modified freight rate data, and the second target corresponding relationship in a hierarchical block of the target data structure.
[0101] It can be seen from the above technical solution that if a modification operation is performed, the historical fare data (old record) that is closest to the target fare data in time will be soft-deleted from the data block of the target data structure, and the target fare data (new record) and the modified fare data (record with the deadline of the old record modified) will be stored in the data block of the target data structure, and the starting version identifier of the target fare data, the starting version identifier of the modified fare data, the first target correspondence relationship and the second first target correspondence relationship will be stored in the hierarchical block of the target data structure. Thus, the fare data with the same logical primary key are stored in the same data structure, and the fare data in the same data structure are stored in layers according to the release time, which not only retains all the historical change information of the fare data, but also is functionally applicable to the refund and change business of the fare system, and can accurately find all the effective data records of the travel time point corresponding to the refund and change, simplifying the possible massive historical data query into a small amount of data query, greatly improving the data query efficiency of the system.
[0102] As a possible implementation, the aforementioned database is a NoSql database, such as Redis. Although data redundancy exists in different data groups due to different search conditions, the NoSql database can be easily expanded horizontally, and the technical solution of the present application can greatly improve the data query efficiency of the system.
[0103] As a possible implementation method, the initial version identifier is an incremental global variable. Each time the data is successfully released, the version identifier is incremented by 1. The mapping between the release time and the initial version identifier can be recorded through the data switching structure. Figure 3, this figure is a schematic diagram of a data switching structure provided in an embodiment of the present application, dataVersion represents the corresponding version identifier at that time, and switchTime represents the release time.
[0104] In order to make the technical solution provided by the embodiment of the present application clearer, the freight rate data storage method provided by the embodiment of the present application is explained below with an example.
[0105] Initially, the freight rate data in the database is empty. The freight rate data can be retrieved according to the airline, origin, and destination, that is, the airline, origin, and destination are the logical primary keys of the freight rate data.
[0106] The target freight rate data obtained is shown in Table 2. The release time of the target freight rate data is 2020-12-31 10:00:00.
[0107] Table 2
[0108]
[0109]
[0110] The logical primary keys of the above five pieces of data are not stored in the database, and the corresponding operations are all new operations. According to the data structure corresponding to the logical primary key, the data structure includes data blocks and hierarchical blocks.
[0111] The target tariff data in Table 2 can be stored in two logical primary keys, namely airline / origin / destination. Figure 2 In the BusinessBlock shown in the figure, BusinessBlock1 stores three BusinessObjects of CA / BJS / NYC, namely, the freight rate data with serial numbers 1, 2, and 3; BusinessBlock2 stores two BusinessObjects of CA / BJS / LAX, namely, the freight rate data with serial numbers 1 and 2.
[0112] For the sake of convenience, BusinessBlock1 is used as an example below. The same is true for BusinessBlock2, so it will not be repeated here.
[0113] Among them, the data structure BusinessBlock1 contains the following:
[0114] (1) dbs, a pointer to a memory block, the content of which is the data block DataBlock.
[0115] (2) sbs, a pointer to a memory block, the content of which is the hierarchical block SliceBlock.
[0116] The following describes DataBlock and SliceBlock respectively.
[0117] The contents of DataBlock are:
[0118] ①count, integer type, value is 3, which is the number of data objects in the memory block pointed to by boss below.
[0119] ②bos, a pointer to the first address of a memory block. The size of this memory block is the size of BusinessObject*count. Assuming that the size of a freight data is 100 (the same below), the size of this memory block is 300. The first address pointer offset 0 points to the freight data with sequence number 1, the pointer offset 100 points to the freight data with sequence number 2, and the pointer offset 200 points to the freight data with sequence number 3.
[0120] The contents of SliceBlock are:
[0121] ①count, integer type, value is 1, which is the number of data objects in the memory block pointed to by sos below.
[0122] ②sos, a pointer to the first address of a memory block. The size of this memory block is the size of SliceObject * count. Since this is the first data release, there is only one SliceObject at this time.
[0123] The contents of SliceObject are:
[0124] ①dataVersionFrom, integer type, value is 1, the starting version identifier when this level is generated.
[0125] ②count, integer type, value is 3, the number of BusinessObjects in this level
[0126] ③bos, a pointer to the first address of a pointer array. This pointer array stores the pointer offsets of each BusinessObject object in the DataBlock, which are 0, 100, and 200 respectively.
[0127] For new operations, since it is the first release, the starting version of the target freight rate data determined according to the release time is marked as 1, and the ending version is marked as MAX.
[0128] The target freight rate data after release is shown in Table 3. The switchTime value is 20201231100000, which is the completion time of this release.
[0129] Table 3
[0130]
[0131] Therefore, two data items are added for each type of freight rate data to be stored, namely the starting version identifier and the ending version identifier. The version identifier is an increasing integer value. Each data release corresponds to a new version identifier. The freight rate data released in the same batch has the same starting data version number; when the data is successfully released and enters the database, the ending data version number is set to the default maximum value.
[0132] The basic operations of data update include adding, deleting and modifying, which respectively add, soft delete and modify the corresponding records in the database. After the freight rate data is released, the data items that can be modified are usually only the deadline and the deadline version mark. The modification of other data items is not achieved by directly modifying the corresponding data items of the original record, thus forming a complex data hierarchy and historical tracking records, which are the historical hierarchy.
[0133] If new target freight rate data is obtained, as shown in Table 4, the publishing completion time is 2021-01-09 12:00:00.
[0134] Table 4
[0135]
[0136]
[0137] When the second target freight rate data is released:
[0138] Added two new freight rate data: CA / BJS / NYC and CA / BJS / LON;
[0139] Delete CA / BJS / NYC freight rate data, but it is not physically deleted, but soft deleted. Soft deletion in the system is achieved by setting the value of the end version identifier of the freight rate data to the value of the start version identifier of the data release batch at that time. Therefore, after soft deletion, the end version identifier value of the old object is set to 2, and the data used for deletion in the original data itself will no longer be inserted into the database;
[0140] Modify CA / BJS / NYC freight rate data. The modification operation is achieved by soft deleting the old object and inserting two corresponding new objects. See Table 5 for details.
[0141] Table 5
[0142]
[0143] As can be seen from Table 5, after the second release, the freight rate data with sequence number 3 in Table 3 has been soft deleted. The freight rate data with sequence number 1 has been modified. The modification logic is to soft delete the old data in Table 3 and insert two data with sequence numbers 6 and 7 in Table 5. The freight rate data with sequence number 7 is the target freight rate data for this release. The freight rate data with sequence number 7 is basically the same as the freight rate data with sequence number 1, except that the deadline is changed to the effective time of the freight rate data with sequence number 7 - 1 day. In addition, two data with sequence numbers 8 and 9 are added.
[0144] The freight rate data in Table 4 can be stored in three BusinessBlocks, namely, BusinessBlocks of CA / BJS / NYC, CA / BJS / LAX and CA / BJS / LON. Let's take BusinessBlock1 of CA / BJS / NYC as an example:
[0145] Among them, the data structure BusinessBlock1 contains the following:
[0146] (1) dbs, a pointer to a memory block, the content of which is the data block DataBlock.
[0147] (2) sbs, a pointer to a memory block, the content of which is the hierarchical block SliceBlock.
[0148] The following describes DataBlock and SliceBlock respectively.
[0149] The contents of DataBlock are:
[0150] ①count, integer type, value is 6, which is the number of data objects in the memory block pointed to by boss below.
[0151] ②bos, a pointer to the first address of a memory block. The size of this memory block is the size of BusinessObject*count. Assuming that the size of a freight rate data is 100 (the same below), the size of this memory block is 600. The first address pointer offset 0 points to the freight rate data with sequence number 1, the pointer offset 100 points to the freight rate data with sequence number 2, the pointer offset 200 points to the freight rate data with sequence number 3, and so on. These are the six freight rate data with sequence numbers 1, 2, 3, 6, 7, and 8 in Table 5.
[0152] The contents of SliceBlock are:
[0153] ①count, integer type, value is 2, which is the number of data objects in the memory block pointed to by sos below.
[0154] ②sos, a pointer to the first address of a memory block, the size of this memory block is SliceObject size * count. At this time, there are two historical levels, so there are two SliceObject objects, the contents are:
[0155] 1) dataVersionFrom of SliceObject1, integer type, value is 1, the starting version identifier when this layer is generated.
[0156] 2) SliceObject1's count is of integer type and has a value of 3, which is the number of BusinessObjects in this level. That is, there are still 3 objects in the first level.
[0157] 3) The bos of SliceObject 1 points to the pointer to the first address of a pointer array. This pointer array stores the pointer offsets of each BusinessObject object in the DataBlock. At this time, they are 0, 100, and 200, pointing to the three freight rate data with serial numbers 1, 2, and 3 in Table 5 respectively.
[0158] 4) dataVersionFrom of SliceObject2, integer type, value is 2, the starting version identifier when this layer is generated.
[0159] 5) SliceObject2's count is of integer type and has a value of 4, which is the number of BusinessObjects in this level, that is, there are 4 objects in the second level at this time.
[0160] 6) The bos of SliceObject2 points to a pointer to the first address of a pointer array. This pointer array stores the pointer offsets of each BusinessObject object in the DataBlock. At this time, they are 100, 300, 400, and 500, pointing to the four freight rate data numbers 2, 6, 7, and 8 in Table 5 respectively.
[0161] It can be seen that two historical levels are generated in the BusinessBlock of CA / BJS / NYC. Both the first and second historical levels include the object with serial number 2 in Table 5, but only the pointer of the object is stored in both levels instead of the actual object, thereby reducing the data storage space. In addition, each historical level contains and retains all historical change information, which can be used for refund and change calculations. When calculating refunds and changes, the value of the starting version identifier at that time can be quickly located based on the comparison between the travel time and the release time of the original ticket at that time, and then compared with the dataVersionFrom in the SliceObject to find the SliceObject object at that time, accurately matching all the data that was in effect at that time, rather than traversing and searching all historical data to obtain the required data.
[0162] As a possible implementation method, users generally store freight rate data in batches. Data release is usually a long process due to the amount of data. In order to ensure the consistency of the release of the same batch of freight rate data, all freight rate data are switched uniformly after being stored, and a mapping between the release time and the start version identifier corresponding to the release is established. When accessing data, the travel time of the query condition is first compared with the release time to obtain the corresponding start version identifier, thereby achieving data consistency in the query.
[0163] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0164] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0165] Although operations are depicted in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or in a sequential order.Multitasking and parallel processing may be advantageous under certain circumstances.
[0166] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0167] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0168] In addition to the freight rate data storage method provided in the embodiment of the present application, a freight rate data storage device is also provided, such as Figure 4 As shown, it includes: an acquisition unit 401, a construction unit 402, a first storage unit 403, a determination unit 404, an establishment unit 405 and a second storage unit 406;
[0169] The acquisition unit 401 is used to acquire target freight rate data and the release time of the target freight rate data;
[0170] The construction unit 402 is used to construct a data structure corresponding to the logical primary key if the logical primary key of the target freight rate data is not stored in the database, and the data structure includes a data block and a hierarchical block;
[0171] The first storage unit 403 is used to store the target freight rate data in the data block;
[0172] The determining unit 404 is used to determine the starting version identifier of the target freight rate data according to the release time;
[0173] The establishing unit 405 is used to establish a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block;
[0174] The second storage unit 406 is used to store the starting version identifier of the target freight rate data and the target corresponding relationship in the hierarchical block.
[0175] As a possible implementation manner, the device further includes: a modification unit, configured to:
[0176] If the logical primary key of the target freight rate data is stored in the database, determining the target data structure corresponding to the logical primary key;
[0177] In the hierarchical block of the target data structure, determining the historical freight rate data that is closest in time to the target freight rate data according to the release time, and the historical starting version identifier corresponding to the historical freight rate data;
[0178] In the data block of the target data structure, modifying the end version identifier of the historical freight rate data according to the historical start version identifier;
[0179] storing the target freight rate data and the modified freight rate data in a data block of the target data structure, wherein the modified freight rate data is the historical freight rate data with the cut-off time data item modified;
[0180] Determining a starting version identifier of the target freight rate data according to the release time, and determining a starting version identifier of the modified freight rate data according to the release time;
[0181] Establishing a first target correspondence between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block of the target data structure, and establishing a second target correspondence between the starting version identifier of the modified freight rate data and the storage position of the modified freight rate data in the data block of the target data structure;
[0182] The starting version identifier of the target freight rate data, the first target corresponding relationship, the starting version identifier of the modified freight rate data and the second target corresponding relationship are stored in a hierarchical block of the target data structure.
[0183] As a possible implementation manner, the device further includes: a deleting unit, configured to:
[0184] If a deletion request for the target freight rate data is obtained, determining a data structure corresponding to the target freight rate data according to a logical primary key of the target freight rate data;
[0185] Determining a starting version identifier of the target freight rate data in a data block included in a data structure corresponding to the target freight rate data;
[0186] The end version identifier of the target freight rate data is modified based on the start version identifier of the target freight rate data.
[0187] As a possible implementation manner, the device further includes: a query unit, configured to:
[0188] Obtain a query request, wherein the query request includes travel time and a logical primary key;
[0189] Finding the hierarchical blocks included in the data structure corresponding to the logical primary key;
[0190] In the hierarchical block, a target release time that is closest to the travel time in time and before the travel time is determined; according to the corresponding relationship between the start version identifier corresponding to the target release time, a target storage position of the freight rate data corresponding to the start version identifier corresponding to the target release time in the data block is determined;
[0191] The freight rate data required by the query request is retrieved from the storage block according to the target storage location.
[0192] It can be seen from the above technical solution that after obtaining the target freight rate data and the release time of the target freight rate data, if the logical primary key of the target freight rate data is not stored in the database, the target freight rate data is added, and the data structure corresponding to the logical primary key is constructed. The target freight rate data is stored in the data block included in the data structure, so that the corresponding freight rate data can be taken out from the data block when searching later. The starting version identifier of the target freight rate data is determined according to the release time, and the target corresponding relationship between the starting version identifier and the storage position of the target freight rate data in the data block is established, and the starting version identifier and the target corresponding relationship are stored in the hierarchical block. Thus, the freight rate data with the same logical primary key are stored in the same data structure, and the starting version identifier is added to the freight rate data and stored in the hierarchical block. Even if the freight rate data will generate a large number of text files, when searching, it can be based on the starting version identifier and the target corresponding relationship, first match the storage location of the required freight rate data from the hierarchical block, and then make an accurate call, instead of searching in all the stored data, which narrows the search range, improves the query efficiency, and thus shortens the calculation time and improves the user experience.
[0193] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0194] Reference below Figure 5, which shows a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0195] like Figure 5 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 606 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0196] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0197] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains target freight rate data and the release time of the target freight rate data; if the logical primary key of the target freight rate data is not stored in the database, constructs a data structure corresponding to the logical primary key, the data structure including a data block and a hierarchical block; stores the target freight rate data in the data block; determines the starting version identifier of the target freight rate data according to the release time; establishes a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block; and stores the starting version identifier of the target freight rate data and the target corresponding relationship in the hierarchical block.
[0198] Alternatively, the computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device: obtains the target freight rate data and the release time of the target freight rate data; if the logical primary key of the target freight rate data is not stored in the database, constructs a data structure corresponding to the logical primary key, the data structure including a data block and a hierarchical block; stores the target freight rate data in the data block; determines the starting version identifier of the target freight rate data according to the release time; establishes a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block; and stores the starting version identifier of the target freight rate data and the target corresponding relationship in the hierarchical block.
[0199] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0200] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0201] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0202] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0203] According to one or more embodiments of the present application, [Example 1] provides a method for storing freight rate data, the method comprising:
[0204] Obtain target freight rate data and the release time of the target freight rate data;
[0205] If the logical primary key of the target freight rate data is not stored in the database, construct a data structure corresponding to the logical primary key, wherein the data structure includes a data block and a hierarchical block;
[0206] storing the target freight rate data in the data block;
[0207] Determine the starting version identifier of the target freight rate data according to the release time;
[0208] Establishing a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block;
[0209] The starting version identifier of the target freight rate data and the target corresponding relationship are stored in the hierarchical block.
[0210] According to one or more embodiments of the present application, [Example 2] provides a method for storing freight rate data, the method further comprising:
[0211] If the logical primary key of the target freight rate data is stored in the database, determining the target data structure corresponding to the logical primary key;
[0212] In the hierarchical block of the target data structure, determining the historical freight rate data that is closest in time to the target freight rate data according to the release time, and the historical starting version identifier corresponding to the historical freight rate data;
[0213] In the data block of the target data structure, modifying the end version identifier of the historical freight rate data according to the historical start version identifier;
[0214] storing the target freight rate data and the modified freight rate data in a data block of the target data structure, wherein the modified freight rate data is the historical freight rate data with the cut-off time data item modified;
[0215] Determining a starting version identifier of the target freight rate data according to the release time, and determining a starting version identifier of the modified freight rate data according to the release time;
[0216] Establishing a first target correspondence between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block of the target data structure, and establishing a second target correspondence between the starting version identifier of the modified freight rate data and the storage position of the modified freight rate data in the data block of the target data structure;
[0217] The starting version identifier of the target freight rate data, the first target corresponding relationship, the starting version identifier of the modified freight rate data and the second target corresponding relationship are stored in a hierarchical block of the target data structure.
[0218] According to one or more embodiments of the present application, [Example 3] provides a method for storing freight rate data, the method further comprising:
[0219] If a deletion request for the target freight rate data is obtained, determining a data structure corresponding to the target freight rate data according to a logical primary key of the target freight rate data;
[0220] Determining a starting version identifier of the target freight rate data in a data block included in a data structure corresponding to the target freight rate data;
[0221] The end version identifier of the target freight rate data is modified based on the start version identifier of the target freight rate data.
[0222] According to one or more embodiments of the present application, [Example 4] provides a method for storing freight rate data, the method further comprising:
[0223] Obtain a query request, wherein the query request includes travel time and a logical primary key;
[0224] Finding the hierarchical blocks included in the data structure corresponding to the logical primary key;
[0225] In the hierarchical block, a target release time that is closest to the travel time in time and before the travel time is determined; according to the corresponding relationship between the start version identifier corresponding to the target release time, a target storage position of the freight rate data corresponding to the start version identifier corresponding to the target release time in the data block is determined;
[0226] The freight rate data required by the query request is retrieved from the storage block according to the target storage location.
[0227] According to one or more embodiments of the present application, [Example 5] provides a freight rate data storage device, the device comprising: an acquisition unit, a construction unit, a first storage unit, a determination unit, an establishment unit, and a second storage unit;
[0228] The acquisition unit is used to acquire the target freight rate data and the release time of the target freight rate data;
[0229] The construction unit is used to construct a data structure corresponding to the logical primary key if the logical primary key of the target freight rate data is not stored in the database, and the data structure includes a data block and a hierarchical block;
[0230] The first storage unit is used to store the target freight rate data in the data block;
[0231] The determining unit is used to determine the starting version identifier of the target freight rate data according to the release time;
[0232] The establishing unit is used to establish a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block;
[0233] The second storage unit is used to store the starting version identifier of the target freight rate data and the target corresponding relationship in the hierarchical block.
[0234] According to one or more embodiments of the present application, [Example 6] provides a freight rate data storage device, wherein the device further includes: a modification unit, which is used to:
[0235] If the logical primary key of the target freight rate data is stored in the database, determining the target data structure corresponding to the logical primary key;
[0236] In the hierarchical block of the target data structure, determining the historical freight rate data that is closest in time to the target freight rate data according to the release time, and the historical starting version identifier corresponding to the historical freight rate data;
[0237] In the data block of the target data structure, modifying the end version identifier of the historical freight rate data according to the historical start version identifier;
[0238] storing the target freight rate data and the modified freight rate data in a data block of the target data structure, wherein the modified freight rate data is the historical freight rate data with the cut-off time data item modified;
[0239] Determining a starting version identifier of the target freight rate data according to the release time, and determining a starting version identifier of the modified freight rate data according to the release time;
[0240] Establishing a first target correspondence between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block of the target data structure, and establishing a second target correspondence between the starting version identifier of the modified freight rate data and the storage position of the modified freight rate data in the data block of the target data structure;
[0241] The starting version identifier of the target freight rate data, the first target corresponding relationship, the starting version identifier of the modified freight rate data and the second target corresponding relationship are stored in a hierarchical block of the target data structure.
[0242] According to one or more embodiments of the present application, [Example 7] provides a freight rate data storage device, the device further comprising: a deletion unit, which is used to:
[0243] If a deletion request for the target freight rate data is obtained, determining a data structure corresponding to the target freight rate data according to a logical primary key of the target freight rate data;
[0244] Determining a starting version identifier of the target freight rate data in a data block included in a data structure corresponding to the target freight rate data;
[0245] The end version identifier of the target freight rate data is modified based on the start version identifier of the target freight rate data.
[0246] According to one or more embodiments of the present application, [Example 8] provides a freight rate data storage device, the device further comprising: a query unit, configured to:
[0247] Obtain a query request, wherein the query request includes travel time and a logical primary key;
[0248] Finding the hierarchical blocks included in the data structure corresponding to the logical primary key;
[0249] In the hierarchical block, a target release time that is closest to the travel time in time and before the travel time is determined; according to the corresponding relationship between the start version identifier corresponding to the target release time, a target storage position of the freight rate data corresponding to the start version identifier corresponding to the target release time in the data block is determined;
[0250] The freight rate data required by the query request is retrieved from the storage block according to the target storage location.
[0251] According to one or more embodiments of the present application, [Example 9] provides an electronic device, characterized in that it includes:
[0252] one or more processors;
[0253] a storage device having one or more programs stored thereon,
[0254] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of [Example 1] to [Example 4].
[0255] According to one or more embodiments of the present application, [Example 10] provides a computer-readable medium on which a computer program is stored, wherein when the program is executed by a processor, the method described in any one of [Example 1] to [Example 4] is implemented.
[0256] According to one or more embodiments of the present application, [Example 11] provides a computer program product, including a computer program or instructions; when the computer program or instructions are executed by a processor, the method described in any one of [Example 1] to [Example 4] is executed.
[0257] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
[0258] Although several specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Certain features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination.
[0259] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
Claims
1. A method for storing freight rate data, characterized in that: The method comprises: Obtain target freight rate data and the release time of the target freight rate data; If the logical primary key of the target freight rate data is not stored in the database, construct a data structure corresponding to the logical primary key, wherein the data structure includes a data block and a hierarchical block; storing the target freight rate data in the data block; Determine the starting version identifier of the target freight rate data according to the release time; Establishing a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block; storing the starting version identifier of the target freight rate data and the target corresponding relationship in the hierarchical block; The method further comprises: If the logical primary key of the target freight rate data is stored in the database, determining the target data structure corresponding to the logical primary key; In the hierarchical block of the target data structure, determining the historical freight rate data that is closest in time to the target freight rate data according to the release time, and the historical starting version identifier corresponding to the historical freight rate data; In the data block of the target data structure, modifying the end version identifier of the historical freight rate data according to the historical start version identifier; storing the target freight rate data and the modified freight rate data in a data block of the target data structure, wherein the modified freight rate data is the historical freight rate data with the cut-off time data item modified; Determining a starting version identifier of the target freight rate data according to the release time, and determining a starting version identifier of the modified freight rate data according to the release time; Establishing a first target correspondence between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block of the target data structure, and establishing a second target correspondence between the starting version identifier of the modified freight rate data and the storage position of the modified freight rate data in the data block of the target data structure; The starting version identifier of the target freight rate data, the first target corresponding relationship, the starting version identifier of the modified freight rate data and the second target corresponding relationship are stored in a hierarchical block of the target data structure.
2. The method according to claim 1, characterized in that The method further comprises: If a deletion request for the target freight rate data is obtained, determining a data structure corresponding to the target freight rate data according to a logical primary key of the target freight rate data; Determining a starting version identifier of the target freight rate data in a data block included in a data structure corresponding to the target freight rate data; The end version identifier of the target freight rate data is modified based on the start version identifier of the target freight rate data.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: Obtain a query request, wherein the query request includes travel time and a logical primary key; Finding the hierarchical blocks included in the data structure corresponding to the logical primary key; In the hierarchical block, a target release time that is closest to the travel time in time and before the travel time is determined; according to the corresponding relationship between the start version identifier corresponding to the target release time, a target storage position of the freight rate data corresponding to the start version identifier corresponding to the target release time in the data block is determined; The freight rate data required by the query request is retrieved from the storage block according to the target storage location.
4. A freight rate data storage device, characterized in that: The device comprises: an acquisition unit, a construction unit, a first storage unit, a determination unit, an establishment unit, and a second storage unit; The acquisition unit is used to acquire the target freight rate data and the release time of the target freight rate data; The construction unit is used to construct a data structure corresponding to the logical primary key if the logical primary key of the target freight rate data is not stored in the database, and the data structure includes a data block and a hierarchical block; The first storage unit is used to store the target freight rate data in the data block; The determining unit is used to determine the starting version identifier of the target freight rate data according to the release time; The establishing unit is used to establish a target corresponding relationship between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block; The second storage unit is used to store the starting version identifier of the target freight rate data and the target corresponding relationship in the hierarchical block; The device further comprises: a modification unit, configured to: If the logical primary key of the target freight rate data is stored in the database, determining the target data structure corresponding to the logical primary key; In the hierarchical block of the target data structure, determining the historical freight rate data that is closest in time to the target freight rate data according to the release time, and the historical starting version identifier corresponding to the historical freight rate data; In the data block of the target data structure, modifying the end version identifier of the historical freight rate data according to the historical start version identifier; storing the target freight rate data and the modified freight rate data in a data block of the target data structure, wherein the modified freight rate data is the historical freight rate data with the cut-off time data item modified; Determining a starting version identifier of the target freight rate data according to the release time, and determining a starting version identifier of the modified freight rate data according to the release time; Establishing a first target correspondence between the starting version identifier of the target freight rate data and the storage position of the target freight rate data in the data block of the target data structure, and establishing a second target correspondence between the starting version identifier of the modified freight rate data and the storage position of the modified freight rate data in the data block of the target data structure; The starting version identifier of the target freight rate data, the first target corresponding relationship, the starting version identifier of the modified freight rate data and the second target corresponding relationship are stored in a hierarchical block of the target data structure.
5. The device according to claim 4, characterized in that The device further comprises: a deleting unit, configured to: If a deletion request for the target freight rate data is obtained, determining a data structure corresponding to the target freight rate data according to a logical primary key of the target freight rate data; Determining a starting version identifier of the target freight rate data in a data block included in a data structure corresponding to the target freight rate data; The end version identifier of the target freight rate data is modified based on the start version identifier of the target freight rate data.
6. The device according to claim 4, characterized in that The device further comprises: a query unit, configured to: Obtain a query request, wherein the query request includes travel time and a logical primary key; Finding the hierarchical blocks included in the data structure corresponding to the logical primary key; In the hierarchical block, a target release time that is closest to the travel time in time and before the travel time is determined; according to the corresponding relationship between the start version identifier corresponding to the target release time, a target storage position of the freight rate data corresponding to the start version identifier corresponding to the target release time in the data block is determined; The freight rate data required by the query request is retrieved from the storage block according to the target storage location.
7. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3.
8. A computer-readable medium, characterized in that A computer program is stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
9. A computer program product, characterized in that The method comprises a computer program or an instruction; when the computer program or the instruction is executed by a processor, the method according to any one of claims 1 to 3 is performed.