CN104936210B - A kind of method and device for determining number state - Google Patents
A kind of method and device for determining number state Download PDFInfo
- Publication number
- CN104936210B CN104936210B CN201510188758.7A CN201510188758A CN104936210B CN 104936210 B CN104936210 B CN 104936210B CN 201510188758 A CN201510188758 A CN 201510188758A CN 104936210 B CN104936210 B CN 104936210B
- Authority
- CN
- China
- Prior art keywords
- value
- subscript
- subscript value
- memory bitmap
- character string
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 63
- 230000006870 function Effects 0.000 claims description 48
- 238000004364 calculation method Methods 0.000 claims description 22
- 238000005516 engineering process Methods 0.000 claims description 3
- 238000010295 mobile communication Methods 0.000 claims 2
- 238000004891 communication Methods 0.000 abstract description 4
- 238000013507 mapping Methods 0.000 description 28
- 230000009977 dual effect Effects 0.000 description 7
- 238000004422 calculation algorithm Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 2
- 238000007493 shaping process Methods 0.000 description 2
- 238000004590 computer program Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000007781 pre-processing Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W24/00—Supervisory, monitoring or testing arrangements
- H04W24/02—Arrangements for optimising operational condition
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
本发明实施例公开了一种确定号码状态的方法及装置,涉及通信技术领域,能够提高查询手机号码是否产生3G上网流量的准确率。本发明实施例的方法包括:服务器获取号码在第一内存位图中对应的第一下标值和第二下标值;服务器根据第一下标值和第二下标值得到字符串;服务器根据字符串得到字符串在第二内存位图中对应的第三下标值和第四下标值;服务器根据预设规则设置第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值;服务器根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定号码的号码状态。本发明适用于确定号码状态。
The embodiment of the invention discloses a method and device for determining a number state, relates to the technical field of communication, and can improve the accuracy rate of inquiring whether a mobile phone number generates 3G Internet traffic. The method in the embodiment of the present invention includes: the server obtains the first subscript value and the second subscript value corresponding to the number in the first memory bitmap; the server obtains the character string according to the first subscript value and the second subscript value; According to the character string, the third subscript value and the fourth subscript value corresponding to the character string in the second memory bitmap are obtained; the server sets the key value and the corresponding position of the third subscript value in the second memory bitmap according to preset rules The key value at the position corresponding to the fourth subscript value; the server uses the key value at the position corresponding to the first subscript value in the first memory bitmap, the key value at the position corresponding to the second subscript value, and the third key value in the second memory bitmap The key value at the position corresponding to the subscript value and the key value at the position corresponding to the fourth subscript value determine the number state of the number. The present invention is suitable for determining number status.
Description
技术领域technical field
本发明涉及通信技术领域,尤其涉及一种确定号码状态的方法及装置。The present invention relates to the technical field of communication, in particular to a method and device for determining the state of a number.
背景技术Background technique
随着通信技术的发展,尤其是网络的普及,大部分用户都会选择使用手机等移动终端进行上网,进而产生大量的上网流量信息。供应商为了从大量的上网流量信息中找到感兴趣的数据,需要先对大量的上网流量信息进行分析处理。在现有技术中,对于手机用户,供应商需要对手机号码进行存储、标记和查询等操作。With the development of communication technology, especially the popularity of the Internet, most users will choose to use mobile terminals such as mobile phones to surf the Internet, thereby generating a large amount of Internet traffic information. In order to find interesting data from a large amount of Internet traffic information, suppliers need to analyze and process a large amount of Internet traffic information. In the prior art, for mobile phone users, suppliers need to perform operations such as storing, marking and querying the mobile phone number.
目前,服务器可以利用Hash算法在内存位图中对手机号码进行映射标记,但是在标记过程中会产生键值冲突。当需要映射标记的手机号码的数量较大时,在标记过程中产生键值冲突的概率也会提高。因此,在服务器利用Hash算法在内存位图中对手机号码进行标记之后,通过标记结果来确定手机号码是否产生3G上网流量的过程中,容易将没有产生3G上网流量的手机号码确定为产生了3G上网流量的手机号码。At present, the server can use the Hash algorithm to map and mark the mobile phone number in the memory bitmap, but key-value conflicts will occur during the marking process. When the number of mobile phone numbers that need to be mapped and marked is large, the probability of key-value conflicts during the marking process will also increase. Therefore, after the server uses the Hash algorithm to mark the mobile phone number in the memory bitmap, and in the process of determining whether the mobile phone number generates 3G Internet traffic through the marking result, it is easy to determine the mobile phone number that does not generate 3G Internet traffic as generating 3G data. Mobile phone number for Internet traffic.
发明内容Contents of the invention
本发明实施例提供一种确定号码状态的方法及装置,能够提高查询手机号码是否产生3G上网流量的准确率。The embodiment of the present invention provides a method and device for determining the state of a number, which can improve the accuracy of querying whether a mobile phone number generates 3G Internet traffic.
为达到上述目的,本发明实施例采用如下技术方案:In order to achieve the above object, the embodiment of the present invention adopts the following technical solutions:
第一方面,本发明实施例提供一种确定号码状态的方法,所述方法包括:In a first aspect, an embodiment of the present invention provides a method for determining a number status, the method comprising:
服务器获取号码在第一内存位图中对应的第一下标值和第二下标值;The server obtains the first subscript value and the second subscript value corresponding to the number in the first memory bitmap;
所述服务器根据所述第一下标值和所述第二下标值得到字符串;The server obtains a character string according to the first subscript value and the second subscript value;
所述服务器根据所述字符串得到所述字符串在第二内存位图中对应的第三下标值和第四下标值;The server obtains the third subscript value and the fourth subscript value corresponding to the character string in the second memory bitmap according to the character string;
所述服务器根据预设规则设置所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值,所述预设规则用于区分产生号码状态信息的号码和未产生号码状态信息的号码;The server sets the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the position corresponding to the fourth subscript value in the second memory bitmap according to a preset rule, and the preset rule is used to distinguish Numbers that generate number status information and numbers that do not generate number status information;
所述服务器根据所述第一内存位图中所述第一下标值对应位置的键值和所述第二下标值对应位置的键值,以及所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值,确定所述号码的号码状态。According to the server, according to the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the first subscript value in the second memory bitmap The key value at the position corresponding to the third subscript value and the key value at the position corresponding to the fourth subscript value determine the number status of the number.
第二方面,本发明实施例提供一种确定号码状态的装置,所述装置包括:In the second aspect, the embodiment of the present invention provides a device for determining the status of a number, and the device includes:
获取模块,用于获取号码在第一内存位图中对应的第一下标值和第二下标值;An acquisition module, configured to acquire the first subscript value and the second subscript value corresponding to the number in the first memory bitmap;
生成模块,用于根据所述第一下标值和所述第二下标值得到字符串;A generating module, configured to obtain a character string according to the first subscript value and the second subscript value;
计算模块,用于根据所述字符串得到所述字符串在第二内存位图中对应的第三下标值和第四下标值;A calculation module, configured to obtain the third subscript value and the fourth subscript value corresponding to the character string in the second memory bitmap according to the character string;
设置模块,用于根据预设规则设置所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值,所述预设规则用于区分产生号码状态信息的号码和未产生号码状态信息的号码;A setting module, configured to set a key value at a position corresponding to the third subscript value in the second memory bitmap and a key value at a position corresponding to the fourth subscript value in the second memory bitmap according to a preset rule, and the preset rule uses It is used to distinguish between numbers that generate number status information and numbers that do not generate number status information;
确定模块,用于根据所述第一内存位图中所述第一下标值对应位置的键值和所述第二下标值对应位置的键值,以及所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值,确定所述号码的号码状态。A determination module, configured to use the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the second subscript value in the first memory bitmap The key value at the position corresponding to the third subscript value and the key value at the position corresponding to the fourth subscript value determine the number status of the number.
本发明实施例提供的一种确定号码状态的方法及装置,服务器获取号码在第一内存位图中对应的第一下标值和第二下标值,根据第一下标值和第二下标值得到字符串,并根据字符串得到字符串在第二内存位图中对应的第三下标值和第四下标值,之后根据预设规则设置第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值。服务器根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定号码的号码状态。相比较于现有技术,本发明实施例可以通过在双内存位图中对手机号码进行映射标记,之后根据四个下标值对应位置的键值来确定手机号码是否产生3G上网流量。而不是在单内存位图中对手机号码进行映射标记,仅根据两个下标值对应位置的键值来确定手机号码是否产生3G上网流量。从而,提高查询手机号码是否产生3G上网流量的准确率。In the method and device for determining the state of a number provided by an embodiment of the present invention, the server acquires the first subscript value and the second subscript value corresponding to the number in the first memory bitmap, and according to the first subscript value and the second subscript value Obtain a string from the subscript value, and obtain the third subscript value and the fourth subscript value corresponding to the string in the second memory bitmap according to the string, and then set the third subscript in the second memory bitmap according to the preset rules The key value corresponding to the position of the value and the key value corresponding to the position of the fourth subscript value. The server uses the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the fourth subscript value The subscript value corresponds to the key value of the position, and determines the number status of the number. Compared with the prior art, the embodiment of the present invention can determine whether the mobile phone number generates 3G Internet traffic by mapping and marking the mobile phone number in the dual memory bitmap, and then according to the key values corresponding to the four subscript values. Instead of mapping and marking the mobile phone number in a single memory bitmap, it is only determined whether the mobile phone number generates 3G Internet traffic according to the key values at the corresponding positions of the two subscript values. Thereby, the accuracy rate of querying whether the mobile phone number generates 3G Internet traffic is improved.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings that need to be used in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For Those of ordinary skill in the art can also obtain other drawings based on these drawings without making creative efforts.
图1为本发明实施例提供的一种确定号码状态的方法的流程图;FIG. 1 is a flowchart of a method for determining a number status provided by an embodiment of the present invention;
图2为本发明实施例提供的另一种确定号码状态的方法的流程图;FIG. 2 is a flow chart of another method for determining the status of a number provided by an embodiment of the present invention;
图3为本发明实施例提供的另一种确定号码状态的方法的流程图;FIG. 3 is a flow chart of another method for determining a number status provided by an embodiment of the present invention;
图4为本发明实施例提供的一种具体应用场景下的结构示意图;FIG. 4 is a schematic structural diagram in a specific application scenario provided by an embodiment of the present invention;
图5为本发明实施例提供的另一种确定号码状态的方法的流程图;FIG. 5 is a flow chart of another method for determining a number status provided by an embodiment of the present invention;
图6为本发明实施例提供的另一种确定号码状态的方法的流程图;FIG. 6 is a flow chart of another method for determining the status of a number provided by an embodiment of the present invention;
图7为本发明实施例提供的一种确定号码状态的装置的结构示意图。Fig. 7 is a schematic structural diagram of an apparatus for determining a number status provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
在本发明实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本发明。在本发明实施例和所附权利要求书中所使用的单数形式的“一种”和“所述”也旨在包括多数形式,除非上下文清楚地表示其他含义。Terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. As used in the embodiments of the present invention and the appended claims, the singular forms "a" and "the" are also intended to include the plural forms unless the context clearly indicates otherwise.
本发明适用于确定号码状态,其中,号码状态可以包括:号码是否产生3G(3rdGeneration,第三代数字通信)上网流量、号码是否产生漫游数据等。为了方便描述,在本发明实施例中,以确定手机号码是否产生3G上网流量为例进行说明。The present invention is suitable for determining the status of the number, wherein the status of the number may include: whether the number generates 3G (3rdGeneration, third-generation digital communication) Internet traffic, whether the number generates roaming data, and the like. For the convenience of description, in the embodiment of the present invention, the determination of whether a mobile phone number generates 3G Internet traffic is taken as an example for illustration.
本发明实施例提供一种确定号码状态的方法,如图1所示,所述方法包括:An embodiment of the present invention provides a method for determining a number status, as shown in FIG. 1 , the method includes:
101、服务器获取号码在第一内存位图中对应的第一下标值和第二下标值。101. The server acquires the first subscript value and the second subscript value corresponding to the number in the first memory bitmap.
当需要通过映射来标记的手机号码的数量为1.93亿个时,服务器可以申请一个3亿bit位的内存位图,将内存位图中的所有下标值对应位置的键值初始化为0。服务器逐行读取1.93亿个手机号码对应的上网流量信息记录,并解析出手机号码和手机号码所产生的3G上网流量的数据。服务器判断每条信息所记录的手机号码使用的3G上网流量是否大于0,当手机号码使用的3G上网流量大于0时,根据手机号码使用两个不同的Hash函数(哈希函数)计算出两个下标值,即第一下标值和第二下标值,在内存位图中找到这两个下标值对应位置,同时将这两个下标值对应位置的键值设置为1;当手机号码使用的3G上网流量小于0时,不进行键值设置。重复上述操作,直到将存储的1.93亿个手机号码对应的上网流量信息全部映射到内存位图中。When the number of mobile phone numbers that need to be marked by mapping is 193 million, the server can apply for a memory bitmap of 300 million bits, and initialize the key values corresponding to all subscript values in the memory bitmap to 0. The server reads the Internet traffic information records corresponding to 193 million mobile phone numbers line by line, and analyzes the mobile phone numbers and the 3G Internet traffic data generated by the mobile phone numbers. The server judges whether the 3G Internet traffic used by the mobile phone number recorded in each piece of information is greater than 0. When the 3G Internet traffic used by the mobile phone number is greater than 0, two different Hash functions (hash functions) are used to calculate two hash functions based on the mobile phone number. The subscript value, that is, the first subscript value and the second subscript value, find the corresponding positions of the two subscript values in the memory bitmap, and set the key value of the corresponding position of the two subscript values to 1; when When the 3G Internet traffic used by the mobile phone number is less than 0, no key value setting is performed. Repeat the above operations until all the Internet traffic information corresponding to the stored 193 million mobile phone numbers are mapped to the memory bitmap.
服务器需要使用两个不相同的Hash函数,对手机号码是否产生3G上网流量进行标记,比如:服务器使用Hash函数1和Hash函数2来计算手机号码The server needs to use two different Hash functions to mark whether the mobile phone number generates 3G Internet traffic, for example: the server uses Hash function 1 and Hash function 2 to calculate the mobile phone number
18612345678在第一内存位图中对应的第一下标值和第二下标值,其中,第一内存位图为上述3亿bit位的内存位图;通过Hash函数1计算得到的为第一下标值,18612345678 corresponds to the first subscript value and the second subscript value in the first memory bitmap, wherein the first memory bitmap is the above-mentioned 300 million bit memory bitmap; the one calculated by Hash function 1 is the first subscript value,
通过Hash函数2计算得到的为第二下标值。The value calculated by the Hash function 2 is the second subscript value.
使用两个Hash函数计算下标值的过程,如表一所示:The process of using two Hash functions to calculate the subscript value is shown in Table 1:
表一Table I
使用Hash函数1计算第一下标值的计算步骤如下:The calculation steps for calculating the first subscript value using Hash function 1 are as follows:
获取手机号码18612345678,并对所获取的手机号码18612345678进行预处理,其中,预处理之后的手机号码和原手机号码相同;将预处理之后的手机号码按照MD5(Message-Digest Algorithm 5,信息-摘要算法5)计算,得到6e2b1ca3675119d8edbad42d6d589817;计算Hash值,得到-479003662;将Hash值和整形最大值MAX_INT相与,得到1668479986;将上述相与的结果1668479986对3亿取模,得到第一下标值168479986。Obtain the mobile phone number 18612345678, and preprocess the obtained mobile phone number 18612345678, wherein the preprocessed mobile phone number is the same as the original mobile phone number; the preprocessed mobile phone number is processed according to MD5 (Message-Digest Algorithm 5, information-summary Algorithm 5) Calculate to get 6e2b1ca3675119d8edbad42d6d589817; calculate the Hash value to get -479003662; AND the Hash value and the maximum shaping value MAX_INT to get 1668479986; take the result of the above AND 1668479986 modulo 300 million to get the first subscript value 168479986 .
使用Hash函数2计算第二下标值的计算步骤和使用Hash函数1计算第一下标值的计算步骤类似,其中,预处理后的结果不同,使用Hash函数1的计算过程中,手机号码预处理之后得到的手机号码和原手机号码相同,使用Hash函数2的计算过程中,手机号码预处理之后得到的手机号码是将原手机号码的前三位移到后三位得到的。The calculation steps of using Hash function 2 to calculate the second subscript value are similar to the calculation steps of using Hash function 1 to calculate the first subscript value, wherein the preprocessed results are different. In the calculation process using Hash function 1, the mobile phone number is pre-processed The mobile phone number obtained after processing is the same as the original mobile phone number. During the calculation process using Hash function 2, the mobile phone number obtained after the mobile phone number preprocessing is obtained by shifting the first three digits of the original mobile phone number to the last three digits.
需要说明的是,由于Hash值可能为负数,为了方便映射,可以将Hash值通过计算得到非负整数,比如:通过将Hash值和整形最大值MAX_INT相与得到非负整数;由于第一内存位图占用3亿bit位的存储空间,在计算过程中,通过将相与的结果对3亿取模来确保计算得到的下标值在[0,3亿)的区间范围内,从而保证计算得到的下标值在第一内存位图所占用的存储空间对应的位置中。It should be noted that since the Hash value may be a negative number, in order to facilitate mapping, the Hash value can be calculated to obtain a non-negative integer, for example: a non-negative integer can be obtained by ANDing the Hash value and the maximum value of shaping MAX_INT; since the first memory bit The graph occupies a storage space of 300 million bits. During the calculation process, the calculated subscript value is within the range of [0, 300 million) by taking the modulus of the AND result to 300 million, so as to ensure that the calculated The subscript value of is in the location corresponding to the storage space occupied by the first memory bitmap.
102、所述服务器根据所述第一下标值和所述第二下标值得到字符串。102. The server obtains a character string according to the first subscript value and the second subscript value.
根据上述步骤101中得到的第一下标值168479986和第二下标值73579646可以得到字符串168479986_73579646、字符串168479986*73579646或其他形式的字符串。According to the first subscript value 168479986 and the second subscript value 73579646 obtained in the above step 101, a character string 168479986_73579646, a character string 168479986*73579646 or character strings in other forms can be obtained.
103、所述服务器根据所述字符串得到所述字符串在第二内存位图中对应的第三下标值和第四下标值。103. The server obtains, according to the character string, a third subscript value and a fourth subscript value corresponding to the character string in the second memory bitmap.
和上述步骤101中的计算方法类似,可以通过Hash函数3和Hash函数4,或通过其他两个不同的散列函数计算得到字符串在第二内存位图中对应的第三下标值和第四下标值,还可以通过其他方式对字符串进行处理,从而得到字符串在第二内存位图中对应的第三下标值和第四下标值。Similar to the calculation method in the above step 101, the third subscript value and the first subscript value corresponding to the string in the second memory bitmap can be obtained through Hash function 3 and Hash function 4, or through other two different hash functions. Four subscript values, the string can also be processed in other ways, so as to obtain the third subscript value and the fourth subscript value corresponding to the string in the second memory bitmap.
104、所述服务器根据预设规则设置所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值。104. The server sets a key value at a position corresponding to the third subscript value in the second memory bitmap and a key value at a position corresponding to the fourth subscript value in the second memory bitmap according to a preset rule.
其中,所述预设规则用于区分产生号码状态信息的号码和未产生号码状态信息的号码。例如:预设规则可以用于区分产生3G上网流量的手机号码和未产生3G上网流量的手机号码,当手机号码产生3G上网流量时,在第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值设置为1;当手机号码未产生3G上网流量时,在第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值保持不变。或者,预设规则还可以用于区分产生漫游数据的手机号码和未产生漫游数据的手机号码,当手机号码产生漫游数据时,在第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值设置为1;当手机号码未产生漫游数据时,在第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值保持不变。Wherein, the preset rule is used to distinguish numbers that generate number state information from numbers that do not generate number state information. For example: the preset rules can be used to distinguish mobile phone numbers that generate 3G Internet traffic from mobile phone numbers that do not generate 3G Internet traffic. The key value at the position corresponding to the key value and the fourth subscript value is set to 1; when the mobile phone number does not generate 3G Internet traffic, the key value at the position corresponding to the third subscript value in the second memory bitmap and the fourth subscript value The key value for the corresponding position remains unchanged. Alternatively, the preset rule can also be used to distinguish mobile phone numbers that generate roaming data from mobile numbers that do not generate roaming data. When the mobile phone number generates roaming data, the key value at the position corresponding to the third subscript value in the second memory bitmap The key value corresponding to the fourth subscript value is set to 1; when the mobile phone number does not generate roaming data, the key value corresponding to the third subscript value in the second memory bitmap and the key value corresponding to the fourth subscript value Key values remain the same.
在本发明实施例中,号码状态信息可以是产生3G上网流量的信息。服务器可以根据预设规则分别设置产生3G上网流量的手机号码在第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,以及未产生3G上网流量的手机号码在第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值。In the embodiment of the present invention, the number status information may be information that generates 3G Internet traffic. The server can set the key value corresponding to the third subscript value and the key value corresponding to the fourth subscript value in the second memory bitmap of the mobile phone number that generates 3G Internet traffic according to the preset rules, and the mobile phone number that does not generate 3G Internet traffic The key value of the mobile phone number at the position corresponding to the third subscript value and the key value at the position corresponding to the fourth subscript value in the second memory bitmap.
105、所述服务器根据所述第一内存位图中所述第一下标值对应位置的键值和所述第二下标值对应位置的键值,以及所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值,确定所述号码的号码状态。105. According to the key value at the position corresponding to the first subscript value and the key value at the position corresponding to the second subscript value in the first memory bitmap, and the key value at the position corresponding to the second subscript value in the first memory bitmap, and the The key value at the position corresponding to the third subscript value and the key value at the position corresponding to the fourth subscript value determine the number status of the number.
在执行完毕步骤101-104之后,在查询手机号码是否产生3G上网流量的过程中,需要通过步骤101中的Hash函数1和Hash函数2计算得到手机号码对应的第一下标值和第二下标值,并获取第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值;再通过步骤103计算得到字符串对应的第三下标值和第四下标值,也就是手机号码在第二内存位图中的第三下标值和第四下标值,并获取第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值;根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定手机号码是否产生3G上网流量。比如:当第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值都为1时,手机号码产生3G上网流量;当第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值中任意一个键值不为1时,手机号码未产生3G上网流量。After executing steps 101-104, in the process of querying whether the mobile phone number generates 3G Internet traffic, it is necessary to calculate the first subscript value and the second subscript value corresponding to the mobile phone number through Hash function 1 and Hash function 2 in step 101. subscript value, and obtain the key value corresponding to the first subscript value in the first memory bitmap and the key value corresponding to the second subscript value; then calculate the third subscript value and the second subscript value corresponding to the character string through step 103 The fourth subscript value, that is, the third subscript value and the fourth subscript value of the mobile phone number in the second memory bitmap, and obtain the key value and the fourth subscript value corresponding to the third subscript value in the second memory bitmap The key value at the position corresponding to the subscript value; according to the key value at the position corresponding to the first subscript value in the first memory bitmap, the key value at the position corresponding to the second subscript value, and the third subscript value in the second memory bitmap The key value corresponding to the position and the key value corresponding to the fourth subscript value determine whether the mobile phone number generates 3G Internet traffic. For example: when the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the position corresponding to the second subscript value When the key values corresponding to the four subscript values are all 1, the mobile phone number generates 3G Internet traffic; when the key value corresponding to the first subscript value in the first memory bitmap and the key value corresponding to the second subscript value, And when any one of the key value corresponding to the third subscript value in the second memory bitmap and the key value corresponding to the fourth subscript value is not 1, the mobile phone number does not generate 3G Internet traffic.
本发明实施例提供的一种确定号码状态的方法,服务器获取号码在第一内存位图中对应的第一下标值和第二下标值,根据第一下标值和第二下标值得到字符串,并根据字符串得到字符串在第二内存位图中对应的第三下标值和第四下标值,之后根据预设规则设置第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值。服务器根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定号码的号码状态。相比较于现有技术,本发明实施例可以通过在双内存位图中对手机号码进行映射标记,之后根据四个下标值对应位置的键值来确定手机号码是否产生3G上网流量。而不是在单内存位图中对手机号码进行映射标记,仅根据两个下标值对应位置的键值来确定手机号码是否产生3G上网流量。从而,提高查询手机号码是否产生3G上网流量的准确率。In a method for determining the state of a number provided by an embodiment of the present invention, the server obtains the first subscript value and the second subscript value corresponding to the number in the first memory bitmap, and according to the first subscript value and the second subscript value to the string, and obtain the third subscript value and the fourth subscript value corresponding to the string in the second memory bitmap according to the string, and then set the third subscript value corresponding to the second memory bitmap according to the preset rules The key value of the location and the fourth index value correspond to the key value of the location. The server uses the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the fourth subscript value The subscript value corresponds to the key value of the position, and determines the number status of the number. Compared with the prior art, the embodiment of the present invention can determine whether the mobile phone number generates 3G Internet traffic by mapping and marking the mobile phone number in the dual memory bitmap, and then according to the key values corresponding to the four subscript values. Instead of mapping and marking the mobile phone number in a single memory bitmap, it is only determined whether the mobile phone number generates 3G Internet traffic according to the key values at the corresponding positions of the two subscript values. Thereby, the accuracy rate of querying whether the mobile phone number generates 3G Internet traffic is improved.
在本发明实施例的另一实现方式中,在如图1所示的实现方式的基础上,步骤103还可以具体实现为如图2所示的步骤1031:In another implementation manner of the embodiment of the present invention, on the basis of the implementation manner shown in FIG. 1, step 103 can also be specifically implemented as step 1031 as shown in FIG. 2:
1031、所述服务器将所述字符串通过散列函数计算得到所述字符串在第二内存位图中对应的所述第三下标值和所述第四下标值。1031. The server calculates the character string through a hash function to obtain the third subscript value and the fourth subscript value corresponding to the character string in the second memory bitmap.
需要说明的是,第一下标值、第二下标值、第三下标值和第四下标值均可以使用散列函数计算得到。对于同一个号码,当使用相同的散列函数计算同一内存位图中的下标值时,会得到相同的结果,因此,为了降低产生键值冲突的概率,用于计算第一下标值和第二下标值的散列函数不相同,用于计算第三下标值和第四下标值的散列函数不相同。It should be noted that the first subscript value, the second subscript value, the third subscript value and the fourth subscript value can all be calculated using a hash function. For the same number, when the same hash function is used to calculate the subscript value in the same memory bitmap, the same result will be obtained. Therefore, in order to reduce the probability of key value conflicts, it is used to calculate the first subscript value and The hash functions for the second subscript value are different, and the hash functions for calculating the third subscript value and the fourth subscript value are different.
本发明实施例提供的一种确定号码状态的方法,服务器获取号码在第一内存位图中对应的第一下标值和第二下标值,根据第一下标值和第二下标值得到字符串,并将字符串通过散列函数计算得到字符串在第二内存位图中对应的第三下标值和第四下标值,之后根据预设规则设置第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值。服务器根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定号码的号码状态。相比较于现有技术,本发明实施例可以通过在双内存位图中对手机号码进行映射标记,其中,将字符串映射的方法也是使用散列函数,通过计算得到第三下标值和第四下标值,从而实现手机号码在第二内存位图中的映射,之后根据四个下标值对应位置的键值来确定手机号码是否产生3G上网流量。而不是在单内存位图中对手机号码进行映射标记,仅根据两个下标值对应位置的键值来确定手机号码是否产生3G上网流量。从而,提高查询手机号码是否产生3G上网流量的准确率。In a method for determining the state of a number provided by an embodiment of the present invention, the server obtains the first subscript value and the second subscript value corresponding to the number in the first memory bitmap, and according to the first subscript value and the second subscript value to the string, and calculate the string through the hash function to obtain the third subscript value and the fourth subscript value corresponding to the string in the second memory bitmap, and then set the second subscript value in the second memory bitmap according to the preset rules. The key value corresponding to the position of the third subscript value and the key value corresponding to the position of the fourth subscript value. The server uses the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the fourth subscript value The subscript value corresponds to the key value of the position, and determines the number status of the number. Compared with the prior art, the embodiment of the present invention can map and mark the mobile phone number in the dual memory bitmap, wherein the method of mapping the character string is also to use a hash function to obtain the third subscript value and the second subscript value through calculation. Four subscript values, so as to realize the mapping of the mobile phone number in the second memory bitmap, and then determine whether the mobile phone number generates 3G Internet traffic according to the key value of the corresponding position of the four subscript values. Instead of mapping and marking the mobile phone number in a single memory bitmap, it is only determined whether the mobile phone number generates 3G Internet traffic according to the key values at the corresponding positions of the two subscript values. Thereby, the accuracy rate of querying whether the mobile phone number generates 3G Internet traffic is improved.
在本发明实施例的另一个实现方式中,将字符串映射到第二内存位图时,第三下标值对应位置位于第二内存位图的前X位,而第四下标值对应位置位于第二内存位图中除了前X位以外的位置。因此,在如图2所示的实现方式的基础上,还可以实现为如图3所示的实现方式,其中,步骤1031可以具体实现为步骤10311-10313:In another implementation of the embodiment of the present invention, when the character string is mapped to the second memory bitmap, the corresponding position of the third subscript value is located in the first X position of the second memory bitmap, and the corresponding position of the fourth subscript value is Located in the position other than the first X bits in the second memory bitmap. Therefore, on the basis of the implementation shown in FIG. 2 , it can also be implemented as the implementation shown in FIG. 3 , wherein step 1031 can be specifically implemented as steps 10311-10313:
10311、所述服务器将所述字符串通过第一散列函数计算得到所述字符串在所述第二内存位图的所述前X位中对应的所述第三下标值。10311. The server calculates the character string through a first hash function to obtain the third subscript value corresponding to the character string in the first X bits of the second memory bitmap.
10312、所述服务器将所述字符串通过第二散列函数计算得到所述字符串在所述第二内存位图中对应的第四下标可能值。10312. The server calculates the character string through a second hash function to obtain a fourth possible subscript value corresponding to the character string in the second memory bitmap.
10313、所述服务器将所述第四下标可能值和所述X通过计算得到所述字符串在所述第二内存位图中除了所述前X位以外的位置对应的所述第四下标值。10313. The server calculates the fourth subscript possible value and the X to obtain the fourth subscript corresponding to the position of the character string in the second memory bitmap except for the first X bits marked value.
使用步骤101中类似的方法,计算字符串在第二内存位图对应的第三下标值和第四下标可能值,之后根据计算得到的第四下标可能值和X,得到第四下标值。如图4所示,通过将第二内存位图划分为前X位和除了前X位以外的位置,并分别将字符串映射到第二内存位图前X位和第二内存位图中除了前X位以外的位置,可以确保手机号码对应的字符串经过散列函数计算得到的第三下标值对应于第二内存位图前X位,而经过散列函数计算得到的第四下标值对应于第二内存位图中除了前X位以外的位置,减少了经过散列函数计算的结果都集中在第二内存位图的前X位或除了前X位以外的位置,从而降低了键值冲突的概率。Using a similar method in step 101, calculate the third subscript value and the fourth possible subscript value corresponding to the character string in the second memory bitmap, and then obtain the fourth subscript value based on the calculated fourth possible subscript value and X. marked value. As shown in Figure 4, by dividing the second memory bitmap into the first X bits and positions other than the first X bits, and mapping the character strings to the first X bits of the second memory bitmap and the positions other than the first X bits in the second memory bitmap For positions other than the first X digits, you can ensure that the third subscript value calculated by the hash function of the string corresponding to the mobile phone number corresponds to the first X digits of the second memory bitmap, and the fourth subscript value obtained by the hash function The value corresponds to the position other than the first X bits in the second memory bitmap, and the results calculated by the hash function are all concentrated in the first X bits of the second memory bitmap or positions other than the first X bits, thereby reducing the Probability of key-value collisions.
需要说明的是,在优选方案中,X的值可以设置为第二内存位图所占bit位的一半,比如:第二内存位图所占存储空间为3亿bit,X的值可以为1.5亿。此外,图3所示的步骤执行顺序只是一种示意,在该实现方式中,对于步骤10311和步骤10312-10313的执行顺序并不做特别的限定。因此,步骤10311和步骤10312-10313可以同时进行;或者先执行步骤10311,再执行步骤10312-10313;或者先执行步骤10312-10313,再执行步骤10311。It should be noted that, in the preferred solution, the value of X can be set to half of the bits occupied by the second memory bitmap, for example: the storage space occupied by the second memory bitmap is 300 million bits, and the value of X can be 1.5 100 million. In addition, the execution order of the steps shown in FIG. 3 is only an illustration. In this implementation manner, there is no special limitation on the execution order of step 10311 and steps 10312-10313. Therefore, step 10311 and steps 10312-10313 can be performed at the same time; or step 10311 is performed first, and then steps 10312-10313 are performed; or steps 10312-10313 are performed first, and then step 10311 is performed.
例如:使用步骤101中的Hash函数1和Hash函数2计算得到下标值code1和下标值code2,具体计算过程,如表二所示:For example: using Hash function 1 and Hash function 2 in step 101 to calculate subscript value code1 and subscript value code2, the specific calculation process is as shown in Table 2:
表二Table II
根据表二中得到的下标值code1和下标值code2,可以得到字符串code1_code2,也就是字符串73347002_28255597。使用类似步骤101中的Hash函数1和Hash函数2的计算方法,得到下标值code3和下标值code4,具体计算过程,如表三所示:According to the subscript value code1 and subscript value code2 obtained in Table 2, the string code1_code2 can be obtained, that is, the string 73347002_28255597. Using a calculation method similar to Hash function 1 and Hash function 2 in step 101, the subscript value code3 and the subscript value code4 are obtained. The specific calculation process is as shown in Table 3:
表三Table three
在本发明实施例中,下标值code3对应位置是第二内存位图的前X位中任一位置,下标值code4对应位置是第二内存位图中除了前X位以外的位置中的任一位置。表二是将和MAX_INT相与的结果1273347002,以及628255597分别对3亿取模,得到下标值code1和code2;表三是将和MAX_INT相与的结果149667983,以及1049856612分别对1.5亿取模,得到下标值code3和第四下标可能值,之后将得到的第四下标可能值加上1.5亿,得到下标值code4。In the embodiment of the present invention, the subscript value code3 corresponds to any position in the first X bits of the second memory bitmap, and the subscript value code4 corresponds to any position in the second memory bitmap except the first X bits. any position. Table 2 is the result of ANDing with MAX_INT 1273347002 and 628255597 are respectively modulo 300 million to obtain subscript values code1 and code2; Table 3 is the result of ANDing with MAX_INT 149667983 and 1049856612 are respectively modulo 150 million, Get the subscript value code3 and the fourth possible subscript value, and then add 150 million to the obtained fourth possible subscript value to get the subscript value code4.
本发明实施例提供的一种确定号码状态的方法,服务器获取号码在第一内存位图中对应的第一下标值和第二下标值,根据第一下标值和第二下标值得到字符串,并根据字符串得到字符串在第二内存位图中对应的第三下标值和第四下标值,之后根据预设规则设置第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值。服务器根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定号码的号码状态。其中,第三下标值对应位置位于第二内存位图的前X位,而第四下标值对应位置位于第二内存位图中除了前X位以外的位置。相比较于现有技术,本发明实施例可以通过在双内存位图中对手机号码进行映射标记,其中,将字符串进行映射标记的过程中,由于第三下标值对应位置位于第二内存位图的前X位,而第四下标值对应位置位于第二内存位图中除了前X位以外的位置,避免了第三下标值对应位置和第四下标值对应位置相同的情况,从而降低了第二内存位图中产生键值冲突的概率,之后根据四个下标值对应位置的键值来确定手机号码是否产生3G上网流量。而不是在单内存位图中对手机号码进行映射标记,仅根据两个下标值对应位置的键值来确定手机号码是否产生3G上网流量。从而,提高查询手机号码是否产生3G上网流量的准确率。In a method for determining the state of a number provided by an embodiment of the present invention, the server obtains the first subscript value and the second subscript value corresponding to the number in the first memory bitmap, and according to the first subscript value and the second subscript value to the string, and obtain the third subscript value and the fourth subscript value corresponding to the string in the second memory bitmap according to the string, and then set the third subscript value corresponding to the second memory bitmap according to the preset rules The key value of the location and the fourth index value correspond to the key value of the location. The server uses the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the fourth subscript value The subscript value corresponds to the key value of the position, and determines the number status of the number. Wherein, the position corresponding to the third subscript value is located in the first X bits of the second memory bitmap, and the corresponding position of the fourth subscript value is located in a position other than the first X bits in the second memory bitmap. Compared with the prior art, the embodiment of the present invention can map and mark the mobile phone number in the dual-memory bitmap, wherein, in the process of mapping and marking the character string, since the corresponding position of the third subscript value is located in the second memory The first X bit of the bitmap, and the corresponding position of the fourth subscript value is located in the position other than the first X bit in the second memory bitmap, avoiding the situation that the corresponding position of the third subscript value and the corresponding position of the fourth subscript value are the same , thereby reducing the probability of key value conflicts in the second memory bitmap, and then determining whether the mobile phone number generates 3G Internet traffic according to the key values at the positions corresponding to the four subscript values. Instead of mapping and marking the mobile phone number in a single memory bitmap, it is only determined whether the mobile phone number generates 3G Internet traffic according to the key values at the corresponding positions of the two subscript values. Thereby, the accuracy rate of querying whether the mobile phone number generates 3G Internet traffic is improved.
在本发明实施例的另一个实现方式中,可以通过将第二内存位图中所有位置的键值初始化,并根据冲突规则修改第三下标对应位置的键值和第四下标对应位置的键值,从而完成号码的映射标记过程。因此,在如图1所示的实现方式的基础上,还可以实现为如图5所示的实现方式,其中,在步骤102所述服务器根据所述第一下标值和所述第二下标值得到字符串和步骤103所述服务器根据所述字符串得到所述字符串在第二内存位图中对应的第三下标值和第四下标值之间,还可以包括步骤106,且步骤104所述服务器根据预设规则设置所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值可以具体实现为步骤1041:In another implementation of the embodiment of the present invention, the key values of all positions in the second memory bitmap can be initialized, and the key value of the position corresponding to the third subscript and the key value of the position corresponding to the fourth subscript can be modified according to the conflict rules. key value, thus completing the mapping and marking process of the number. Therefore, on the basis of the implementation shown in FIG. 1 , it can also be implemented as the implementation shown in FIG. 5 , wherein in step 102, the server Obtaining the character string by the subscript value and step 103, the server obtaining the string according to the character string between the third subscript value and the fourth subscript value corresponding to the second memory bitmap, may also include step 106, And the server in step 104 sets the key value corresponding to the position of the third subscript value in the second memory bitmap and the key value corresponding to the position of the fourth subscript value in the second memory bitmap according to preset rules, which can be specifically implemented as step 1041 :
106、所述服务器将所述第二内存位图中所有位置的键值初始化为0。106. The server initializes key values of all positions in the second memory bitmap to 0.
1041、所述服务器根据所述预设规则,将产生所述号码状态信息的号码对应的第三下标值对应位置的键值和第四下标值对应位置的键值设置为1。1041. The server sets the key value corresponding to the third subscript value and the key value corresponding to the fourth subscript value corresponding to the number that generates the number status information to 1 according to the preset rule.
如图4所示的手机号码为产生了3G上网流量的手机号码,在执行完毕步骤106之后,使用2个不同的散列函数对手机号码进行处理,得到第一下标值和第二下标值,之后将第一内存位图中第一下标值对应位置的键值设置为1,并将第一内存位图中第二下标值对应位置的键值设置为1;根据第一下标值和第二下标值,得到字符串,使用2个不同的散列函数对字符串进行处理,得到第三下标值和第四下标值,之后将第二内存位图中第三下标值对应位置的键值设置为1,并将第二内存位图中第四下标值对应位置的键值设置为1。The mobile phone number shown in Figure 4 is the mobile phone number that has generated 3G Internet traffic. After step 106 is executed, the mobile phone number is processed using two different hash functions to obtain the first subscript value and the second subscript value, and then set the key value at the position corresponding to the first subscript value in the first memory bitmap to 1, and set the key value at the position corresponding to the second subscript value in the first memory bitmap to 1; according to the first The subscript value and the second subscript value are obtained to obtain a string, and two different hash functions are used to process the string to obtain the third subscript value and the fourth subscript value, and then the third subscript value in the second memory bitmap The key value at the position corresponding to the subscript value is set to 1, and the key value at the position corresponding to the fourth subscript value in the second memory bitmap is set to 1.
分别按照单内存位图映射和双内存位图映射两种方法,对相同的手机号码进行标记和查询,实验结果如表四所示:According to the two methods of single-memory bitmap mapping and double-memory bitmap mapping respectively, the same mobile phone number is marked and queried. The experimental results are shown in Table 4:
表四Table four
从表四所示的实验结果中,可以得出:From the experimental results shown in Table 4, it can be concluded that:
对相同的193080812个手机号码,使用双内存位图映射的方法对手机号码进行标记所占用的时间比使用单内存位图映射的方法对手机号码进行标记所占用的时间长2分钟,且双内存位图占用的内存比单内存位图占用的内存多39MB。但是,在查询手机号码是否产生3G上网流量时,使用双内存位图映射的方法对手机号码进行标记之后,查询到的产生3G上网流量的手机号码的数量为98462056,使用单内存位图映射的方法对手机号码进行标记之后,查询到的产生3G上网流量的手机号码的数量为115320797,而实际产生3G上网流量的手机号码的数量为93806567。根据上述使用两种方法进行标记之后,查询到的产生3G上网流量的手机号码的数量和实际产生3G上网流量的手机号码的数量,通过计算可以得到,使用单内存位图映射的方法对手机号码进行标,在查询过程中出现关键字冲突的概率为22.93%;使用双内存位图映射的方法对手机号码进行标,在查询过程中出现关键字冲突的概率为4.96%。也就是说,使用双内存位图映射的方法对手机号码进行标在查询过程中的准确率,远远高于使用单内存位图映射的方法对手机号码进行标。For the same 193080812 mobile phone numbers, the time taken to mark the mobile phone number by using the method of dual memory bitmap mapping is 2 minutes longer than that of using the method of single memory bitmap mapping, and the double memory The bitmap takes up 39MB more memory than the single-memory bitmap. However, when inquiring whether a mobile phone number generates 3G Internet traffic, after marking the mobile phone number with the double-memory bitmap mapping method, the number of mobile phone numbers that generate 3G Internet traffic is 98462056. Method After marking the mobile phone numbers, the number of mobile phone numbers that generate 3G Internet traffic is 115320797, while the actual number of mobile phone numbers that generate 3G Internet traffic is 93806567. After using the above two methods to mark, the number of mobile phone numbers that generate 3G Internet traffic and the number of mobile phone numbers that actually generate 3G Internet traffic can be obtained through calculation, and the method of single memory bitmap mapping is used for mobile phone numbers The probability of keyword conflicts during the query process is 22.93%; the mobile phone number is marked using the method of double memory bitmap mapping, and the probability of keyword conflicts during the query process is 4.96%. That is to say, the accuracy rate of using the method of double memory bitmap mapping to mark the mobile phone number in the query process is much higher than that of using the method of single memory bitmap mapping to mark the mobile phone number.
本发明实施例提供的一种确定号码状态的方法,服务器获取号码在第一内存位图中对应的第一下标值和第二下标值,根据第一下标值和第二下标值得到字符串,并根据字符串得到字符串在第二内存位图中对应的第三下标值和第四下标值,之后根据预设规则将已经完成初始化的第二内存位图中,产生号码状态信息的号码对应的第三下标值对应位置的键值和第四下标值对应位置的键值设置为1。服务器根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定号码的号码状态。相比较于现有技术,本发明实施例可以通过在双内存位图中对手机号码进行映射标记,其中,通过将第二内存位图中所有位置的键值初始化为0,并将产生3G上网流量的手机号码对应的第三下标值对应位置的键值和第四下标值对应位置的键值设置为1来完成手机号码在第二内存位图中的映射标记,也就是用下标值对应位置的键值为0或1来区分手机号码的状态,之后根据四个下标值对应位置的键值来确定手机号码是否产生3G上网流量。而不是在单内存位图中对手机号码进行映射标记,仅根据两个下标值对应位置的键值来确定手机号码是否产生3G上网流量。从而,提高查询手机号码是否产生3G上网流量的准确率。In a method for determining the state of a number provided by an embodiment of the present invention, the server obtains the first subscript value and the second subscript value corresponding to the number in the first memory bitmap, and according to the first subscript value and the second subscript value to the string, and obtain the third subscript value and the fourth subscript value corresponding to the string in the second memory bitmap according to the string, and then generate the initialized second memory bitmap according to the preset rules The key value corresponding to the third subscript value and the key value corresponding to the fourth subscript value corresponding to the number in the number status information are set to 1. The server uses the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the fourth subscript value The subscript value corresponds to the key value of the position, and determines the number status of the number. Compared with the prior art, the embodiment of the present invention can map and mark the mobile phone number in the dual memory bitmap, wherein, by initializing the key values of all positions in the second memory bitmap to 0, 3G Internet access will be generated The key value corresponding to the third subscript value and the key value corresponding to the fourth subscript value corresponding to the traffic mobile phone number are set to 1 to complete the mapping mark of the mobile phone number in the second memory bitmap, that is, use the subscript The key value corresponding to the value is 0 or 1 to distinguish the status of the mobile phone number, and then determine whether the mobile phone number generates 3G Internet traffic according to the key values corresponding to the four subscript values. Instead of mapping and marking the mobile phone number in a single memory bitmap, it is only determined whether the mobile phone number generates 3G Internet traffic according to the key values at the corresponding positions of the two subscript values. Thereby, the accuracy rate of querying whether the mobile phone number generates 3G Internet traffic is improved.
在本发明实施例的另一个实现方式中,字符串可以通过将第一下标值的最后一位字符和第二下标值的第一位字符通过非数字的字符连接来生成。因此,在如图1所示的实现方式的基础上,步骤102还可以具体实现为如图6所示的步骤1021:In another implementation manner of the embodiment of the present invention, the character string may be generated by connecting the last character of the first subscript value and the first character of the second subscript value through non-numeric characters. Therefore, on the basis of the implementation shown in FIG. 1, step 102 can also be specifically implemented as step 1021 as shown in FIG. 6:
1021、所述服务器将所述第一下标值的最后一位字符和所述第二下标值的第一位字符用连接符连接,所述连接符为非数字的字符。1021. The server connects the last character of the first subscript value and the first character of the second subscript value with a connector, where the connector is a non-numeric character.
服务器获取手机号码使用2个不同的散列函数计算得到的第一下标值和第二下标值,并将第一下标值的字符和第二下标值的字符相连接。在本发明实施例中,可以在第一下标值的最后一位字符和第二下标之的第一位字符之间添加非数字的字符作为连接符,连接符可以是“_”、“*”、“&”等其他非数字字符。The server obtains the first subscript value and the second subscript value calculated by using two different hash functions of the mobile phone number, and connects the characters of the first subscript value and the characters of the second subscript value. In the embodiment of the present invention, a non-numeric character can be added between the last character of the first subscript value and the first character of the second subscript as a connector, and the connector can be "_", " *", "&" and other non-numeric characters.
本发明实施例提供的一种确定号码状态的方法,服务器获取号码在第一内存位图中对应的第一下标值和第二下标值,服务器将第一下标值的最后一位字符和第二下标值的第一位字符用非数字的字符连接,得到字符串,并根据字符串得到字符串在第二内存位图中对应的第三下标值和第四下标值,之后根据预设规则设置第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值。服务器根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定号码的号码状态。相比较于现有技术,本发明实施例可以通过在双内存位图中对手机号码进行映射标记,之后根据四个下标值对应位置的键值来确定手机号码是否产生3G上网流量。而不是在单内存位图中对手机号码进行映射标记,仅根据两个下标值对应位置的键值来确定手机号码是否产生3G上网流量。从而,提高查询手机号码是否产生3G上网流量的准确率。In the method for determining the state of a number provided by an embodiment of the present invention, the server acquires the first subscript value and the second subscript value corresponding to the number in the first memory bitmap, and the server stores the last character of the first subscript value The first character of the second subscript value is connected with a non-numeric character to obtain a string, and the third subscript value and the fourth subscript value corresponding to the string in the second memory bitmap are obtained according to the string, Then set the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the position corresponding to the fourth subscript value in the second memory bitmap according to preset rules. The server uses the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the fourth subscript value The subscript value corresponds to the key value of the position, and determines the number status of the number. Compared with the prior art, the embodiment of the present invention can determine whether the mobile phone number generates 3G Internet traffic by mapping and marking the mobile phone number in the dual memory bitmap, and then according to the key values corresponding to the four subscript values. Instead of mapping and marking the mobile phone number in a single memory bitmap, it is only determined whether the mobile phone number generates 3G Internet traffic according to the key values at the corresponding positions of the two subscript values. Thereby, the accuracy rate of querying whether the mobile phone number generates 3G Internet traffic is improved.
本发明实施例提供一种确定号码状态的装置20,如图7所示,所述装置20包括:The embodiment of the present invention provides a device 20 for determining the status of a number. As shown in FIG. 7, the device 20 includes:
获取模块21,用于获取号码在第一内存位图中对应的第一下标值和第二下标值。The acquiring module 21 is configured to acquire the first subscript value and the second subscript value corresponding to the number in the first memory bitmap.
生成模块22,用于根据所述第一下标值和所述第二下标值得到字符串。A generating module 22, configured to obtain a character string according to the first subscript value and the second subscript value.
计算模块23,用于根据所述字符串得到所述字符串在第二内存位图中对应的第三下标值和第四下标值。The calculation module 23 is configured to obtain, according to the character string, a third subscript value and a fourth subscript value corresponding to the character string in the second memory bitmap.
设置模块24,用于根据预设规则设置所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值,所述预设规则用于区分产生号码状态信息的号码和未产生号码状态信息的号码。A setting module 24, configured to set a key value at a position corresponding to the third subscript value in the second memory bitmap and a key value at a position corresponding to the fourth subscript value in the second memory bitmap according to preset rules, the preset rule It is used to distinguish numbers that generate number status information from numbers that do not generate number status information.
确定模块25,用于根据所述第一内存位图中所述第一下标值对应位置的键值和所述第二下标值对应位置的键值,以及所述第二内存位图中所述第三下标值对应位置的键值和所述第四下标值对应位置的键值,确定所述号码的号码状态。Determining module 25, configured to use the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value in the first memory bitmap, and the key value at the position corresponding to the second subscript value in the second memory bitmap The key value at the position corresponding to the third subscript value and the key value at the position corresponding to the fourth subscript value determine the number status of the number.
在本发明实施例的另一个实现方式中,所述计算模块23,包括:In another implementation of the embodiment of the present invention, the calculation module 23 includes:
计算单元231,用于将所述字符串通过散列函数计算得到所述字符串在第二内存位图中对应的所述第三下标值和所述第四下标值。The calculating unit 231 is configured to calculate the character string through a hash function to obtain the third subscript value and the fourth subscript value corresponding to the character string in the second memory bitmap.
在本发明实施例的另一个实现方式中,所述第三下标值对应位置位于所述第二内存位图的前X位;所述计算单元231,具体用于将所述字符串通过第一散列函数计算得到所述字符串在所述第二内存位图的所述前X位中对应的所述第三下标值;In another implementation manner of the embodiment of the present invention, the position corresponding to the third subscript value is located in the first X bits of the second memory bitmap; the calculation unit 231 is specifically configured to pass the character string through the first X bit A hash function is calculated to obtain the third subscript value corresponding to the character string in the first X bits of the second memory bitmap;
将所述字符串通过第二散列函数计算得到所述字符串在所述第二内存位图中对应的第四下标可能值,并将根据所述第四下标可能值和所述X通过计算得到所述字符串在所述第二内存位图中除了所述前X位以外的位置对应的所述第四下标值。Calculating the character string through a second hash function to obtain a fourth possible subscript value corresponding to the character string in the second memory bitmap, and using the fourth possible subscript value and the X The fourth subscript value corresponding to the position of the character string in the second memory bitmap other than the first X bits is obtained through calculation.
在本发明实施例的另一个实现方式中,所述设置模块24,还用于将所述第二内存位图中所有位置的键值初始化为0。In another implementation manner of the embodiment of the present invention, the setting module 24 is further configured to initialize key values of all positions in the second memory bitmap to 0.
所述计算模块23,具体用于根据所述预设规则,将产生所述号码状态信息的号码对应的第三下标值对应位置的键值和第四下标值对应位置的键值设置为1。The calculation module 23 is specifically configured to set the key value corresponding to the position corresponding to the third subscript value and the key value corresponding to the fourth subscript value corresponding to the number corresponding to the number that generates the number state information as 1.
在本发明实施例的另一个实现方式中,所述生成模块22,具体用于将所述第一下标值的最后一位字符和所述第二下标值的第一位字符用连接符连接,所述连接符为非数字的字符。In another implementation manner of the embodiment of the present invention, the generating module 22 is specifically configured to use a connector between the last character of the first subscript value and the first character of the second subscript value Connect, the connector is a non-numeric character.
本发明实施例提供的一种确定号码状态的装置,服务器获取号码在第一内存位图中对应的第一下标值和第二下标值,根据第一下标值和第二下标值得到字符串,并根据字符串得到字符串在第二内存位图中对应的第三下标值和第四下标值,之后根据预设规则设置第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值。服务器根据第一内存位图中第一下标值对应位置的键值和第二下标值对应位置的键值,以及第二内存位图中第三下标值对应位置的键值和第四下标值对应位置的键值,确定号码的号码状态。相比较于现有技术,本发明实施例可以通过在双内存位图中对手机号码进行映射标记,之后根据四个下标值对应位置的键值来确定手机号码是否产生3G上网流量。而不是在单内存位图中对手机号码进行映射标记,仅根据两个下标值对应位置的键值来确定手机号码是否产生3G上网流量。从而,提高查询手机号码是否产生3G上网流量的准确率。In the device for determining the state of a number provided by an embodiment of the present invention, the server obtains the first subscript value and the second subscript value corresponding to the number in the first memory bitmap, and according to the first subscript value and the second subscript value to the string, and obtain the third subscript value and the fourth subscript value corresponding to the string in the second memory bitmap according to the string, and then set the third subscript value corresponding to the second memory bitmap according to the preset rules The key value of the location and the fourth index value correspond to the key value of the location. The server uses the key value at the position corresponding to the first subscript value in the first memory bitmap and the key value at the position corresponding to the second subscript value, and the key value at the position corresponding to the third subscript value in the second memory bitmap and the key value at the fourth subscript value The subscript value corresponds to the key value of the position, and determines the number status of the number. Compared with the prior art, the embodiment of the present invention can determine whether the mobile phone number generates 3G Internet traffic by mapping and marking the mobile phone number in the dual memory bitmap, and then according to the key values corresponding to the four subscript values. Instead of mapping and marking the mobile phone number in a single memory bitmap, it is only determined whether the mobile phone number generates 3G Internet traffic according to the key values at the corresponding positions of the two subscript values. Thereby, the accuracy rate of querying whether the mobile phone number generates 3G Internet traffic is improved.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, as for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for relevant parts, please refer to part of the description of the method embodiment.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random AccessMemory,RAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. During execution, it may include the processes of the embodiments of the above-mentioned methods. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM) or a random access memory (Random Access Memory, RAM) and the like.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。The above is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Anyone skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present invention. All should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be determined by the protection scope of the claims.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510188758.7A CN104936210B (en) | 2015-04-20 | 2015-04-20 | A kind of method and device for determining number state |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510188758.7A CN104936210B (en) | 2015-04-20 | 2015-04-20 | A kind of method and device for determining number state |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN104936210A CN104936210A (en) | 2015-09-23 |
| CN104936210B true CN104936210B (en) | 2018-04-10 |
Family
ID=54123112
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201510188758.7A Active CN104936210B (en) | 2015-04-20 | 2015-04-20 | A kind of method and device for determining number state |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN104936210B (en) |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6389123B1 (en) * | 1999-11-08 | 2002-05-14 | Lucent Technologies Inc. | Decreased-size representation employed with portion of automated number identification information in determination of network control point address |
| CN1437374A (en) * | 2003-01-20 | 2003-08-20 | 广东省电信公司科学技术研究院 | Efficient separating method of long distance call area number |
| CN101707750A (en) * | 2009-10-12 | 2010-05-12 | 南京联创科技集团股份有限公司 | Flow control method based on cross operator SMS application |
| CN103345521A (en) * | 2013-07-17 | 2013-10-09 | 腾讯科技(深圳)有限公司 | Method and device for processing key values in hash table database |
| CN103778452A (en) * | 2014-01-10 | 2014-05-07 | 惠州Tcl移动通信有限公司 | Two-dimension code encoding method, two-dimension code decoding method, two-dimension code encoding system and two-dimension code decoding method based on mobile phone |
| CN104486777A (en) * | 2014-12-01 | 2015-04-01 | 中国联合网络通信集团有限公司 | Method and device for processing data |
-
2015
- 2015-04-20 CN CN201510188758.7A patent/CN104936210B/en active Active
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6389123B1 (en) * | 1999-11-08 | 2002-05-14 | Lucent Technologies Inc. | Decreased-size representation employed with portion of automated number identification information in determination of network control point address |
| CN1437374A (en) * | 2003-01-20 | 2003-08-20 | 广东省电信公司科学技术研究院 | Efficient separating method of long distance call area number |
| CN101707750A (en) * | 2009-10-12 | 2010-05-12 | 南京联创科技集团股份有限公司 | Flow control method based on cross operator SMS application |
| CN103345521A (en) * | 2013-07-17 | 2013-10-09 | 腾讯科技(深圳)有限公司 | Method and device for processing key values in hash table database |
| CN103778452A (en) * | 2014-01-10 | 2014-05-07 | 惠州Tcl移动通信有限公司 | Two-dimension code encoding method, two-dimension code decoding method, two-dimension code encoding system and two-dimension code decoding method based on mobile phone |
| CN104486777A (en) * | 2014-12-01 | 2015-04-01 | 中国联合网络通信集团有限公司 | Method and device for processing data |
Also Published As
| Publication number | Publication date |
|---|---|
| CN104936210A (en) | 2015-09-23 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN106407201B (en) | A data processing method, apparatus and computer readable storage medium | |
| CN104516921B (en) | Automatic reply method and device | |
| CN105740405B (en) | Method and apparatus for storing data | |
| CN113383314B (en) | User similarity calculation method and device, server and storage medium | |
| CN111049735B (en) | Group head portrait display method, device, equipment and storage medium | |
| CN113961961B (en) | A privacy set intersection method and device based on scalable-ot | |
| CN111680504A (en) | Legal information extraction model, method, system, device and auxiliary system | |
| CN105808583A (en) | File type identification method and device | |
| TW201327203A (en) | Methods and apparatus for progressive pattern matching in a mobile environment | |
| TWI749349B (en) | Text restoration method, device, electronic equipment and computer readable storage medium | |
| CN114185873A (en) | Data migration method, device, server and storage medium | |
| CN112950640A (en) | Video portrait segmentation method and device, electronic equipment and storage medium | |
| CN108776665B (en) | Data processing method and device | |
| CN105320641B (en) | Text verification method and user terminal | |
| CN105469783A (en) | Audis identification method and device | |
| CN104102748A (en) | Method and device for file mapping and method and device for file recommendation | |
| CN103957211B (en) | Data communications method and device between client and front end page | |
| CN104936210B (en) | A kind of method and device for determining number state | |
| CN106304026B (en) | The determination method and device of end message | |
| CN113837765B (en) | Payment verification method, device, equipment and storage medium | |
| CN105653713B (en) | It is a kind of to determine the method and device that EIC equipment identification code is present | |
| WO2019062067A1 (en) | User interface unit test method and apparatus, readable storage medium and device | |
| CN112100453B (en) | Character string distribution statistical method, system, equipment and computer storage medium | |
| WO2015078124A1 (en) | Network data processing method and device | |
| CN112101023B (en) | Text processing method and device and electronic equipment |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |