A method and system for generating a unique hash number

By combining hash functions and hash chains, an auto-incrementing hash index is generated, which solves the problems of large hash value ranges and hash collisions, improves storage space utilization and data query efficiency, and achieves efficient data access capabilities.

CN115203211BActive Publication Date: 2026-04-07SHANGHAI FINANCIAL FUTURES INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-02
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing hash functions suffer from problems such as slow processing speed, hash collisions, and large range of hash values ​​when processing strings, resulting in low storage space utilization and low data query efficiency.

Method used

A unique hash index generation method is adopted. The string is processed by a hash function to generate a hash value. The code_table of type cblock_map and the hash linked list are used to check whether there is a valid value at the index position. If not, a hash item is created and the hash index is incremented. Otherwise, the linked list is traversed to compare the strings and generate a hash index that increments from 0 as an index, thereby improving space utilization and query efficiency.

Benefits of technology

It effectively solves the problem of large hash value range, improves the space utilization and data query efficiency of string-indexed objects during storage, saves storage space and ensures efficient data read and write capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115203211B_ABST
    Figure CN115203211B_ABST
Patent Text Reader

Abstract

The application discloses a unique hash serial number generation method and system, solves the problem of a large hash value range interval, and improves the space utilization rate and data query efficiency of an object with a string as an index during storage. The technical scheme is as follows: a string is processed to generate a hash serial number which is self-incremented from 0, the hash serial number is used as an index to replace the original storage data structure which needs a string as an index; a cblock_map data cache structure is used, the cblock_map uses a hash value of a hash item as an index when storing the hash item, and contains information such as a string and a hash serial number. In the running process of the method, the cblock_map memory structure is stable, all possible spaces are prepared in advance in the construction method, and there is no scenario of recreating an object and copying data after the space is full. The cblock_map provides efficient and stable read and write capabilities, supports O(1) efficiency of the index storage position of the hash value, and even in the case of hash conflict, the query time can be controlled in a constant range through the way of list traversal.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to a serial number generation technology, in particular to a unique hash serial number generation method and system. BACKGROUND

[0002] In the development and design of background systems, it is necessary to hash a string, or when processing structured data, it is necessary to store it by using a string as an index. The above scenarios all need to use a hash function to hash the string to obtain the hash value of the string. The hash value is in the form of a number, which is used as an index number for data storage.

[0003] A hash function (English: Hash) is a method of creating a small number "fingerprint" from any kind of data. The hash function compresses the message or data into a digest, so that the amount of data is reduced, the format of the data is fixed, and a "hash value" fingerprint is created. The hash value is usually represented by a short string of random letters and numbers.

[0004] However, the commonly used hash function currently applied to this scenario has the problems of slow processing, hash value conflict, and large hash value range interval. SUMMARY

[0005] The following gives a brief summary of one or more aspects to provide a basic understanding of these aspects. This summary is not an exhaustive overview of all contemplated aspects, and neither is it intended to identify key or critical elements of all aspects nor to delineate the scope of any or all aspects. Its only purpose is to present some concepts of one or more aspects in a simplified form as a prelude to the more detailed description given later.

[0006] The present application aims to solve the above problems and provides a unique hash serial number generation method and system, which effectively solves the problem of large hash value range interval and improves the space utilization and data query efficiency of objects with string as index when storing.

[0007] The technical solution of the present application is as follows: the present application discloses a unique hash serial number generation method, which comprises a new unique hash serial number generation process. The new process comprises:

[0008] First, a string to be taken as a hash serial number is obtained, and a hash function is used to process and map the characters into a hash value;

