A method for accessing user card status lists in an ETC toll collection system based on B+ tree
By using the B+ tree structure to optimize the access method of user card status list in the ETC charging system, the problems of large memory usage and time-consuming loading are solved, and efficient data access and system stability are achieved.
Patent Information
- Application Number
- CN202211159072.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-22
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2042-09-22
AI Technical Summary
In the ETC charging system, memory loading combined with hash search method results in large memory usage, high software code complexity and long loading, making it difficult to meet the requirements of fast operation.
Using a B+ tree-based data structure, the user card status list is converted into a single-link data structure dictionary instance, and the B+ tree is used to implement concurrent writes, cancel hash calculations, and optimize the data access process.
It reduces memory usage to 1.16G, improves system robustness and robustness. It takes only 110 seconds to load the status list of 44.5 million user cards, and takes less than 1ms to query a single record, which meets the efficient operation of the ETC charging system.
Smart Images

Figure CN115510059B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a data writing and retrieving method, in particular to a method for accessing a highway user card status list based on a B+ tree, and belongs to the field of intelligent transportation. Background Art
[0002] As the number of ETC cards issued increases, the number of user cards added to the user status list due to reasons such as user cancellation, card loss, and deactivation due to unpaid fees has also increased. As of May 2022, the number of ETC user card status lists nationwide has reached 44.5 million.
[0003] The user card status list contains the following main attributes:
[0004] 1) User card number: a 40-byte string used to uniquely identify the user card;
[0005] 2) Status list creation time: time type, used to identify the release time of the status list;
[0006] 3) Status list effective time: time type, used to identify the effective time of the status list;
[0007] 4) Operation type: integer type, used to identify the operation type of the status list, such as card cancellation, insufficient balance, etc.
[0008] 5) Operation status: integer type, used to identify the processing status of the status list, such as entering the blacklist or removing the blacklist;
[0009] 6) Issuer: A 12-byte character string used to identify the issuing unit of the user card.
[0010] The design of the user card status list allows the same card to have multiple states, and the final user state is a combination of multiple states. In the ETC toll collection system, in order to ensure the rapid passage of vehicles, the system processing timeliness of each link is extremely high.
[0011] Currently, to ensure efficient processing in the ETC toll collection system, user card status lists are implemented using a combination of memory loading and hash lookup. Storing a single user card status list requires 92 bytes: 40 bytes for the user card number, 8 bytes for the status list creation time, 8 bytes for the status list effective time, 4 bytes for the operation type, 4 bytes for the operation status, 12 bytes for the issuer, 8 bytes for the object descriptor, and an 8-byte hash code. Therefore, loading a list of 44.5 million entries requires a total of 3.8GB of memory. The hash table lookup algorithm requires calculating the hash value of the user card number. Calculating the hash value and loading it into memory for a list of 44.5 million entries takes approximately 20 minutes.
[0012] Therefore, the method of using memory loading combined with hash lookup to implement user status access in the ETC charging system has the following disadvantages:
[0013] 1) Large memory usage
[0014] In addition to the user card status list, the ETC toll collection system also contains other operational data that needs to be loaded into memory. Increasing memory usage will increase the construction cost of the ETC toll collection system. At the same time, the large memory usage is not conducive to the management of normal software operations. In operation and maintenance scenarios, high memory usage reduces the robustness and robustness of the system.
[0015] 2) The hash algorithm has hash collisions, which cause different user card numbers to be calculated as the same hash value. The existence of hash collisions requires the redesign of the hash jump table to ensure the mapping relationship between different user card numbers under the same hash value, which increases the complexity of the software code and reduces the robustness of the system.
[0016] 3) The current situation where loading takes more than 20 minutes also poses a great challenge to the requirements for fast and efficient operation of the ETC toll collection system.
[0017] In summary, in the scenario of accessing the user card status list, it is difficult to achieve satisfactory results by using the method of memory loading combined with hash table. Summary of the Invention
[0018] The technical problem to be solved by the present invention is that the method of using memory loading combined with hash search to implement user status access in the ETC charging system has the defects of large memory usage, high software code complexity and time-consuming loading.
[0019] In order to solve the above technical problems, the technical solution of the present invention is to provide a method for accessing the user card status list of the ETC toll collection system based on a B+ tree, characterized by comprising the following steps:
[0020] The first step is to convert the user card status list into a single-chain data structure dictionary instance. The chain data structure dictionary includes a key field for recording the user card number, a value field for recording the user card status information, and a next field for storing pointers to other single-chain data structure dictionary instances.
[0021] Step 2: When writing the user card status list, the processing of the current single-chain data structure dictionary instance includes the following steps:
[0022] Step 1. Get the value of the key field of the current single-chain data structure dictionary instance. Find the value of each key element in the key array of each leaf node in the B+ tree instance corresponding to the current user's card slot:
[0023] If there is a key element value equal to the value Key in the current key array, the key element value equal to the value Key is defined as the current key element value, and the process goes to step 6;
[0024] If a key element value equal to the value Key is not found in the current B+ tree instance, but a key element value less than the value Key exists in the current key array, then the leaf node corresponding to the current key array is used as the current leaf node and the process goes to step 3.
[0025] If no key element value less than or equal to the value Key is found in the current B+ tree instance, go to step 2;
[0026] Step 2: Create a new leaf node, set the new leaf node as the current leaf node, and proceed to step 3;
[0027] Step 3: Determine whether the current leaf node is full. If the current leaf node is full, split the current leaf node and use the resulting leaf node as the new current leaf node, and proceed to step 4. If the current leaf node is not full, proceed directly to step 4.
[0028] Step 4: Store the value Key as a key element value in the key array of the current leaf node, and reorganize and sort all key element values in the key array to obtain the sorting number k of the value Key in the current key array after reorganization and sorting, and then go to step 5;
[0029] Step 5: Create a new k-th value array, and store the current single-chain data structure dictionary instance in the corresponding position of the k-th value array according to the next field of the current single-chain data structure dictionary instance;
[0030] Step 6: Get the value array corresponding to the current key element value and the first single-chain data structure dictionary instance stored therein, define the single-chain data structure dictionary instance as the previous single-chain data structure dictionary instance, and proceed to step 7;
[0031] Step 7. If the next field of the previous single-chain data structure dictionary instance is empty, point the next field of the previous single-chain data structure dictionary instance to the current single-chain data structure dictionary instance, store the current single-chain data structure dictionary instance in the current value array, and place the current single-chain data structure dictionary instance after the previous single-chain data structure dictionary instance in the current value array. If the next field of the previous single-chain data structure dictionary instance is not empty, further obtain the next single-chain data structure dictionary instance pointed to by the next field of the single-chain data structure dictionary instance, define the obtained next single-chain data structure dictionary instance as the new previous single-chain data structure dictionary instance, and then return to step 7 for loop execution.
[0032] When querying the user card status list, the query is performed in the B+ tree instance.
[0033] Preferably, in the first step, when converting the user card status list, the first N characters of the user card number are intercepted as the user card slot, and the same user card slot corresponds to a B+ tree instance, and the data with the same first four digits of the user card number are aggregated in one B+ tree;
[0034] In the second step, when querying the user card status list, first intercept the first N characters of the user card number, hit the B+ tree instance of the corresponding user card slot, and then query in the B+ tree instance.
[0035] Preferably, if the user card number is a numeric string of length 20, the first 4 characters of the user card number are taken as the card slot mark, and the last 16 characters of the user card number are taken as the user card mark. The user card mark is converted to long type, and the card slot mark and the user card mark converted to long type are stored in the key field.
[0036] Preferably, the value field is only used to record the status effective time, operation type and operation status in the user card status information, and the 15-bit long value type data obtained by calculating the status effective time + operation status * 10 + operation type to obtain the length is stored in the value field.
[0037] Compared with the access method of memory loading combined with hash table, the user card status list access method based on B+ tree provided by the present invention cancels the hash calculation operation and solves the data conflict caused by hash collision. The present invention introduces the aggregation model of user card slots, which can realize concurrent writing of b+ trees under the same slot, greatly improving the data writing performance. It takes only 110 seconds to load the 44.5 million user card status lists. Combined with the access characteristics of b+ tree, a single record of the user card status list is compressed to 28 bytes, and only 1.16G memory space is required for full loading, which effectively reduces the construction cost of the ETC charging system and improves the robustness and robustness of the system. In terms of query efficiency, after adopting the technical solution provided by the present invention, the time taken to hit a single record is less than 1ms, which is slightly longer than the time taken by the hash search algorithm, but can still meet the efficient operation of the ETC charging system. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 This diagram illustrates the application of B+ tree in the user card status list scenario;
[0039] Figure 2 The data writing process is shown in the figure;
[0040] Figure 3 It illustrates the B+ tree access method in the user card status list. DETAILED DESCRIPTION
[0041] Below in conjunction with specific embodiment, further set forth the present invention.Should be understood that these embodiments are only used to illustrate the present invention and are not used in limiting the scope of the present invention.In addition, should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall equally within the scope limited by the appended claims of the application.
[0042] The present invention provides a B+ tree-based ETC toll collection system user card status list access method, which includes user card status list conversion and user card status list access.
[0043] 1) User card status list conversion
[0044] The user card status list essentially describes the user card status information. The present invention designs a single-link data structure dictionary for storing user card status information. Each user card status list is converted into a single-link data structure dictionary instance.
[0045] In the present invention, the chain data structure dictionary has three attribute fields, namely the key field, the value field and the next field, where:
[0046] The key field is used to record the user card number. The user card number is a 20-byte numeric string. When encoded in UTF-8, each character occupies 2 bytes, totaling 40 bytes. The first 4 characters of the string are used as the card slot tag. When stored, user card numbers with the same card slot tag are aggregated in a B+ tree, and there is no need to store card slot information. The last 16 characters of the string are the user card tag. In a 64-bit operating system, the long value range is -9223372036854774808 to 9223372036854774807. The user card identifier is converted to long type for storage, with a length of 8 bytes.
[0047] The value field is used to record user card status information. The three main attributes of the user card status information are status effective time, operation type, and operation status. Issuer information is included in the user card number and does not need to be stored. The list creation time is primarily used for verification delays and does not need to be stored. Therefore, only these three attributes are stored. The time when the status takes effect is a timestamp, a 13-bit long value. The operation type is a 1-bit int value, and the operation status is a 1-bit int value. The calculation of status effective time + operation status * 10 + operation type yields a 15-bit long value, occupying 8 bytes.
[0048] The next field is a pointer to another single-link data structure dictionary instance and is 4 bytes long.
[0049] Based on the above definition, the chain data structure dictionary can be expressed as:
[0050] typedef struct Dictionary{
[0051] long key;
[0052] long value;
[0053] Dictionary*next;
[0054] }Dictionary
[0055] Therefore, in the present invention, a single-link data structure dictionary instance occupies 28 bytes of space - 8 bytes for the key field, 8 bytes for the value field, 4 bytes for the next field, and 8 bytes for the object descriptor.
[0056] A single-link data structure dictionary instance is constructed for each user card status list. During construction, the first four characters of the user card number are truncated as the user card slot. Each user card slot corresponds to a B+ tree instance. Data with the same first four digits of the user card number are aggregated in one B+ tree, thereby reducing the performance bottleneck caused by a single B+ tree being too large.
[0057] 2) Access to user card status list
[0058] When writing the user card status list, the processing of the current single-chain data structure dictionary instance includes the following steps:
[0059] Step 1. Get the value of the key field of the current single-chain data structure dictionary instance. Find the value of each key element in the key array of each leaf node in the B+ tree instance corresponding to the current user's card slot:
[0060] If there is a key element value equal to the value Key in the current key array, it means that there are multiple user card status lists for the current user card number. The key element value equal to the value Key is defined as the current key element value, and the process goes to step 6;
[0061] If a key element value equal to the value Key is not found in the current B+ tree instance, but a key element value less than the value Key exists in the current key array, then the leaf node corresponding to the current key array is used as the current leaf node and the process goes to step 3.
[0062] If no key element value less than or equal to the value Key is found in the current B+ tree instance, go to step 2;
[0063] Step 2: Create a new leaf node, set the new leaf node as the current leaf node, and proceed to step 3;
[0064] Step 3: Determine whether the current leaf node is full. If the current leaf node is full, split the current leaf node and use the resulting leaf node as the new current leaf node, and proceed to step 4. If the current leaf node is not full, proceed directly to step 4.
[0065] Step 4: Store the value Key as a key element value in the key array of the current leaf node, and reorganize and sort all key element values in the key array to obtain the sorting number k of the value Key in the current key array after reorganization and sorting, and then go to step 5;
[0066] Step 5: Create a new k-th value array, and store the current single-chain data structure dictionary instance in the corresponding position of the k-th value array according to the next field of the current single-chain data structure dictionary instance;
[0067] Step 6: Get the value array corresponding to the current key element value and the first single-chain data structure dictionary instance stored therein, define the single-chain data structure dictionary instance as the previous single-chain data structure dictionary instance, and proceed to step 7;
[0068] Step 7. If the next field of the previous single-link data structure dictionary instance is empty, point the next field of the previous single-link data structure dictionary instance to the current single-link data structure dictionary instance, store the current single-link data structure dictionary instance in the current value array, and place the current single-link data structure dictionary instance after the previous single-link data structure dictionary instance in the current value array. If the next field of the previous single-link data structure dictionary instance is not empty, further obtain the next single-link data structure dictionary instance pointed to by the next field of the single-link data structure dictionary instance, define the obtained next single-link data structure dictionary instance as the new previous single-link data structure dictionary instance, and then return to step 7 for a loop.
[0069] When querying the user card status list, first intercept the first 4 characters of the user card number, hit the B+ tree instance of the corresponding user card slot, and then query in the B+ tree instance.
Claims
1. A method for accessing the user card status list of an ETC toll collection system based on a B+ tree, characterized in that: The following steps are involved: The first step is to convert the user card status list into a single-chain data structure dictionary instance. The chain data structure dictionary includes a key field for recording the user card number, a value field for recording the user card status information, and a next field for storing pointers to other single-chain data structure dictionary instances. Step 2: When writing the user card status list, the processing of the current single-chain data structure dictionary instance includes the following steps: Step 1. Get the value of the key field of the current single-chain data structure dictionary instance. Find the value of each key element in the key array of each leaf node in the B+ tree instance corresponding to the current user's card slot: If there is a key element value equal to the value Key in the current key array, the key element value equal to the value Key is defined as the current key element value, and the process goes to step 6; If a key element value equal to the value Key is not found in the current B+ tree instance, but a key element value less than the value Key exists in the current key array, then the leaf node corresponding to the current key array is used as the current leaf node and the process goes to step 3. If no key element value less than or equal to the value Key is found in the current B+ tree instance, go to step 2; Step 2: Create a new leaf node, set the new leaf node as the current leaf node, and proceed to step 3; Step 3: Determine whether the current leaf node is full. If the current leaf node is full, split the current leaf node and use the resulting leaf node as the new current leaf node, and proceed to step 4. If the current leaf node is not full, proceed directly to step 4. Step 4: Store the value Key as a key element value in the key array of the current leaf node, and reorganize and sort all key element values in the key array to obtain the sorting number k of the value Key in the current key array after reorganization and sorting, and then go to step 5; Step 5: Create a new k-th value array, and store the current single-chain data structure dictionary instance in the corresponding position of the k-th value array according to the next field of the current single-chain data structure dictionary instance; Step 6: Get the value array corresponding to the current key element value and the first single-chain data structure dictionary instance stored therein, define the single-chain data structure dictionary instance as the previous single-chain data structure dictionary instance, and proceed to step 7; Step 7. If the next field of the previous single-chain data structure dictionary instance is empty, point the next field of the previous single-chain data structure dictionary instance to the current single-chain data structure dictionary instance, store the current single-chain data structure dictionary instance in the current value array, and place the current single-chain data structure dictionary instance after the previous single-chain data structure dictionary instance in the current value array. If the next field of the previous single-chain data structure dictionary instance is not empty, further obtain the next single-chain data structure dictionary instance pointed to by the next field of the single-chain data structure dictionary instance, define the obtained next single-chain data structure dictionary instance as the new previous single-chain data structure dictionary instance, and then return to step 7 for loop execution. When querying the user card status list, the query is performed in the B+ tree instance.
2. The method for accessing the user card status list of an ETC toll collection system based on a B+ tree according to claim 1, wherein: In the first step, when converting the user card status list, the first N characters of the user card number are intercepted as the user card slot. The same user card slot corresponds to a B+ tree instance, and the data with the same first four digits of the user card number are aggregated in one B+ tree; In the second step, when querying the user card status list, first intercept the first N characters of the user card number, hit the B+ tree instance of the corresponding user card slot, and then query in the B+ tree instance.
3. The method for accessing the user card status list of an ETC toll collection system based on a B+ tree according to claim 1, wherein: If the user card number is a numeric string of length 20, the first 4 characters of the user card number are taken as the card slot mark, and the last 16 characters of the user card number are the user card mark. The user card mark is converted to long type, and the card slot mark and the user card mark converted to long type are stored in the key field.
4. The method for accessing the user card status list of an ETC toll collection system based on a B+ tree according to claim 1, wherein: The value field is only used to record the status effective time, operation type and operation status in the user card status information, and the 15-bit long value type data obtained by calculating the status effective time + operation status * 10 + operation type is stored in the value field.
Citation Information
Patent Citations
Application-driven data storage and indexing method
CN110109914A
Range query method and device, computer readable storage medium and electronic equipment
CN112800067A