WO2021008024A1 - 数据处理的方法、装置和服务器 - Google Patents

数据处理的方法、装置和服务器 Download PDF

Info

Publication number
WO2021008024A1
WO2021008024A1 PCT/CN2019/116646 CN2019116646W WO2021008024A1 WO 2021008024 A1 WO2021008024 A1 WO 2021008024A1 CN 2019116646 W CN2019116646 W CN 2019116646W WO 2021008024 A1 WO2021008024 A1 WO 2021008024A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
bit
bucket
value
target
Prior art date
Application number
PCT/CN2019/116646
Other languages
English (en)
French (fr)
Inventor
张�杰
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021008024A1 publication Critical patent/WO2021008024A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/215Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • This application belongs to the field of data processing technology, and particularly relates to a data processing method, device, and server.
  • Data judgment is mainly used to judge whether there are duplicate records in the data, and is widely used in various business scenarios. For example, when a user registers an account, the data can be used to determine whether the account has been registered with rm
  • judging data is mainly implemented in two ways.
  • One is to directly query whether a record exists in the database. For example, when a user registers an account with the username "Zhang San", he needs to query the database for the same record. If there is already a record named "Zhang San" in the database, the newly registered user name is not allowed to be put into the warehouse, if it does not exist, it can be put into the warehouse.
  • This method of weight determination is mainly used when the amount of data is small. If the amount of data that needs to be stored in the database is very large, the number of judgment queries will be very large, resulting in very large database overhead. Therefore, the judgment of big data is mainly realized through the use of local memory, for example, combined with Bloom filters. However, since the bits in the Bloom filter are not allowed to be reset, the Bloom filter cannot be expanded and contracted, and data cannot be deleted using this weight determination method. With more and more data, more and more memory will be occupied, and the false positive rate will gradually increase.
  • the embodiments of the present application provide a data processing method, device, and server to solve the problem that the data cannot be deleted when the Bloom filter is used in the prior art to determine the weight of big data.
  • a data processing method including:
  • each data bucket includes a plurality of bits, and the initial bit values of the plurality of bits are all a first value
  • the target data bucket used to write the new data is identified, and the bit corresponding to the new data in the target data bucket is determined by determining the new data Whether the bit value of the bit corresponding to the data is the second value, determining whether to write the new data into the target data bucket;
  • a data processing device including:
  • the obtaining module is used to obtain the existing data records in the database
  • the bucketing module is configured to bucket the data records and set the expiration time of each data bucket.
  • Each data bucket includes a plurality of bits, and the initial bit values of the plurality of bits are all Is the first value
  • the change module is configured to determine the bit corresponding to any data record in each data bucket, and set the bit value of the bit corresponding to each data record to a second value;
  • the determining module is used to identify the target data bucket used to write the new data and the bit position corresponding to the new data in the target data bucket when a request for warehousing of new data is received, Determining whether to write the new data into the target data bucket by determining whether the bit value of the bit corresponding to the new data is the second value;
  • the processing module is configured to delete the data bucket and the data bucket when the expiration time is reached, if no new data is written in the data bucket before the expiration time of the data bucket is reached Data records, Otherwise, the expiration time of the data bucket is extended.
  • a server including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor executes the computer-readable The following steps to implement the above data processing method when instructing:
  • each data bucket includes a plurality of bits, and the initial bit values of the plurality of bits are all a first value
  • the target data bucket used to write the new data is identified, and the bit corresponding to the new data in the target data bucket is determined by determining the new data Whether the bit value of the bit corresponding to the data is the second value, determining whether to write the new data into the target data bucket;
  • a computer non-volatile readable storage medium stores computer readable instructions, and when the computer readable instructions are executed by a processor The following steps to implement the above data processing method:
  • each data bucket includes a plurality of bits, and the initial bit values of the plurality of bits are all the first value
  • the target data bucket used to write the new data is identified, and the bit corresponding to the new data in the target data bucket is determined by determining the new Whether the bit value of the bit corresponding to the data is the second value, determining whether to write the new data into the target data bucket; [0030] If no new data is written in the data bucket before the expiration time of the data bucket is reached, delete the data bucket and the data records in the data bucket when the expiration time is reached, otherwise To extend the expiration time of the data bucket.
  • the data processing method, device, and server provided by the embodiments of the application have the following beneficial effects: the weighting range of data is reduced by bucketing, and the data of some buckets gradually expires because they are no longer active, and the data is deleted.
  • the purpose without causing the data to permanently exist in the bloom filter over time, to achieve the purpose of deleting the data in the bloom filter. Since the data record will continue to increase, the Bloom filter needs more and more bits to judge the weight.
  • the bitmap of the Bloom filter will increase and decrease, so as to achieve the effect of the stretchable Bloom filter. The purpose is to reduce the memory usage and solve the problem of increased false positive rate when data is judged to be heavy.
  • FIG. 1 is a schematic flow diagram of the steps of a data processing method according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of steps of another data processing method according to an embodiment of the present application.
  • FIG. 3 is a schematic diagram of a data processing device according to an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a server according to an embodiment of the present application.
  • each switch can be numbered. If there are 10,000 switches, you can start numbering from 0 and continue to 9999.
  • the switch in the Bloom filter refers to bit (bit). On means that the bit is 1, and off means that the bit is 0. By default, all switches are set to off, that is, all bits are 0.
  • n different hash values can be obtained through different hash methods. For example, for a string A, after hashing it, a set of hash values can be obtained ⁇ 5, 300, 891, 2999, 7821 ⁇
  • bit positions numbered 5, 300, 891, 2999, 7821 can be set to 1.
  • the same hash method can be used to obtain the same set of hash values ⁇ 5, 300, 891, 2999, 7821 ⁇ , and the process of judging the weight is only It is necessary to determine whether the bits of this group of numbers are all 1.
  • Using the hash method to obtain the hash value of a character string may collide. Collision is that different strings may obtain the same hash value through different hash methods. For example, the hash value obtained by the hash method of string A is ⁇ 5, 300, 891, 2999, 7821 ⁇ , and the hash value obtained by the hash method of string B is ⁇ 300, 2999, 5 , 7821, 891 ⁇ , although their order is not the same, but they are actually stored in the Bloom filter is the same.
  • the Bloom filter judges (the so-called bit of the hash value is set to 1) is an existing character String B, this is the so-called false positive, false existence. However, there is a certain probability that this collision is exactly the same, so it is called the false positive rate. When most bit bits in the Bloom filter are set to 1, the false positive rate will be higher and higher.
  • redis a memory-based caching tool
  • redis has a bitmap node.
  • the structure can be used as a Bloom filter. Therefore, by constructing a lot of small bitmap structure Bloom filters, and setting the expiration time of the Bloom filter of each bitmap structure to 30 days, when a certain bitmap structure When the Bloom filter does not write data for more than 30 days, it will be automatically deleted by redis expiration. In this way, memory space is saved and the purpose of data scaling is achieved.
  • FIG. 1 there is shown a schematic flow chart of the steps of a data processing method according to an embodiment of the present application, which may specifically include the following steps:
  • the existing data records in the database of this embodiment may refer to various types of data records stored in the server. For example, user ID and so on.
  • the data record can also be of other types, such as mailbox accounts, URLs, etc., and this embodiment does not limit the type of data record.
  • S102 Bucket the data records, and set an expiration time of each data bucket, where each data bucket includes a plurality of bits, and the initial bit values of the plurality of bits are all a first value ;
  • each data bucket is a Bloom filter with a bitmap structure designed based on the redis timeout expiration feature.
  • Redis is a memory-based caching tool with a bitmap structure.
  • the basic principle of Bitmap is to use a bit to mark the value corresponding to an element, and the key is the element, and the bitmap structure can be used as a Bloom filter. Because one bit is used to store one piece of data, the storage space can be greatly saved.
  • each Bloom filter is a data bucket used to store data records later. Therefore, each data bucket includes multiple bits, and the initial bit values of the multiple bits may all be the first value. For example, at the beginning, the value of each bit is 0. At the same time, in order to distinguish each data bucket easily, a corresponding number can also be set for each data bucket. For example, 0-9999 and so on. [0059] Therefore, the acquired data records can be relatively evenly distributed to each data bucket according to certain rules.
  • a preset random function may be used to generate integer values for each data record, and then the integer value of each data record may be divided by the number of data buckets.
  • the buckets respectively have corresponding bucket numbers. Therefore, each data record can be placed in a data bucket corresponding to the same bucket number as the calculated remainder, thereby achieving a relatively uniform distribution of the data records.
  • the crc32 function can generate a long integer value from a string through a certain algorithm process, so the crc32 random function can be used to bucket existing data records.
  • the crc32 random function can be used to divide the above user IDs into 200,000 data buckets, and each data bucket includes 10,000 user IDs.
  • each data record can be randomly distributed in each data bucket relatively evenly according to the number of all data records, which is not limited in this embodiment.
  • the expiration time of each data bucket is the expiration time of the bitmap, that is, the TTL (Time To Live, time to live value) expiration time in redis.
  • TTL Time To Live, time to live value
  • the expiration time of each data bucket may be specifically determined according to business requirements. For example, you can set the expiration time of each data bucket to be 30 days.
  • S103 Determine a bit position corresponding to any data record in each data bucket, and set the bit value of the bit position corresponding to each data record to a second value; [0069]
  • corresponding numbers may be set for the bits in each data bucket. For example, each bit position can be numbered from 0 to 9999, so that each data record in the data bucket corresponds to one or more bit positions.
  • a preset algorithm may be used to calculate the hash value of any data record, and then the bit value of the bit with the same bit number as the hash value is set to the second value. For example, the bit value of the bit position is changed from the initial value 0 to 1.
  • Hash calculation can be understood as mapping a certain character string to a value within 10000, and using different hash methods to obtain n different hash values. Therefore, the hash value corresponding to a data record can also include multiple.
  • bit values of multiple bits with the same bit number as the above hash value can be set to 1.
  • the newly received data can be judged based on each data bucket.
  • the target data bucket used to write the new data can be identified first, and the bit corresponding to the new data in the target data bucket, by judging that the newly received data is in the target data bucket. Whether the bit value of the corresponding bit in the target data bucket is the second value is used to determine whether the data is existing data in the database.
  • the target data bucket of the new data can be determined according to the operation mode when the existing data records are bucketed, that is, which database the new data should be written into.
  • the crc32 function can be used to convert the new data into an integer value, and then the value can be divided by the number of data buckets, and the obtained remainder can be used as the number of the target data bucket.
  • the data in the database When the data is recorded in buckets, multiple hash values can be calculated by using multiple hash methods, and the bit values of bits corresponding to the multiple hash values are all set to the second value. Therefore, when judging the weight of the received new data, the same multiple hashing methods should also be used to calculate multiple hash values, and by determining whether the bit value of the bit corresponding to each hash value is the second Numerical value to complete the process of judging weight.
  • bit values of the bits corresponding to the multiple hash values obtained after hashing the new data are all the second value, it can be determined that the new data is an existing data record in the database. At this time, the storage request for new data can be rejected.
  • any one of the bit values of the bits corresponding to the multiple hash values is not the second value, it can be confirmed that the new data is not an existing data record in the database, so that the new data can be written In the current data bucket.
  • the expiration time of the Bloom filter of the Bitmap structure will start to count down after it is set, and when the countdown is 0, the record will be automatically deleted by redis. Since the data bucket in this embodiment is a Bloom filter with a bitmap structure, when the expiration time of the data bucket arrives, the data bucket and the data records stored therein will also be deleted.
  • the data bucket after setting the expiration time of the data bucket until the expiration time is reached, if no new data is written in the data bucket, when the expiration time is reached, the data bucket can be directly And the data records in it are deleted, reducing the memory usage.
  • extending the expiration time of the data bucket may be performed when new data is written into the data bucket, and the extended expiration time may also be the same as the duration of the originally set expiration time. For example, if the expiration time of a certain data bucket is 30 days, and new data is written in the data bucket on the third day after the countdown starts, the expiration time of the data bucket can be extended to 30 days at this time. That is, when new data is written into the data bucket, the expiration time of the data bucket is reset. [0088] Of course, the method for extending the expiration time described above is only an example, and those skilled in the art use other methods to extend the expiration time of the data bucket, which is not limited in this embodiment.
  • the weight judgment range of the data is reduced by bucketing, and the data of some buckets gradually expires because they are no longer active, so as to achieve the purpose of deleting the data, but will not cause
  • the data permanently exists in the bloom filter, and the purpose of deleting the data in the bloom filter is realized. Since the data record will continue to increase, the Bloom filter needs more and more bits to judge the weight.
  • the bitmap of the Bloom filter will increase and decrease, so as to achieve the effect of the stretchable Bloom filter. The purpose is to reduce the memory usage and solve the problem of increased false positive rate when data is judged to be heavy.
  • FIG. 2 there is shown a step flow diagram of another data processing method according to an embodiment of the present application, which may specifically include the following steps:
  • S201 Acquire existing data records in the database
  • the existing data records in the database of this embodiment may refer to various types of data records stored in the server. For example, user ID, email account, URL, etc., this embodiment does not limit the type of data record.
  • this implementation takes the data record in the database as the user ID as an example for subsequent introduction.
  • S202 Bucket the data record and set an expiration time of each data bucket, where each data bucket includes multiple bits, and the initial bit values of the multiple bits are all a first value ;
  • Each data bucket in this embodiment is a Bloom filter with a bitmap structure designed based on the redis timeout expiration feature.
  • multiple Bloom filters with a bitmap structure can be constructed as subsequent data buckets for storing data records, and the same bucket number can be set for each data bucket.
  • Each data bucket includes multiple bits, which can be understood as a group of numbered electrical switches, and then each switch can be numbered to get the bit number of each bit. For example, if there are 10,000 switches, you can start numbering from 0 and continue to 9999.
  • the switch on can refer to the bit value of a bit, and off refers to the bit value of 0.
  • the crc32 random function may be used to bucket existing data records. E.g You can first use the crc32 random function to generate an integer value for each user ID, then divide the value by the number of data buckets, and then use the remainder as the number of the data bucket, and place the user ID in the corresponding data bucket in.
  • the expiration time of each data bucket may be specifically determined according to business requirements. For example, you can set the expiration time of each data bucket to be 30 days.
  • S203 Calculate the hash value of any data record by using a preset algorithm
  • a hash calculation may be performed on them first, and then the bit value of each bit is set according to the result of the hash calculation.
  • Hash calculation can be understood as mapping a certain character string to a value within 10000, and using different hash methods to obtain n different hash values. Therefore, the hash value corresponding to a data record can also include multiple.
  • n different hash values. For example, a set of hash values can be obtained ⁇ 5, 300, 891, 2999, 7821 ⁇ .
  • the first numerical value and the second numerical value respectively represent the "off” and "on” states of the switch indicated by each bit position. Therefore, after the hash value of a certain user ID is calculated, the bit value of the bit corresponding to the hash value can be changed from the initial state 0 to 1.
  • bit positions in the current data bucket may be numbered 5, 300, 891, 2999, and 7821 as 1.
  • each data bucket can use 239,627 bits for weight determination, and each data bucket can determine 10,000 user IDs. Heavy
  • the target data bucket is the data bucket into which the received new data should be written after the re-determination.
  • the target data bucket to which the new data is to be written can be determined according to the operation mode when the existing data records are divided into buckets.
  • crc32 function For example, you can use the crc32 function to convert the new data into an integer value, and then divide the value by the number of data buckets, and use the obtained remainder as the number of the target data bucket.
  • the same hashing method as the bucketing should be used to calculate multiple hash values, and then by comparing the multiple hash values with the corresponding ones in the target data bucket The bit value of the bit position confirms whether the new data is an existing data record in the target data bucket.
  • S207 Determine whether the bit values of the multiple bit bits in the target data bucket whose bit numbers are the same as the multiple target hash values are all second values;
  • judging the new data may be implemented by determining whether the bit values of the bits corresponding to each hash value of the new data are all the second values.
  • step S208 can be performed to identify that the new data is already in the target data bucket. Data logging. At this time, the storage request for the new data can be rejected.
  • step S210 If any one of the bit values of the bits corresponding to the multiple hash values is not the second value, it can be confirmed that the new data is not an existing data record in the database, so that step S210 can be executed, and The new data is written into the current target data bucket.
  • the expiration time of the data bucket can be extended. For example, if the expiration time of a certain data bucket is 30 days and new data is written in the data bucket on the third day after the countdown starts, the expiration time of the data bucket can be extended to 30 days at this time.
  • the data records in the data bucket can be re-buckled, and the bucketing process is as described in step S202. After deleting and rebuilding the bitmap, active data can be rewritten, and zombie users are also eliminated.
  • bitmap Bitmap (bloom filter)
  • some data records can be deleted.
  • a bitmap expires and is deleted, it can be regarded as within 30 days, the data in this bitmap has not been written or updated, then it will be deleted and the space will be released.
  • new data is written into this bitmap, the system creates this bitmap again.
  • the expiration time setting of Bitmap (Bloom Filter) has very important significance:
  • bitmap is no longer written or updated. There is also a situation where the false positive rate is very high, that is, when most of the bits are full. In this case, deleting and rebuilding the bitmap will rewrite the active data, and zombie users will be excluded. [0133] It should be noted that the size of the sequence number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, instead of the implementation process of the embodiment of this application. Constitute any limitation.
  • FIG. 3 a schematic diagram of a data processing apparatus according to an embodiment of the present application is shown, which may specifically include the following modules:
  • the obtaining module 301 is used to obtain existing data records in the database
  • the bucketing module 302 is configured to bucket the data record and set the expiration time of each data bucket, where each data bucket includes a plurality of bits, and the initial bit value of the plurality of bits Are the first value;
  • the changing module 303 is configured to determine the bit position corresponding to any data record in each data bucket, and set the bit value of the bit position corresponding to each data record to a second value;
  • the determining module 304 is configured to identify the target data bucket used to write the new data and the bit position corresponding to the new data in the target data bucket when a request for warehousing of new data is received Determining whether to write the new data into the target data bucket by determining whether the bit value of the bit corresponding to the new data is the second value;
  • the processing module 305 is configured to delete the data bucket and the data bucket when the expiration time is reached, if no new data is written in the data bucket before the expiration time of the data bucket is reached Otherwise, extend the expiration time of the data bucket.
  • the bucketing module 302 may specifically include the following sub-modules:
  • the integer value generation sub-module is used to generate integer values for each data record by using a preset random function
  • the remainder calculation sub-module is used to calculate the remainder obtained by dividing the integer value of each data record by the number of data buckets, and each data bucket has a corresponding bucket number;
  • the data record bucketing sub-module is configured to respectively place the data records into the data buckets corresponding to the bucket numbers with the same remainder.
  • the multiple bits respectively have corresponding bit numbers
  • the modification module 303 may specifically include the following sub-modules:
  • a hash value calculation submodule configured to calculate the hash value of any data record by using a preset algorithm
  • bit value change submodule is used to set the bit value of the bit with the same bit number as the hash value Is the second value.
  • the calculated hash value of any data record includes multiple, and the bit value change submodule may specifically include the following units:
  • the bit value changing unit is configured to set the bit values of multiple bits with the same bit number as the multiple hash values to the second value.
  • the determining module 304 may specifically include the following sub-modules:
  • the integer value generation sub-module is configured to use a preset random function to generate an integer value for the new data when a request for warehousing of new data is received;
  • the remainder calculation sub-module is configured to calculate the remainder obtained by dividing the integer value by the number of data buckets, and each data bucket has a corresponding bucket number;
  • the target data bucket identification sub-module is configured to identify the data bucket with the same bucket number as the remainder as the target data bucket.
  • the determining module 304 may further include the following sub-modules:
  • a target hash value calculation sub-module for calculating multiple target hash values of the new data by using a preset algorithm
  • bit value judging submodule configured to judge whether the bit values of the multiple bits in the target data bucket whose bit numbers are the same as the multiple target hash values are all second values
  • the data record identification sub-module is configured to identify all bits in the target data bucket whose bit values are the same as the plurality of target hash values.
  • the new data is an existing data record in the target data bucket;
  • the data record writing submodule is configured to, if any bit value of the multiple bits in the target data bucket whose bit number is the same as the multiple target hash values is not the second value, Then write the new data into the target data bucket.
  • the bucketing module 302 is further configured to, when the number of data records in any data bucket exceeds a preset number, perform bucketing on the data records in the data bucket again, and set the buckets respectively The expiration time of each subsequent data bucket.
  • the server 400 of this embodiment includes: a processor 410, a memory 420, and computer-readable instructions 421 that are stored in the memory 420 and run on the processor 410.
  • the processor 410 executes the computer-readable instruction 421
  • the steps in each embodiment of the foregoing data processing method are implemented, for example, steps S101 to S105 shown in FIG. 1.
  • the processor 410 executes the computer-readable instructions 421
  • the functions of the modules/units in the foregoing device embodiments such as the functions of the modules 301 to 305 shown in FIG. 3, are implemented.
  • the computer-readable instructions 421 may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 420 and executed by the processor 410 execute to complete this application.
  • the one or more modules/units may be a series of computer-readable instruction segments capable of completing specific functions, and the instruction segments may be used to describe the execution process of the computer-readable instructions 421 in the server 400.
  • the computer-readable instruction 421 may be divided into an acquisition module, a bucketing module, a change module, a determination module, and a processing module, and the specific functions of each module are as follows:
  • the obtaining module is used to obtain existing data records in the database
  • the bucketing module is configured to bucket the data records and set the expiration time of each data bucket, where each data bucket includes multiple bits, and the initial bit values of the multiple bits are all Is the first value
  • the change module is configured to determine the bit corresponding to any data record in each data bucket, and set the bit value of the bit corresponding to each data record to a second value;
  • the determining module is used to identify the target data bucket used for writing the new data and the bit position corresponding to the new data in the target data bucket when a request for warehousing of new data is received, Determining whether to write the new data into the target data bucket by determining whether the bit value of the bit corresponding to the new data is the second value;
  • a processing module configured to delete the data bucket and the data bucket when the expiration time is reached, if no new data is written in the data bucket before the expiration time of the data bucket is reached.
  • the data record of the data bucket, otherwise, the expiration time of the data bucket is extended.
  • the server 400 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the server 400 may include, but is not limited to, a processor 410 and a memory 420.
  • FIG. 4 is only an example of the server 400, and does not constitute a limitation on the server 400.
  • the server 400 may also include input and output devices, network access devices, buses, and the like.
  • the processor 410 may be a central processing unit (Central Processing Unit, CPU), or may be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), and dedicated integrated circuits (Application Specific Integrated Circuits).
  • CPU Central Processing Unit
  • DSP Digital Signal Processor
  • DSP dedicated integrated circuits
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the memory 420 may be an internal storage unit of the server 400, for example, a hard disk or a memory of the server 400.
  • the memory 420 may also be an external storage device of the server 400, for example, a plug-in hard disk, a Smart Media Card (SMC), or a Secure Digital (SD) card equipped on the server 400, Flash memory card
  • the memory 420 may also include both an internal storage unit of the server 400 and an external storage device.
  • the memory 420 is used to store the computer-readable instructions 421 and other instructions and data required by the server 400.
  • the memory 420 can also be used to temporarily store data that has been output or will be output.
  • Non-volatile memory may include read-only memory (ROM), programmable ROM (PRO M), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDR AM), and memory bus dynamic RAM (RDRAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种数据处理的方法、装置和服务器,该方法包括:对数据库中的数据记录进行分桶并设置过期时间;确定任一数据记录对应的比特位,将对应比特位的比特值置为第二数值;当接收到新数据的入库请求时,识别目标数据桶以及新数据在目标数据桶中对应的比特位,通过判断对应比特位的比特值是否为第二数值,确定是否将新数据写入目标数据桶中;若在到达过期时间之前,数据桶中未有新数据写入,则在到达过期时间时删除数据桶及其数据记录,否则,延长过期时间。通过分桶将数据的判重范围缩小,某些桶的数据因为不再活跃而逐渐过期,达到删除数据的目的,解决了数据判重时假阳率增大的问题。

Description

数据处理的方法、 装置和服务器
[0001] 本申请申明享有 2019年 07月 12日递交的申请号为 201910628181.5、 名称为“数据 处理的方法、 装置和服务器”中国专利申请的优先权, 该中国专利申请的整体内 容以参考的方式结合在本申请中。
技术领域
[0002] 本申请属于数据处理技术领域, 特别是涉及一种数据处理的方法、 装置和服务 器。
背景技术
[0003] 数据判重主要用于对数据中是否存在重复记录进行判断, 广泛应用于各种业务 场景下。 例如, 在用户注册账号时, 通过数据判重可以确认该账号是否已被注 rm
册。
[0004] 目前, 对数据进行判重主要通过两种方式来实现。 一种是在数据库中直接查询 某条记录是否存在。 例如, 当用户使用“张三”这一用户名注册账号时, 需要在数 据库中查询是否存在相同的记录。 如果数据库中已经有一条叫“张三”的记录, 则 新注册的用户名不允许入库, 如果不存在则可以入库。 这种判重方式主要用于 数据量较小时。 如果需要入库的数据量非常大, 那么判断查询的次数将会非常 多, 导致数据库开销也非常大。 因此, 针对大数据的判重主要通过使用本地内 存来实现, 例如结合布隆过滤器等等。 但是, 由于布隆过滤器中的比特位是不 允许重置的, 使得布隆过滤器无法伸缩, 采用这种判重方式无法删除数据。 随 着数据越来越多, 占用的内存也会越来越多, 假阳率也会逐渐增大。
发明概述
技术问题
[0005] 有鉴于此, 本申请实施例提供了一种数据处理的方法、 装置和服务器, 以解决 5见有技术中结合布隆过滤器进行大数据的判重时, 由于数据无法删除, 导致占 用内存较多、 假阳率增大的问题。
问题的解决方案 技术解决方案
[0006] 为解决上述技术问题, 本申请实施例采用的技术方案是:
[0007] 第一方面, 提供了一种数据处理的方法, 包括:
[0008] 获取数据库中已有的数据记录;
[0009] 对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所述各个数据桶中 包括多个比特位, 所述多个比特位的初始比特值均为第一数值;
[0010] 确定所述各个数据桶中任一数据记录对应的比特位, 将所述各个数据记录对应 的比特位的比特值置为第二数值;
[0011] 当接收到新数据的入库请求时, 识别用于写入所述新数据的目标数据桶, 以及 所述新数据在所述目标数据桶中对应的比特位, 通过判断所述新数据对应的比 特位的比特值是否为所述第二数值, 确定是否将所述新数据写入所述目标数据 桶中;
[0012] 若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据写入, 则在到达 所述过期时间时删除所述数据桶及所述数据桶中的数据记录, 否则, 延长所述 数据桶的过期时间。
[0013] 第二方面, 提供了一种数据处理的装置, 包括:
[0014] 获取模块, 用于获取数据库中已有的数据记录;
[0015] 分桶模块, 用于对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所 述各个数据桶中包括多个比特位, 所述多个比特位的初始比特值均为第一数值
[0016] 变更模块, 用于确定所述各个数据桶中任一数据记录对应的比特位, 将所述各 个数据记录对应的比特位的比特值置为第二数值;
[0017] 确定模块, 用于当接收到新数据的入库请求时, 识别用于写入所述新数据的目 标数据桶, 以及所述新数据在所述目标数据桶中对应的比特位, 通过判断所述 新数据对应的比特位的比特值是否为所述第二数值, 确定是否将所述新数据写 入所述目标数据桶中;
[0018] 处理模块, 用于若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据 写入, 则在到达所述过期时间时删除所述数据桶及所述数据桶中的数据记录, 否则, 则延长所述数据桶的过期时间。
[0019] 第三方面, 提供了一种服务器, 包括存储器、 处理器以及存储在所述存储器中 并可在所述处理器上运行的计算机可读指令, 所述处理器执行所述计算机可读 指令时实现上述数据处理的方法的如下步骤:
[0020] 获取数据库中已有的数据记录;
[0021] 对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所述各个数据桶中 包括多个比特位, 所述多个比特位的初始比特值均为第一数值;
[0022] 确定所述各个数据桶中任一数据记录对应的比特位, 将所述各个数据记录对应 的比特位的比特值置为第二数值;
[0023] 当接收到新数据的入库请求时, 识别用于写入所述新数据的目标数据桶, 以及 所述新数据在所述目标数据桶中对应的比特位, 通过判断所述新数据对应的比 特位的比特值是否为所述第二数值, 确定是否将所述新数据写入所述目标数据 桶中;
[0024] 若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据写入, 则在到达 所述过期时间时删除所述数据桶及所述数据桶中的数据记录, 否则, 延长所述 数据桶的过期时间。
[0025] 第四方面, 提供了一种计算机非易失性可读存储介质, 所述计算机非易失性可 读存储介质存储有计算机可读指令, 所述计算机可读指令被处理器执行时实现 上述数据处理的方法的如下步骤:
[0026] 获取数据库中已有的数据记录;
[0027] 对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所述各个数据桶中 包括多个比特位, 所述多个比特位的初始比特值均为第一数值;
[0028] 确定所述各个数据桶中任一数据记录对应的比特位, 将所述各个数据记录对应 的比特位的比特值置为第二数值;
[0029] 当接收到新数据的入库请求时, 识别用于写入所述新数据的目标数据桶, 以及 所述新数据在所述目标数据桶中对应的比特位, 通过判断所述新数据对应的比 特位的比特值是否为所述第二数值, 确定是否将所述新数据写入所述目标数据 桶中; [0030] 若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据写入, 则在到达 所述过期时间时删除所述数据桶及所述数据桶中的数据记录, 否则, 延长所述 数据桶的过期时间。
[0031] 本申请实施例提供的数据处理的方法、 装置和服务器的有益效果在于: 通过分 桶将数据的判重范围缩小, 某些桶的数据因为不再活跃而逐渐过期, 达到删除 数据的目的, 而不会随着时间的推移, 导致数据永久的存在于布隆过滤器中, 实现删除布隆过滤器中数据的目的。 由于数据记录会一直增加, 布隆过滤器需 要越来越多的 bit位来进行判重, 采用本实施例的方法, 布隆过滤器的 bitmap会增 加也会减少, 达到伸缩布隆过滤器的目的, 减少了对内存的占用, 解决了数据 判重时假阳率增大的问题。
发明的有益效果
对附图的简要说明
附图说明
[0032] 图 1是本申请一个实施例的一种数据处理的方法的步骤流程示意图;
[0033] 图 2是本申请一个实施例的另一种数据处理的方法的步骤流程示意图;
[0034] 图 3是本申请一个实施例的一种数据处理的装置的示意图;
[0035] 图 4是本申请一个实施例的一种服务器的示意图。
发明实施例
本发明的实施方式
[0036] 为了便于理解, 首先对布隆过滤器作一简单介绍。
[0037] 1、 比喻
[0038] 假如将布隆过滤器比喻为一组电器开关, 可以给每个开关进行编号。 如果有 10 000个开关, 那么就可以从 0开始编号, 一直到 9999。 在布隆过滤器中的开关指 的就是 bit (比特位) 。 开指代 bit位为 1, 关指代 bit位为 0 默认所有的开关都置 为关, 也就是所有的 bit位为 0
[0039] 2、 入库的过程
[0040] 假设有一个字符串 A, 将其进行哈希计算 (可以理解为将字符串映射为一个 100 00以内的数值) , 经过不同的哈希方法可以得到 n个不同的哈希值。 例如, 对于 字符串 A, 将其进行哈希计算后, 可以得到一组哈希值为{5, 300, 891, 2999, 7821}
。 那么, 可以将编号为 5, 300, 891 , 2999 , 7821的 bit位置为 1。
[0041] 3、 判重的过程
[0042] 当对字符串 A进行判重的时候, 可以使用入库时相同的哈希方法得到相同的一 组哈希值{5, 300, 891, 2999, 7821}, 判重的过程就只需要判断这组编号的 bit位是否 都为 1。
[0043] 4、 为什么会出现假阳率
[0044] 使用哈希方法去获取一个字符串的哈希值是可能发生碰撞的。 碰撞就是不同的 字符串经过不同的哈希方法可能获取到的哈希值是相同的。 例如, 字符串 A经过 哈希方法得到的一组哈希值是{5, 300, 891, 2999, 7821}, 字符串 B经过哈希方法得 到的一组哈希值是{300, 2999, 5, 7821, 891}, 虽然他们的顺序是不一样的, 但是他 们其实在布隆过滤器中的存储是一致的。 当对字符串 B来进行判重的时候, 实际 上数据库中并不存在这个字符串, 但是布隆过滤器判断 (所谓编号为哈希值的 bi t位都置为 1了) 是已存在字符串 B, 这就是所谓的假阳, 假的存在。 但是, 这个 碰撞完全相同是有一定的概率的, 所以称为假阳率。 当布隆过滤器中的大多数 bi t位都被置为 1后, 假阳率就会越来越高。
[0045] 5、 为什么无法删除
[0046] 通过上面的描述, 有一种观点可能会认为, 如果要删除布隆过滤器中的字符串 A, 那么将{5, 300, 891, 2999, 7821}这 5个编号的 bit位再置为 0就可以了。 但, 这是 不允许的。
[0047] 当另外一个字符串 C得到的哈希值为{ 5,300, 1000,4521,123}, 因为哈希的碰撞, 这组哈希值和字符串 A得到的有部分相同。 那么当删除了字符串 A, 也就是将其 所有的哈希值对应的 bit位都置为 0了之后, 那么字符串 C在判重的时候就会发现 编号为 5和 300的 bit位是 0, 此时字符串 C就会被误判。 所以布隆过滤器中的 bit位 是不允许重置的。 也就是不能删除数据了。
[0048] 因此, 基于布隆过滤器的上述特性, 提出了本实施例的一种数据处理的方法的 核心构思在于, 采用 redis这一个基于内存的缓存工具, 由于 redis有一个 bitmap结 构正好可以当成布隆过滤器来使用, 所以, 通过构建很多个小的 bitmap结构的布 隆过滤器, 并设置各个 bitmap结构的布隆过滤器的过期时间为 30天, 当某个 bitm ap结构的布隆过滤器超过 30天不再写入数据时, 就会自动被 redis过期删除, 通过 这种方式来节省内存空间, 达到数据伸缩的目的。
[0049] 参照图 1, 示出了本申请一个实施例的一种数据处理的方法的步骤流程示意图 , 具体可以包括如下步骤:
[0050] S101、 获取数据库中已有的数据记录;
[0051] 需要说明的是, 本方法可以应用于对大数据的判重处理。
[0052] 本实施例的数据库中已有的数据记录可以是指存储于服务器中的各种类型的数 据记录。 例如, 用户 ID等等。 当然, 数据记录也可以是其他类型的, 如邮箱账 号、 URL等等, 本实施例对数据记录的类型不作限定。
[0053] 在按照本方法对数据进行判重前, 需要首先对数据库中已有的数据记录进行处 理。 因此, 可以获取数据库中已有的数据记录。
[0054] S102、 对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所述各个数 据桶中包括多个比特位, 所述多个比特位的初始比特值均为第一数值;
[0055] 在获取到数据库中已有的数据记录后, 可以首先将这些数据记录划分至多个数 据桶中。
[0056] 在本申请实施例中, 每个数据桶都是一个基于 redis超时过期特性来设计的 bitma p结构的布隆过滤器。
[0057] Redis是一个基于内存的缓存工具, 具有 bitmap结构。 Bitmap的基本原理就是用 一个 bit (比特位) 来标记某个元素对应的 value, 而 key即是该元素, bitmap结构 可以当成布隆过滤器来使用。 由于采用一个 bit来存储一个数据, 因此可以大大 的节省存储空间。
[0058] 在本申请实施例中, 可以构建多个 bitmap结构的布隆过滤器, 每一个布隆过滤 器便是后续用于存储数据记录的一个数据桶。 因此, 各个数据桶中都包括有多 个比特位, 上述多个比特位的初始比特值均可以为第一数值。 例如, 在初始时 , 每个比特位的值均为 0。 与此同时, 为了便于区分各个数据桶, 还可以为每个 数据桶分别设置相应的编号。 例如, 0-9999等等。 [0059] 因此, 可以按照一定的规则, 将获取到的数据记录相对均匀地分配到各个数据 桶中。
[0060] 作为本申请的一种示例, 可以首先采用预设随机函数分别将各个数据记录生成 整数值, 然后计算各个数据记录的整数值除以上述数据桶的数量后得到的余数 , 由于各个数据桶分别具有相应的桶编号, 因此可以分别将各个数据记录置入 与计算得到的余数相同的桶编号对应的数据桶中, 从而实现对数据记录的相对 均匀的分配。
[0061] 在具体实现中, crc32函数可以将字符串经过一定的算法过程生成一个长整型的 数值, 因此可以使用 crc32随机函数对已有的数据记录进行分桶。
[0062] 以已有的数据记录为用户 ID为例。 若有 20亿用户 ID, 可以使用 crc32随机函数 将上述用户 ID分成 200000个数据桶, 每个数据桶中包括 10000个用户 ID。
[0063] 即, 首先使用 crc32随机函数将每个用户 ID生成一个整型数值, 然后使用该数 值除以数据桶的数量, 即除以 200000, 然后以得到的余数作为数据桶的编号, 将该用户 ID置于对应的数据桶中。
[0064] 由于 crc32随机函数对不同字符串生成的整型数值具有随机性, 使用该函数分桶 会使数据记录相对均匀地分布在每个数据桶中。
[0065] 当然, 上述分桶方式仅为本实施例的一种示例, 本领域技术人员可以根据实际 需要采用其他方式对获取到的数据记录进行分桶。 例如, 可以按照全部数据记 录的数量, 随机地将各个数据记录相对平均地分布在每个数据桶中, 本实施例 对此不作限定。
[0066] 各个数据桶的过期时间即是 bitmap的过期时间, 也就是 redis中的 TTL (Time To Live, 生存时间值) 过期时间。 在设置有 TTL时间后, 若用户没有再重新设置该 TTL时间的时候, 它就开始倒计时。 当倒计时为 0时, redis中这条记录就会被 redi s自动删除, 不再占用内存。
[0067] 在本申请实施例中, 每个数据桶的过期时间可以根据业务需求来具体确定。 例 如, 可以设置各个数据桶的过期时间均为 30天。
[0068] S103、 确定所述各个数据桶中任一数据记录对应的比特位, 将所述各个数据记 录对应的比特位的比特值置为第二数值; [0069] 在本申请实施例中, 可以为各个数据桶中的比特位设置相应的编号。 例如, 各 个比特位可以从 0开始编号, 一直到 9999 , 使得该数据桶中的每个数据记录均与 一个或多个比特位相对应。
[0070] 在具体实现中, 可以采用预设算法计算得到任一数据记录的哈希值, 然后将比 特位编号与该哈希值相同的比特位的比特值置为第二数值。 例如, 将比特位的 比特值由初始值 0变更为 1。
[0071] 哈希计算可以理解为将某个字符串映射为一个 10000以内的数值, 采用不同的 哈希方法可以得到 n个不同的哈希值。 因此, 一个数据记录所对应的哈希值也可 以包括多个。
[0072] 当采用多种哈希方法计算得到一个数据记录的多个哈希值后, 可以将比特位编 号与上述哈希值相同的多个比特位的比特值均置为 1。
[0073] S104、 当接收到新数据的入库请求时, 识别用于写入所述新数据的目标数据桶
, 以及所述新数据在所述目标数据桶中对应的比特位, 通过判断所述新数据对 应的比特位的比特值是否为所述第二数值, 确定是否将所述新数据写入所述目 标数据桶中;
[0074] 在按照前述步骤完成对数据库中已有的数据记录的处理后, 便可以基于各个数 据桶, 对新接收到的数据进行判重。
[0075] 在本申请实施例中, 可以首先识别用于写入新数据的目标数据桶, 以及该新数 据在目标数据桶中对应的比特位, 通过判断新接收到的数据在待写入的目标数 据桶中所对应的比特位的比特值是否为第二数值, 来确定该数据是否是数据库 中已有的数据。
[0076] 在具体实现中, 可以按照对已有的数据记录进行分桶时的操作方式, 确定新数 据的目标数据桶是哪一个, 即确定该新数据应当被写入哪个数据库中。
[0077] 例如, 可以使用 crc32函数将新数据转换为一个整型数值, 然后使用该数值除以 数据桶的数量, 以得到的余数作为目标数据桶的编号。
[0078] 在识别出目标数据桶后, 可以继续判断在该数据桶中, 与新数据对应的各个比 特位的比特值是否为第二数值。
[0079] 作为本申请的一种示例, 为了提高数据判重的准确性, 在对数据库中已有的数 据记录进行分桶时可以采用多种哈希方法计算得到多个哈希值, 并将多个哈希 值对应的比特位的比特值均置为第二数值。 因此, 在对接收到的新数据进行判 重时, 也应当采用同样的多种哈希方法计算得到多个哈希值, 通过确定各个哈 希值对应的比特位的比特值是否均为第二数值来完成判重的过程。
[0080] 如果对新数据进行哈希计算后得到的多个哈希值所对应的比特位的比特值均为 第二数值, 则可以判定新数据是数据库中已有的数据记录。 此时, 可以拒绝新 数据的入库请求。
[0081] 若上述多个哈希值所对应的比特位的比特值中任意一个比特值不是第二数值, 则可以确认该新数据并非数据库中已有的数据记录, 从而可以将新数据写入当 前的数据桶中。
[0082] S105、 若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据写入, 则 在到达所述过期时间时删除所述数据桶及所述数据桶中的数据记录, 否则, 则 延长所述数据桶的过期时间。
[0083] Bitmap结构的布隆过滤器的过期时间在设置后便会开始倒计时, 当倒计时为 0 时, 该条记录就会被 redis自动删除。 由于本实施例中的数据桶即是 bitmap结构的 布隆过滤器, 因此, 在数据桶的过期时间到达时, 该数据桶及在其中存储的数 据记录也会一并被删除。
[0084] 因此, 在本申请实施例中, 可以通过是否更改数据桶的过期时间来决定是否保 留该数据桶及桶中的数据记录。
[0085] 在具体实现中, 在设置数据桶的过期时间后, 一直到该过期时间到达之前, 如 果该数据桶中未有新数据写入, 则在过期时间到达时, 可以直接将该数据桶及 其中的数据记录删除, 减少对内存的占用。
[0086] 而在此过程中, 若有新数据写入数据桶中, 则可以延长该数据桶的过期时间。
[0087] 需要说明的是, 延长数据桶的过期时间可以是在新数据写入数据桶时进行, 延 长的过期时间也可以是与原先设置的过期时间的时长相同。 例如, 若某个数据 桶的过期时间为 30天, 在倒计时开始后第 3天该数据桶中有新数据写入, 则可以 在此时, 将该数据桶的过期时间延长为 30天。 即, 在新数据写入数据桶当时, 重新设置该数据桶的过期时间。 [0088] 当然, 以上介绍的延长过期时间的方式仅为一种示例, 本领域技术人员开采用 其他方式延长数据桶的过期时间, 本实施例对此不作限定。
[0089] 在本申请实施例中, 通过分桶将数据的判重范围缩小, 某些桶的数据因为不再 活跃而逐渐过期, 达到删除数据的目的, 而不会随着时间的推移, 导致数据永 久的存在于布隆过滤器中, 实现删除布隆过滤器中数据的目的。 由于数据记录 会一直增加, 布隆过滤器需要越来越多的 bit位来进行判重, 采用本实施例的方 法, 布隆过滤器的 bitmap会增加也会减少, 达到伸缩布隆过滤器的目的, 减少了 对内存的占用, 解决了数据判重时假阳率增大的问题。
[0090] 参照图 2, 示出了本申请一个实施例的另一种数据处理的方法的步骤流程示意 图, 具体可以包括如下步骤:
[0091] S201、 获取数据库中已有的数据记录;
[0092] 需要说明的是, 本方法可以应用于对大数据的判重处理。
[0093] 本实施例的数据库中已有的数据记录可以是指存储于服务器中的各种类型的数 据记录。 例如, 用户 ID、 邮箱账号、 URL等等, 本实施例对数据记录的类型不 作限定。
[0094] 为了便于理解, 本实施以数据库中的数据记录为用户 ID为例进行后续介绍。
[0095] S202、 对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所述各个数 据桶中包括多个比特位, 所述多个比特位的初始比特值均为第一数值;
[0096] 在获取到数据库中已有的数据记录后, 可以将这些数据记录划分至多个数据桶 中。 本实施例的每个数据桶都是一个基于 redis超时过期特性来设计的 bitmap结构 的布隆过滤器。
[0097] 因此, 可以构建多个 bitmap结构的布隆过滤器作为后续用于存储数据记录的数 据桶, 并为每个数据桶设置相同的桶编号。 在每个数据桶中都包括有多个比特 位, 可以理解为一组带编号的电器开关, 然后可以给每个开关编号, 得到每个 比特位的比特位编号。 例如, 若有一万个开关, 那么就可以从 0开始编号, 一直 到 9999。 在布隆过滤器中, 开关的开可以指代比特位的比特值为 1, 关指代比特 位的比特值为 0。
[0098] 在本申请实施例中, 可以使用 crc32随机函数对已有的数据记录进行分桶。 例如 , 可以首先使用 crc32随机函数将每个用户 ID生成一个整型数值, 然后使用该数 值除以数据桶的数量, 然后以得到的余数作为数据桶的编号, 将该用户 ID置于 对应的数据桶中。
[0099] 由于 crc32随机函数对不同字符串生成的整型数值具有随机性, 使用该函数分桶 会使数据记录相对均匀地分布在每个数据桶中。
[0100] 在本申请实施例中, 每个数据桶的过期时间可以根据业务需求来具体确定。 例 如, 可以设置各个数据桶的过期时间均为 30天。
[0101] S203、 采用预设算法计算得到所述任一数据记录的哈希值;
[0102] 在本申请实施例中, 对于已经分桶后的数据记录, 可以首先对其进行哈希计算 , 然后根据哈希计算的结果, 设置各个比特位的比特值。
[0103] 哈希计算可以理解为将某个字符串映射为一个 10000以内的数值, 采用不同的 哈希方法可以得到 n个不同的哈希值。 因此, 一个数据记录所对应的哈希值也可 以包括多个。
[0104] 假设存在一个用户 ID, 在对其进行哈希计算时, 采用不同的哈希方法可以得到 n个不同的哈希值。 例如, 可以得到一组哈希值为{5, 300, 891, 2999, 7821}。
[0105] S204、 将比特位编号与多个哈希值相同的多个比特位的比特值均置为第二数值
[0106] 在本申请实施例中, 第一数值与第二数值分别表示各个比特位所指代的开关的 “关”和“开”两种状态。 因此, 在计算得到某个用户 ID的哈希值后, 可以将该哈希 值所对应的比特位的比特值由初始状态的 0变更为 1.
[0107] 例如, 针对上述一组哈希值{5, 300, 891, 2999, 7821}, 可以将当前数据桶中比特 位编号为 5, 300, 891 , 2999 , 7821的比特位置为 1。
[0108] 需要说明的是, 根据布隆过滤器的特点, 为保证假阳率小于 0.00001, 每个数据 桶可以使用 239627个 bit来进行判重, 每个数据桶可以对 10000个用户 ID进行判重
[0109] S205、 当接收到新数据的入库请求时, 识别用于写入所述新数据的目标数据桶
[0110] 在按照前述步骤完成对数据库中已有的数据记录的处理后, 便可以基于各个数 据桶, 对新接收到的数据进行判重。
[0111] 在本申请实施例中, 目标数据桶即是接收到的新数据在经过判重后应该被写入 的数据桶。 可以按照对已有的数据记录进行分桶时的操作方式, 确定新数据待 写入的目标数据桶是哪一个。
[0112] 例如, 可以使用 crc32函数将新数据转换为一个整型数值, 然后使用该数值除以 数据桶的数量, 以得到的余数作为目标数据桶的编号。
[0113] S206、 采用所述预设算法计算得到所述新数据的多个目标哈希值;
[0114] 在对接收到的新数据进行判重时, 应当采用与分桶时相同的哈希方法计算得到 多个哈希值, 然后通过比较上述多个哈希值与目标数据桶中对应的比特位的比 特值, 确认该新数据是否是目标数据桶中已有的数据记录。
[0115] S207、 判断所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个比 特位的比特值是否均为第二数值;
[0116] 在本申请实施例中, 对新数据进行判重可以通过确定新数据的各个哈希值对应 的比特位的比特值是否均为第二数值来实现。
[0117] 如果对新数据进行哈希计算后得到的多个哈希值所对应的比特位的比特值均为 第二数值, 则可以执行步骤 S208 , 识别该新数据是目标数据桶中已有的数据记 录。 此时, 可以拒绝该新数据的入库请求。
[0118] 若上述多个哈希值所对应的比特位的比特值中任意一个比特值不是第二数值, 则可以确认该新数据并非数据库中已有的数据记录, 从而可以执行步骤 S210, 将新数据写入当前的目标数据桶中。
[0119] S208、 识别所述新数据为所述目标数据桶中已有的数据记录;
[0120] S209、 若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据写入, 则 在到达所述过期时间时删除所述数据桶及所述数据桶中的数据记录;
[0121] 在本申请实施例中, 可以通过是否更改数据桶的过期时间来决定是否保留该数 据桶及桶中的数据记录。
[0122] 在具体实现中, 在设置数据桶的过期时间后, 一直到该过期时间到达之前, 如 果该数据桶中未有新数据写入, 则在过期时间到达时, 可以直接将该数据桶及 其中的数据记录删除, 减少对内存的占用。 [0123] S210、 将所述新数据写入所述目标数据桶中;
[0124] S211、 延长所述数据桶的过期时间;
[0125] 若在设置数据桶的过期时间后, 到该过期时间到达的过程中, 有新数据写入数 据桶中, 则可以延长该数据桶的过期时间。 例如, 若某个数据桶的过期时间为 3 0天, 在倒计时开始后第 3天该数据桶中有新数据写入, 则可以在此时, 将该数 据桶的过期时间延长为 30天。
[0126] S212、 当任一数据桶中的数据记录超过预设数量时, 再次对所述数据桶中的数 据记录进行分桶, 并分别设置分桶后的各个数据桶的过期时间。
[0127] 对于有新数据写入的数据桶, 随着数据的不断写入, 每个数据桶中包含的用户 ID的数量也会越来越多。 这种情况下该数据桶的假阳率也会越来越高, 也就是 出现大部分比特位被写满的情况。
[0128] 此时, 可以对该数据桶中的数据记录重新进行分桶, 其分桶过程如步骤 S202所 述。 经过对 bitmap的删除和重建, 可以重新写入活跃的数据, 僵尸用户也就被排 除出去了。
[0129] 在本申请实施例中, 通过设置 bitmap (布隆过滤器) 的过期时间, 可以将某些 数据记录删除。 当某个 bitmap过期被删除, 可以视作在 30天范围里, 这个 bitmap 里的数据没有再被写入和更新, 这时就会被删除, 并且释放空间。 当有新数据 写入到这个 bitmap时, 系统再创建这个 bitmap。 Bitmap (布隆过滤器) 的过期时 间设置具有非常重要的意义:
[0130] 第一, 一些用户已经成为僵尸用户, 过期后, bitmap被删除, 那么这些僵尸用 户就不再存在于 bitmap中, 可以达到删除用户的目的。
[0131] 第二, bitmap过期可以节省很大的内存空间, 相当于布隆过滤器被清空了。 虽 然在被清空的这一小段时间内, 有些数据库中已存在的活跃用户数据需要重新 入库。 但这个空档期并不是集中的, 也就是说并不是所有 bitmap在同一时间被清 空。
[0132] 第三, bitmap不再写入或者更新, 也有一种情况就是假阳率非常高的情况, 也 就是大部分 bit位被写满的情况下。 这种情况下, 删除并重建 bitmap将会重新写入 活跃的数据, 僵尸用户就被排除出去了。 [0133] 需要说明的是, 上述实施例中各步骤序号的大小并不意味着执行顺序的先后, 各过程的执行顺序应以其功能和内在逻辑确定, 而不应对本申请实施例的实施 过程构成任何限定。
[0134] 参照图 3 , 示出了本申请一个实施例的一种数据处理的装置的示意图, 具体可 以包括如下模块:
[0135] 获取模块 301, 用于获取数据库中已有的数据记录;
[0136] 分桶模块 302, 用于对所述数据记录进行分桶, 并设置各个数据桶的过期时间 , 所述各个数据桶中包括多个比特位, 所述多个比特位的初始比特值均为第一 数值;
[0137] 变更模块 303 , 用于确定所述各个数据桶中任一数据记录对应的比特位, 将所 述各个数据记录对应的比特位的比特值置为第二数值;
[0138] 确定模块 304, 用于当接收到新数据的入库请求时, 识别用于写入所述新数据 的目标数据桶, 以及所述新数据在所述目标数据桶中对应的比特位, 通过判断 所述新数据对应的比特位的比特值是否为所述第二数值, 确定是否将所述新数 据写入所述目标数据桶中;
[0139] 处理模块 305 , 用于若在到达所述数据桶过期时间之前, 所述数据桶中未有新 数据写入, 则在到达所述过期时间时删除所述数据桶及所述数据桶中的数据记 录, 否则, 则延长所述数据桶的过期时间。
[0140] 在本申请实施例中, 所述分桶模块 302具体可以包括如下子模块:
[0141] 整数值生成子模块, 用于采用预设随机函数分别将各个数据记录生成整数值;
[0142] 余数计算子模块, 用于计算所述各个数据记录的整数值除以所述数据桶的数量 后得到的余数, 所述各个数据桶分别具有相应的桶编号;
[0143] 数据记录分桶子模块, 用于分别将所述各个数据记录置入与所述余数相同的桶 编号对应的数据桶中。
[0144] 在本申请实施例中, 所述多个比特位分别具有相应的比特位编号, 所述变更模 块 303具体可以包括如下子模块:
[0145] 哈希值计算子模块, 用于采用预设算法计算得到所述任一数据记录的哈希值;
[0146] 比特值变更子模块, 用于将比特位编号与所述哈希值相同的比特位的比特值置 为第二数值。
[0147] 在本申请实施例中, 计算得到的所述任一数据记录的哈希值包括多个, 所述比 特值变更子模块具体可以包括如下单元:
[0148] 比特值变更单元, 用于将比特位编号与多个哈希值相同的多个比特位的比特值 均置为第二数值。
[0149] 在本申请实施例中, 所述确定模块 304具体可以包括如下子模块:
[0150] 整数值生成子模块, 用于在接收到新数据的入库请求时, 采用预设随机函数将 所述新数据生成整数值;
[0151] 余数计算子模块, 用于计算所述整数值除以所述数据桶的数量后得到的余数, 所述各个数据桶分别具有相应的桶编号;
[0152] 目标数据桶识别子模块, 用于识别所述桶编号与所述余数相同的数据桶为目标 数据桶。
[0153] 在本申请实施例中, 所述确定模块 304还可以包括如下子模块:
[0154] 目标哈希值计算子模块, 用于采用预设算法计算得到所述新数据的多个目标哈 希值;
[0155] 比特值判断子模块, 用于判断所述目标数据桶中比特位编号与所述多个目标哈 希值相同的多个比特位的比特值是否均为第二数值;
[0156] 数据记录识别子模块, 用于若所述目标数据桶中比特位编号与所述多个目标哈 希值相同的多个比特位的比特值均为所述第二数值, 则识别所述新数据为所述 目标数据桶中已有的数据记录;
[0157] 数据记录写入子模块, 用于若所述目标数据桶中比特位编号与所述多个目标哈 希值相同的多个比特位的任一比特值不为所述第二数值, 则将所述新数据写入 所述目标数据桶中。
[0158] 在本申请实施例中, 所述分桶模块 302还用于在任一数据桶中的数据记录超过 预设数量时, 再次对数据桶中的数据记录进行分桶, 并分别设置分桶后的各个 数据桶的过期时间。
[0159] 对于装置实施例而言, 由于其与方法实施例基本相似, 所以描述得比较简单, 相关之处参见方法实施例部分的说明即可。 [0160] 参照图 4, 示出了本申请一个实施例的一种服务器的示意图。 如图 4所示, 本实 施例的服务器 400包括: 处理器 410、 存储器 420以及存储在所述存储器 420中并 可在所述处理器 410上运行的计算机可读指令 421。 所述处理器 410执行所述计算 机可读指令 421时实现上述数据处理的方法各个实施例中的步骤, 例如图 1所示 的步骤 S101至 S105。 或者, 所述处理器 410执行所述计算机可读指令 421时实现 上述各装置实施例中各模块 /单元的功能, 例如图 3所示模块 301至 305的功能。
[0161] 示例性的, 所述计算机可读指令 421可以被分割成一个或多个模块 /单元, 所述 一个或者多个模块 /单元被存储在所述存储器 420中, 并由所述处理器 410执行, 以完成本申请。 所述一个或多个模块 /单元可以是能够完成特定功能的一系列计 算机可读指令段, 该指令段可以用于描述所述计算机可读指令 421在所述服务器 400中的执行过程。 例如, 所述计算机可读指令 421可以被分割成获取模块、 分 桶模块、 变更模块、 确定模块和处理模块, 各模块具体功能如下:
[0162] 获取模块, 用于获取数据库中已有的数据记录;
[0163] 分桶模块, 用于对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所 述各个数据桶中包括多个比特位, 所述多个比特位的初始比特值均为第一数值
[0164] 变更模块, 用于确定所述各个数据桶中任一数据记录对应的比特位, 将所述各 个数据记录对应的比特位的比特值置为第二数值;
[0165] 确定模块, 用于当接收到新数据的入库请求时, 识别用于写入所述新数据的目 标数据桶, 以及所述新数据在所述目标数据桶中对应的比特位, 通过判断所述 新数据对应的比特位的比特值是否为所述第二数值, 确定是否将所述新数据写 入所述目标数据桶中;
[0166] 处理模块, 用于若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据 写入, 则在到达所述过期时间时删除所述数据桶及所述数据桶中的数据记录, 否则, 则延长所述数据桶的过期时间。
[0167] 所述服务器 400可以是桌上型计算机、 笔记本、 掌上电脑及云端服务器等计算 设备。 所述服务器 400可包括, 但不仅限于, 处理器 410、 存储器 420。 本领域技 术人员可以理解, 图 4仅仅是服务器 400的一种示例, 并不构成对服务器 400的限 定, 可以包括比图示更多或更少的部件, 或者组合某些部件, 或者不同的部件 , 例如所述服务器 400还可以包括输入输出设备、 网络接入设备、 总线等。
[0168] 所述处理器 410可以是中央处理单元 (Central Processing Unit, CPU) , 还可以 是其他通用处理器、 数字信号处理器 (Digital Signal Processor, DSP) 、 专用集 成电路 (Application Specific Integrated
Circuit, ASIC) 、 现成可编程门阵列 (Field- Programmable Gate Array, FPGA) 或者其他可编程逻辑器件、 分立门或者晶体管逻辑器件、 分立硬件组件等。 通 用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
[0169] 所述存储器 420可以是所述服务器 400的内部存储单元, 例如服务器 400的硬盘 或内存。 所述存储器 420也可以是所述服务器 400的外部存储设备, 例如所述服 务器 400上配备的插接式硬盘, 智能存储卡 (Smart Media Card, SMC) , 安全数 字 (Secure Digital, SD) 卡, 闪存卡 (Flash
Card) 等等。 进一步地, 所述存储器 420还可以既包括所述服务器 400的内部存储 单元也包括外部存储设备。 所述存储器 420用于存储所述计算机可读指令 421以 及所述服务器 400所需的其他指令和数据。 所述存储器 420还可以用于暂时地存 储已经输出或者将要输出的数据。
[0170] 本领域普通技术人员可以理解, 实现上述实施例方法中的全部或部分流程, 是 可以通过计算机可读指令来指令相关的硬件来完成, 所述的计算机可读指令可 存储于一非易失性计算机可读取存储介质中, 该计算机可读指令在执行时, 可 包括如上述各方法的实施例的流程。 其中, 本申请所提供的各实施例中所使用 的对存储器、 存储、 数据库或其它介质的任何引用, 均可包括非易失性和 /或易 失性存储器。 非易失性存储器可包括只读存储器 (ROM) 、 可编程 ROM (PRO M) 、 电可编程 ROM (EPROM) 、 电可擦除可编程 ROM (EEPROM) 或闪存。 易失性存储器可包括随机存取存储器 (RAM) 或者外部高速缓冲存储器。 作为 说明而非局限, RAM以多种形式可得, 诸如静态 RAM (SRAM) 、 动态 RAM ( DRAM) 、 同步 DRAM (SDRAM) 、 双数据率 SDRAM (DDRSDRAM) 、 增强 型 SDRAM (ESDRAM) 、 同步链路 (Synchlink) DRAM (SLDRAM) 、 存储 器总线 (Rambus) 直接 RAM (RDRAM) 、 直接存储器总线动态 RAM (DRDR AM) 、 以及存储器总线动态 RAM (RDRAM) 等。
[0171] 以上所述实施例仅用以说明本申请的技术方案, 而非对其限制; 尽管参照前述 实施例对本申请进行了详细的说明, 本领域的普通技术人员应当理解: 其依然 可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分技术特征进 行等同替换; 而这些修改或者替换, 并不使相应技术方案的本质脱离本申请各 实施例技术方案的精神和范围, 均应包含在本申请的保护范围之内。

Claims

权利要求书
[权利要求 1] 一种数据处理的方法, 其特征在于, 包括:
获取数据库中已有的数据记录;
对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所述各个 数据桶中包括多个比特位, 所述多个比特位的初始比特值均为第一数 值;
确定所述各个数据桶中任一数据记录对应的比特位, 将所述各个数据 记录对应的比特位的比特值置为第二数值;
当接收到新数据的入库请求时, 识别用于写入所述新数据的目标数据 桶, 以及所述新数据在所述目标数据桶中对应的比特位, 通过判断所 述新数据对应的比特位的比特值是否为所述第二数值, 确定是否将所 述新数据写入所述目标数据桶中;
若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据写入, 则在到达所述过期时间时删除所述数据桶及所述数据桶中的数据记录 , 否则, 则延长所述数据桶的过期时间。
[权利要求 2] 根据权利要求 1所述的方法, 其特征在于, 所述对所述数据记录进行 分桶的步骤包括:
采用预设随机函数分别将各个数据记录生成整数值;
计算所述各个数据记录的整数值除以所述数据桶的数量后得到的余数 , 所述各个数据桶分别具有相应的桶编号;
分别将所述各个数据记录置入与所述余数相同的桶编号对应的数据桶 中。
[权利要求 3] 根据权利要求 1所述的方法, 其特征在于, 所述多个比特位分别具有 相应的比特位编号, 所述将所述各个数据记录对应的比特位的比特值 置为第二数值的步骤包括:
采用预设算法计算得到所述任一数据记录的哈希值;
将比特位编号与所述哈希值相同的比特位的比特值置为第二数值。
[权利要求 4] 根据权利要求 3所述的方法, 其特征在于, 计算得到的所述任一数据 记录的哈希值包括多个, 所述将比特位编号与所述哈希值相同的比特 位的比特值置为第二数值的步骤包括:
将比特位编号与多个哈希值相同的多个比特位的比特值均置为第二数 值。
[权利要求 5] 根据权利要求 1所述的方法, 其特征在于, 所述当接收到新数据的入 库请求时, 识别用于写入所述新数据的目标数据桶的步骤包括: 当接收到新数据的入库请求时, 采用预设随机函数将所述新数据生成 整数值;
计算所述整数值除以所述数据桶的数量后得到的余数, 所述各个数据 桶分别具有相应的桶编号;
识别所述桶编号与所述余数相同的数据桶为目标数据桶。
[权利要求 6] 根据权利要求 4所述的方法, 其特征在于, 所述通过判断所述新数据 对应的比特位的比特值是否为所述第二数值, 确定是否将所述新数据 写入所述目标数据桶中的步骤包括:
采用所述预设算法计算得到所述新数据的多个目标哈希值; 判断所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个 比特位的比特值是否均为第二数值;
若所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个比 特位的比特值均为所述第二数值, 则识别所述新数据为所述目标数据 桶中已有的数据记录;
若所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个比 特位的任一比特值不为所述第二数值, 则将所述新数据写入所述目标 数据桶中。
[权利要求 7] 根据权利要求 1所述的方法, 其特征在于, 还包括:
当任一数据桶中的数据记录超过预设数量时, 再次对所述数据桶中的 数据记录进行分桶, 并分别设置分桶后的各个数据桶的过期时间。
[权利要求 8] 一种数据处理的装置, 其特征在于, 包括:
获取模块, 用于获取数据库中已有的数据记录; 分桶模块, 用于对所述数据记录进行分桶, 并设置各个数据桶的过期 时间, 所述各个数据桶中包括多个比特位, 所述多个比特位的初始比 特值均为第一数值;
变更模块, 用于确定所述各个数据桶中任一数据记录对应的比特位, 将所述各个数据记录对应的比特位的比特值置为第二数值; 确定模块, 用于当接收到新数据的入库请求时, 识别用于写入所述新 数据的目标数据桶, 以及所述新数据在所述目标数据桶中对应的比特 位, 通过判断所述新数据对应的比特位的比特值是否为所述第二数值 , 确定是否将所述新数据写入所述目标数据桶中; 处理模块, 用于若在到达所述数据桶过期时间之前, 所述数据桶中未 有新数据写入, 则在到达所述过期时间时删除所述数据桶及所述数据 桶中的数据记录, 否则, 则延长所述数据桶的过期时间。
[权利要求 9] 根据权利要求 8所述的装置, 其特征在于, 所述多个比特位分别具有 相应的比特位编号, 所述变更模块包括:
哈希值计算子模块, 用于采用预设算法计算得到所述任一数据记录的 哈希值;
比特值变更子模块, 用于将比特位编号与所述哈希值相同的比特位的 比特值置为第二数值。
[权利要求 10] 根据权利要求 9所述的装置, 其特征在于, 计算得到的所述任一数据 记录的哈希值包括多个, 所述比特值变更子模块包括:
比特值变更单元, 用于将比特位编号与多个哈希值相同的多个比特位 的比特值均置为第二数值。
[权利要求 11] 根据权利要求 10所述的装置, 其特征在于, 所述确定模块包括: 目标哈希值计算子模块, 用于采用所述预设算法计算得到所述新数据 的多个目标哈希值;
比特值判断子模块, 用于判断所述目标数据桶中比特位编号与所述多 个目标哈希值相同的多个比特位的比特值是否均为第二数值; 数据记录识别子模块, 用于若所述目标数据桶中比特位编号与所述多 个目标哈希值相同的多个比特位的比特值均为所述第二数值, 则识别 所述新数据为所述目标数据桶中已有的数据记录; 数据记录写入子模块, 用于若所述目标数据桶中比特位编号与所述多 个目标哈希值相同的多个比特位的任一比特值不为所述第二数值, 则 将所述新数据写入所述目标数据桶中。
[权利要求 12] 一种服务器, 包括存储器、 处理器以及存储在所述存储器中并可在所 述处理器上运行的计算机可读指令, 其特征在于, 所述处理器执行所 述计算机可读指令时实现如下步骤:
获取数据库中已有的数据记录;
对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所述各个 数据桶中包括多个比特位, 所述多个比特位的初始比特值均为第一数 值;
确定所述各个数据桶中任一数据记录对应的比特位, 将所述各个数据 记录对应的比特位的比特值置为第二数值;
当接收到新数据的入库请求时, 识别用于写入所述新数据的目标数据 桶, 以及所述新数据在所述目标数据桶中对应的比特位, 通过判断所 述新数据对应的比特位的比特值是否为所述第二数值, 确定是否将所 述新数据写入所述目标数据桶中;
若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据写入, 则在到达所述过期时间时删除所述数据桶及所述数据桶中的数据记录 , 否则, 则延长所述数据桶的过期时间。
[权利要求 13] 根据权利要求 12所述的服务器, 其特征在于, 所述多个比特位分别具 有相应的比特位编号, 所述处理器执行所述计算机可读指令时还实现 如下步骤:
采用预设算法计算得到所述任一数据记录的哈希值;
将比特位编号与所述哈希值相同的比特位的比特值置为第二数值。
[权利要求 14] 根据权利要求 13所述的服务器, 其特征在于, 计算得到的所述任一数 据记录的哈希值包括多个, 所述处理器执行所述计算机可读指令时还 实现如下步骤:
将比特位编号与多个哈希值相同的多个比特位的比特值均置为第二数 值。
[权利要求 15] 根据权利要求 12所述的服务器, 其特征在于, 所述处理器执行所述计 算机可读指令时还实现如下步骤:
当接收到新数据的入库请求时, 采用预设随机函数将所述新数据生成 整数值;
计算所述整数值除以所述数据桶的数量后得到的余数, 所述各个数据 桶分别具有相应的桶编号;
识别所述桶编号与所述余数相同的数据桶为目标数据桶。
[权利要求 16] 根据权利要求 14所述的服务器, 其特征在于, 所述处理器执行所述计 算机可读指令时还实现如下步骤:
采用所述预设算法计算得到所述新数据的多个目标哈希值; 判断所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个 比特位的比特值是否均为第二数值;
若所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个比 特位的比特值均为所述第二数值, 则识别所述新数据为所述目标数据 桶中已有的数据记录;
若所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个比 特位的任一比特值不为所述第二数值, 则将所述新数据写入所述目标 数据桶中。
[权利要求 17] 一种计算机非易失性可读存储介质, 所述计算机非易失性可读存储介 质存储有计算机可读指令, 其特征在于, 所述计算机可读指令被处理 器执行时实现如下步骤:
获取数据库中已有的数据记录;
对所述数据记录进行分桶, 并设置各个数据桶的过期时间, 所述各个 数据桶中包括多个比特位, 所述多个比特位的初始比特值均为第一数 值; 确定所述各个数据桶中任一数据记录对应的比特位, 将所述各个数据 记录对应的比特位的比特值置为第二数值;
当接收到新数据的入库请求时, 识别用于写入所述新数据的目标数据 桶, 以及所述新数据在所述目标数据桶中对应的比特位, 通过判断所 述新数据对应的比特位的比特值是否为所述第二数值, 确定是否将所 述新数据写入所述目标数据桶中;
若在到达所述数据桶过期时间之前, 所述数据桶中未有新数据写入, 则在到达所述过期时间时删除所述数据桶及所述数据桶中的数据记录 , 否则, 则延长所述数据桶的过期时间。
[权利要求 18] 根据权利要求 17所述的计算机非易失性可读存储介质, 其特征在于, 所述多个比特位分别具有相应的比特位编号, 所述计算机可读指令被 处理器执行时还实现如下步骤:
采用预设算法计算得到所述任一数据记录的哈希值;
将比特位编号与所述哈希值相同的比特位的比特值置为第二数值。
[权利要求 19] 根据权利要求 18所述的计算机非易失性可读存储介质, 其特征在于, 计算得到的所述任一数据记录的哈希值包括多个, 所述计算机可读指 令被处理器执行时还实现如下步骤:
将比特位编号与多个哈希值相同的多个比特位的比特值均置为第二数 值。
[权利要求 20] 根据权利要求 19所述的计算机非易失性可读存储介质, 其特征在于, 所述计算机可读指令被处理器执行时还实现如下步骤:
采用所述预设算法计算得到所述新数据的多个目标哈希值; 判断所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个 比特位的比特值是否均为第二数值;
若所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个比 特位的比特值均为所述第二数值, 则识别所述新数据为所述目标数据 桶中已有的数据记录;
若所述目标数据桶中比特位编号与所述多个目标哈希值相同的多个比 特位的任一比特值不为所述第二数值, 则将所述新数据写入所述目标 数据桶中。
PCT/CN2019/116646 2019-07-12 2019-11-08 数据处理的方法、装置和服务器 WO2021008024A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910628181.5 2019-07-12
CN201910628181.5A CN110489405B (zh) 2019-07-12 2019-07-12 数据处理的方法、装置和服务器

Publications (1)

Publication Number Publication Date
WO2021008024A1 true WO2021008024A1 (zh) 2021-01-21

Family

ID=68547033

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/116646 WO2021008024A1 (zh) 2019-07-12 2019-11-08 数据处理的方法、装置和服务器

Country Status (2)

Country Link
CN (1) CN110489405B (zh)
WO (1) WO2021008024A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113516506A (zh) * 2021-06-10 2021-10-19 深圳市云网万店科技有限公司 一种数据处理方法、装置及电子设备
CN114528053A (zh) * 2022-02-28 2022-05-24 上海识装信息科技有限公司 一种业务功能执行方法、装置、电子设备及存储介质
WO2023155849A1 (zh) * 2022-02-18 2023-08-24 中兴通讯股份有限公司 基于时间衰减的样本删除方法及其装置、存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112035479A (zh) * 2020-08-31 2020-12-04 平安医疗健康管理股份有限公司 医药类数据库的访问方法、装置和计算机设备
CN112487177B (zh) * 2020-12-17 2022-05-10 杭州火石数智科技有限公司 一种海量短文本自适应分桶的反向去重方法
CN113590890B (zh) * 2021-08-04 2024-03-26 拉卡拉支付股份有限公司 信息存储方法、装置、电子设备、存储介质及程序产品

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130007008A1 (en) * 2010-09-13 2013-01-03 Tencent Technology (Shenzhen) Company Limited Hash algorithm-based data storage method and system
CN106570025A (zh) * 2015-10-10 2017-04-19 北京国双科技有限公司 一种数据过滤的方法及装置
CN107291746A (zh) * 2016-03-31 2017-10-24 阿里巴巴集团控股有限公司 一种存储和读取数据的方法及设备
CN107391034A (zh) * 2017-07-07 2017-11-24 华中科技大学 一种基于局部性优化的重复数据检测方法
CN109656901A (zh) * 2018-10-15 2019-04-19 阿里巴巴集团控股有限公司 数据处理方法和装置、电子设备

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106407207B (zh) * 2015-07-29 2020-06-16 阿里巴巴集团控股有限公司 一种实时新增数据更新方法和装置
KR101666758B1 (ko) * 2015-08-03 2016-10-17 성균관대학교산학협력단 개선된 블룸 필터를 이용하는 데이터 검색 방법
CN108121810A (zh) * 2017-12-26 2018-06-05 北京锐安科技有限公司 一种数据去重方法、系统、中心服务器及分布式服务器

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130007008A1 (en) * 2010-09-13 2013-01-03 Tencent Technology (Shenzhen) Company Limited Hash algorithm-based data storage method and system
CN106570025A (zh) * 2015-10-10 2017-04-19 北京国双科技有限公司 一种数据过滤的方法及装置
CN107291746A (zh) * 2016-03-31 2017-10-24 阿里巴巴集团控股有限公司 一种存储和读取数据的方法及设备
CN107391034A (zh) * 2017-07-07 2017-11-24 华中科技大学 一种基于局部性优化的重复数据检测方法
CN109656901A (zh) * 2018-10-15 2019-04-19 阿里巴巴集团控股有限公司 数据处理方法和装置、电子设备

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113516506A (zh) * 2021-06-10 2021-10-19 深圳市云网万店科技有限公司 一种数据处理方法、装置及电子设备
CN113516506B (zh) * 2021-06-10 2024-04-26 深圳市云网万店科技有限公司 一种数据处理方法、装置及电子设备
WO2023155849A1 (zh) * 2022-02-18 2023-08-24 中兴通讯股份有限公司 基于时间衰减的样本删除方法及其装置、存储介质
CN114528053A (zh) * 2022-02-28 2022-05-24 上海识装信息科技有限公司 一种业务功能执行方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN110489405B (zh) 2024-01-12
CN110489405A (zh) 2019-11-22

Similar Documents

Publication Publication Date Title
WO2021008024A1 (zh) 数据处理的方法、装置和服务器
CN104035923B (zh) 查询数据的方法及装置
Einziger et al. Counting with tinytable: Every bit counts!
WO2021003921A1 (zh) 数据处理方法及终端设备
WO2022134128A1 (zh) 多版本数据存储方法、装置、计算机设备及存储介质
CN110543448A (zh) 数据同步方法、装置、设备及计算机可读存储介质
WO2018036549A1 (zh) 分布式数据库查询方法、装置及管理系统
US9928178B1 (en) Memory-efficient management of computer network resources
US11244073B2 (en) Method and system for anonymising data stocks
WO2020220540A1 (zh) 基于点对点网络的数据存储方法、装置、介质及终端设备
WO2020207248A1 (zh) 一种流分类方法及装置
CN111629051A (zh) 一种用于工业互联网标识解析系统的性能优化方法及装置
Xiao et al. Using parallel bloom filters for multiattribute representation on network services
JP2019145925A (ja) ブロックチェーン・ネットワークにおいてトランザクションを検証するための方法及び当該ネットワークを構成するためのノード
WO2022017167A1 (zh) 一种信息处理方法、系统、电子设备及存储介质
CN108093024B (zh) 一种基于数据频度的分类路由方法及装置
US20220311773A1 (en) Method and device for communication between microservices
US20150278543A1 (en) System and Method for Optimizing Storage of File System Access Control Lists
WO2019052469A1 (zh) 一种网络请求处理方法、装置、电子设备及存储介质
JP2019146137A (ja) ブロックチェーン・ネットワークにおいてトランザクションを検証するための方法及び当該ネットワークを構成するためのノード
CN111488987A (zh) 一种深度学习大模型训练的方法、系统、设备及介质
WO2021082936A1 (zh) 一种网页访客数量统计方法及装置
CN111638925A (zh) 一种接口方法表生成方法、函数指针查询方法及装置
WO2016175880A1 (en) Merging incoming data in a database
CN113297266A (zh) 数据处理方法、装置、设备及计算机存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19937989

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19937989

Country of ref document: EP

Kind code of ref document: A1