[0009] The method comprises the following steps: taking a hash value as an index, checking whether there is a valid value in the code_table of the cblock_map type at the index corresponding position, if not, creating a hash item, assigning the hash serial number to the newly created hash item, and increasing 1, meanwhile, creating a hash linked list with the hash item as the head pointer, saving the hash linked list at the index position of the code_table, and returning the hash serial number, if there is a valid value in the code_table at the index corresponding position, taking the valid value as the head node of the hash linked list, traversing the child nodes of the hash linked list, comparing the cached string in each hash item with the input string, if there is an equal string, returning the hash serial number of the hash item, if there is no equal string, creating a new hash item at the tail node of the linked list, updating the hash serial number and the string value of the hash item, increasing 1 of the hash serial number, and returning the hash serial number of the new hash item.

[0010] According to an embodiment of the unique hash serial number generation method, the method further comprises a hash serial number obtaining process, and the obtaining process comprises the following steps:

[0011] Firstly, a string to be taken as a hash serial number is obtained, and a hash value is mapped by using a hash function according to the characters;

[0012] The hash value is taken as an index to check the code_table of the cblock_map type, whether there is a valid value at the index corresponding position, if not, returning a query failure, if there is a valid value at the index corresponding position in the code_table, taking the valid value as the head node of the hash linked list, traversing the child nodes of the hash linked list, comparing the cached string in each hash item with the input string, if there is an equal string, returning the hash serial number of the hash item, if there is no equal string, returning a query failure.

[0013] According to an embodiment of the unique hash serial number generation method, the data cache structure of the cblock_map is used for quickly reading the cache value according to the index, wherein the bottom layer of the cblock_map stores and manages data in the form of a two-dimensional pointer array, the row and column values can be defined during initialization, but no memory is applied, the two-dimensional pointer array is initialized according to the index position during insertion, and the array of the index row is initialized each time.

[0014] According to an embodiment of the unique hash serial number generation method, the bottom layer storage component of the cblock_map is further configured with an initialization process, a data saving process and a data reading process, wherein:

[0015] The code_table of the cblock_map type initialization process is further configured as follows: first, a pointer of the cblock_map type is created, parameters of the number of rows and the number of pages are added in the construction method, the cblock_map is stored in the form of a two-dimensional pointer array in the bottom layer, the value of the number of rows*the number of pages specifies the maximum index number supported by the code_table, in the array initialization, the row array is uniformly set to a null pointer, and no additional space is applied;

[0016] The code_table of the cblock_map type data saving process is further configured as follows: first, according to the input hash serial number value, it is judged that the data to be saved should be located in which row array, if the row array does not exist, the row array is newly created and initialized, and then the storage position is obtained according to the hash serial number modulo the number of pages, and the to-be-stored array is updated to the storage position;

[0017] The code_table of the cblock_map type data reading process is further configured as follows: first, according to the input hash serial number value, it is judged that the data to be read should be located in which row array, if the row array does not exist, the reading fails; according to the hash serial number modulo the number of pages, the specific storage position is obtained, it is judged whether the storage position is empty, if it is empty, the query fails, otherwise the value stored at the index is returned.

[0018] The application also discloses a unique hash serial number generation system, the system comprises: a unique hash serial number generation subsystem, wherein the unique hash serial number generation subsystem further comprises:

[0019] A hash serial number generation mapping module is arranged, which obtains an input string of a to-be-taken hash serial number, and maps the hash value by processing the characters according to a hash function;

[0020] A first branch module of the unique hash serial number generation is arranged, which takes the hash value as an index, checks whether there is a valid value in the code_table of the cblock_map type at the index corresponding position, if there is no valid value, a hash item is created, the hash serial number is assigned to the newly created hash item, and is increased by 1, a hash linked list with the hash item as a head pointer is created, the hash linked list is saved at the index position of the code_table, and the hash serial number is returned;

[0021] The second branch module, which creates a hash index, checks if a valid value exists at the indexed position in the `code_table` of type `cblock_map`. If a valid value exists at the indexed position in the `code_table`, it uses that valid value as the first node of the hash linked list. It then traverses the sub-items of the hash linked list, comparing the cached string in each hash item with the input string. If a matching string exists, it returns the hash index of that hash item. If no matching string exists, it creates a new hash item at the tail node of the linked list, updates the hash index and string value of the hash item, increments the hash index by 1, and returns the hash index of the new hash item.

