CN103345469B - The storage of set of numbers, querying method and device thereof - Google Patents

The storage of set of numbers, querying method and device thereof Download PDF

Info

Publication number
CN103345469B
CN103345469B CN201310199286.6A CN201310199286A CN103345469B CN 103345469 B CN103345469 B CN 103345469B CN 201310199286 A CN201310199286 A CN 201310199286A CN 103345469 B CN103345469 B CN 103345469B
Authority
CN
China
Prior art keywords
tail
list
segment
stored
numbers
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201310199286.6A
Other languages
Chinese (zh)
Other versions
CN103345469A (en
Inventor
刘胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Union Mobile Pay Co Ltd
Original Assignee
Union Mobile Pay Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Union Mobile Pay Co Ltd filed Critical Union Mobile Pay Co Ltd
Priority to CN201310199286.6A priority Critical patent/CN103345469B/en
Publication of CN103345469A publication Critical patent/CN103345469A/en
Application granted granted Critical
Publication of CN103345469B publication Critical patent/CN103345469B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses the storage of a kind of set of numbers, querying method and device thereof, in the present invention according to predetermined number format, by the number of being stored as section in set of numbers and the tail number list corresponding with number section, each list element one_to_one corresponding in tail number list includes the tail number of number of number section corresponding with tail number list in each, it is possible to effectively save memory space;Set of numbers is inquired about when whether having stored a number to be checked, first inquire about when inquiry and whether number section stored need number section of directory enquiry code, the most again in the tail number list corresponding with number section, whether the value of the list element of the tail number of inquiry serial number number to be checked is predetermined mark, compared to checking numbers in prior art, set carries out traversal queries, query script can be simplified, improve the time efficiency of inquiry, additionally it is possible to ensure the accuracy of inquiry.

Description

Number set storage and query method and device
Technical Field
The invention relates to the field of computer data structures, in particular to a number set storage and query method and a number set storage and query device.
Background
In computer information systems, a certain type of key information, such as a cell phone number, bank card number, identification number, RMB banknote number, etc., is typically identified by some ID represented by a string of numbers (e.g., a combination of numbers and letters). To prevent risk, in many important businesses, it is necessary to determine whether these IDs are in a certain set, such as a black list or a white list.
If an element is to be determined to be in a set, all elements are usually saved as an element set, and then the element to be determined is compared with the stored element set, so as to determine whether the element to be determined is in the element set. The idea is adopted for data structures such as a linked list, a tree and a hash table (also called hash table, Hashtable), the spatial complexity of the three data structures is O (n), and the retrieval time complexity is O (n), O (logn) and O (1). From the time efficiency point of view, the retrieval speed of only the hash table in the three data structures is fixed and cannot be increased along with the increase of the size of the set. From the storage space, the three will increase with the increase of the aggregate size, when the aggregate data amount is large to a certain extent, the space occupied by the storage structure is too large, even exceeding the capacity of the physical memory of the common single host, and the retrieval can not be completed.
For this situation, the space storage efficiency can be improved by the following schemes:
the first scheme is as follows: the collected data is stored in an external storage space, such as an external file, an external single database, a plurality of external databases and the like, so that the occupation of the local memory space is reduced.
Scheme II: the bloom filter (BloomFilter) algorithm is used, which is based on the principle that when an element is added to a set, the element is mapped to k points in a bittail list (BitArray) by k hash functions, and they are set to 1. During retrieval: if all points are 1, then the element may be in the set; if there is a 0, the element must not be in the set. Compared with other data structures, bloom filters have great advantages in both space and time. Both bloom filter storage space and insertion/query time are constants o (k). The biggest disadvantage is that a certain error rate exists, namely, when the judgment result is 'in the set', the judgment is possibly misjudged.
However, the above solutions all have some technical problems.
The first solution has the following technical disadvantages: in space, there is no improvement in nature, and only the memory space of the computer is moved out to the outside. The capacity of blacklist data that can be stored is still limited when a single database is used. When multiple databases are used, the access operation is complicated, although the space capacity is nearly infinite. In time, since the external memory space needs to be frequently accessed, the efficiency of the access operation is reduced. Whether single bank or multi-bank, the access performance decreases with the increase of data volume, and the response delay increases, eventually resulting in inaccessibility.
The second solution has the following technical disadvantages: the algorithm improves the space storage efficiency and the query efficiency by sacrificing a certain accuracy. The main body is as follows: only when the judgment result is 'not in the set', the correct judgment can be ensured; however, if the determination result is "in the set", it may be a false determination.
On the other hand, in some important real-time transactions such as payment, accurate judgment on massive blacklist data is often required.
The first scheme described above is unsatisfactory in terms of access time efficiency, and requires frequent access to external storage.
The second scheme does not meet the requirement of accurate judgment in terms of accuracy.
It is obvious that in the current technical scheme of storing and inquiring number sets such as a white list or a black list, the problems of low access time efficiency, low space storage efficiency and low inquiry accuracy exist.
Disclosure of Invention
In view of this, embodiments of the present invention provide a number set storage and query method and device, so as to solve the problems of low access time efficiency, low space storage efficiency, and low query accuracy in the number set storage and query schemes in the prior art.
The technical scheme of the embodiment of the invention is as follows:
a method of storing a set of numbers, comprising: identifying number segments included by each number in the number set according to a preset number format, wherein the preset number format is that the number comprises the number segments and the tail numbers; respectively establishing tail number lists corresponding to the identified different number segments, determining the number of list elements in the tail number lists according to the preset digits of the tail numbers and the counting system of the tail numbers, and setting the sequence numbers of the list elements in the tail number lists according to the counting sequence of the tail numbers; sequentially reading numbers in the number set, and setting a value of a list element with a sequence number being the tail number of the current number in a tail number list corresponding to a number segment of the current number as a preset identifier for the current number, wherein the preset identifier indicates that the current number is stored in the number set; and respectively storing the number segments and the tail number lists corresponding to the number segments.
An apparatus for storing a set of numbers, comprising: the identification module is used for identifying number segments included by all numbers in the number set according to a preset number format, wherein the preset number format is that the numbers include the number segments and tail numbers; the establishing module is used for respectively establishing tail number lists corresponding to the identified different number segments, determining the number of the list elements in the tail number lists according to the preset digits of the tail numbers and the counting system of the tail numbers, and setting the sequence numbers of the list elements in the tail number lists according to the counting sequence of the tail numbers; the setting module is used for reading the numbers in the number set in sequence, and for the current number, setting the value of a list element with the sequence number being the tail number of the current number in a tail number list corresponding to the number segment of the current number as a preset identifier, wherein the preset identifier indicates that the current number is stored in the number set; and the storage module is used for respectively storing the number sections identified by the identification module and the tail number list which corresponds to the number sections and is set by the setting module.
A number set query method comprises the following steps: when whether the number to be inquired is stored in the inquiry number set or not is judged, the number segment part and the tail number part of the number to be inquired are respectively identified according to a preset number format; the preset number format is that the number comprises a number segment and a tail number, the number set is stored as the number segment and a tail number list corresponding to the number segment, the number of list elements in the tail number list is determined according to the digit of the tail number and the counting system of the tail number, and the sequence number of the list elements in the tail number list is set according to the counting sequence of the tail number; under the condition that the number section of the number to be inquired is not stored in the stored number sections, the number to be inquired is determined not to be stored in the number set; under the condition that the number section with the number to be inquired in the stored number sections is judged, determining a tail number list corresponding to the number section with the number to be inquired according to the pre-established corresponding relation between the number section and the tail number list; and judging in the determined tail number list, determining that the number to be inquired is stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is a preset identifier, and determining that the number to be inquired is not stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is not the preset identifier.
An apparatus for querying a set of numbers, comprising: the identification module is used for respectively identifying the number segment part and the tail number part of the number to be inquired according to a preset number format when inquiring whether the number to be inquired is stored in the number set; the preset number format is that the number comprises a number segment and a tail number, the number set is stored as the number segment and a tail number list corresponding to the number segment, the number of list elements in the tail number list is determined according to the digit of the tail number and the counting system of the tail number, and the sequence number of the list elements in the tail number list is set according to the counting sequence of the tail number; the query determining module is used for determining that the number to be queried is not stored in the number set under the condition that the stored number segment is judged to have no number segment of the number to be queried; under the condition that the number section with the number to be inquired in the stored number sections is judged, determining a tail number list corresponding to the number section with the number to be inquired according to the pre-established corresponding relation between the number section and the tail number list; and judging in the determined tail number list, determining that the number to be inquired is stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is a preset identifier, and determining that the number to be inquired is not stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is not the preset identifier.
In the embodiment of the invention, according to a preset number format, the number segment of each number is identified in a number set, and a plurality of number segments in the number set are read; respectively establishing tail number lists corresponding to the identified different number segments, determining the number of list elements in the tail number lists according to the preset digits of the tail numbers and the counting system of the tail numbers, and setting the sequence numbers of the list elements in the tail number lists according to the counting sequence of the tail numbers; sequentially reading numbers in the number set, and setting a value of a list element with a sequence number being the tail number of the current number in a tail number list corresponding to a number segment of the current number as a preset identifier for the current number, wherein the preset identifier indicates that the current number is stored in the number set; the number segments and the tail number lists corresponding to the number segments are respectively stored, and compared with the prior art that all numbers in the number set are directly stored, the storage space can be effectively saved, and the space storage efficiency is improved. When a number to be inquired is stored in the inquiry number set, the number set is stored as a number segment and a tail number list corresponding to the number segment, the number segment part and the tail number part of the number to be inquired are respectively identified during inquiry, the number segment of the number to be inquired is inquired first, then whether the value of a list element with the sequence number being the tail number of the number to be inquired is a preset identifier or not is inquired in the tail number list corresponding to the number segment, compared with the prior art that the number set is subjected to traversal inquiry, the inquiry process can be simplified, the inquiry time efficiency is improved, and compared with the prior art that a bloom filter is arranged according to the counting sequence of the tail numbers, the inquiry accuracy can be ensured, so that the problems that the access time efficiency and the space storage efficiency in the storage and inquiry scheme of the number set in the prior art are low, The query accuracy is low.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
Fig. 1 is a flowchart of a method for storing a number set according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the step 103 in FIG. 1;
fig. 3 is a block diagram of a storage device for number sets according to an embodiment of the present invention;
fig. 4 is a flowchart of a method for querying a number set according to an embodiment of the present invention;
fig. 5 is a block diagram of a number set query apparatus according to an embodiment of the present invention.
Detailed Description
The embodiments of the present invention will be described in conjunction with the accompanying drawings, and it should be understood that the embodiments described herein are only for the purpose of illustrating and explaining the present invention, and are not intended to limit the present invention.
Aiming at the problems of low access time efficiency, low space storage efficiency and low query accuracy rate in the existing technical scheme of storing and querying the number set such as a white list or a black list, the embodiment of the invention provides a number set storage method and a number set query method, which are used for solving the problems.
In the embodiment of the invention, the number set is stored into the number segments and the tail number lists corresponding to the number segments according to the preset number format, and each list element in the tail number list corresponds to each tail number comprising the number of the number segment corresponding to the tail number list one by one, so that the storage space can be effectively saved; when inquiring whether a number to be inquired is stored in the number set, inquiring whether the number segment of the number to be inquired in the stored number segment is in the inquiring process, and then inquiring whether the value of the list element with the sequence number being the tail number of the number to be inquired is a preset identifier in the tail number list corresponding to the number segment.
The following provides a detailed description of embodiments of the invention.
Fig. 1 shows a work flow diagram of a number set storage method provided by an embodiment of the present invention, where the method includes:
step 101, identifying number segments included by each number in a number set according to a preset number format, wherein the preset number format is that the number comprises the number segments and a tail number;
specifically, the number segment part includes a combination of numbers and/or letters and/or symbols, and the tail part includes a combination of numbers; the technical means is widely applicable to various numbers or numbers in practical application; according to the requirement of practical application, the formats of various number segments and tail numbers can be predefined;
for example, the renminbi number is EOF7650583, EOF7 may be predefined as a number segment, 7650583 as a tail number;
for another example, the format of the 18-digit identity number in China is in the form of aabbccyymmdeeex, where AA includes provincial-level region information, BB includes local-level region information, CC includes county-level region information, yyymmdd is a birth year and month, EEE is a serial number part, and X is a check bit, then AA may be predefined as a number segment part, bbccyymymmdeee may be predefined as a tail number part, AABB may be predefined as a number segment part, ccyymymmdeee may be predefined as a tail number part, AABBCC may be predefined as a number segment part, yymmdeee may be predefined as a tail number part, aabbccyyyyyyyyyymmdeee may be predefined as a number segment part, mmeee may be predefined as a tail number segment part, or aabbbbyymymdyymdymdym may be predefined as a number segment part, and EEE may be predefined as a tail number segment part;
for another example, the mobile phone number is 1 abyyyxxxxx, 1AB may be predefined as a number segment, yyyyxxxx may be predefined as a tail number, or 1 abyyyyy may be predefined as a number segment, and xxxx may be predefined as a tail number;
the number is predefined to be a combination of different number segments and tail numbers, so that a plurality of query modes with different granularities can be provided for the query processing of a subsequent number set, and the method is suitable for various application scenes;
preferably, when number segments are predefined, the longer the digits of the predefined number segment part are, the shorter the digits of the tail number part are, the more likely blank number segments in the number set are found, so that the blank number segments can be stripped, in the subsequent process of establishing a tail number list and storing, the storage space can be saved, and the processing speed of query processing of the subsequent number set is improved;
preferably, in some application scenarios, some numbers or coded tail numbers are not expressed by decimal, and the tail numbers can be converted into combinations of decimal numbers;
for example, the MAC address is AAABBB, the AAA byte is vendor information, the BBB byte is unique identification information, AAA can be predefined as a number segment, BBB can be predefined as a tail number, and BBB byte is converted into a decimal number expression;
in some scenes, the number or the serial number cannot be obviously divided into a number segment and a tail number, and the number can be converted, combined or calculated and then divided into the number segment and the tail number;
for example, for a two-dimensional code, the two-dimensional code may be converted into a decimal expression form, and then the decimal expression two-dimensional code is divided into a number segment and a tail number according to the specification of the format of the two-dimensional code in a specific application scene;
102, respectively establishing tail number lists corresponding to the identified different number segments, determining the number of list elements in the tail number lists according to the preset digits of the tail numbers and the counting system of the tail numbers, and setting the sequence numbers of the list elements in the tail number lists according to the counting sequence of the tail numbers;
specifically, a power operation result with the numeric value of the counting scale of the tail number as a base number and the digit of the tail number as an exponent is determined as the number of list elements in the tail number list; for example, if the mobile phone number has a tail number of BBBB-BBBB, the mobile phone tail number has 8 digits, and the mobile phone tail number has decimal notation, then 10 is determined8The number of list elements in the tail number list; the counting sequence of the mobile phone tail numbers is 0000 + 0000, 0000 + 0001, 0000 + 0002, …, 9999 + 9999, and the sequence numbers of the list elements are 0000 + 0000, 0000 + 0001, 0000 + 0002, …, 9999 + 9999;
specifically, a corresponding tail number list can be respectively established for each number segment through a predetermined hash table; or, establishing a tail number list with the same number as the number of the number segments in the number set, and distributing the established tail number list to each number segment in a one-to-one correspondence manner;
103, sequentially reading the numbers in the number set, and setting the value of a list element with the sequence number being the tail number of the current number in a tail number list corresponding to the number segment of the current number as a preset identifier for the current number, wherein the preset identifier indicates that the current number is stored in the number set;
for example, fig. 2 shows that the tail number list established for the number segment 138 of the mobile phone number, the tail numbers of the numbers 138-, and the value of the list element with the sequence number 0000-;
for another example, the MAC address AAABBB is predefined as a number segment AAA and a tail number BBB, and each bit of the MAC address is a byte, and in the process of mapping the tail number and the list elements, if the byte of the tail number is not converted into a decimal expression manner in advance, the tail number may be converted first, a decimal value corresponding to the tail number is determined, the determined decimal value is used as a serial number of the list elements, the list elements and the tail number are corresponded, and the value of the list elements is set as a predetermined identifier;
step 104, respectively storing the number segments and tail number lists corresponding to the number segments;
specifically, under the condition that the memory space is large enough, the number segment and the tail number list corresponding to the number segment can be stored in the memory, so that the query speed can be improved in the subsequent query processing;
under the condition that the memory space is limited, the number segment can be stored in the memory, and a tail number list corresponding to the number segment is stored in the external memory; or, storing the predetermined number segment in the memory, and storing other number segments in the number set and a tail number list corresponding to each number segment in the external memory, where the predetermined number segment may be a number segment with higher use frequency determined according to experience, for example, the number segments 135 and 138 in the mobile phone number segment are number segments with higher use frequency, or, in the blacklist number set, the predetermined number segment may also be a number segment to be filtered in a highlight manner; by the technical means, the query speed is reduced in the subsequent query processing;
under the condition that the memory space is very limited and the relevant information of the number set cannot be loaded, the number segment and the tail number list corresponding to the number segment can be stored in the external memory. Thus, the query speed is reduced in the subsequent query processing.
By the method, the number set is stored into the number segment and the tail number list corresponding to the number segment, when massive number sets are stored, the storage space can be saved, the number segment in the number set is only stored, the invalid number segment can be eliminated, the storage space can be further saved, the unused number segment can be eliminated by adjusting the formats of the preset number segment and the tail number, the storage space can be further saved, and therefore compared with the method of directly storing each number in the number set in the prior art, the storage space can be obviously and effectively saved, and the space storage efficiency is improved.
Based on the same inventive concept, the embodiment of the invention also provides a storage device of the number set.
Fig. 3 is a block diagram illustrating a structure of a storage apparatus for a number set according to an embodiment of the present invention, where the storage apparatus includes:
the identification module 31 is configured to identify a number segment included in each number in a number set according to a predetermined number format, where the predetermined number format is that a number includes a number segment and a tail number;
the establishing module 32 is connected to the identifying module 31, and is configured to respectively establish a tail number list corresponding to the identified different number segments, determine the number of list elements in the tail number list according to the predetermined digits of the tail number and the counting system of the tail number, and set the sequence numbers of the list elements in the tail number list according to the counting sequence of the tail number;
specifically, the establishing module 32 determines the power operation result, which takes the numerical value of the counting system of the tail number as the base number and the digit of the tail number as the exponent, as the number of list elements in the tail number list;
the establishing module 32 establishes a corresponding tail number list for each number segment through a predetermined hash table; or, establishing a tail number list with the same number as the number of the number segments in the number set, and distributing the established tail number list to each number segment in a one-to-one correspondence manner;
the setting module 33 is connected to the identifying module 31 and the establishing module 32, and is configured to sequentially read numbers in the number set, and for a current number, set a value of a list element having a sequence number that is a tail number of the current number in a tail number list corresponding to a number segment of the current number as a predetermined identifier, where the predetermined identifier indicates that the current number is stored in the number set;
and the storage module 34 is connected to the identification module 31 and the setting module 33 and is used for respectively storing the number segments identified by the identification module 31 and the tail number lists set by the setting module 33 corresponding to the number segments.
Specifically, the storage module 34 stores both the number segment and the tail number list corresponding to the number segment in the memory; or, storing the number segment in a memory, and storing a tail number list corresponding to the number segment in an external memory; or, storing the preset number segment into the memory, and storing other number segments in the number set and the tail number list corresponding to each number segment into the external memory; or, storing the number segment and the tail number list corresponding to the number segment in an external memory.
By storing the number sets as number segments and a tail number list corresponding to the number segments by the storage device of the number sets as shown in fig. 3, the storage space can be saved, and only the number segments included in the number sets are stored, so that invalid number segments can be eliminated, the storage space can be further saved, and unused number segments can be eliminated by adjusting the formats of the predetermined number segments and tail numbers, the storage space can be further saved, thereby compared with the method of directly storing each number in the number sets in the prior art, the storage space can be remarkably and effectively saved, and the space storage efficiency is improved.
Fig. 4 is a flowchart illustrating a method for querying a number set according to an embodiment of the present invention, where the method includes:
step 401, when inquiring whether the number to be inquired is stored in the number set, respectively identifying the number segment part and the tail number part of the number to be inquired according to a preset number format; the preset number format is that the number comprises a number segment and a tail number, the number set is stored as the number segment and a tail number list corresponding to the number segment, the number of list elements in the tail number list is determined according to the digit of the tail number and the counting system of the tail number, and the sequence number of the list elements in the tail number list is set according to the counting sequence of the tail number;
wherein, the number segment part comprises the combination of numbers and/or letters and/or symbols, and the tail number part comprises the combination of numbers;
step 402, determining that the number to be inquired is not stored in the number set under the condition that the stored number segment is judged to have no number segment of the number to be inquired;
specifically, corresponding to the storage method of the number set shown in fig. 1, when the number segment is stored in the memory, the number segment is queried in the memory; under the condition that the preset number segment is stored in the memory and other number segments in the number set are stored in the external memory, inquiring the preset number segment in the memory and inquiring other number segments in the number set in the external memory; in the case where the number segment is stored in the external memory, the number segment is queried in the external memory;
step 403, under the condition that the stored number segments are judged to have the number segments of the numbers to be inquired, determining a tail number list corresponding to the number segments of the numbers to be inquired according to the pre-established corresponding relation between the number segments and the tail number list; and judging in the determined tail number list, determining that the number to be inquired is stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is a preset identifier, and determining that the number to be inquired is not stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is not the preset identifier.
Specifically, corresponding to the storage method of the number set shown in fig. 1, when the tail number list is stored in the memory, the tail number list is queried in the memory; in the case where the tail number list is stored in the external memory, the tail number list is queried in the external memory.
Through the method shown in fig. 4, when inquiring whether a number to be inquired is stored in a number set, the number set is stored as a number segment and a tail number list corresponding to the number segment, and the sequence number of a list element in the tail number list is consistent with the counting sequence of the tail number, the number segment of the number to be inquired is inquired first during inquiry, and then in the tail number list corresponding to the number segment, whether the value of the list element with the sequence number being the tail number of the number to be inquired is a predetermined identifier is inquired, compared with traversing inquiry of the number set in the prior art, the inquiry process can be simplified, and the inquiry time efficiency can be improved.
Based on the same inventive concept, the embodiment of the invention also provides a number set query device.
Fig. 5 is a block diagram illustrating a structure of an apparatus for querying a number set according to an embodiment of the present invention, where the apparatus includes:
the identification module 51 is configured to identify a number segment part and a tail number part of a number to be queried according to a predetermined number format when querying whether the number to be queried is stored in the number set; the preset number format is that the number comprises a number segment and a tail number, the number set is stored as the number segment and a tail number list corresponding to the number segment, the number of list elements in the tail number list is determined according to the digit of the tail number and the counting system of the tail number, and the sequence number of the list elements in the tail number list is set according to the counting sequence of the tail number;
the query determining module 52 is connected to the identifying module 51, and is configured to determine that the number to be queried is not stored in the number set when it is determined that there is no number segment of the number to be queried in the stored number segments; under the condition that the number section with the number to be inquired in the stored number sections is judged, determining a tail number list corresponding to the number section with the number to be inquired according to the pre-established corresponding relation between the number section and the tail number list; judging in the determined tail number list, determining that the number to be inquired is stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is a preset identifier, and determining that the number to be inquired is not stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is not the preset identifier;
specifically, the query determining module 52 queries the number segment in the memory when the number segment is stored in the memory; under the condition that the preset number segment is stored in the memory and other number segments in the number set are stored in the external memory, inquiring the preset number segment in the memory and inquiring other number segments in the number set in the external memory; in the case where the number segment is stored in the external memory, the number segment is queried in the external memory;
under the condition that the tail number list is stored in the memory, inquiring the tail number list in the memory; in the case where the tail number list is stored in the external memory, the tail number list is queried in the external memory.
Through the device shown in fig. 5, when inquiring whether a number to be inquired is stored in the number set, the number set is stored as a number segment and a tail number list corresponding to the number segment, and the sequence number of the list element in the tail number list is consistent with the counting sequence of the tail number, the number segment of the number to be inquired is inquired first during inquiry, and then in the tail number list corresponding to the number segment, whether the value of the list element with the sequence number being the tail number of the number to be inquired is a predetermined identifier is inquired, compared with traversing inquiry of the number set in the prior art, the inquiry process can be simplified, and the inquiry time efficiency can be improved.
In summary, in the embodiments of the present invention, according to a predetermined number format, the number segment of each number is identified in the number set, and a plurality of number segments in the number set are read; respectively establishing tail number lists corresponding to the identified different number segments, determining the number of list elements in the tail number lists according to the preset digits of the tail numbers and the counting system of the tail numbers, and setting the sequence numbers of the list elements in the tail number lists according to the counting sequence of the tail numbers; sequentially reading numbers in the number set, and setting a value of a list element with a sequence number being the tail number of the current number in a tail number list corresponding to a number segment of the current number as a preset identifier for the current number, wherein the preset identifier indicates that the current number is stored in the number set; the number segments and the tail number lists corresponding to the number segments are respectively stored, and compared with the prior art that all numbers in the number set are directly stored, the storage space can be effectively saved, and the space storage efficiency is improved. When a number to be inquired is stored in the inquiry number set, the number set is stored as a number segment and a tail number list corresponding to the number segment, the number segment part and the tail number part of the number to be inquired are respectively identified during inquiry, the number segment of the number to be inquired is inquired first, then whether the value of a list element with the sequence number being the tail number of the number to be inquired is a preset identifier or not is inquired in the tail number list corresponding to the number segment, compared with the prior art that the number set is subjected to traversal inquiry, the inquiry process can be simplified, the inquiry time efficiency is improved, and compared with the prior art that a bloom filter is arranged according to the counting sequence of the tail numbers, the inquiry accuracy can be ensured, so that the problems that the access time efficiency and the space storage efficiency in the storage and inquiry scheme of the number set in the prior art are low, The query accuracy is low.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
In addition, each functional unit in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (14)

1. A method for storing a set of numbers, comprising:
identifying number segments included by each number in the number set according to a preset number format, wherein the preset number format is that the number comprises the number segments and the tail numbers;
respectively establishing tail number lists corresponding to the identified different number segments, determining the number of list elements in the tail number lists according to the preset digits of the tail numbers and the counting system of the tail numbers, and setting the sequence numbers of the list elements in the tail number lists according to the counting sequence of the tail numbers;
sequentially reading numbers in the number set, and setting a value of a list element with a sequence number being the tail number of the current number in a tail number list corresponding to a number segment of the current number as a preset identifier for the current number, wherein the preset identifier indicates that the current number is stored in the number set;
and respectively storing the number segments and the tail number lists corresponding to the number segments.
2. The method according to claim 1, wherein determining the number of list elements in the tail number list according to the predetermined number of digits of the tail number and the count number of the tail number comprises:
and determining the power operation result which takes the numerical value of the counting system of the tail number as a base number and takes the digit of the tail number as an exponent as the number of the list elements in the tail number list.
3. The method according to claim 1, wherein the step of respectively establishing the tail number lists corresponding to the number segments comprises:
respectively establishing a corresponding tail number list for each number segment through a preset hash table; or,
and establishing a tail number list with the number same as the number of the number segments in the number set, and distributing the established tail number list to each number segment in a one-to-one correspondence manner.
4. The method according to claim 1, wherein storing the number segment and the tail number list corresponding to the number segment respectively comprises:
storing the number segment and the tail number list corresponding to the number segment in a memory; or,
storing the number segment in a memory, and storing a tail number list corresponding to the number segment in an external memory; or,
storing the preset number segments into a memory, and storing other number segments in the number set and a tail number list corresponding to each number segment into an external memory; or,
and storing the number segment and the tail number list corresponding to the number segment into an external memory.
5. The method of claim 1, wherein the number segment portion comprises a combination of numbers and/or letters and/or symbols and the tail portion comprises a combination of numbers.
6. An apparatus for storing a set of numbers, comprising:
the identification module is used for identifying number segments included by all numbers in the number set according to a preset number format, wherein the preset number format is that the numbers include the number segments and tail numbers;
the establishing module is used for respectively establishing tail number lists corresponding to the identified different number segments, determining the number of the list elements in the tail number lists according to the preset digits of the tail numbers and the counting system of the tail numbers, and setting the sequence numbers of the list elements in the tail number lists according to the counting sequence of the tail numbers;
the setting module is used for reading the numbers in the number set in sequence, and for the current number, setting the value of a list element with the sequence number being the tail number of the current number in a tail number list corresponding to the number segment of the current number as a preset identifier, wherein the preset identifier indicates that the current number is stored in the number set;
and the storage module is used for respectively storing the number sections identified by the identification module and the tail number list which corresponds to the number sections and is set by the setting module.
7. The apparatus according to claim 6, wherein the establishing module is specifically configured to:
and determining the power operation result which takes the numerical value of the counting system of the tail number as a base number and takes the digit of the tail number as an exponent as the number of the list elements in the tail number list.
8. The apparatus according to claim 6, wherein the establishing module is specifically configured to:
respectively establishing a corresponding tail number list for each number segment through a preset hash table; or,
and establishing a tail number list with the number same as the number of the number segments in the number set, and distributing the established tail number list to each number segment in a one-to-one correspondence manner.
9. Device according to claim 6, characterized in that said storage means are, in particular, intended for
Storing the number segment and the tail number list corresponding to the number segment in a memory; or,
storing the number segment in a memory, and storing a tail number list corresponding to the number segment in an external memory; or,
storing the preset number segments into a memory, and storing other number segments in the number set and a tail number list corresponding to each number segment into an external memory; or,
and storing the number segment and the tail number list corresponding to the number segment into an external memory.
10. A method for querying a number set, comprising:
when whether the number to be inquired is stored in the inquiry number set or not is judged, the number segment part and the tail number part of the number to be inquired are respectively identified according to a preset number format; the preset number format is that the number comprises a number segment and a tail number, the number set is stored as the number segment and a tail number list corresponding to the number segment, the number of list elements in the tail number list is determined according to the digit of the tail number and the counting system of the tail number, and the sequence number of the list elements in the tail number list is set according to the counting sequence of the tail number;
under the condition that the number section of the number to be inquired is not stored in the stored number sections, the number to be inquired is determined not to be stored in the number set;
under the condition that the number section with the number to be inquired in the stored number sections is judged, determining a tail number list corresponding to the number section with the number to be inquired according to the pre-established corresponding relation between the number section and the tail number list; and judging in the determined tail number list, determining that the number to be inquired is stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is a preset identifier, and determining that the number to be inquired is not stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is not the preset identifier.
11. The method of claim 10, further comprising:
inquiring the number segment and a tail number list corresponding to the number segment in the memory; or,
inquiring the number segment in the memory, and inquiring a tail number list corresponding to the number segment in the external memory; or,
inquiring a preset number segment in the memory, and inquiring other number segments in the number set and a tail number list corresponding to each number segment in the external memory; or,
and inquiring the number segment and a tail number list corresponding to the number segment in the external memory.
12. The method of claim 10, wherein the number segment portion comprises a combination of numbers and/or letters and/or symbols and the tail portion comprises a combination of numbers.
13. An apparatus for querying a set of numbers, comprising:
the identification module is used for respectively identifying the number segment part and the tail number part of the number to be inquired according to a preset number format when inquiring whether the number to be inquired is stored in the number set; the preset number format is that the number comprises a number segment and a tail number, the number set is stored as the number segment and a tail number list corresponding to the number segment, the number of list elements in the tail number list is determined according to the digit of the tail number and the counting system of the tail number, and the sequence number of the list elements in the tail number list is set according to the counting sequence of the tail number;
the query determining module is used for determining that the number to be queried is not stored in the number set under the condition that the stored number segment is judged to have no number segment of the number to be queried; under the condition that the number section with the number to be inquired in the stored number sections is judged, determining a tail number list corresponding to the number section with the number to be inquired according to the pre-established corresponding relation between the number section and the tail number list; and judging in the determined tail number list, determining that the number to be inquired is stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is a preset identifier, and determining that the number to be inquired is not stored in the number set under the condition that the value of the list element with the sequence number being the tail number of the number to be inquired is not the preset identifier.
14. The apparatus according to claim 13, wherein the query determining module is specifically configured to query the number segment in the memory when the number segment is stored in the memory; under the condition that the preset number segment is stored in the memory and other number segments in the number set are stored in the external memory, inquiring the preset number segment in the memory and inquiring other number segments in the number set in the external memory; in the case where the number segment is stored in the external memory, the number segment is queried in the external memory;
the query module is specifically configured to query the tail number list in the memory when the tail number list is stored in the memory; in the case where the tail number list is stored in the external memory, the tail number list is queried in the external memory.
CN201310199286.6A 2013-05-24 2013-05-24 The storage of set of numbers, querying method and device thereof Active CN103345469B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310199286.6A CN103345469B (en) 2013-05-24 2013-05-24 The storage of set of numbers, querying method and device thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310199286.6A CN103345469B (en) 2013-05-24 2013-05-24 The storage of set of numbers, querying method and device thereof

Publications (2)

Publication Number Publication Date
CN103345469A CN103345469A (en) 2013-10-09
CN103345469B true CN103345469B (en) 2016-08-03

Family

ID=49280264

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310199286.6A Active CN103345469B (en) 2013-05-24 2013-05-24 The storage of set of numbers, querying method and device thereof

Country Status (1)

Country Link
CN (1) CN103345469B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657481B (en) * 2015-02-26 2018-05-04 华为技术有限公司 A kind of method and device for storing, inquiring about data
CN106681995B (en) * 2015-11-05 2020-08-18 菜鸟智能物流控股有限公司 Data caching method, data query method and device
CN105427450A (en) * 2015-11-10 2016-03-23 东方通信股份有限公司 ATM counterfeit banknote identification system and method based on novel banknote serial number storage structure
CN105847508B (en) * 2016-03-16 2018-09-18 北京羽乐创新科技有限公司 A kind of storage method of telephone number, recognition methods and device
CN106407299A (en) * 2016-08-31 2017-02-15 东方通信股份有限公司 Banknote crown word number blacklist data storage and retrieval methods supporting wildcard characters
CN106777178A (en) * 2016-12-22 2017-05-31 上海大汉三通无线通信有限公司 The storage method and querying method of a kind of phone number
CN107657061A (en) * 2017-10-23 2018-02-02 中国联合网络通信集团有限公司 Data processing method and device
CN108055397A (en) * 2017-12-06 2018-05-18 广东欧珀移动通信有限公司 Realize method, electronic equipment and the computer readable storage medium of do-not-disturb functionality
CN109977033A (en) * 2017-12-28 2019-07-05 北京顺智信科技有限公司 Store the method and device of telecom number
CN109558387B (en) * 2018-12-11 2020-10-30 北京锐安科技有限公司 Method and device for processing identity card number, storage medium and terminal
CN115883508B (en) * 2021-09-26 2024-06-07 中移物联网有限公司 Number processing method and device, electronic equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751475A (en) * 2010-01-08 2010-06-23 联动优势科技有限公司 Method for compressing section records and device therefor

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007103815A2 (en) * 2006-03-03 2007-09-13 Perfect Search Corporation Hyperspace index

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101751475A (en) * 2010-01-08 2010-06-23 联动优势科技有限公司 Method for compressing section records and device therefor

Also Published As

Publication number Publication date
CN103345469A (en) 2013-10-09

Similar Documents

Publication Publication Date Title
CN103345469B (en) The storage of set of numbers, querying method and device thereof
CN110149803B (en) Data storage method, system and terminal equipment
CN106874348B (en) File storage and index method and device and file reading method
CN111552692B (en) Plus-minus cuckoo filter
TWI406130B (en) Data processing system, controller, and method thereof for searching specific memory area
CN105468642A (en) Data storage method and apparatus
CN108027713A (en) Data de-duplication for solid state drive controller
CN102629234A (en) Fast retrieval method for data of built-in Flash of single chip microcomputer
CN104298736A (en) Method and device for aggregating and connecting data as well as database system
CN109062936A (en) A kind of data query method, computer readable storage medium and terminal device
CN112783971B (en) Transaction recording method, transaction query method, electronic device and storage medium
CN104142979B (en) A kind of indexing means for realizing RFID tag storage management
CN103870511A (en) Shared memory-based information inquiring equipment and method
CN116975006A (en) Data deduplication method, system and medium based on disk cache and B-tree index
CN104866535A (en) Compression method and device of number segment records
CN112015672A (en) Data processing method, device, equipment and storage medium in storage system
CN107329702B (en) Self-simplification metadata management method and device
CN103744927A (en) Attribution information storage and obtaining method and device
CN112380174A (en) XFS file system analysis method containing deleted files, terminal equipment and storage medium
CN101625902B (en) Method, system and device for acquiring service life of semiconductor storage medium
CN105653464B (en) Structure of JAVA intelligent card and object management method thereof
CN117270766A (en) Data storage architecture, method for data storage, electronic device and storage medium
CN109165172A (en) Caching data processing method and relevant device
US20230076550A1 (en) Method and apparatus for sorting data, storage apparatus
KR102396424B1 (en) Method for Providing Card Information

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CB03 Change of inventor or designer information
CB03 Change of inventor or designer information

Inventor after: Liu Sheng

Inventor after: Xu Chunlong

Inventor after: Zhao Yan

Inventor before: Liu Sheng