A hash table-based point information tracing method, device, equipment and medium

By combining the hash table and the first-in-first-out principle, the point information can be quickly traced, which solves the problem of difficulty in tracking point information in the existing technology, improves the traceability efficiency and saves storage space.

CN115858533BActive Publication Date: 2025-10-14CHINA UNIONPAY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211633694.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-19
Publication Date
2025-10-14
Estimated Expiration
2042-12-19

AI Technical Summary

Technical Problem

Existing technologies lack a fast and effective solution for tracing points information, especially when the issuance and redemption of points are separated in accounting processing, making it difficult to track and verify points information.

Method used

A hash table-based method is adopted to map user identifiers to a point information list through hash values. Combined with the first-in-first-out principle, a two-level storage structure of hash tables in memory and disk storage is used to achieve rapid traceability of point information.

Benefits of technology

It achieves fast and effective point information traceability, reduces memory data storage, reduces data processing, does not require additional disk storage space, and does not damage the original data set.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115858533B_ABST
    Figure CN115858533B_ABST
Patent Text Reader

Abstract

The application discloses a hash table-based point information tracing method and device, equipment and medium, when transaction information of consumption or refund is generated, point information generated by the transaction information is stored to a disk according to a transaction user and a transaction time as a sequence index. When point tracing is needed, first, corresponding point information linked list is determined according to a user identifier and a pre-configured hash table, then, point information in the point information linked list is traced according to a first-in-first-out principle. And only point information is stored in a first block, and only disk hash indexes are stored in other blocks. The point information in the first block is traced, if the first block is empty, corresponding point information in the disk is written into a non-first block according to the disk hash index, and the written point information is traced according to the first-in-first-out principle. Thus, an effective point information tracing scheme is realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of financial technology, in particular to a point information tracing method and device based on hash table, equipment and medium. BACKGROUND

[0002] Commercial points are an important way for large enterprises to strengthen channel marketing and improve product user stickiness. In this right, commercial points are referred to as user points, which are obtained through activities, consumption, login, etc. and can be used to exchange user interests. In accounting transaction processing, points involve "debit marketing expenses" and "credit tax payable" and other accounting transaction processing, and the time of point issuance and cancellation is often separated, so point information tracing is very important.

[0003] Point information tracing mainly includes: the number of points obtained each time, the time of obtaining points, the activity ID of obtaining points, and the way of obtaining points, such as obtaining through transactions, obtaining through login application App behavior, etc. There is no fast and effective point information tracing scheme at present. SUMMARY

[0004] The embodiments of the present application provide a point information tracing method and device based on hash table, equipment and medium, to provide a fast and effective point information tracing scheme.

[0005] The present application provides a point information tracing method based on hash table, the method comprising:

[0006] When receiving transaction information of consumption or application for refund, storing point information generated by the transaction information to the disk according to the transaction user and the transaction time as the order index;

[0007] When receiving a point tracing request, mapping the user identifier corresponding to the point tracing request to the corresponding hash value, and determining the point information chain table corresponding to the user in the hash table pre-configured in the memory according to the hash value;

[0008] Tracing the point information in the first block of the point information chain table according to the first-in first-out principle, if the first block is empty, writing the point information corresponding to the disk hash index in the disk into the non-first block according to the disk hash index in the non-first block, and tracing the point information in the non-first block according to the first-in first-out principle.

[0009] Further, the when receiving transaction information of consumption or application for refund, storing point information generated by the transaction information to the disk according to the transaction user and the transaction time as the order index comprises:

[0010] In the application module, when receiving transaction information of consumption or refund application, the points information corresponding to the transaction information is temporarily stored in the memory;

[0011] The cleaning module in the memory writes the temporarily stored point information into the disk in order according to the transaction user and transaction time as the order index.

[0012] Furthermore, mapping the user identifier corresponding to the points tracing request to a corresponding hash value includes:

[0013] Mapping the user ID corresponding to the points tracing request into a corresponding hash code through a hash algorithm;

[0014] The hash code is mapped to a set range interval through a compression function to obtain a hash value corresponding to the user identifier.

[0015] Further, including:

[0016] Configure the number of hash table buckets and establish a corresponding relationship between each bucket and a user; for each user, establish a corresponding relationship between the user and the point information linked list in the form of a key-value pair;

[0017] The point information linked list includes the first block and non-first blocks; each block is configured with point information capacity, the first block includes the capacity point information, and the non-first block includes a disk hash index.

[0018] Furthermore, the method further comprises:

[0019] If the first block is empty, the linked list pointer of the point information linked list is updated, and the non-first block adjacent to the first block is updated to the first block.

[0020] Further, including:

[0021] The number of points redeemed in the point tracing request and the number of points acquired in the currently traced point information are obtained; and the point information is traced based on the number of points redeemed and the number of points acquired.

[0022] Furthermore, tracing the point information based on the number of points redeemed and the number of points acquired includes:

[0023] If the number of points redeemed is greater than the number of points acquired, the source information is updated and the point information is removed. Based on the difference between the number of points redeemed and the number of points acquired, the next point information of the point information is sourced;

[0024] If the number of points redeemed is equal to the number of points acquired, update the traceability information and remove the point information;

[0025] If the number of points redeemed is less than the number of points acquired, the traceability information is updated, and the difference between the number of points acquired and the number of points redeemed is used as the updated number of points acquired in the point information.

[0026] On the other hand, the present application provides a point information tracing device based on a hash table, the device comprising:

[0027] A storage module is used to store the points information generated by the transaction information to a disk according to the transaction user and transaction time as a sequential index when receiving the transaction information of consumption or refund application;

[0028] a determination module configured to, upon receiving a point tracing request, map the user identifier corresponding to the point tracing request to a corresponding hash value, and determine, based on the hash value, a linked list of point information corresponding to the user in a hash table pre-configured in memory;

[0029] A tracing module is used to trace the point information in the first block of the point information list according to the first-in-first-out principle. If the first block is empty, the point information corresponding to the disk hash index in the non-first block is written into the non-first block according to the disk hash index, and the point information in the non-first block is traced according to the first-in-first-out principle.

[0030] Furthermore, the storage module is specifically used to temporarily store the points information corresponding to the transaction information into the memory when receiving transaction information of consumption or refund application in the application module; the cleaning module in the memory writes the temporarily stored points information into the disk in sequence according to the transaction user and transaction time as the order index.

[0031] Furthermore, the determination module is specifically configured to map the user identifier corresponding to the points tracing request into a corresponding hash code through a hash algorithm; and map the hash code to a set range interval through a compression function to obtain a hash value corresponding to the user identifier.

[0032] Furthermore, the determination module is also used to configure the number of hash table buckets and establish a corresponding relationship between each bucket and the user; for each user, a corresponding relationship between the user and the point information linked list is established in the form of a key-value pair; wherein the point information linked list includes the first block and non-first blocks; each block is configured with a point information capacity, the first block includes the capacity point information, and the non-first block includes a disk hash index.

[0033] Furthermore, the tracing module is further configured to update the linked list pointer of the point information linked list if the first block is empty, and update the non-first block adjacent to the first block to the first block.

[0034] Furthermore, the traceability module is specifically used to obtain the number of points to be redeemed carried in the point tracing request, as well as the number of points obtained in the currently traced point information; and trace the point information based on the number of points to be redeemed and the number of points obtained.

[0035] Furthermore, the traceability module is specifically used to update the traceability information and remove the point information if the number of points written off is greater than the number of points acquired, and trace the next point information of the point information based on the difference between the number of points written off and the number of points acquired; if the number of points written off is equal to the number of points acquired, update the traceability information and remove the point information; if the number of points written off is less than the number of points acquired, update the traceability information and use the difference between the number of points acquired and the number of points written off as the updated point acquisition number in the point information.

[0036] In another aspect, the present application provides an electronic device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0037] Memory for storing computer programs;

[0038] The processor is configured to implement any of the above method steps when executing a program stored in the memory.

[0039] On the other hand, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of the above are implemented.

[0040] The present application provides a method, apparatus, device and medium for tracing point information based on a hash table, the method comprising: upon receiving transaction information of consumption or refund application, storing the point information generated by the transaction information to a disk according to the transaction user and transaction time as a sequential index; upon receiving a point tracing request, mapping the user identifier corresponding to the point tracing request to a corresponding hash value, and determining a point information linked list corresponding to the user in a hash table pre-configured in memory according to the hash value; tracing the point information in the first block of the point information linked list according to the first-in-first-out principle; if the first block is empty, writing the point information corresponding to the disk hash index in the non-first block into the non-first block according to the disk hash index, and tracing the point information in the non-first block according to the first-in-first-out principle.

[0041] The above technical solution has the following advantages or beneficial effects:

[0042] In this application, when a purchase or refund transaction is generated, the resulting point information is stored on disk, using the transaction user and transaction time as a sequential index. When point tracing is required, the corresponding point information linked list is first determined based on the user ID and a preconfigured hash table. The points information in the linked list is then traced according to the first-in, first-out principle. Point information is stored only in the first block, while only the disk hash index is stored in other blocks. The point information in the first block is traced. If the first block is empty, the corresponding point information on disk is written to a non-first block based on the disk hash index, and the written point information is traced according to the first-in, first-out principle. This achieves a fast and efficient point information traceability solution. Through the design of the hash table and point information linked list in this application, only a small amount of point information is stored in memory. For the remaining point information, only the corresponding disk hash index is stored in memory. When tracing is required, the point information corresponding to the disk hash index is retrieved from disk and traced. This application can significantly reduce the amount of data stored in memory, reduce the amount of data processing, and ensure the efficiency of point information traceability. It also does not require additional disk storage space and does not damage the original data set on disk. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0044] Figure 1 Schematic diagram of the point information tracing process based on the hash table provided by this application;

[0045] Figure 2 Flowchart of the point information tracing system based on hash tables provided by this application;

[0046] Figure 3 This is a diagram illustrating the construction process of a hash table provided in this application;

[0047] Figure 4 Flowchart of the point tracing algorithm provided for this application;

[0048] Figure 5 This is a schematic diagram of the structure of the point information tracing device based on the hash table provided by this application;

[0049] Figure 6An electronic device structure diagram is provided for the present application. DETAILED DESCRIPTION

[0050] In order to make the purpose and implementation of the present application more clear, the following will combine the drawings in the exemplary embodiments of the present application to clearly and completely describe the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only a part of the embodiments of the present application, but not all the embodiments.

[0051] It should be noted that the brief description of the terms in the present application is only for the convenience of understanding the subsequently described embodiments, and is not intended to limit the embodiments of the present application. Unless otherwise specified, these terms should be understood according to their ordinary and general meanings.

[0052] The terms "first", "second", "third", and the like in the specification and claims of the present application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit the specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchanged under appropriate circumstances.

[0053] The terms "include" and "have" and any variations thereof are intended to cover but not exclusive inclusion, for example, a product or device including a series of components does not have to be limited to all the components clearly listed, but can include other components not clearly listed or inherent to these products or devices.

[0054] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or a combination of hardware or / and software code capable of performing functions related to the element.

[0055] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

[0056] For the convenience of explanation, the above description has been made in combination with specific embodiments. However, the above exemplary discussion is not intended to exhaust or limit the embodiments to the specific forms disclosed above. Various modifications and variations can be derived according to the above teachings. The selection and description of the above embodiments are for better explanation of the principles and practical applications, so that those skilled in the art can better use the embodiments and various different modified embodiments suitable for specific use considerations.

[0057] Figure 1 A hash table-based point information tracing process diagram is provided for the present application, and the process includes:

[0058] S101: When receiving transaction information of consumption or application for refund, store point information generated by the transaction information into a disk according to transaction user and transaction time as order indexes.

[0059] S102: When receiving a point tracing request, map a user identifier corresponding to the point tracing request into a corresponding hash value, and determine a point information linked list corresponding to the user in a hash table pre-configured in the memory according to the hash value.

[0060] S103: Trace point information in a first block of the point information linked list according to a first-in-first-out principle, if the first block is empty, write point information corresponding to a disk hash index in the disk into a non-first block according to the disk hash index, and trace point information in the non-first block according to the first-in-first-out principle.

[0061] The hash table-based point information tracing method provided by the present application is applied to an electronic device, which can be a PC, a tablet computer, or the like, or a server.