[0022] According to an embodiment of the unique hash sequence number generation system of the present invention, the system includes: a subsystem for obtaining unique hash sequences, wherein the subsystem for obtaining unique hash sequences further includes:

[0023] The mapping module for obtaining hash sequence numbers takes a string of input hash sequence numbers and uses a hash function to process the hash value character by character.

[0024] The first branch module that obtains the hash sequence number checks the code_table of type cblock_map using the hash value as the index. It checks whether a valid value exists at the corresponding index position. If no valid value exists, it returns a query failure.

[0025] The second branch module, which obtains the hash index, checks the `code_table` of type `cblock_map` using the hash value as an index. It checks if a valid value exists at the indexed position in the `code_table`. If a valid value exists at the indexed position, it uses that valid value as the first node of the hash linked list. It then traverses the sub-items of the hash linked list, comparing the cached string in each hash item with the input string. If an equal string exists, it returns the hash index of that hash item; otherwise, it returns a query failure.

[0026] According to an embodiment of the unique hash sequence number generation system of the present invention, the data cache structure of cblock_map is to quickly read the cache value according to the index. The underlying layer of cblock_map stores and manages data in the form of a two-dimensional pointer array. During initialization, row and column values ​​can be defined, but no memory allocation is performed. The two-dimensional pointer array is initialized as needed according to the index position at the time of insertion. Each time, the array of the row where the index is located is initialized.

[0027] According to an embodiment of the unique hash sequence number generation system of the present invention, the system further includes an underlying storage component of cblock_map, wherein the underlying storage component of cblock_map is further configured with an initialization unit, a data storage unit, and a data reading unit, wherein:

[0028] The initialization unit is configured to first create a pointer of type cblock_map. The constructor adds parameters for the number of rows and the number of pages. The cblock_map is stored in the form of a two-dimensional pointer array. The value of the number of rows * the number of pages specifies the maximum number of indices supported by code_table. During array initialization, the row array is uniformly set to a null pointer and no additional space is allocated.

[0029] The data storage unit is configured to first determine which row array the data to be stored should be located in based on the input hash sequence number value. If the row array does not exist, it is created and initialized. Then, the specific storage location is obtained by taking the remainder of the hash sequence number with the page number, and the array to be stored is updated to that storage location.

[0030] The data reading unit is configured to first determine which row array the data to be read should be located in based on the input hash index value. If the row array does not exist, the read failure is returned. The specific storage location is obtained by taking the remainder of the hash index with the page number. The unit then determines whether the storage location is empty. If it is empty, the query failure is returned; otherwise, the value stored at that index is returned.

[0031] Compared with the prior art, the present invention has the following beneficial effects: The unique hash number generation method of the present invention processes the string to generate a hash number starting from 0, which effectively solves the problem of a large range of hash values. When processing structured data storage indexed by strings, the index string is converted into a value that increments from 0, which effectively improves the space utilization and data query efficiency of objects indexed by strings during storage.

[0032] In detail, the features of this invention are as follows:

[0033] 1. The method of the present invention processes strings to generate hash numbers that increment from 0. The hash numbers can be used as indexes to replace the original storage data structures that require strings as indexes, which greatly improves the data access capability of the storage data structures and saves memory space used during storage.

[0034] 2. The method of this invention uses the cblock_map data cache structure to provide large-scale data storage capabilities. When storing hash items, cblock_map uses the hash value of the hash item as an index, containing information such as the string and hash index. The index range supports data sizes from 0 to MAX_INT. During the method's execution, the cblock_map memory structure remains stable, and all potentially usable space is pre-prepared in the constructor, eliminating the scenario of recreating objects and copying data when the space is full.

