Method and apparatus for storing data using bitmap index, and computer device
By creating a bitmap index table and using integer variables to store data status information, the problem of Boolean data occupying a large amount of storage space is solved, and more efficient use of storage resources is achieved.
Patent Information
- Application Number
- CN202310101656.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-08
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2043-02-08
AI Technical Summary
In existing technologies, Boolean data storage occupies a large amount of storage space, resulting in high storage resource consumption and reduced data storage efficiency.
A bitmap index table is created using integer variables, which are used to identify data status information, thus reducing storage space usage.
Storing data status information using integer variables reduces storage space consumption and improves storage efficiency.
Smart Images

Figure CN116257524B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of data encoding processing, and particularly relates to a method and device for storing data by using a bitmap index, and a computer device. BACKGROUND
[0002] With the diversification of data, in the process of project research and development, a developer usually uses a Boolean variable to store relevant information, and the value of the information is "0" or "1". 0 can be considered as "no" and 1 can be considered as "yes", thereby marking various information.
[0003] The Boolean data usually occupies at least one byte of storage space, and one Boolean data is usually used to identify one data. However, when a large amount of data needs to be accessed or recorded, a large number of Boolean data need to be added to identify each kind of data, which will occupy a large amount of storage space, consume a large amount of storage resources, and reduce the storage efficiency of data. SUMMARY
[0004] Therefore, it is necessary to provide a method and device for storing data by using a bitmap index, and a computer device, which do not need to occupy a large amount of storage space and reduce the consumption of storage resources when storing relevant information.
[0005] In a first aspect, the present disclosure provides a method for storing data by using a bitmap index. The method comprises:
[0006] obtaining data identification information to be stored and data state information corresponding to the data identification information, wherein the data state information comprises system service information described by a Boolean variable;
[0007] determining an integer variable to be stored corresponding to the data state information, wherein the integer variable to be stored is a positive number;
[0008] creating a bitmap index table according to the integer variable to be stored and the data identification information, wherein the data state information is described by the integer variable to be stored in the bitmap index table, and the bitmap index table is used to store the integer variable to be stored and the data identification information.
[0009] In one embodiment, the method further comprises: in response to a need to obtain data state information corresponding to data identification information, obtaining the bitmap index table and the data identification information;
[0010] extracting the integer variable to be stored corresponding to the data identification information from the bitmap index table;
[0011] determining original code data corresponding to the integer variable to be stored;
[0012] According to the original code data, data state information corresponding to the data identification information is determined.
[0013] In one embodiment, after the original code data corresponding to the integer variable to be stored is determined, the method further comprises:
[0014] In response to the bit width of the original code data being less than the bit width of the data state information, and the bit width of the data state information being less than 32 bytes, padding is performed on the original code data, so that the bit width of the original code data obtained after padding is equal to the bit width of the data state information.
[0015] Correspondingly, the determination of the data state information corresponding to the data identification information according to the original code data comprises: determining the data state information according to the original code data obtained after padding.
[0016] In one embodiment, the determination of the integer variable to be stored corresponding to the data state information comprises:
[0017] In response to the bit width of the data state information being less than or equal to 31 bytes, the data state information is converted into a corresponding integer variable to be stored.
[0018] In one embodiment, the determination of the integer variable to be stored corresponding to the data state information further comprises:
[0019] In response to the bit width of the data state information being greater than 31 bytes, the data state information is divided according to a preset bit width to obtain a plurality of sub-state information, and the preset bit width is 31 bytes.
[0020] Each of the sub-state information is converted into a corresponding integer variable to be stored.
[0021] In one embodiment, the determination of the data state information corresponding to the data identification information according to the original code data comprises:
[0022] In response to the bit width of the data state information being greater than 31 bytes, a plurality of original code data corresponding to a plurality of integer variables to be stored are obtained.
[0023] A plurality of sub-state information corresponding to the plurality of original code data are determined.
[0024] The plurality of sub-state information are spliced to obtain the data state information.
[0025] In a second aspect, the disclosure further provides a device for storing data by using a bitmap index. The device comprises:
[0026] The information acquisition module is configured to acquire data identifier information to be stored and data state information corresponding to the data identifier information, wherein the data state information comprises system service information described by using a Boolean variable.
[0027] The variable determination module is configured to determine an integer variable to be stored corresponding to the data state information, wherein the integer variable to be stored is a positive number.
[0028] The bitmap index creation module is configured to create a bitmap index table according to the integer variable to be stored and the data identifier information, wherein the data state information is described by using the integer variable to be stored in the bitmap index table, and the bitmap index table is configured to store the integer variable to be stored and the data identifier information.
[0029] In a third aspect, the present disclosure further provides a computer device. The computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above method embodiments when executing the computer program.
[0030] In a fourth aspect, the present disclosure further provides a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program implements the steps of any of the above method embodiments when executed by a processor.
[0031] In a fifth aspect, the present disclosure further provides a computer program product. The computer program product comprises a computer program, and the computer program implements the steps of any of the above method embodiments when executed by a processor.
[0032] In the above embodiments, the data identifier information to be stored and the data state information corresponding to the data identifier information are acquired, and the integer variable to be stored corresponding to the data state information is determined. The data state information is stored by using the integer variable. Since the integer variable usually occupies four bytes of storage space, and each Boolean variable usually occupies one byte. When the data state information exceeds four bytes of storage space, the bitmap index table is created according to the integer variable to be stored and the data identifier information. The data state information corresponding to the data identifier information is identified by using the integer variable to be stored, which can reduce the space occupied when the data state information is stored. When the related information is stored, a large amount of storage space is not required, and the consumption of storage resources is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0033] To more clearly illustrate the technical solutions in the specific embodiments of this disclosure or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0034] Figure 1 This is a schematic diagram illustrating the application environment of a method for storing data using a bitmap index in one embodiment;
[0035] Figure 2 This is a flowchart illustrating a method for storing data using a bitmap index in one embodiment;
[0036] Figure 3 This is a schematic diagram of the process for obtaining data status information from a bitmap index table in one embodiment;
[0037] Figure 4 This is a schematic diagram of the processing procedure in one embodiment;
[0038] Figure 5 This is a flowchart illustrating the process after step S306 in one embodiment;
[0039] Figure 6 This is a flowchart illustrating step S206 in one embodiment;
[0040] Figure 7 This is a flowchart illustrating step S308 in one embodiment;
[0041] Figure 8 This is a flowchart illustrating a method for storing data using bitmap indexes in another embodiment;
[0042] Figure 9 This is a schematic block diagram of a device for storing data using a bitmap index in one embodiment;
[0043] Figure 10 This is a schematic diagram of the internal structure of a computer device in one embodiment. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of this disclosure clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this disclosure.
[0045] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings herein are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, apparatus, product, or device that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0046] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0047] Currently, in typical cases, for example, if we construct the following table, we use the STATUS field to record account status. Each bit of STATUS is either "0" or "1", representing a boolean label. The STATUS field is of type CHAR(31) and occupies 31 bytes.
[0048] Table 1 Bitmap Index Table
[0049]
[0050] When there are a large number of account numbers that need to be stored, a large number of CHAR types will be used to describe their corresponding data status, which will increase the space occupied.
[0051] Therefore, to solve the above problems, this disclosure provides a method for storing data using a bitmap index, which can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with business server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated on server 104 or placed on a cloud or other network server. Terminal 102 can obtain data identification information to be stored and data status information corresponding to the data identification information from business server 104. The data status information includes system business information described using Boolean variables. Terminal 102 determines the integer variable to be stored corresponding to the data status information, and the integer variable to be stored is a positive number. Terminal 102 creates a bitmap index table based on the integer variable to be stored and the data identification information. The bitmap index table uses the integer variable to be stored to describe the data status information, and the bitmap index table is used to store the integer variable to be stored and the data identification information. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, etc. Business server 104 can be implemented using a standalone server or a server cluster composed of multiple servers. Understandably, this method can also be applied to the business server 104 alone, or to a system that includes both a terminal and a business server, and can be implemented through the interaction between the terminal and the business server.
[0052] In one embodiment, such as Figure 2 As shown, a method for storing data using bitmap indexes is provided, which can be applied to... Figure 1 Taking terminal 102 as an example, the explanation includes the following steps:
[0053] S202, obtain the data identification information to be stored and the data status information corresponding to the data identification information, wherein the data status information includes system business information described by Boolean variables.
[0054] System business information typically refers to information generated or recorded during the processing of different business operations. Data identification information typically involves recording information using numerous Boolean variables. For example, in banking, data identification information might include whether a customer is a dormant account, a high-net-worth individual, or a valid account. In production and operation, data identification information might include whether a product has been shipped, whether it is a qualified product, or whether its model number is correct. The specific data identification information varies depending on the business application scenario, and this disclosure does not limit the specific data identification information used. Data status information typically refers to system business information described by Boolean variables; for example, a dormant account can be represented by 1, and a non-dormant account by 0. Each data identification information will have corresponding data status information.
[0055] Specifically, when there is a large amount of data identification information to be stored, each data identification information may correspond to one or more data status information. Therefore, it is necessary to obtain the data identification information to be stored and the data status information corresponding to the data identification information.
[0056] S204, determine the integer variable to be stored corresponding to the data status information, wherein the integer variable to be stored is a positive number.
[0057] The integer variable to be stored is typically an `int` variable, which represents integer data. An `int` variable usually occupies 4 bytes of storage space and is represented in decimal, with a range typically between -2^3 and 10^4. 31 Up to 2 31 Between -1 and 1.
[0058] Specifically, data status information can be viewed as binary representation, but it is typically a Boolean variable of type CHAR, with each unit of data status information usually occupying one byte of space. Therefore, when there are more than four units in the data status information, using integer variables can reduce storage space. The binary representation can be converted into a decimal integer to be stored. Furthermore, since the first bit after converting an int variable to binary is the sign bit, to facilitate subsequent algorithmic conversions, in some embodiments of this disclosure, integer variables are typically specified to use only positive numbers, that is, only the remaining 31 bits (excluding the sign bit) are used, ignoring the sign bit. Therefore, data status information is usually distinguished by 31 bits, grouped into 31-bit sets. After omitting the sign bit, the converted integer variable to be stored is usually a positive number. Typically, one byte equals 8 bits.
[0059] For example, if the data status information is 010101, it can be regarded as six units, occupying 6 bytes of space. If the original storage method is used, it occupies 6 bytes of space. If it is converted to the int type, it only occupies 4 bytes of space, that is, it is represented by 21.
[0060] S206, Create a bitmap index table based on the integer variable to be stored and the data identification information, wherein the bitmap index table uses the integer variable to be stored to describe the data status information, and the bitmap index table is used to store the integer variable to be stored and the data identification information.
[0061] Bitmap indexing refers to bitmap indexing technology, a special type of database indexing technology that uses bit arrays (or bitmap, bit set, bit string, bit vector) for storage and computation.
[0062] Specifically, to address the issue of excessive storage space occupied by the CHAR type in the STATUS field of the current bitmap index table, an int type variable can be used to describe the STATUS field, and the corresponding binary number of the int type variable can be used to describe the tag information of the STATUS field. The binary number corresponding to the int type variable can be called the bitmap index. Table 2, the bitmap index table, is created based on the data identification information and the integer variable to be stored. Table 2, the bitmap index table, is used to store the data identification information and the data status information corresponding to the data identification information.
[0063] Table 2 Bitmap Index Table
[0064]
[0065] In the above method of storing data using a bitmap index, the method involves obtaining the data identifier information to be stored and the data status information corresponding to the data identifier information, and determining the integer variable to be stored corresponding to the data status information. Using an integer variable to store the data status information is advantageous because integer variables typically occupy four bytes of storage space, while each Boolean variable typically occupies one byte. When the data status information exceeds four bytes of storage space, a bitmap index table is created based on the integer variable to be stored and the data identifier information. Using the integer variable to be stored to identify the data status information corresponding to the data identifier information reduces the space occupied when storing data status information. This eliminates the need for a large amount of storage space when storing related information, thus reducing the consumption of storage resources.
[0066] The above only describes how to store data. The following specific example illustrates how to retrieve data from the bitmap index table created above. In one embodiment, such as... Figure 3 As shown, the method further includes:
[0067] S302, in response to the need to obtain data status information corresponding to data identification information, the bitmap index table and data identification information are obtained.
[0068] S304, extract the corresponding integer variable to be stored from the bitmap index table according to the data identification information.
[0069] S306, determine the original code data corresponding to the integer variable to be stored.
[0070] S308, determine the data status information corresponding to the data identifier information based on the source code data.
[0071] In this context, the original code data is usually a binary fixed-point representation of numbers in a computer, and in this embodiment, it can generally be understood as an encoding method.
[0072] Specifically, when it is necessary to obtain data status information corresponding to data identification information, the data identification information and the bitmap index table obtained above can be obtained first. Based on the data identification information, the integer variable to be stored corresponding to the data identification information is extracted from the bitmap index table. Typically, the integer variable to be stored is decimal and a positive number. Therefore, it needs to be converted to binary to determine the data status information. The original code data corresponding to the integer variable to be stored is determined, and then the data status information is determined based on each binary value in the original code data. Typically, each value in the binary representation has its corresponding meaning. For example, binary 010 can typically be used to determine whether the account is a dormant account, a high-net-worth user, or a suspicious account. The meaning of the corresponding setting varies depending on the situation. Those skilled in the art can determine the meaning of each value in the binary representation according to actual needs. In some embodiments of this disclosure, the specific meaning of each value in the binary representation is not limited.
[0073] In some exemplary embodiments, for example, if the STATUS field value of an account is 354, and the binary number (original code data) corresponding to 354 is 10110010, then the data status information corresponding to the number 354 is defined as: "000000000000000000000010110010", a total of 31 bits. FLAG1, FLAG2...FLAG31, FLAG31 can be used to represent the data status information corresponding to the above STATUS field in right-to-left order, resulting in: FLAG1=0, FLAG2=1, FLAG3=0, FLAG4=0, FLAG5=1, FLAG6=1, FLAG7=0, FLAG8=1, and the remaining FLAG9 to FLAG31 are all equal to 0. Through... Figure 4 The program shown calculates the data status information corresponding to the data identifier information in the bitmap index of the int type variable, and can be run directly in the database. Figure 4 The program in the middle.
[0074] In this embodiment, when it is desired to obtain information from the bitmap index table, the data identification information can be used to match the corresponding variable to be stored in the bitmap index table, and then the original code data corresponding to the variable to be stored can be used to determine the data status information. This can significantly reduce the space occupancy rate of database fields and determine the desired data status information.
[0075] In one embodiment, such as Figure 5 As shown, after determining the original code data corresponding to the integer variable to be stored, the method further includes:
[0076] S402, determine whether the bit width of the original code data is less than the bit width of the data status information.
[0077] S404, in response to the fact that the bit width of the original code data is less than the bit width of the data status information, and the bit width of the data status information is less than 32 bytes, the original code data is padded so that the bit width of the padded original code data is equal to the bit width of the data status information.
[0078] The bit width typically refers to the number of bits in the original code data or data status information. For example, if the original code information is 0101, its bit width can be 4 bytes. In some embodiments of this disclosure, the bit width of the data status information is generally 31 bytes, and the corresponding bit width of the data status information is usually set during storage.
[0079] Specifically, first, it is determined whether the bit width of the obtained original code data is less than the bit width of the data status information. If it is less, it proves that the original code data is incomplete. If the data status information is determined by the incomplete original code data, the final information may also be missing. Therefore, the original code data needs to be padded. Usually, 0 or 1 is used for padding so that the bit width of the padded original code data is the same as the bit width of the data status information.
[0080] In some exemplary embodiments, for example, the width of the original code data is 4 bytes, while the width of the data status information is 31 bytes. If padding is not performed, 27 bytes of information will be missing. Therefore, padding is required to ensure the integrity of the information.
[0081] S406, correspondingly, determining the data status information corresponding to the data identifier information based on the original code data includes: determining the data status information based on the original code data obtained after padding.
[0082] Specifically, after the original code data is padded, the padded original code data and the data status information have the same bit width, so there will be no information loss. Therefore, the data status information can be determined based on the padded original code data.
[0083] In some exemplary embodiments, for example, if the integer variable to be stored obtained by extracting data identification information is 354, the binary number of the original code data corresponding to 354 is 10110010, and the bit width of the data status information is 31 bytes, then the binary value of the original code data needs to be padded. Taking 0 as an example, after padding, it can be obtained as: "00000000000000000000000010110010", a total of 31 bytes.
[0084] In this embodiment, when the bit width of the original code data is less than the bit width of the data status information, padding can be performed to avoid missing data information.
[0085] In one embodiment, such as Figure 6 As shown, determining the integer variable to be stored corresponding to the data status information includes:
[0086] S502, determine whether the bit width of the data status information is less than or equal to 31 bytes.
[0087] S504, in response to the data status information having a bit width of less than or equal to 31 bytes, the data status information is converted into a corresponding integer variable to be stored.
[0088] Specifically, first determine whether the bit width of the data status information to be stored is less than or equal to 31 bytes. If so, an integer variable can be used to represent it. Therefore, the data status information can be directly converted into the corresponding integer variable to be stored.
[0089] S506, in response to the data status information having a bit width greater than 31 bytes, the data status information is divided according to a preset bit width to obtain multiple sub-status information, wherein the preset bit width is 31 bytes.
[0090] S508, convert each of the sub-state information into a corresponding integer variable to be stored.
[0091] Specifically, when the bit width of the data status information is greater than 31 bytes, since a single integer variable can typically represent a maximum of 31 bytes, multiple integer variables are needed. Multiple sub-status information can be obtained by grouping data into sets of 31 bytes, according to a preset bit width. Each sub-status information is then converted into a corresponding integer variable to be stored.
[0092] In some exemplary embodiments, for example, if the data status information is 86 bits, then three sub-status information can be obtained, namely the first sub-status information, the second sub-status information, and the third sub-status information. The first and second sub-status information can each be 31 bytes, and the third sub-status information can be 24 bytes.
[0093] In this embodiment, when the stored data conversion information is greater than 31 bytes, it can be split and stored separately using integer variables. Compared to directly using character types to identify data status information, and without changing the structure of the bitmap index table, each integer variable used to represent data status information only occupies 4 bytes. Taking 86 bytes of data status information as an example, only 4 × 3 = 12 bytes are needed using integer variables, reducing the space occupancy rate to 12 / 86 = 13.9% of the original.
[0094] In one embodiment, such as Figure 7 As shown, determining the data status information corresponding to the data identifier information based on the source code data includes:
[0095] S602, in response to the data status information having a bit width greater than 31 bytes, acquire multiple source code data corresponding to multiple integer variables to be stored;
[0096] S604, determine multiple corresponding sub-state information based on multiple source code data;
[0097] S606, concatenate multiple sub-state information to obtain the data state information.
[0098] Among these, splicing can usually be done according to the splitting order of the original code data or data state information.
[0099] Specifically, when the bit width of the data status information is greater than 31 bytes, a single integer is usually insufficient to represent it. Therefore, as in the above embodiment, it is split into multiple integer variables to be stored. At this point, the multiple integer variables to be stored obtained after splitting can be acquired, and the corresponding source code data for each variable can be obtained, resulting in multiple source code data. Then, multiple sub-state information is determined based on the multiple source code data, and the multiple sub-state information is concatenated in a certain order to obtain the data status information.
[0100] In some exemplary embodiments, each sub-state information can be marked at the data state information position, and then multiple sub-state information can be concatenated according to the order of the markings.
[0101] In this embodiment, when the bit width of the data status information is greater than 31 bytes, multiple original code data corresponding to multiple integer variables to be stored can be obtained. Then, multiple sub-state information corresponding to the multiple original code data can be determined. The multiple sub-state information is concatenated to obtain the data status information. This ensures that even when the bit width of the data status information is greater than 31 bytes, the corresponding data status information can be accurately obtained from multiple integer variables to be stored, thus ensuring the accuracy of the data.
[0102] In one embodiment, this disclosure also provides a method for storing data using a bitmap index, such as... Figure 8 As shown, the method includes:
[0103] S702, obtain the data identification information to be stored and the data status information corresponding to the data identification information, wherein the data status information includes: system business information described by Boolean variables.
[0104] S704, determine whether the bit width of the data status information is less than or equal to 31 bytes.
[0105] S706, in response to the data status information having a bit width of less than or equal to 31 bytes, the data status information is converted into a corresponding integer variable to be stored.
[0106] S708, in response to the data status information having a bit width greater than 31 bytes, the data status information is divided according to a preset bit width to obtain multiple sub-status information, wherein the preset bit width is 31 bytes.
[0107] S710, convert each of the sub-state information into a corresponding integer variable to be stored.
[0108] S712, Create a bitmap index table based on the integer variable to be stored and the data identification information, wherein the bitmap index table uses the integer variable to be stored to describe the data status information, and the bitmap index table is used to store the integer variable to be stored and the data identification information.
[0109] The specific implementation and limitations of this embodiment are the same as those described in the above embodiments, and will not be repeated here.
[0110] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0111] Based on the same inventive concept, this disclosure also provides an apparatus for implementing the method of storing data using bitmap indexes as described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, specific limitations in one or more apparatus embodiments for storing data using bitmap indexes provided below can be found in the limitations of the method for storing data using bitmap indexes described above, and will not be repeated here.
[0112] In one embodiment, such as Figure 9 As shown, a device 800 for storing data using a bitmap index is provided, comprising: an information acquisition module 802, a variable determination module 804, and a bitmap index creation module 806, wherein:
[0113] The information acquisition module 802 is used to acquire data identification information to be stored and data status information corresponding to the data identification information. The data status information includes system business information described using Boolean variables.
[0114] The variable determination module 804 is used to determine the integer variable to be stored corresponding to the data status information, wherein the integer variable to be stored is a positive number.
[0115] Bitmap index creation module 806 is used to create a bitmap index table based on the integer variable to be stored and the data identification information, wherein the bitmap index table uses the integer variable to be stored to describe the data status information, and the bitmap index table is used to store the integer variable to be stored and the data identification information.
[0116] In one embodiment of the device, the device further includes:
[0117] The data acquisition module is used to acquire the bitmap index table and the data identification information in response to the need to acquire data status information corresponding to the data identification information;
[0118] The information extraction module is used to extract the corresponding integer variable to be stored from the bitmap index table based on the data identification information.
[0119] The original code data determination module is used to determine the original code data corresponding to the integer variable to be stored;
[0120] The status information determination module is used to determine the data status information corresponding to the data identification information based on the source code data.
[0121] In one embodiment of the device, data status information corresponding to the data identification information is determined based on the source code data.
[0122] In one embodiment of the device, the original code data determination module is further configured to, in response to the fact that the bit width of the original code data is less than the bit width of the data status information and the bit width of the data status information is less than 32 bytes, pad the original code data so that the bit width of the padded original code data is equal to the bit width of the data status information.
[0123] Accordingly, the state information determination module is used to: determine the data state information based on the original code data obtained after padding.
[0124] In one embodiment of the device, the variable determination module 804 is further configured to, in response to the data status information having a bit width greater than 31 bytes, divide the data status information according to a preset bit width to obtain multiple sub-status information, wherein the preset bit width is 31 bytes; and convert each sub-status information into a corresponding integer variable to be stored.
[0125] In one embodiment of the device, the variable determination module 804 is further configured to convert the data status information into a corresponding integer variable to be stored in response to the data status information having a bit width of less than or equal to 31 bytes.
[0126] In one embodiment of the device, the state information determination module is further configured to, in response to the data state information having a bit width greater than 31 bytes, acquire multiple source code data corresponding to multiple integer variables to be stored; determine multiple sub-state information corresponding to the multiple source code data; and concatenate the multiple sub-state information to obtain the data state information.
[0127] The modules in the aforementioned data storage device utilizing bitmap indexes can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0128] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores source code data and bitmap index tables. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a method for storing data using bitmap indexes.
[0129] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present disclosure and does not constitute a limitation on the computer device to which the present disclosure is applied. A specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0130] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in any of the above method embodiments.
[0131] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in any of the above method embodiments.
[0132] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.
[0133] It should be noted that the system business information and data identification information involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0134] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this disclosure may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this disclosure may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0135] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0136] The embodiments described above are merely illustrative of several implementations of this disclosure, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent disclosure. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this disclosure, and these all fall within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the appended claims.
Claims
1. A method for storing data using a bitmap index, characterized in that, The method comprises: obtaining data identification information to be stored and data state information corresponding to the data identification information, the data state information comprising system service information described by a Boolean variable; in response to a bit width of the data state information being less than or equal to 31 bytes, converting the data state information into a corresponding to-be-stored integer variable, the to-be-stored integer variable being a positive number; in response to the bit width of the data state information being greater than 31 bytes, dividing the data state information according to a preset bit width to obtain a plurality of sub-state information, the preset bit width being a bit width of 31 bytes; and converting each of the sub-state information into a corresponding to-be-stored integer variable; creating a bitmap index table according to the to-be-stored integer variable and the data identification information, wherein the data state information is described by the to-be-stored integer variable in the bitmap index table, and the bitmap index table is used to store the to-be-stored integer variable and the data identification information; in response to a need to obtain data state information corresponding to data identification information, obtaining the bitmap index table and the data identification information; extracting the corresponding to-be-stored integer variable from the bitmap index table according to the data identification information; determining original code data corresponding to the to-be-stored integer variable; in response to the bit width of the data state information being greater than 31 bytes, obtaining a plurality of original code data corresponding to a plurality of to-be-stored integer variables; determining a plurality of sub-state information corresponding to the plurality of original code data; and splicing the plurality of sub-state information to obtain the data state information.
2. The method of claim 1, wherein, After the determination of the original code data corresponding to the to-be-stored integer variable, the method further comprises: in response to a bit width of the original code data being less than a bit width of the data state information and the bit width of the data state information being less than 32 bytes, performing bit padding on the original code data, so that a bit width of the original code data obtained after the bit padding is equal to the bit width of the data state information; correspondingly, the determination of the data state information corresponding to the data identification information according to the original code data comprises the determination of the data state information according to the original code data obtained after the bit padding.
3. An apparatus for storing data using bitmap indexing, the apparatus comprising: The apparatus comprises: an information obtaining module configured to obtain data identification information to be stored and data state information corresponding to the data identification information, the data state information comprising system service information described by a Boolean variable; a variable determining module configured to, in response to a bit width of the data state information being less than or equal to 31 bytes, convert the data state information into a corresponding to-be-stored integer variable, the to-be-stored integer variable being a positive number; in response to the bit width of the data state information being greater than 31 bytes, divide the data state information according to a preset bit width to obtain a plurality of sub-state information, the preset bit width being a bit width of 31 bytes; and convert each of the sub-state information into a corresponding to-be-stored integer variable; A bitmap index creating module is configured to create a bitmap index table according to the to-be-stored integer variable and the data identification information, wherein the data state information is described by using the to-be-stored integer variable in the bitmap index table, and the bitmap index table is configured to store the to-be-stored integer variable and the data identification information. The state information determining module is further configured to, in response to a need to acquire data state information corresponding to data identification information, acquire the bitmap index table and the data identification information; extract the to-be-stored integer variable corresponding to the data identification information from the bitmap index table; determine original code data corresponding to the to-be-stored integer variable; in response to a bit width of the data state information being greater than 31 bytes, acquire a plurality of original code data corresponding to a plurality of to-be-stored integer variables; determine a plurality of sub-state information corresponding to the plurality of original code data; and splice the plurality of sub-state information to obtain the data state information.
4. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 2.
5. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 2.
6. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 2.
Citation Information
Patent Citations
Rapid storage method of routing table entry
CN102571599A
Database substring filtering index system and method for constructing and inquiring database substring filtering index system
CN102831146A