Dynamic expansion bloom filter and design and use method and device thereof
Through the design of the dynamic expansion Bloom filter, the problem of memory efficiency and misjudgment balance of the Bloom filter in the unknown scale data environment in the existing technology is solved, and dynamic expansion and misjudgment are realized according to the increase in the number of independent visitors. Rate control provides a method of real-time statistics of independent visitors with convenient access and excellent performance.
Patent Information
- Application Number
- CN202410776279.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-10-18
AI Technical Summary
Existing Bloom filters cannot effectively balance memory efficiency and misjudgment rate when counting independent visitors, especially in data environments of unknown scale. The predefined bit array length cannot meet the memory utilization of small-scale data and large-scale data. misjudgment rate requirements.
Adopting the design of dynamically expanding Bloom filters, by creating an empty Bloom filter list, initializing and dynamically adding Bloom filters, creating new Bloom filters when elements exceed the expected capacity, and traversing the list to determine the repeatability of elements. , ensuring that the number of elements of each Bloom filter is within the expected capacity to avoid memory waste and an increase in misjudgment rates.
It realizes the dynamic expansion of Bloom filters according to the increase in the number of independent visitors, ensuring a controllable misjudgment rate and good space efficiency, avoiding memory waste, and providing real-time statistics of independent visitors with convenient access, excellent performance, and controllable errors. method.
Smart Images