[0062] When the electronic device receives transaction information of consumption or application for refund, first determine point information to be cancelled or refunded by the current transaction information, which includes point acquisition number, acquisition time, activity number, and acquisition path. Store the point information into a disk according to transaction user and transaction time as order indexes.

[0063] Specifically, the process of storing point information into a disk is as follows: in an application module, when receiving transaction information of consumption or application for refund, temporarily store point information corresponding to the transaction information into a memory; a cleaning module in the memory sequentially writes the temporarily stored point information into a disk according to transaction user and transaction time as order indexes. In this way, for each user, historical point information of the user is stored in the disk according to time information. Storing point information into a disk according to transaction user and transaction time as order indexes is beneficial to reducing the complexity of subsequently establishing a disk hash index and improving the efficiency of subsequently searching point information in the disk according to the disk hash index.

[0064] It should be noted that, compared with “random writing”, the present application uses a “sequential writing” mode to store point information into a disk. Sequential writing ensures the continuity of point information on the physical address of the disk, prevents the generation of file fragments, and ensures that, when tracing, a non-first block can be quickly updated according to a hash address, instead of wasting time on needle seeking.

[0065] When the electronic device receives the loyalty point traceability request, the electronic device first acquires the user identifier carried in the loyalty point traceability request. The user identifier can be the user's name, mobile phone number, ID number, etc. The user identifier is mapped to a corresponding hash value. Specifically, the user identifier corresponding to the loyalty point traceability request is mapped to a corresponding hash code through a hash algorithm; the hash code is mapped to a set range interval through a compression function to obtain the hash value corresponding to the user identifier. For example, the user identifier is mapped to a corresponding hash code through a cyclic shift hash algorithm, and the hash code can be an integer. Then the hash code is mapped to the interval [0, N-1] through the Median Absolute Deviation (MAD) method to obtain the hash value corresponding to the user identifier.

[0066] The electronic device is pre-configured with a hash table, which records the correspondence between the hash value corresponding to each user and the loyalty point information chain table. After determining that the user identifier corresponding to the loyalty point traceability request is mapped to a corresponding hash value, the correspondence can be used to determine the loyalty point information chain table corresponding to the user corresponding to the loyalty point traceability request.

[0067] The loyalty point information chain table includes a first block and a non-first block. The non-first block can be one or multiple. If the non-first block is multiple, they are arranged in order after the first block and the order between the blocks is indicated by a chain table pointer. The first block stores a set number of loyalty point information in chronological order, and the non-first block only stores the disk hash index of the corresponding loyalty point information. The application realizes two-level storage of the data to be traced: part of the hash table is in the memory and the other part is in the disk.

[0068] Specifically, the number of hash table buckets is configured, and the correspondence between each bucket and the user is established. For each user, the correspondence between the user and the loyalty point information chain table is established in the form of a key-value pair. The loyalty point information chain table includes a first block and a non-first block. Each block is configured with a loyalty point information capacity. The first block includes the capacity of loyalty point information, and the non-first block includes a disk hash index.

[0069] For example, 10 point information of user A is stored in the disk, in the order of time from early to late, they are point information 1, point information 2, point information 3, point information 4, point information 5, point information 6, point information 7, point information 8, point information 9, point information 10. Assuming that the point information capacity of each block in the point information chain table corresponding to user A is 4, then it is calculated that three blocks need to be set in the point information chain table corresponding to user A, which are called first block, second block and third block. The first block stores point information 1, point information 2, point information 3 and point information 4, the second block stores point information 5, point information 6, point information 7 and point information 8 corresponding to the disk hash index, and the third block stores point information 9 and point information 10 corresponding to the disk hash index.

[0070] The point information in the first block of the point information chain table is traced according to the first-in first-out principle, and after the trace of one point information is completed, the point information is deleted from the first block. If the first block is empty, according to the disk hash index in the non-first block adjacent to the first block, the point information corresponding to the disk hash index in the disk is written into the non-first block, and the point information in the non-first block is traced according to the first-in first-out principle, and so on.