[0035] 3. The method of the present invention uses cblock_map to provide efficient and stable read and write capabilities, supports O(1) efficiency lookup for the index storage location of hash values, and even in the event of hash collisions, the query time can be controlled within a constant range by traversing the linked list. Attached Figure Description

[0036] The above-described features and advantages of the present invention will be better understood after reading the following detailed description of embodiments of the present disclosure in conjunction with the accompanying drawings. In the drawings, components are not necessarily drawn to scale, and components having similar related characteristics or features may have the same or similar reference numerals.

[0037] Figure 1 A flowchart illustrating the creation of a new hash number according to the present invention is shown.

[0038] Figure 2 A flowchart for obtaining the hash sequence number according to the present invention is shown.

[0039] Figure 3 The initialization flowchart of the underlying storage cblock_map of the present invention is shown.

[0040] Figure 4 The flowchart of the set (save) process of the underlying storage cblock_map of the present invention is shown.

[0041] Figure 5 The flowchart of the get (read) process of the underlying storage cblock_map of the present invention is shown.

[0042] Figure 6 A schematic diagram of an embodiment of the unique hash number generation system of the present invention is shown. Detailed Implementation

[0043] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. It should be noted that the aspects described below with reference to the accompanying drawings and specific embodiments are merely exemplary and should not be construed as limiting the scope of protection of the present invention in any way.

[0044] The external calling interface of an embodiment of the unique hash sequence number generation method of the present invention is as follows: Figure 1 and Figure 2 The images show the newly created and retrieved API calls, respectively.

[0045] like Figure 1 As shown, the process for creating a new unique hash sequence number is detailed below.

[0046] First, obtain the string containing the hash index to be generated, and use a hash function to process it character by character and map it to a long type hash value (the hash value ranges from 0 to MAX_INT).

[0047] Using the hash value as an index, check if a valid value exists at the corresponding index position in the `code_table` (a string hash value mapping table) of type `cblock_map`. If not, create a hash entry, assign the hash index to the new hash entry, increment it by 1, and simultaneously create a hash linked list with the hash entry as its head pointer. Store the hash linked list at the corresponding index position in `code_table` and return the hash index. If a valid value exists at the corresponding index position in `code_table`, then that valid value becomes the head node of the hash linked list. Traverse the child items of the hash linked list, comparing the cached string in each hash entry with the input string. If an equal string exists, return the hash index of that hash entry. If no equal string exists, create a new hash entry at the tail node of the linked list, update the hash index and string value of the hash entry, increment the hash index by 1, and return the hash index of the new hash entry.

[0048] like Figure 2 As shown, the process of obtaining the hash sequence number is detailed below.

[0049] First, obtain the string containing the hash index to be generated, and use a hash function to process it character by character and map it to a long type hash value (the hash value ranges from 0 to MAX_INT).

[0050] The function checks if a valid value exists at the index corresponding to the index in the `code_table` of type `cblock_map`. If no valid value exists, the query fails. If a valid value exists at the index in the `code_table`, the valid value is the first node of the hash chain. The function then traverses the sub-items of the hash chain and compares the cached string in each hash item with the input string. If a matching string exists, the function returns the hash index of the hash item. Otherwise, the query fails.

[0051] The core methods of cblock_map, the underlying storage component that implements the methods, include the initialization, data saving, and data reading processes of cblock_map.

[0052] Cblock_map is a data caching structure that allows for fast access to cached values ​​based on indices. Underlyingly, Cblock_map stores and manages data using a two-dimensional array of pointers. During initialization, row and column values ​​can be defined, but no memory allocation is performed. The array is initialized as needed based on the insertion index position, initializing only the row containing the index each time to prevent excessive memory consumption and effectively improve data storage performance.

[0053] Figure 3The initialization process of the code_table of type cblock_map is described. For example... Figure 3 As shown, a pointer of type `cblock_map` is first created. The constructor can include parameters for the number of rows and pages. `cblock_map` is stored internally as a two-dimensional array of pointers, and the value of `row number * page number` specifies the maximum number of indices supported by `code_table`. During array initialization, the row array is uniformly set to a null pointer, and no additional space is allocated.