Figure CN118802573A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Bloom filter deduplication, and in particular to a dynamically expanded Bloom filter and a method and device for designing and using the same. Background Art
[0002] When conducting network data statistics, you can analyze the user traffic of the website / webpage by counting the number of unique visitors (i.e., UV) who visit the same website / webpage, and provide a data basis for subsequent website / webpage management.
[0003] A client accessing a website / webpage can be called an independent visitor. As the number of users accessing the website / webpage increases, the statistics of independent visitor UVs also increase. The number of UVs is an important indicator for measuring the user traffic of a website / webpage. The number of UVs accessed by a website / webpage is of unknown scale and constantly changing, ranging from single digits to hundreds of millions. Counting the number of UVs is essentially deduplication of data of unknown scale. The most commonly used technical solution is to use Bloom filters to perform deduplication and implement UV statistics.
[0004] A Bloom filter is essentially a very long bit array and a series of mapping functions. Elements are mapped to multiple bits of the bit array through a series of hash functions. If all the corresponding bits are 1, the Bloom filter is considered to contain the element, thereby achieving element deduplication.
[0005] The misjudgment rate of the Bloom filter is affected by the number of inserted elements and the capacity of the Bloom filter. For data of unknown size, if the expected capacity of the Bloom filter is defined too large, it will lead to memory waste for small-scale data. If it is defined too small, it will lead to high misjudgment rate for large-scale data. The actual usage scenario cannot meet the balance between memory efficiency and misjudgment rate. The reasons are:
[0006] Bloom filters use hash functions to map to finite-length arrays to remove duplicates. There is inevitably a certain misjudgment rate. The misjudgment rate formula is:
[0007]
[0008] Where m is the size of the bit array, n is the actual number of elements, and k is the number of hash functions. When n is large:
[0009]
[0010] When initializing the Bloom filter, the bit array size needs to be predefined and cannot be changed. In theory, the larger the bit array length is, the lower the false positive rate is, but the actual memory usage is also larger. On the other hand, the increase in actual elements will increase the false positive rate. For data of unknown size, if the defined bit array length is too large, it will lead to a waste of memory when there are few actual elements. If the defined bit array length is too small, it will lead to a high false positive rate when there are many actual elements. Therefore, when using the Bloom filter to count the number of unique visitors, it is impossible to achieve a balance between space efficiency and false positive rate for data of unknown size. Summary of the invention
[0011] In order to solve the problem that the existing solution cannot meet the balance between space efficiency and error rate when using Bloom filter to count the number of independent visitors, the present invention provides a dynamically expanding Bloom filter and a method and device for designing and using the same, which can ensure a controllable error rate and good space efficiency.
[0012] According to a first aspect of the present invention, a design method for a dynamically expanding Bloom filter is provided, comprising:
[0013] Set the creation parameters of the Bloom filter and an empty Bloom filter list;
[0014] Initialize and create a Bloom filter when in use, and add it to the Bloom filter list as the latest Bloom filter;
[0015] Traversing all Bloom filters in the Bloom filter list for the newly added element to determine whether it is repeated, and when it is determined that all Bloom filters do not contain the newly added element, further determining whether the elements in the current latest Bloom filter have exceeded the expected capacity;
[0016] When it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, create a new Bloom filter and add it to the Bloom filter list as the current latest Bloom filter;
[0017] When it is determined that all Bloom filters do not contain the newly added element, the newly added element is added to the current latest Bloom filter.
[0018] According to a second aspect of the present invention, a design device for a dynamically expanding Bloom filter is provided, comprising:
[0019] The setup unit is used to set the creation parameters of the Bloom filter and an empty Bloom filter list;
[0020] An initialization unit, used for initializing and creating a Bloom filter when in use, and adding the Bloom filter to the Bloom filter list as the current latest Bloom filter;
[0021] A judging unit, configured to traverse all Bloom filters in the Bloom filter list to judge whether the newly added element is repeated, and when it is judged that all Bloom filters do not contain the newly added element, further judge whether the elements in the current latest Bloom filter have exceeded the expected capacity;
[0022] A Bloom filter adding unit, configured to create a new Bloom filter when it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, and add the new Bloom filter to the Bloom filter list as the current latest Bloom filter;
[0023] The element adding unit is used to add the newly added element to the current latest Bloom filter when it is determined that all Bloom filters do not contain the newly added element.
[0024] According to a third aspect of the present invention, a dynamically expanding Bloom filter is provided, including the following parameters and methods:
[0025] Creation parameters of Bloom filter;
[0026] A Bloom filter list, wherein the Bloom filter list is empty before initialization, and a Bloom filter is created when used, and is added to the Bloom filter list as the latest Bloom filter;
[0027] The current latest Bloom filter, the new elements will be added to the current latest Bloom filter;
[0028] Methods for creating Bloom filters;
[0029] A method for determining whether a newly added element is repeated is performed by traversing all Bloom filters in the Bloom filter list;
[0030] A method for adding an element, when it is determined that all Bloom filters in the Bloom filter list do not contain the newly added element, adding the newly added element to the current latest Bloom filter, and before adding, determining whether the elements in the current latest Bloom filter have exceeded the expected capacity;
[0031] The method for adding a Bloom filter creates a new Bloom filter when it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, and adds the new Bloom filter as the current latest Bloom filter to the Bloom filter list.
[0032] According to a fourth aspect of the present invention, a method for real-time counting of independent visitors is provided, comprising:
[0033] Use tracking tools to generate log files of visitor information;
[0034] Collect the visitor information from the log file and convert it into messages and transmit it to the message queue;
[0035] The message of the message queue is consumed in real time to parse the visitor information, and the visitor information is deduplicated through the aforementioned dynamically expanding Bloom filter to obtain the number of independent visitors in the statistical period.
[0036] According to a fifth aspect of the present invention, there is provided a device for real-time counting of independent visitor numbers, comprising:
[0037] A log file generation unit, used to generate a log file of visitor information using a tracking tool;
[0038] A visitor information collection unit, used to collect the visitor information from the log file and convert it into a message and transmit it to a message queue;
[0039] The independent visitor quantity statistics unit is used to consume the messages in the message queue in real time to parse the visitor information, deduplicate the visitor information through the aforementioned dynamically expanding Bloom filter, and obtain the independent visitor quantity within the statistical period.
[0040] According to a sixth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned method for designing a dynamic expansion Bloom filter is executed.
[0041] According to the seventh aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the aforementioned method for designing a dynamically expanding Bloom filter.
[0042] The beneficial effects of the embodiments of the present invention are:
[0043] The embodiment of the present invention provides a dynamically expandable Bloom filter and a design method and device thereof. By setting the creation parameters of the Bloom filter and an empty Bloom filter list, a Bloom filter is initialized when used and added to the Bloom filter list as the latest Bloom filter; the newly added element is determined to be repeated by traversing all Bloom filters in the Bloom filter list, and when it is determined that all Bloom filters do not contain the newly added element, it is further determined whether the elements in the latest Bloom filter have exceeded the expected capacity; if it has exceeded the expected capacity, a new Bloom filter is created and added to the Bloom filter list as the latest Bloom filter; when it is determined that all Bloom filters do not contain the newly added element, the newly added element is added to the latest Bloom filter. Therefore, compared with the existing single Bloom filter solution, the solution of the embodiment of the present invention can dynamically expand the Bloom filter according to the increase in the number of independent visitors, thereby avoiding memory waste, and the number of elements in each Bloom filter is within the expected capacity, so a controllable error rate can be guaranteed, and the relationship between space efficiency and error rate is well balanced.
[0044] The method and device for real-time statistics of independent visitor numbers provided in the embodiments of the present invention are based on real-time statistics of independent visitor numbers based on dynamically expanding Bloom filters. Compared with the existing solutions based on counting independent visitor numbers based on a single Bloom filter, it has the advantages of convenient access, excellent performance and controllable errors. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0046] Figure 1 A schematic flow chart of a design method for a dynamically expanding Bloom filter provided in Embodiment 1 of the present invention is shown;
[0047] Figure 2 A schematic diagram of the structure of a design device for a dynamically expanding Bloom filter provided in Embodiment 2 of the present invention is shown;
[0048] Figure 3 A schematic diagram of an inheritance architecture of a dynamically expanded Bloom filter provided in Embodiment 3 of the present invention is shown;
[0049] Figure 4 A schematic flow chart of a method for real-time counting of independent visitor numbers provided by Embodiment 4 of the present invention is shown;
[0050] Figure 5 A schematic diagram showing the structure of a device for real-time counting of independent visitor numbers provided by Embodiment 5 of the present invention;
[0051] Figure 6 A schematic structural diagram of an electronic device provided by Embodiment 7 of the present invention is shown. DETAILED DESCRIPTION
[0052] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0053] It should be noted that the terms "including" and "having" and any variations thereof in the specification and claims of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0054] The design concept of the present invention is to provide a dynamically expandable Bloom filter, which is composed of one or more Bloom filters connected in series. When in use, a Bloom filter is first initialized. When the actual elements exceed the expected capacity, a new Bloom filter is created. When judging whether the elements are repeated, all Bloom filters are traversed. When all Bloom filters do not contain the element, the element will be added to the latest Bloom filter. In this way, dynamic expansion can be achieved according to the increase in actual elements, and the number of elements of each Bloom filter is within the expected capacity, thereby ensuring a controllable misjudgment rate.
[0055] Example 1
[0056] According to the first aspect of the present invention, see Figure 1 As shown, Embodiment 1 of the present invention provides a design method for a dynamically expanding Bloom filter, including:
[0057] S11, setting the creation parameters of the Bloom filter and an empty Bloom filter list.
[0058] S12, when used, initialize and create a Bloom filter, and add it to the Bloom filter list as the current latest Bloom filter.
[0059] S13, traversing all Bloom filters in the Bloom filter list to determine whether the newly added element is repeated, and when it is determined that all Bloom filters do not contain the newly added element, further determining whether the elements in the current latest Bloom filter have exceeded the expected capacity.
[0060] S14, when it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, create a new Bloom filter and add it to the Bloom filter list as the current latest Bloom filter.
[0061] S15, when it is determined that all Bloom filters do not contain the newly added element, adding the newly added element to the current latest Bloom filter.
[0062] In some embodiments, the creation parameters of the Bloom filter set in step S11 include: default expected capacity, expected capacity, default expected error rate, expected error rate, and a method for converting element types into bit arrays; when creating the Bloom filter, steps S12 and S14 calculate the bit array size and the number of hash functions of each Bloom filter based on the default expected capacity / expected capacity, default expected error rate / expected error rate, and a method for converting element types into byte arrays.
[0063] It is easy to understand that if the expected capacity parameter is not provided in the creation parameters set during initialization, the default expected capacity parameter is used; if the expected error rate parameter is not provided, the default expected error rate parameter is used.
[0064] In summary, the design method of dynamically expanding Bloom filter provided by Embodiment 1 of the present invention sets the creation parameters of Bloom filter and an empty Bloom filter list, initializes a Bloom filter when in use, and adds it to the Bloom filter list as the latest Bloom filter; determines whether the newly added element is repeated by traversing all Bloom filters in the Bloom filter list, and further determines whether the elements in the latest Bloom filter have exceeded the expected capacity when it is determined that all Bloom filters do not contain the newly added element; if it has exceeded the expected capacity, creates a new Bloom filter and adds it to the Bloom filter list as the latest Bloom filter; when it is determined that all Bloom filters do not contain the newly added element, adds the newly added element to the latest Bloom filter. Therefore, compared with the existing single Bloom filter solution, the solution of the embodiment of the present invention can dynamically expand the Bloom filter according to the increase in the number of independent visitors, thereby avoiding memory waste, and the number of elements of each Bloom filter is within the expected capacity, so that a controllable error rate can be guaranteed, and the relationship between space efficiency and error rate is well balanced.
[0065] Example 2
[0066] According to a second aspect of the present invention, Figure 2 As shown, Embodiment 2 of the present invention provides a design device for a dynamically expanding Bloom filter, comprising:
[0067] A setting unit 21, used for setting creation parameters of a Bloom filter and an empty Bloom filter list;
[0068] An initialization unit 22, used for initializing and creating a Bloom filter when in use, and adding the Bloom filter to the Bloom filter list as the current latest Bloom filter;
[0069] A judging unit 23 is used to traverse all Bloom filters in the Bloom filter list to determine whether the newly added element is repeated, and when it is determined that all Bloom filters do not contain the newly added element, further determine whether the elements in the current latest Bloom filter have exceeded the expected capacity;
[0070] A Bloom filter adding unit 24 is used to create a new Bloom filter when it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, and add it to the Bloom filter list as the current latest Bloom filter;
[0071] The element adding unit 25 is used to add the newly added element to the current latest Bloom filter when it is determined that all Bloom filters do not contain the newly added element.
[0072] It can be understood that the device embodiment 2 has the same inventive concept as the aforementioned method embodiment 1. Figure 2 The implementation of each unit in the device embodiment shown can refer to the aforementioned method embodiment 1, which will not be repeated here. In addition, it should be noted that the unit name described in device embodiment 2 does not constitute a limitation on the unit itself in some cases.
[0073] Example 3
[0074] According to the third aspect of the present invention, see Figure 3 The inheritance system of the dynamically expanding Bloom filter shown in the figure, embodiment 3 of the present invention provides a dynamically expanding Bloom filter, including the following parameters and methods:
[0075] 1) Bloom filter creation parameters
[0076] According to some implementation methods of Example 3 of the present invention, the creation parameters of the Bloom filter include:
[0077] (1) DEFAULT_EXPECTED_INSERTIONS: Default expected capacity. This parameter is used when the expected capacity is not provided during initialization.
[0078] (2) DEFAULT_FPP: default estimated false positive rate, which is used when the estimated false positive rate is not provided during initialization;
[0079] (3)fpp: expected false positive rate;
[0080] (4) expectedInsertions: expected capacity;
[0081] (5) funnel: A method that converts an element type into a bit array.
[0082] 2) bloomFilterList: Bloom filter list. Before initialization, the Bloom filter list is empty. When used, a Bloom filter is initialized and added to the Bloom filter list as the current latest Bloom filter.
[0083] 3)lastBloomFilter: The current latest Bloom filter, the new elements will be added to the current latest Bloom filter.
[0084] 4) How to create a Bloom filter
[0085] According to some implementation methods of Example 3 of the present invention, the method for creating a Bloom filter includes:
[0086] (1)+DynamicScalableBloomFilter(): a parameterless creation method that creates a Bloom filter using default parameters;
[0087] (2)+DynamicScalableBloomFilter(expectedInsertions:long,fpp:double): a parameterized creation method that creates a Bloom filter using the passed parameters;
[0088] (3)+DynamicScalableBloomFilter(funnel: Funnel<? superT>, expectedInsertions: long, fpp: double): Another parameterized creation method that creates a Bloom filter using the passed parameters.
[0089] When creating a Bloom filter, the size of each Bloom filter bit array and the number of hash functions are calculated based on the default expected capacity / expected capacity, the default expected false positive rate / expected false positive rate, and the method of converting the element type to a bit (byte) array. It is easy to understand that if the expected capacity parameter is not provided in the creation parameters set during initialization, the default expected capacity parameter is used, and if the expected false positive rate parameter is not provided, the default expected false positive rate parameter is used.
[0090] 5) +mightContain(element:T): a method for determining whether a newly added element is a duplicate, by traversing all Bloom filters in the Bloom filter list;
[0091] 6)+put(element:T): a method for adding an element. When it is determined that all Bloom filters in the Bloom filter list do not contain the newly added element, the newly added element is added to the current latest Bloom filter. Before adding, it is determined whether the elements in the current latest Bloom filter have exceeded the expected capacity.
[0092] 7) +addBloomfilter(): a method for adding a Bloom filter. When it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, a new Bloom filter is created and added to the Bloom filter list as the current latest Bloom filter.
[0093] It can be seen that the dynamically expanding Bloom filter provided in Example 3 of the present invention is composed of one or more Bloom filters, which are connected in series in sequence. When used, a Bloom filter is first initialized. When the actual elements exceed the expected capacity, a new Bloom filter is created. When determining whether the newly added elements are repeated, all Bloom filters are traversed. When all Bloom filters do not contain the newly added elements, the newly added elements will be added to the latest Bloom filter. In this way, the Bloom filter can be dynamically expanded according to the increase in actual elements, and the number of elements of each Bloom filter is within the expected capacity, thereby ensuring a controllable Bloom filter misjudgment rate.
[0094] It can be understood that the dynamically expandable Bloom filter provided in Example 3 of the present invention is a product embodiment, which is a product obtained by adopting the design method of Example 1. The product embodiment 3 has the same inventive concept as the aforementioned method embodiment 1, and the two embodiments can be understood in comparison with each other, and will not be repeated here.
[0095] Example 4
[0096] According to a fourth aspect of the present invention, Figure 4 As shown, Embodiment 4 of the present invention provides a method for real-time counting of independent visitor numbers, including:
[0097] S41, use the tracking tool to generate a log file of visitor information.
[0098] Among them, the tracking tool refers to the log generation toolkit used to collect specified content.
[0099] S42, collecting the visitor information from the log file and converting it into a message and transmitting it to a message queue.
[0100] In this step S42, log file data can be collected by Filebeat, and the collected data can be transmitted through the message queue. Wherein Filebeat is a real-time log collector, which can collect and deliver log file data to the message queue.
[0101] S43, consuming the messages in the message queue in real time to parse the visitor information, and deduplicating the visitor information through a dynamically expanding Bloom filter to obtain the number of independent visitors in the statistical period.
[0102] In step S43, Flink can consume queue messages in real time, parse data to extract visitor information, and remove duplicates through dynamically expanding Bloom filters to obtain the number of independent visitors in the statistical period. Flink, namely Apache Flink, is a framework and distributed processing engine that can be used for real-time analysis and calculation of data streams.
[0103] In some embodiments, the method of Example 4 of the present invention further includes:
[0104] Manage the statistical results and the status of the dynamically expanding Bloom filter; and adjust the window size of the time dimension of the statistical period.
[0105] For example, you can use ValueState to manage independent visitor UV statistics and dynamically expand the Bloom filter status, persist the data to a database or other storage medium after a statistical cycle, and clear the data in time at the end of the statistical cycle. At the same time, by adjusting the window size of the time dimension of the statistical cycle, you can count the UV volume in different time dimensions. Among them, ValueState is a data structure provided by Flink that can store and periodically clear historical data.
[0106] The method of Example 4 of the present invention is based on a dynamically expanding Bloom filter to count the number of independent visitors in real time. It is a method for using a dynamically expanding Bloom filter. Compared with the existing solution of counting the number of independent visitors based on a single Bloom filter, it provides a method for real-time counting of the number of independent visitors with easy access, excellent performance and controllable errors.
[0107] Example 5
[0108] According to a fifth aspect of the present invention, Figure 5 As shown, an embodiment of the present invention provides a device for real-time counting of independent visitor numbers, including:
[0109] A log file generating unit 51 is used to generate a log file of visitor information using a tracking tool;
[0110] The visitor information collection unit 52 is used to collect the visitor information from the log file and convert it into a message and transmit it to the message queue;
[0111] The independent visitor quantity statistics unit 53 is used to consume the messages in the message queue in real time to parse the visitor information, deduplicate the visitor information through a dynamically expanded Bloom filter, and obtain the independent visitor quantity within the statistical period.
[0112] It can be understood that the device embodiment 5 and the method embodiment 4 have the same inventive concept. Figure 5 The implementation of each unit in the device embodiment shown can refer to the aforementioned method embodiment 4, which will not be repeated here. In addition, it should be noted that the unit name described in device embodiment 5 does not constitute a limitation on the unit itself in some cases.
[0113] Example 6
[0114] According to a sixth aspect of the present invention, embodiment 6 of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program executes the method described in the aforementioned embodiment 1 when executed by a processor.
[0115] The computer-readable storage medium of Embodiment 6 of the present invention may be any tangible medium containing a stored program. Furthermore, the computer-readable storage medium of Embodiment 6 of the present invention may be located in any computer terminal in a computer terminal group in a computer network, or in any communication device in a communication device group.
[0116] In particular, the processes described in the above flowcharts can be implemented as computer software programs. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, the above functions defined in the method of embodiment 1 of the present invention are executed.
[0117] Example 7
[0118] According to the seventh aspect of the present invention, embodiment 7 of the present invention provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the aforementioned embodiment 1.
[0119] Reference below Figure 6, which shows a schematic diagram of the structure of an electronic device suitable for implementing Embodiment 7 of the present invention. The electronic device in the embodiment of the present invention may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0120] like Figure 6 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage device into a random access memory (RAM). In the RAM, various programs and data required for the operation of the electronic device are also stored. The processing device, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.
[0121] Typically, the following systems can be connected to the I / O interface: input devices including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices including, for example, a magnetic tape, a hard disk, etc.; and communication devices. The communication device can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.
[0122] Finally, it is necessary to explain:
[0123] The serial numbers of the embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The embodiments of the present invention can be implemented by hardware, software, firmware or a combination thereof.
[0124] In the several embodiments provided by the present invention, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the system embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, units or modules, which can be electrical or other forms.
[0125] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0126] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the method, device and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0127] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit. Moreover, if the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
Claims
1. A design method for a dynamically scalable Bloom filter, characterized in that: include: Set the creation parameters of the Bloom filter and an empty Bloom filter list; Initialize and create a Bloom filter when in use, and add it to the Bloom filter list as the latest Bloom filter; Traversing all Bloom filters in the Bloom filter list for the newly added element to determine whether it is repeated, and when it is determined that all Bloom filters do not contain the newly added element, further determining whether the elements in the current latest Bloom filter have exceeded the expected capacity; When it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, create a new Bloom filter and add it to the Bloom filter list as the current latest Bloom filter; When it is determined that all Bloom filters do not contain the newly added element, the newly added element is added to the current latest Bloom filter.
2. The design method according to claim 1, characterized in that: The creation parameters of the Bloom filter that are set include: default expected capacity, expected capacity, default expected false positive rate, expected false positive rate, and the method for converting element types to bit arrays; When creating a Bloom filter, the size of each Bloom filter bit array and the number of hash functions are calculated based on the default expected capacity / expected capacity, the default expected false positive rate / expected false positive rate, and the method of converting the element type into a bit array.
3. A design device for a dynamically expanding Bloom filter, characterized in that: include: The setup unit is used to set the creation parameters of the Bloom filter and an empty Bloom filter list; An initialization unit, used for initializing and creating a Bloom filter when in use, and adding the Bloom filter to the Bloom filter list as the current latest Bloom filter; A judging unit, configured to traverse all Bloom filters in the Bloom filter list to judge whether the newly added element is repeated, and when it is judged that all Bloom filters do not contain the newly added element, further judge whether the elements in the current latest Bloom filter have exceeded the expected capacity; A Bloom filter adding unit, configured to create a new Bloom filter when it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, and add the new Bloom filter to the Bloom filter list as the current latest Bloom filter; The element adding unit is used to add the newly added element to the current latest Bloom filter when it is determined that all Bloom filters do not contain the newly added element.
4. A dynamically scalable Bloom filter, characterized in that: Includes the following parameters and methods: Creation parameters of Bloom filter; A Bloom filter list, wherein the Bloom filter list is empty before initialization, and a Bloom filter is created when used, and is added to the Bloom filter list as the latest Bloom filter; The current latest Bloom filter, the new elements will be added to the current latest Bloom filter; Methods for creating Bloom filters; A method for determining whether a newly added element is repeated is performed by traversing all Bloom filters in the Bloom filter list; The method for adding elements, when it is determined that all Bloom filters in the Bloom filter list do not contain the newly added element, adds the newly added element to the current latest Bloom filter, and before adding, determines whether the elements in the current latest Bloom filter have exceeded the expected capacity. The method for adding a Bloom filter creates a new Bloom filter when it is determined that the elements in the current latest Bloom filter have exceeded the expected capacity, and adds the new Bloom filter as the current latest Bloom filter to the Bloom filter list.
5. The dynamically expandable Bloom filter according to claim 4, characterized in that: The creation parameters of the Bloom filter include: a default expected capacity, an expected capacity, a default expected false positive rate, an expected false positive rate, and a method for converting an element type into a bit array; The method for creating a Bloom filter includes: calculating the size of each Bloom filter bit array and the number of hash functions based on the default expected capacity / expected capacity, the default expected false positive rate / expected false positive rate, and a method for converting the element type into a bit array.
6. A method for real-time statistics of the number of independent visitors, characterized in that: include: Use tracking tools to generate log files of visitor information; Collect the visitor information from the log file and convert it into messages and transmit it to the message queue; The messages in the message queue are consumed in real time to parse out the visitor information, and the visitor information is deduplicated through the dynamically expanding Bloom filter described in claim 4 to obtain the number of independent visitors within the statistical period.
7. The method according to claim 6, characterized in that Also includes: Managing the statistical results and the status of the dynamically expanding Bloom filter; and, Adjust the time dimension window size of the statistical period.
8. A device for real-time statistics of independent visitors, characterized in that: include: A log file generation unit, used to generate a log file of visitor information using a tracking tool; A visitor information collection unit, used to collect the visitor information from the log file and convert it into a message and transmit it to a message queue; The independent visitor quantity statistics unit is used to consume the messages in the message queue in real time to parse the visitor information, deduplicate the visitor information through the dynamically expanding Bloom filter described in claim 4, and obtain the independent visitor quantity within the statistical period.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to claim 1 or 2 is performed.
10. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to claim 1 or 2.
Citation Information
Cited By
Response result cache optimization method and device, equipment, storage medium and product
CN119583648A