[0071] Specifically, if the first block is empty, the chain table pointer of the point information chain table is updated, and the non-first block adjacent to the first block is updated to the first block. For example, the first bucket in the hash table corresponds to the point information chain table of user A, and the initial chain table pointer is, for example, the first bucket pointing to user A, then pointing to the first block, then pointing to the second block, and then pointing to the third block. If the first block is empty, the chain table pointer is updated to the first bucket pointing to user A, then pointing to the second block, and then pointing to the third block. That is, the first block is deleted, and the original second block becomes the updated first block. Then, according to the disk hash index in the updated first block, the corresponding point information in the disk is written into the updated first block, and the point information in the updated first block is traced according to the first-in first-out principle.

[0072] The electronic device obtains the number of verified points carried in the point acquisition trace request and the number of point acquisitions in the currently traced point information; and traces the point information according to the number of verified points and the number of point acquisitions.

[0073] Specifically, if the redeemed points are greater than the points acquired, the traceability information is updated and the points information is removed. Based on the difference between the redeemed points and the points acquired, the next points information of the points information is traced back. If the difference between the redeemed points and the points acquired is still greater than the points acquired in the next points information, the difference is calculated and the next points information is traced back. If the redeemed points are equal to the points acquired, the traceability information is updated and the points information is removed. If the redeemed points are less than the points acquired, the traceability information is updated and the difference between the points acquired and the redeemed points is used as the updated points acquired in the points information.

[0074] The following is a detailed description of the point information tracing process based on the hash table with reference to the accompanying drawings.

[0075] This application provides a method for tracing the origin of commercial points. First, based on the application module, cleanup module, and storage module, data is sequentially flushed to disk using a log-structured merge tree, using a "user + timestamp" order index. This reduces the complexity of establishing the subsequent disk hash index. Second, using the hash module and traceability module, point traceability for a single transaction is achieved with constant time overhead. A data structure based on a hash table is provided. The key of a key-value pair is a user ID mapped to an integer in the range [0, N-1] via a hash function, and the value is a linked list consisting of several point queues. The queues in the first block contain complete point information, while non-first blocks only contain hash disk index information, saving memory space. Points redeemed by users are traced based on the "first in, first out" (FIFO) principle. The hash table is used to quickly locate the linked list consisting of several blocks storing point information. First, the head element information is obtained from the first block. If the queue in the first block is empty, the queue contents and linked list pointer are updated based on the disk index information of the second block. Based on this concept, an algorithm flow for specific operations is provided.

[0076] Figure 2 This is a flowchart of the point information traceability system based on hash tables provided by this application. To implement the traceability method based on hash tables, it is necessary to first optimize the update and storage method of the point flow data and flush the data to the disk in batches and in sequence, such as Figure 2 Steps 1 to 5 are shown.

[0077] Specifically, in the application module, when users use the app to make purchases or request refunds, the points that have been cancelled or returned are submitted to the server via the data interface via a point update request. Memory refers to internal storage, which stores the data and output results required by the CPU to execute calculations. After the server receives the point data update request, the data to be written is temporarily stored in memory. Disk refers to a hard disk, consisting of multiple magnetically coated platters stacked on top of each other. It stores binary representations of point flow data and maintains data integrity even after a power outage. The cleanup module, when performing a disk flush, uses a "user + timestamp" index to aggregate pending data using a log-structured merge tree. Data is written based on the principles of "deferred, batched, and sequential" to increase write speed and avoid file fragmentation. The cleanup module also regularly maintains disk data, merging sequential files on the disk so that interval point data is organized by user and time. This reduces seek time for read operations and reduces the complexity of subsequent disk hash index creation.

[0078] The specific process steps of the point traceability system are as follows: Figure 2 Steps 6 to 13 are shown.

[0079] Specifically, based on the consumption flow data table, the server batch-processes point traceability requests from different users in chronological order. The hash module is used to construct a hash table. Taking user A as an example, first, a hash code is calculated for user A using a method such as circular shift hashing, mapping the user ID to an integer. The hash code set should minimize collisions. Second, a compression function, such as the MAD method, is used to map the hash code to the interval [0, N-1]. The compression function should minimize the number of hash code collisions. The purpose of constructing a hash table is to maintain a fast addressing data structure, avoiding repeated calculations or disk reads during traceability. The traceability module is used to update the point traceability information for a specific consumption record. Still using user A as an example, the key of the key-value pair is the integer mapped to [0, N-1] by user A using the hash function, and the value is a linked list consisting of several point queues. Queue 1 contains complete point information, while subsequent queues only contain hash disk index information to conserve memory space. In the tracing of user consumption points, the first element of queue 1 is taken in sequence and traced according to the first-in-first-out principle; if queue 1 is empty, the points information is updated according to the disk hash index of queue 2, and the linked list pointer is updated.