[0054] Figure 4 This describes the data storage process for the code_table of type cblock_map. For example... Figure 4 As shown, firstly, based on the input hash index value, it is determined which row array the data to be saved should be located in. If the row array does not exist, it is created and initialized. Then, based on the hash index modulo the page number, the specific storage location is obtained, and the array to be stored is updated to that storage location.

[0055] Figure 5 This describes the data reading process for the code_table of type cblock_map. For example... Figure 5 As shown, first, based on the input hash index value, determine which row array the data to be read should be located in. If the row array does not exist, return a read failure. Then, based on the hash index modulo the page number, obtain the specific storage location. Check if the storage location is empty. If it is empty, return a query failure; otherwise, return the value stored at that index.

[0056] like Figures 3 to 5 As shown, this method adds a `code_table` of type `cblock_map` to the hash function to cache all processed strings. Relying on the fast access capability of `cblock_map`, it converts the disordered hash values ​​after hashing into auto-incrementing hash indices, providing the caller with ordered string hash values. When encountering hash collisions when processing strings using the hash function, a linked list is used to compare string values ​​sequentially, completely avoiding hash collisions. Considering the low probability of hash collisions and the efficient traversal of linked lists, the algorithm processing jitter caused by hash collisions is negligible.

[0057] The above embodiments can be appropriately extended. For example, the underlying storage class of cblock_map can be replaced by other types of classes, and the underlying storage can use other non-two-dimensional pointer array data structures, requiring only the provision of a mapping of a wide range of hash values. The linked list addressing method used in the above embodiments to resolve hash collisions can be replaced by other methods such as open addressing, linear probing, quadratic probing, and establishing a common overflow area. The characteristics of the above methods can be summarized as performing sequential numerical conversion of strings, and possessing high performance and zero-collision characteristics.

[0058] Figure 6 The principle of an embodiment of the unique hash number generation system of the present invention is illustrated. Please refer to [link / reference]. Figure 6 The system in this embodiment includes: a subsystem for creating a unique hash sequence number, a subsystem for obtaining a unique hash sequence number, and the underlying storage component of cblock_map.

[0059] The subsystem for creating unique hash numbers includes a mapping module for creating hash numbers, a first branch module for creating hash numbers, and a second branch module for creating hash numbers.

[0060] Create a new hash index mapping module, configured to retrieve the string of the input hash index to be retrieved, and use a hash function to process the characters and map them to hash values.

[0061] The first branch module of the newly created hash index is configured to use the hash value as the index. It checks whether there is a valid value at the index position in the code_table of type cblock_map. If there is no valid value, it creates a hash item, assigns the hash index to the newly created hash item, increments it by 1, creates a hash linked list with the hash item as the head pointer, saves the hash linked list at the index position of the code_table, and returns the hash index.

[0062] The second branch module for creating hash indexes is configured to use hash values ​​as indices. It checks if a valid value exists at the indexed position in the `code_table` of type `cblock_map`. If a valid value exists at the indexed position in the `code_table`, it uses that valid value as the first node of the hash linked list. It then traverses the sub-items of the hash linked list, comparing the cached string in each hash item with the input string. If a matching string exists, it returns the hash index of that hash item. If no matching string exists, it creates a new hash item at the tail node of the linked list, updates the hash index and string value of the hash item, increments the hash index by 1, and returns the hash index of the new hash item.

[0063] The subsystem for obtaining a unique hash sequence number includes: a mapping module for obtaining hash sequence numbers, a first branch module for obtaining hash sequence numbers, and a second branch module for obtaining hash sequence numbers.

[0064] The mapping module for obtaining hash sequence numbers is configured to retrieve the string of the input hash sequence number and use a hash function to process the hash value character by character.