[0080] Figure 3 This is an example diagram of the hash table construction process provided in this application. Figure 3As shown, assume the hash table capacity N = 6, meaning it contains six buckets. The number of users n = 3, representing users A, B, and C, is also assumed. The queue capacity M = 4, meaning one block stores four points, or the corresponding disk hash indexes. User A has 10 points-acquired records, User B has none, and User C has two. It's important to note that if a hash conflict occurs, such as in bucket number 0, it's handled by splitting the linked list.

[0081] The value of the key-value pair is a linked list consisting of several point queues, consisting of the first block and several non-first blocks. The first block stores the first several specific information of the point queue and the corresponding disk hash index, while the non-first block only stores the disk hash index. The specific information of the point is shown in the following table:

[0082]

[0083] Figure 4 This is the flow chart of the point tracing algorithm provided by this application. The algorithm flow is as follows:

[0084] 1. Start.

[0085] 2. Read the data set that needs to be traced and initialize i = 0, that is, start tracing from the first record.

[0086] 3. Read the i-th record, including the user ID and the number of points redeemed by the user (Use_num). Initialize the traceability information Dict for this record.

[0087] 4. Calculate the hash function value of the user ID of the i-th record through the hash function hash(), and read the linked list in the secondary container corresponding to the user ID from the hash table.

[0088] 5. Read the first block in the linked list. If the queue for the first block is empty, read the specific information of the points based on the disk hash index of the second block, generate a first-in-first-out queue, and update the linked list pointer, making the second block the first block.

[0089] 6. Return the first element from the first block's FIFO queue, which contains the following information: Get_num, Time, Campid, and Way. If the return fails (the queue is empty), return to step 5.

[0090] 7. Compare the user's redemption points number Use_num and the points obtained number Get_num. If Use_num>Get_num, update the traceability information Dict, remove the first element of the first block's first-in-first-out queue, and return to step 6.

[0091] 8. If Use_num is equal to Get_num, update the traceability information Dict and remove the first element of the first block's first-in-first-out queue.

[0092] 9. If Use_num <Get_num,则更新溯源信息Dict,更新第一区块先进先出队列的队首元素,使新数值=Get_num–Use_num。

[0093] 10. The value of i increases by 1, indicating that the next record is ready for tracing. Determine whether tracing is complete. If not, return to step 3.

[0094] 11. End.

[0095] This application uses a commercial points traceability method based on a hash table, optimizes the data flushing process, and uses data structures such as hash tables and first-in-first-out queues to achieve point traceability for a single transaction with constant time overhead. The technical effects achieved are as follows:

[0096] 1. For each user's consumption transaction data, if redemption of points is involved, the points are traced. Redemption points may be composed of multiple points that the user has previously claimed, and the claiming time and method may vary. The traceability information includes the claiming time, claiming method, and activity ID of the multiple points.

[0097] 2. The time overhead for tracing the points of a single transaction is constant, with an expected value of O(1) and a worst-case value of O(n). The tracing time is fast and the hardware requirements are low.

[0098] 3. There is no need to apply for additional disk storage space, and it does not constitute damage to the original data set.

[0099] Figure 5 This is a schematic diagram of the structure of the point information tracing device based on the hash table provided in this application. The device includes:

[0100] Storage module 51, for storing the points generated by the transaction information to disk upon receiving the transaction information of consumption or refund application, sorting by transaction user and transaction time as the order index;

[0101] Determination module 52, configured to, upon receiving a point tracing request, map the user identifier corresponding to the point tracing request to a corresponding hash value, and determine, based on the hash value, a linked list of point information corresponding to the user in a pre-configured hash table in memory;

[0102] The tracing module 53 is used to trace the point information in the first block of the point information list according to the first-in-first-out principle. If the first block is empty, the point information corresponding to the disk hash index in the non-first block is written into the non-first block according to the disk hash index, and the point information in the non-first block is traced according to the first-in-first-out principle.

[0103] The storage module 51 is specifically used to temporarily store the points information corresponding to the transaction information into the memory when receiving transaction information of consumption or refund application in the application module; the cleaning module in the memory writes the temporarily stored points information into the disk in sequence according to the transaction user and transaction time as the order index.

[0104] The determining module 52 is specifically configured to map the user identifier corresponding to the points tracing request into a corresponding hash code using a hash algorithm; and map the hash code to a set range using a compression function to obtain a hash value corresponding to the user identifier.

[0105] The determination module 52 is further configured to configure the number of hash table buckets and establish a corresponding relationship between each bucket and a user; for each user, a corresponding relationship between the user and a point information linked list is established in the form of a key-value pair; wherein the point information linked list includes a first block and non-first blocks; each block is configured with a point information capacity, the first block includes the capacity point information, and the non-first block includes a disk hash index.

[0106] The tracing module 53 is further configured to update the linked list pointer of the point information linked list if the first block is empty, and update the non-first block adjacent to the first block to the first block.

[0107] The tracing module 53 is specifically configured to obtain the number of points redeemed in the point tracing request and the number of points acquired in the currently traced point information; and to trace the point information based on the number of points redeemed and the number of points acquired.

[0108] The traceability module 53 is specifically used to update the traceability information and remove the point information if the number of points written off is greater than the number of points acquired, and trace the next point information of the point information based on the difference between the number of points written off and the number of points acquired; if the number of points written off is equal to the number of points acquired, update the traceability information and remove the point information; if the number of points written off is less than the number of points acquired, update the traceability information and use the difference between the number of points acquired and the number of points written off as the updated point acquisition number in the point information.

[0109] The present application also provides an electronic device, such asFigure 6 As shown, the electronic device includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304.

[0110] The memory 303 stores a computer program, which, when executed by the processor 301, causes the processor 301 to perform any of the above method steps.

[0111] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in the figure, but it does not mean that there is only one bus or only one type of bus.

[0112] The communication interface 302 is used for communication between the electronic device and other devices.

[0113] The memory can include a Random Access Memory (RAM) and can also include a Non-Volatile Memory (NVM), such as at least one disk memory. Alternatively, the memory can also be at least one storage device located away from the aforementioned processor.

[0114] The processor can be a general-purpose processor, including a central processing unit, a network processor (NP), and the like; can also be a Digital Signal Processing (DSP), an application-specific integrated circuit, a field programmable gate array, or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and the like.

[0115] The present application also provides a computer storage readable storage medium, which stores a computer program executable by an electronic device, and when the program runs on the electronic device, causes the electronic device to perform any of the above method steps.

[0116] Although the preferred embodiments of the present application have been described, those skilled in the art can make additional changes and modifications to the embodiments once they know the basic inventive concept. Therefore, the appended claims are intended to be interpreted as including all changes and modifications falling within the scope of the present application.

[0117] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.

Claims

1. A method for tracing the source of points information based on a hash table, characterized in that: The method comprises: When receiving transaction information for consumption or refund application, the points information generated by the transaction information is stored to disk according to the transaction user and transaction time as the order index; When receiving a point tracing request, mapping the user identifier corresponding to the point tracing request to a corresponding hash value, and determining the point information linked list corresponding to the user in the hash table pre-configured in the memory according to the hash value; The point information in the first block of the point information list is traced according to the first-in-first-out principle. If the first block is empty, the point information corresponding to the disk hash index in the non-first block is written into the non-first block according to the disk hash index, and the point information in the non-first block is traced according to the first-in-first-out principle.

2. The method according to claim 1, wherein When receiving transaction information of consumption or refund application, storing the points information generated by the transaction information to disk according to the transaction user and transaction time as the order index includes: In the application module, when receiving transaction information of consumption or refund application, the points information corresponding to the transaction information is temporarily stored in the memory; The cleaning module in the memory writes the temporarily stored point information into the disk in order according to the transaction user and transaction time as the order index.