[0065] The first branch module for obtaining the hash sequence number is configured to check if a valid value exists at the corresponding index position in the cblock_map type code_table using the hash value as the index. If no valid value exists, the query fails.

[0066] The second branch module for obtaining the hash index is configured to check the `code_table` of type `cblock_map` using the hash value as an index. It checks if a valid value exists at the index position. If a valid value exists in the `code_table`, it uses that valid value as the first node of the hash chain. It then traverses the sub-items of the hash chain, comparing the cached string in each hash item with the input string. If an equal string exists, it returns the hash index of that hash item; otherwise, it returns a query failure.

[0067] The data caching structure of cblock_map is based on the index to quickly read the cached value. The underlying cblock_map uses a two-dimensional pointer array to store and manage the data. During initialization, row and column values ​​can be defined, but no memory allocation is performed. The two-dimensional pointer array is initialized as needed according to the index position at the time of insertion, and the array of the row where the index is located is initialized each time.

[0068] The underlying storage component of cblock_map is further configured with an initialization unit, a data storage unit, and a data reading unit.

[0069] The initialization unit is configured to first create a pointer of type cblock_map. The constructor adds parameters for the number of rows and the number of pages. The cblock_map is stored in the form of a two-dimensional pointer array. The value of the number of rows * the number of pages specifies the maximum number of indices supported by code_table. During array initialization, the row array is uniformly set to a null pointer and no additional space is allocated.

[0070] The data storage unit is configured to first determine which row array the data to be stored should be located in based on the input hash sequence number value. If the row array does not exist, it is created and initialized. Then, the specific storage location is obtained by taking the remainder of the hash sequence number with the page number, and the array to be stored is updated to that storage location.

[0071] The data reading unit is configured to first determine which row array the data to be read should be located in based on the input hash index value. If the row array does not exist, the read failure is returned. The specific storage location is obtained by taking the remainder of the hash index with the page number. The unit then determines whether the storage location is empty. If it is empty, the query failure is returned; otherwise, the value stored at that index is returned.

[0072] Although the methods described above are illustrated and depicted as a series of actions for the sake of simplicity, it should be understood and appreciated that these methods are not limited by the order of the actions, as some actions may occur in a different order and / or concurrently with other actions from the illustrations and descriptions herein or not illustrated and described herein but which may be understood by those skilled in the art, according to one or more embodiments.

[0073] Those skilled in the art will further appreciate that the various illustrative logic blocks, modules, circuits, and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or a combination of both. To clearly illustrate this interchangeability between hardware and software, the various illustrative components, blocks, modules, circuits, and steps are described above in a generalized manner in terms of their functionality. Whether such functionality is implemented as hardware or software depends on the specific application and the design constraints imposed on the overall system. Those skilled in the art may implement the described functionality in different ways for each specific application, but such implementation decisions should not be construed as departing from the scope of the invention.

[0074] The various illustrative logic blocks, modules, and circuits described in conjunction with the embodiments disclosed herein can be implemented or performed using a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. The general-purpose processor may be a microprocessor, but in alternatives, it may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors cooperating with a DSP core, or any other such configuration.

[0075] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of both. The software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor such that the processor can read and write information to / from the storage medium. In an alternative, the storage medium may be integrated into the processor. The processor and storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In an alternative, the processor and storage medium may reside as discrete components in the user terminal.

[0076] In one or more exemplary embodiments, the described functionality may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software as a computer program product, the functionality may be stored or transmitted as one or more instructions or code on or through a computer-readable medium. A computer-readable medium includes both computer storage media and communication media, encompassing any medium that facilitates the transfer of a computer program from one location to another. A storage medium may be any available medium accessible to a computer. By way of example and not limitation, such a computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disc storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and is accessible to a computer. Any connection is also legitimately referred to as a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of a medium. As used in this article, disk and disc include compact discs (CDs), laser discs, optical discs, digital multi-purpose discs (DVDs), floppy disks, and Blu-ray discs. Disks typically reproduce data magnetically, while discs reproduce data optically using lasers. Combinations of these should also be included within the scope of computer-readable media.

[0077] The prior description of this disclosure is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to this disclosure will be apparent to those skilled in the art, and the general principles defined herein may be applied to other variations without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not intended to be limited to the examples and designs described herein, but should be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for generating a unique hash sequence number for data storage, characterized in that, The method includes a process for creating a unique hash sequence number. The creation process includes: First, obtain the string containing the hash index to be retrieved, and then use a hash function to process it character by character and map it to a hash value; Using the hash value as an index, check if a valid value exists at the corresponding index position in the `code_table` of type `cblock_map`. If not, create a hash entry, assign the hash index to the new hash entry, and increment it by 1. The `cblock_map` type data cache structure provides large-scale data storage capacity, and its memory structure is stable, offering efficient and stable read / write capabilities. Simultaneously, create a hash linked list with the hash entry as its head pointer, store the hash linked list at the corresponding index position in the `code_table`, and return the hash index. This allows the hash index to be used as the storage data structure for indexing, improving the efficiency of the storage data structure. The data storage capacity is improved, saving memory space used during storage; if a valid value exists in the code_table at the index position, the valid value is used as the first node of the hash list, the sub-items of the hash list are traversed, and the string cached in each hash item is compared with the input string. If an equal string exists, the hash index of the hash item is returned; if no equal string exists, a new hash item is created at the tail node of the list, the hash index and string value of the hash item are updated, the hash index is incremented by 1, and the hash index of the new hash item is returned. The lookup of the index position of the hash value is controlled within a constant range by traversing the list when facing hash collisions. The data caching structure of cblock_map is based on the index to quickly read the cached value. The underlying cblock_map uses a two-dimensional pointer array to store and manage the data. During initialization, row and column values ​​can be defined, but no memory allocation is performed. The two-dimensional pointer array is initialized as needed according to the index position at the time of insertion. Each time, the array of the row where the index is located is initialized. The underlying storage component of cblock_map is further configured with initialization, data saving, and data reading processes, including: The initialization process for the `code_table` of type `cblock_map` is further configured as follows: First, a pointer of type `cblock_map` is created. The constructor adds parameters for the number of rows and pages. The underlying storage of `cblock_map` is a two-dimensional array of pointers, with the number of rows... The page number specifies the maximum number of indices supported by code_table. During array initialization, the row array is uniformly set to a null pointer and no additional space is allocated. The data saving process of the code_table of type cblock_map is further configured as follows: First, based on the input hash index value, determine which row array the data to be saved should be located in. If the row array does not exist, create and initialize the row array. Then, based on the hash index and the remainder of the page number, obtain the specific storage location and update the array to be stored to that storage location. The data reading process for the cblock_map type code_table is further configured as follows: First, based on the input hash index value, determine which row array the data to be read should be located in. If the row array does not exist, return a read failure. Then, based on the hash index modulo the page number, obtain the specific storage location. Determine if the storage location is empty. If it is empty, return a query failure; otherwise, return the value stored at that index.

2. The method for generating a unique hash sequence number for data storage according to claim 1, characterized in that, The method also includes a process for obtaining the hash sequence number, which includes: First, obtain the string containing the hash index to be retrieved, and then use a hash function to process the hash value character by character. The function checks the `code_table` of type `cblock_map` using the hash value as an index. It checks if a valid value exists at the indexed position. If no valid value exists, the query fails. If a valid value exists at the indexed position in the `code_table`, it uses that valid value as the first node of the hash chain. It then traverses the hash chain, comparing the cached string in each hash item with the input string. If a matching string exists, it returns the hash index of that hash item. Otherwise, the query fails.