3. The method according to claim 1, wherein Mapping the user identifier corresponding to the points tracing request to a corresponding hash value includes: Mapping the user ID corresponding to the points tracing request into a corresponding hash code through a hash algorithm; The hash code is mapped to a set range interval through a compression function to obtain a hash value corresponding to the user identifier.

4. The method according to claim 1, wherein include: Configure the number of hash table buckets and establish a corresponding relationship between each bucket and a user; for each user, establish a corresponding relationship between the user and the point information linked list in the form of a key-value pair; The point information linked list includes the first block and non-first blocks; each block is configured with point information capacity, the first block includes the capacity point information, and the non-first block includes a disk hash index.

5. The method according to claim 1, wherein The method further comprises: If the first block is empty, the linked list pointer of the point information linked list is updated, and the non-first block adjacent to the first block is updated to the first block.

6. The method according to claim 1, wherein include: Obtain the number of points redeemed in the points tracing request and the number of points acquired in the current tracing points information; The point information is traced based on the number of points redeemed and the number of points acquired.

7. The method according to claim 6, wherein The tracing of the point information based on the number of points redeemed and the number of points acquired includes: If the number of points redeemed is greater than the number of points acquired, the source information is updated and the point information is removed. Based on the difference between the number of points redeemed and the number of points acquired, the next point information of the point information is sourced; If the number of points redeemed is equal to the number of points acquired, update the traceability information and remove the point information; If the number of points redeemed is less than the number of points acquired, the traceability information is updated, and the difference between the number of points acquired and the number of points redeemed is used as the updated number of points acquired in the point information.

8. A point information tracing device based on a hash table, characterized in that: The device comprises: A storage module is used to store the points information generated by the transaction information to a disk according to the transaction user and transaction time as a sequential index when receiving the transaction information of consumption or refund application; a determination module configured to, upon receiving a point tracing request, map the user identifier corresponding to the point tracing request to a corresponding hash value, and determine, based on the hash value, a linked list of point information corresponding to the user in a hash table pre-configured in memory; A tracing module is used to trace the point information in the first block of the point information list according to the first-in-first-out principle. If the first block is empty, the point information corresponding to the disk hash index in the non-first block is written into the non-first block according to the disk hash index, and the point information in the non-first block is traced according to the first-in-first-out principle.

9. The device according to claim 8, wherein The storage module is specifically used to temporarily store the points information corresponding to the transaction information into the memory when receiving transaction information of consumption or refund application in the application module; the cleaning module in the memory writes the temporarily stored points information into the disk in sequence according to the transaction user and transaction time as the order index.

10. The device according to claim 8, wherein The determination module is specifically configured to map the user identifier corresponding to the points tracing request into a corresponding hash code through a hash algorithm; and map the hash code to a set range interval through a compression function to obtain a hash value corresponding to the user identifier.

11. The device according to claim 8, wherein The determination module is further configured to configure the number of hash table buckets and establish a corresponding relationship between each bucket and a user; for each user, a corresponding relationship between the user and a point information linked list is established in the form of a key-value pair; wherein the point information linked list includes a first block and non-first blocks; each block is configured with a point information capacity, the first block includes the capacity point information, and the non-first block includes a disk hash index.

12. The device according to claim 8, wherein The tracing module is further configured to update the linked list pointer of the point information linked list if the first block is empty, and update the non-first block adjacent to the first block to the first block.

13. The device according to claim 8, wherein The tracing module is specifically used to obtain the number of points redeemed in the point tracing request and the number of points acquired in the current point information being traced; and to trace the point information based on the number of points redeemed and the number of points acquired.

14. The device according to claim 13, wherein The tracing module is specifically configured to update the tracing information and remove the point information if the number of points redeemed is greater than the number of points acquired, and to trace the next point information of the point information based on the difference between the number of points redeemed and the number of points acquired; and to update the tracing information and remove the point information if the number of points redeemed is equal to the number of points acquired; If the number of points redeemed is less than the number of points acquired, the traceability information is updated, and the difference between the number of points acquired and the number of points redeemed is used as the updated number of points acquired in the point information.

15. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory for storing computer programs; A processor, configured to implement the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.

16. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Block chain-based data storage method, electronic integral processing method and system

    CN112035491A

  • Data tracing method and device, computer equipment and storage medium

    CN114490808A