3. A unique hash sequence number generation system for data storage, characterized in that, The system includes: a subsystem for creating unique hash sequences, wherein the subsystem for creating unique hash sequences further includes: Create a new hash index mapping module, obtain the string of the input hash index to be retrieved, and use a hash function to process the characters and map them to hash values; The first branch module, which creates a new hash index, checks if a valid value exists at the corresponding index position in the `code_table` of type `cblock_map`. If no valid value exists, a hash entry is created, the hash index is assigned to the new hash entry, and incremented by 1. The `cblock_map` type data cache structure provides large-scale data storage capacity, and the `cblock_map` memory structure is stable, providing efficient and stable read and write capabilities. Simultaneously, a hash linked list with the hash entry as its head pointer is created. After storing the hash linked list at the corresponding index position in the `code_table`, the hash index is returned. This allows the hash index to be used as the storage data structure, improving the data storage capacity of the storage data structure and saving memory space used during storage. The second branch module for creating hash indexes checks if a valid value exists at the indexed position in the `code_table` of type `cblock_map`. If a valid value exists at the indexed position in the `code_table`, that valid value is used as the first node of the hash linked list. The sub-items of the hash linked list are traversed, and the string cached in each hash item is compared with the input string. If an equal string exists, the hash index of the hash item is returned. If no equal string exists, a new hash item is created at the tail node of the linked list, the hash index and string value of the hash item are updated, the hash index is incremented by 1, and the hash index of the new hash item is returned. The lookup of the index position of the hash value is kept within a constant range when facing hash collisions by traversing the linked list. The data caching structure of cblock_map is based on the index to quickly read the cached value. The underlying cblock_map uses a two-dimensional pointer array to store and manage the data. During initialization, row and column values ​​can be defined, but no memory allocation is performed. The two-dimensional pointer array is initialized as needed according to the index position at the time of insertion. Each time, the array of the row where the index is located is initialized. The system also includes the underlying storage component of cblock_map, which is further configured with an initialization unit, a data storage unit, and a data retrieval unit, wherein: The initialization unit is configured to first create a pointer of type `cblock_map`, with parameters for the number of rows and pages added to the constructor. The `cblock_map` is stored internally as a two-dimensional array of pointers, with the number of rows... The page number specifies the maximum number of indices supported by code_table. During array initialization, the row array is uniformly set to a null pointer and no additional space is allocated. The data storage unit is configured to first determine which row array the data to be stored should be located in based on the input hash sequence number value. If the row array does not exist, it is created and initialized. Then, the specific storage location is obtained by taking the remainder of the hash sequence number with the page number, and the array to be stored is updated to that storage location. The data reading unit is configured to first determine which row array the data to be read should be located in based on the input hash index value. If the row array does not exist, the read failure is returned. The specific storage location is obtained by taking the remainder of the hash index with the page number. The unit then determines whether the storage location is empty. If it is empty, the query failure is returned; otherwise, the value stored at that index is returned.

4. The unique hash sequence number generation system for data storage according to claim 3, characterized in that, The system includes: a subsystem for obtaining a unique hash sequence number, wherein the subsystem for obtaining a unique hash sequence number further includes: The mapping module for obtaining hash sequence numbers takes a string of input hash sequence numbers and uses a hash function to process the hash value character by character. The first branch module that obtains the hash sequence number checks the code_table of type cblock_map using the hash value as the index. It checks whether a valid value exists at the corresponding index position. If no valid value exists, it returns a query failure. The second branch module, which obtains the hash index, checks the `code_table` of type `cblock_map` using the hash value as an index. It checks if a valid value exists at the indexed position in the `code_table`. If a valid value exists at the indexed position, it uses that valid value as the first node of the hash linked list. It then traverses the sub-items of the hash linked list, comparing the cached string in each hash item with the input string. If an equal string exists, it returns the hash index of that hash item; otherwise, it returns a query failure.

Citation Information

Patent Citations

  • Method and device for processing table items based on Hash table

    CN102682116A

  • Chain log storage structure, hash index structure and data operation method thereof, server and medium

    CN107515901A