Data storage method, device, equipment and storage medium
By using different storage rules to store row data according to data attributes, the problem of wasted storage space in the existing technology is solved and more efficient data storage is achieved.
Patent Information
- Application Number
- CN202010477537.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-29
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2040-05-29
AI Technical Summary
There is a waste of storage space when storing data in the existing technology, which cannot meet the storage needs of the current database.
By obtaining the row data to be stored, its data attributes are determined, and different storage rules are used for storage according to different data attributes, including merging fixed-length attribute data, establishing null value attribute identifiers, generating compressed bitmaps, and processing variable-length attribute data. to optimize storage.
It effectively reduces the space occupied by data, avoids waste of storage space, and improves the efficiency of data storage.
Smart Images

Figure CN113742332B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more specifically, to a data storage method, a data storage device, a data storage equipment and a computer storage medium. Background Art
[0002] With the continuous development of computer technology, the amount of data is gradually increasing, and the space for storing data is becoming larger and larger.
[0003] Currently, data generated by running applications is usually stored in a database.
[0004] In the prior art, the process of storing data in a database is usually to insert the data to be stored into a row of the database. Specifically, the data to be stored is classified according to each attribute field in the row, and the classified data is inserted into the corresponding attribute field.
[0005] However, there is still a large waste of storage space in the prior art, which is insufficient to meet the current database storage requirements. Therefore, it is necessary to provide a data storage method that saves more storage space. Summary of the invention
[0006] An object of the present invention is to provide a new technical solution for data storage.
[0007] According to a first aspect of the present invention, there is provided a data storage method, comprising:
[0008] Get the row data to be stored;
[0009] Determining data attributes of the row data;
[0010] The row data is stored according to the storage rule corresponding to the data attribute, wherein different data attributes correspond to different storage rules.
[0011] Optionally, determining the data attribute of the row data includes:
[0012] Determining fixed-length attribute data included in the row data;
[0013] Storing the row data according to the storage rule corresponding to the data attribute includes:
[0014] Merge fixed-length attribute data that does not exceed the preset byte length;
[0015] The merged fixed-length attribute data and other fixed-length attribute data are stored together in the fixed-length attribute field.
[0016] Optionally, determining the data attribute of the row data further includes:
[0017] Determining the null value attribute data included in the row data;
[0018] Storing the row data according to the storage rule corresponding to the data attribute includes:
[0019] Establishing an identification of the null value attribute data;
[0020] The identifier of the null-value attribute data is added to any blank storage unit in the null-value attribute field.
[0021] Optionally, the method further comprises:
[0022] Generate a first compression bitmap according to the combined fixed-length attribute data, other fixed-length attribute data and the null-value attribute data, wherein the data in each storage unit in the first compression bitmap corresponds to at least two fixed-length attribute data and / or at least two null-value attribute data;
[0023] The first compression bitmap is stored in a compression control bitmap field.
[0024] Optionally, generating a first compressed bitmap according to the merged fixed-length attribute data, other fixed-length attribute data and the null value attribute data includes:
[0025] Obtaining a first-level compression bitmap according to the combined fixed-length attribute data, other fixed-length attribute data and the null-value attribute data;
[0026] According to the first-level compression bitmap, a second-level compression bitmap is obtained;
[0027] The first compression bitmap includes the first-level compression bitmap and the second-level compression bitmap.
[0028] Optionally, determining the data attribute of the row data further includes:
[0029] Determining variable-length attribute data included in the row data;
[0030] Storing the row data according to the storage rule corresponding to the data attribute includes:
[0031] For each of the variable-length attribute data, generate a second compressed bitmap corresponding to the variable-length attribute data, and obtain the length of the second compressed bitmap;
[0032] Determine the bytes of the specified type within the variable-length attribute data;
[0033] Remove all bytes of the specified type;
[0034] Placing the second compressed bitmap length and the compressed bitmap before the variable-length attribute data after the bytes are removed, to obtain a variable-length attribute data block corresponding to the variable-length attribute data;
[0035] According to a preset storage order, the variable-length attribute data block corresponding to each variable-length attribute data is stored in the variable-length attribute field.
[0036] Optionally, determining the data attribute of the row data further includes:
[0037] Determining variable-length attribute data included in the row data;
[0038] Storing the row data according to the storage rule corresponding to the data attribute includes:
[0039] For each variable-length attribute data, determining the bytes of a specified type and the number thereof in the tail of the variable-length attribute data;
[0040] Remove all bytes of the specified type;
[0041] Placing the number of bytes of the specified type before the variable-length attribute data after the bytes are removed, to obtain a variable-length attribute data block corresponding to the variable-length attribute data;
[0042] According to a preset storage order, the variable-length attribute data block corresponding to each variable-length attribute data is stored in the variable-length attribute field.
[0043] Optionally, the method further comprises:
[0044] Get the byte length of each variable-length attribute data after removing bytes;
[0045] Determine the offset length of each variable-length attribute data according to the byte length of each variable-length attribute data after the bytes are removed;
[0046] Counting the number of variable-length attribute data whose offset length exceeds a preset length;
[0047] Storing the offset length in a first field;
[0048] The counted quantity is stored in the second field.
[0049] According to a second aspect of the present invention, there is provided a data storage device, comprising:
[0050] An acquisition module, used to acquire row data to be stored;
[0051] A determination module, used to determine the data attribute of the row data;
[0052] The storage module is used to store the row data according to the storage rules corresponding to the data attributes, wherein different data attributes correspond to different storage rules.
[0053] According to a third aspect of the present invention, there is provided a data storage device, comprising a data storage device; or,
[0054] The device comprises: a processor and a memory;
[0055] The memory is used to store executable instructions, and the instructions are used to control the processor to execute the data storage method according to the first aspect.
[0056] According to a fourth aspect of the present invention, a computer storage medium is provided, wherein the storage medium stores computer instructions. When the computer instructions in the storage medium are executed by a processor, the data storage method described in the first aspect is implemented.
[0057] In this embodiment, different storage rules are used to store the row data according to different data attributes in the row data, which can effectively reduce the space occupied by the data and avoid the waste of storage space.
[0058] Further features and advantages of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.
[0060] Figure 1 is a block diagram of a hardware configuration of a data storage device provided by an embodiment of the present invention;
[0061] Figure 2 is a flow chart of a data storage method provided by an embodiment of the present invention;
[0062] Figure 3 is a schematic diagram of a data storage structure provided by an embodiment of the present invention;
[0063] Figure 4 is a structural schematic diagram of a data storage device provided by an embodiment of the present invention;
[0064] Figure 5 It is a structural schematic diagram of a data storage device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0065] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.
[0066] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0067] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0068] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0069] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0070] <Hardware Configuration>
[0071] Figure 1 It is a block diagram of a hardware configuration of a data storage device provided by an embodiment of the present invention.
[0072] The data storage device 1000 may be a virtual machine or a physical machine. The data storage device 1000 may include a processor 1100, a memory 1200, an interface device 1300, a communication device 1400, a display device 1500, an input device 1600, a speaker 1700, a microphone 1800, and the like. The processor 1100 may be a central processing unit CPU, a microprocessor MCU, and the like. The memory 1200 may include, for example, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, and the like. The interface device 1300 may include, for example, a USB interface, a headphone interface, and the like. The communication device 1400 may, for example, be capable of wired or wireless communication. The display device 1500 may be, for example, a liquid crystal display screen, a touch display screen, and the like. The input device 1600 may include, for example, a touch screen, a keyboard, and the like. The user may input / output voice information through the speaker 1700 and the microphone 1800.
[0073] In this embodiment, the memory 1200 is used to store computer program instructions, which are used to control the processor 1100 to operate to perform the storage method according to any embodiment of the present invention. A technician can design the instruction according to the scheme disclosed in the present invention. How the instruction controls the processor 1100 to operate is well known in the art, so it will not be described in detail here.
[0074] Despite Figure 1 In the figures, multiple devices are shown for the data storage device 1000, but the present invention may only involve some of the devices, for example, the data storage device 1000 only involves the memory 1200 and the processor 1100.
[0075] In the above description, a technician can design instructions according to the scheme disclosed in the present invention. How instructions control the processor to operate is well known in the art, so it will not be described in detail here.
[0076] <Method Example>
[0077] An embodiment of the present invention provides a data storage method, such as Figure 2 As shown, including the following:
[0078] S201: Acquire row data to be stored.
[0079] In actual applications, the data generated by running the application is usually stored in a database.
[0080] Furthermore, in the process of storing data in the embodiments of this specification, it is necessary to first obtain the row data to be stored.
[0081] It should be noted that the row data described in the embodiments of this specification include different data attributes.
[0082] S202: Determine the data attributes of the row data.
[0083] Furthermore, since the present invention uses different storage rules to store row data according to different data attributes in the row data, the embodiment of the present invention needs to determine the data attributes of the row data after acquiring the row data to be stored.
[0084] It should be noted here that the data attributes of the row data may include one data attribute or may include multiple different data attributes, and the number of data attributes may be determined according to a preset division rule.
[0085] In the embodiment of the present invention, the division rules may be as follows:
[0086] The data attributes of the row data can be divided into different data attributes according to the data type, or can be divided into different data attributes according to the storage characteristics of the data, such as dividing different data attributes according to the byte type of the data.
[0087] S203: Store the row data according to the storage rule corresponding to the data attribute.
[0088] Furthermore, after determining the data attributes of the row data, the embodiment of the present invention stores the row data according to the storage rule corresponding to each data attribute.
[0089] It should be noted here that each data attribute corresponds to a storage rule, and different data attributes have different storage rules.
[0090] In the process of storing row data, each data attribute stores the data corresponding to the data attribute according to its corresponding storage rule.
[0091] Through the above method, different storage rules are used to store row data according to different data attributes in the row data, which can effectively reduce the space occupied by the data and avoid the waste of storage space.
[0092] Furthermore, in actual applications, the storage space (i.e., the number of bytes) occupied by some attribute data when stored in the database is fixed, that is, fixed-length attribute data, such as numeric data, no matter what kind of value it is or how much the value is, the number of bytes occupied by each data value is fixed and the same. Therefore, in the embodiments of this specification, for the above-mentioned fixed-length attribute data, the space occupied by the data can be reduced in a specific way each time. That is to say, assuming that method A is used when storing row data for the first time, method A is still used when storing row data for the second time.
[0093] Based on this, in the embodiment of the present specification, after acquiring the row data to be stored, determining the data attribute of the row data may be to determine the fixed-length attribute data included in the row data.
[0094] Furthermore, since the number of bytes occupied by some fixed-length attributes is not an integer number of bytes, that is, the number of bytes occupied by some fixed-length attributes is half a byte, for example, the number of bytes occupied by an attribute value of 60 is half a byte. Such attributes are stored in one byte in the prior art, and the half byte stores the attribute value 60, and all bits corresponding to the other half byte are represented by 0. It can be seen that the storage space occupied by the attribute value 60 is a complete byte as a whole. Therefore, in the embodiments of this specification, for fixed-length attribute data, fixed-length attributes that are not an integer number of bytes can be merged. For example, assuming that the attribute value of attribute A occupies half a byte, and the attribute value of data B also occupies half a byte, attribute A and attribute B are merged together and stored in the same byte. For example, the name of attribute 1 is "gender" and the attribute value is "male", and the name of attribute 2 is "score" and the attribute value is "60". Attribute 1 and attribute 2 can be merged into one byte.
[0095] Based on this, in the embodiment of this specification, after determining the fixed-length attribute data included in the row data, the row data may be stored using the following storage rules for the fixed-length attribute data, specifically:
[0096] The fixed-length attribute data that does not exceed the preset byte length are merged, and the merged fixed-length attribute data and other fixed-length attribute data are stored together in the fixed-length attribute field.
[0097] It should be noted here that the preset byte length can be one byte, two bytes, or multiple bytes, and can be set according to actual conditions.
[0098] Further, after merging the fixed-length attribute data that does not exceed the preset byte length, in the embodiment of the present specification, for other fixed-length attribute data, the other fixed-length attribute data can be sorted from large to small according to the length of the storage space occupied, and for the fixed-length attribute data with the same length, they are arranged according to the original arrangement order of the attributes, and finally, the sorted other fixed-length attribute data and the merged fixed-length attribute data are stored together in a storage medium such as Figure 3 In the fixed-length attribute field shown, Figure 3 A new data storage structure is provided in the embodiments of this specification.
[0099] Through the above method, fixed-length attribute data that does not exceed the preset byte length is merged and stored in the fixed-length attribute field, which effectively reduces the space occupied by the data and avoids the waste of storage space.
[0100] Furthermore, in actual applications, some attribute data are empty and do not record any data. Therefore, after obtaining the row data to be stored, determining the data attributes of the row data can be to determine the empty value attribute data included in the row data.
[0101] For null value attribute data, the following storage rules can be used to store the row data, specifically:
[0102] Establish the identifier of the null value attribute data, and add the identifier of the null value attribute data to the Figure 3 Any blank storage cell in the empty attribute field shown.
[0103] It should be noted here that a blank storage unit can be a bit or a byte. For example, a storage unit in a null value attribute field records the identifier of a null value attribute data, that is, a storage unit in a null value attribute field represents an attribute.
[0104] Furthermore, in actual applications, the storage space (i.e., the number of bytes) occupied by some attributes and some attribute data when stored in the database changes with different attribute values, that is, variable-length attribute data, such as character data. Therefore, in the embodiments of the present specification, the space occupied by the above-mentioned variable-length attribute data can also be reduced in a specific manner each time. That is to say, assuming that method A is used when storing row data for the first time, method A is still used when storing row data for the second time.
[0105] Based on this, in the embodiment of the present specification, after acquiring the row data to be stored, determining the data attribute of the row data may be to determine the variable-length attribute data included in the row data.
[0106] It should be noted that, in the embodiments of this specification, for variable-length attribute data, the following two storage rules may be used to store the row data, specifically:
[0107] The first method is: for each variable-length attribute data, generate a second compressed bitmap corresponding to the variable-length attribute data, and obtain the length of the second compressed bitmap; determine the bytes of the specified type in the variable-length attribute data; remove all the bytes of the specified type; place the second compressed bitmap length and the compressed bitmap before the variable-length attribute data after the bytes are removed, and obtain the variable-length attribute data block corresponding to the variable-length attribute data; store the variable-length attribute data block corresponding to each variable-length attribute data in a preset storage order. Figure 3 The variable-length attribute field is shown.
[0108] It should be noted that the byte of the specified type can be 0 bytes. The data in each storage unit of the generated second compressed bitmap corresponds to at least two bytes in the variable-length attribute data before the byte of the specified type is removed. The order of the data stored in the variable-length attribute data block is: the length of the second compressed bitmap is located before the second compressed bitmap, and the second compressed bitmap is located before the variable-length attribute data after the byte is removed. The preset storage order is the storage order between the variable-length attribute data, which describes the storage relationship between each variable-length attribute data block.
[0109] The second method: for each of the variable-length attribute data, determine the bytes of the specified type and their quantity in the tail of the variable-length attribute data; remove all the bytes of the specified type; place the number of bytes of the specified type in front of the variable-length attribute data after the bytes are removed to obtain the variable-length attribute data block corresponding to the variable-length attribute data; store the variable-length attribute data block corresponding to each variable-length attribute data in the variable-length attribute field according to a preset storage order.
[0110] It should be noted that the bytes of the specified type in the tail of the variable-length attribute data refer to the bytes of the specified type that are continuously repeated at the tail of the variable-length attribute data. For example, assuming that the byte of the specified type is 0 and the variable-length attribute data is aafa0000, then 0000 is the last consecutive byte of the specified type in the variable-length attribute data. The number of bytes of the specified type in the tail of the variable-length attribute data is stored in the variable-length attribute field so that the variable-length attribute data before the bytes are removed can be restored when the user accesses the variable-length attribute. The order of the data stored in the variable-length attribute data block is: the number of bytes of the specified type is located before the variable-length attribute data after the bytes are removed. The preset storage order is the storage order between the variable-length attribute data, which describes the storage relationship between each variable-length attribute data block.
[0111] Furthermore, since after the variable-length attribute data is compressed by the above two storage rules and stored in the variable-length attribute field, the position of each variable-length attribute data in the variable-length attribute field needs to be known in the subsequent access process, therefore, in the embodiment of the present specification, the byte length of each variable-length attribute data after the bytes are removed is obtained, and the offset length of each variable-length attribute data is determined according to the byte length of each variable-length attribute data after the bytes are removed, and the offset length is stored in the variable-length attribute field as shown in FIG. Figure 3 In the first field shown, subsequently, in the process of accessing the variable-length attribute data in the variable-length attribute field, if you want to access a certain variable-length attribute data, you can directly obtain the offset length of the variable-length attribute data from the first field, and search for the variable-length attribute data in the variable-length attribute field based on the offset length of the variable-length attribute data.
[0112] It should be noted here that, according to the byte length of each variable-length attribute data after bytes are removed, the offset length of the variable-length attribute data can be determined specifically by determining the offset length of each variable-length attribute data from back to front according to the arrangement order of the variable-length attribute data stored in the variable-length attribute field, wherein the offset length of each variable-length attribute data is the sum of the byte lengths of each variable-length attribute data after bytes are removed that follows the variable-length attribute data.
[0113] It should also be noted here that the offset length of the variable-length attribute data refers to the length of the variable-length attribute data from the end of the variable-length attribute field.
[0114] In addition, the variable-length attribute data stored in the variable-length attribute field is stored in the original order, wherein the original order refers to the storage order of the variable-length attribute data in the prior art. According to the storage order of the variable-length attribute data in the variable-length attribute field, the offset length corresponding to the variable-length attribute is stored in the first field, and an offset length exceeding a certain value will occupy two bytes when stored, that is, a double-byte offset, and an offset length below a certain value will occupy one byte when stored, that is, a single-byte offset.
[0115] Furthermore, although the offset length is stored in the first field according to the storage order of the variable-length attribute data in the variable-length attribute field, and the offset length exceeding a certain value will occupy two bytes when stored, that is, a double-byte offset, and the offset length below a certain value will occupy one byte when stored, that is, a single-byte offset, but it is not known which offset length in the first field occupies two bytes and which offset length occupies one byte. Therefore, in the embodiment of the present specification, if you want to accurately find the offset length corresponding to each variable-length attribute data, you can count the number of variable-length attribute data whose offset length exceeds the preset length, and store the counted number in a file such as Figure 3 In the second field shown, in the subsequent process of accessing the variable-length attribute data in the variable-length attribute field, if you want to obtain the offset length of a variable-length attribute data from the first field, you can determine the offset length of the variable-length attribute data to be accessed based on the number stored in the second field and the order of the offset lengths of the variable-length attribute data in the first field.
[0116] According to the offset length of the variable-length attribute data, the variable-length attribute data is searched in the variable-length attribute field.
[0117] It should be noted here that the preset length can be two bytes.
[0118] It should also be noted that, in the prior art, when accessing certain attribute data based on the storage structure of the prior art, it is necessary to parse the entire row data after storage into each individual attribute data, and then search for the attribute data to be accessed from the parsed attribute data, while the present invention determines the offset length of each variable-length attribute data according to the byte length of each variable-length attribute data after removing bytes, counts the number of variable-length attribute data whose offset length exceeds a preset length, stores the offset length in the first field, and stores the counted number in the second field. When accessing certain attribute data subsequently, it is only necessary to determine the offset length of the variable-length attribute data to be accessed based on the number stored in the second field and the sorting of the offset lengths of the variable-length attribute data in the first field, and then obtain the offset length in the first field. Finally, the attribute data to be accessed is directly searched in the variable-length attribute field based on the offset length, thereby greatly improving the speed at which users access attribute data.
[0119] Furthermore, the above-mentioned improvement in the speed of user access to attribute data is mainly for variable-length attribute data. In the embodiments of this specification, the speed of user access to attribute data can also be improved for fixed-length attribute data and null-value attribute data in the following manner.
[0120] Specifically, a first compressed bitmap is generated according to the merged fixed-length attribute data, other fixed-length attribute data and the null-value attribute data, wherein the data in each storage unit in the first compressed bitmap corresponds to at least two fixed-length attribute data and / or at least two null-value attribute data, and the first compressed bitmap is stored in a Figure 3 The Compression Control Bitmap field is shown.
[0121] It should be noted here that a first compressed bitmap is generated based on the merged fixed-length attribute data, other fixed-length attribute data and the null value attribute data. Specifically, a compression algorithm (such as a bitmap algorithm) can be used to compress the merged fixed-length attribute data, other fixed-length attribute data and the null value attribute data to generate the first compressed bitmap.
[0122] The data in each storage unit in the first compression bitmap corresponds to at least two fixed-length attribute data and / or at least two null value attribute data, which means that assuming one byte of data is stored in a storage unit in the first compression bitmap, the one byte of data is equivalent to eight bytes of data in the fixed-length attribute field or the null value attribute data.
[0123] In addition, the generated first compression bitmap can be a multi-level compression bitmap, each level of compression bitmap is generated based on the previous level of compression bitmap, and the storage units of each level of compression bitmap correspond to multiple storage units of the previous level of compression bitmap, that is, each level of compression bitmap is an index of the previous level of compression bitmap, such as generating a two-level compression bitmap, that is, a first-level compression bitmap and a second-level compression bitmap, wherein the second level compression is generated based on the first-level compression bitmap, one byte of data in the first-level compression bitmap corresponds to eight bytes of data in the fixed-length attribute field, and one double-byte of data in the second-level compression bitmap corresponds to four bytes or eight bytes of data in the first-level compression bitmap.
[0124] Based on this, an embodiment of the present invention provides an implementation method for generating a first compressed bitmap according to the merged fixed-length attribute data, other fixed-length attribute data and the null value attribute data, which is specifically as follows:
[0125] A first-level compression bitmap is obtained based on the merged fixed-length attribute data, other fixed-length attribute data and the null value attribute data, and a second-level compression bitmap is obtained based on the first-level compression bitmap, wherein the first compression bitmap includes the first-level compression bitmap and the second-level compression bitmap.
[0126] Through the above implementation, by means of multi-level compression bitmaps, a multi-level index is established, which can greatly improve the speed at which users access attribute data.
[0127] <Device Example>
[0128] like Figure 4 As shown, this embodiment also provides a data storage device, the device comprising:
[0129] The acquisition module 401 is used to acquire the row data to be stored;
[0130] A determination module 402, configured to determine a data attribute of the row data;
[0131] The storage module 403 is used to store the row data according to the storage rules corresponding to the data attributes, wherein different data attributes correspond to different storage rules.
[0132] The determination module 402 is specifically used to determine the fixed-length attribute data included in the row data; the storage module 403 is specifically used to merge the fixed-length attribute data that does not exceed the preset byte length; and store the merged fixed-length attribute data and other fixed-length attribute data together in the fixed-length attribute field.
[0133] The determination module 402 is specifically used to determine the null value attribute data included in the row data; the storage module 403 is specifically used to establish an identifier of the null value attribute data; and add the identifier of the null value attribute data to any blank storage unit in the null value attribute field.
[0134] The device also includes:
[0135] The compression bitmap establishment module 404 is used to generate a first compression bitmap based on the merged fixed-length attribute data, other fixed-length attribute data and the null value attribute data, wherein the data in each storage unit in the first compression bitmap corresponds to at least two fixed-length attribute data and / or at least two null value attribute data; and store the first compression bitmap in the compression control bitmap field.
[0136] The compression bitmap establishment module 404 is specifically used to obtain a first-level compression bitmap based on the merged fixed-length attribute data, other fixed-length attribute data and the null value attribute data; obtain a second-level compression bitmap based on the first-level compression bitmap; wherein the first compression bitmap includes the first-level compression bitmap and the second-level compression bitmap.
[0137] The determination module 402 is specifically used to determine the variable-length attribute data included in the row data; the storage module 403 is specifically used to generate a second compression bitmap corresponding to each variable-length attribute data, and obtain the length of the second compression bitmap; determine the bytes of a specified type in the variable-length attribute data; remove all bytes of the specified type; place the second compression bitmap length and the compression bitmap before the variable-length attribute data after the bytes are removed to obtain a variable-length attribute data block corresponding to the variable-length attribute data; store the variable-length attribute data block corresponding to each variable-length attribute data in the variable-length attribute field according to a preset storage order.
[0138] The determination module 402 is specifically used to determine the variable-length attribute data included in the row data; the storage module 403 is specifically used to, for each of the variable-length attribute data, determine the bytes of a specified type and their quantity in the tail of the variable-length attribute data; remove all bytes of the specified type; place the number of bytes of the specified type before the variable-length attribute data after the bytes are removed to obtain a variable-length attribute data block corresponding to the variable-length attribute data; and store the variable-length attribute data block corresponding to each variable-length attribute data in the variable-length attribute field according to a preset storage order.
[0139] The device also includes:
[0140] The offset length storage module 405 is used to obtain the byte length of each variable-length attribute data after bytes are removed; determine the offset length of each variable-length attribute data according to the byte length of each variable-length attribute data after bytes are removed; count the number of variable-length attribute data whose offset length exceeds the preset length; store the offset length in the first field; and store the counted number in the second field.
[0141] <Equipment Embodiment>
[0142] The embodiment of the present invention also provides a data storage device, such as Figure 5 As shown, the data storage device includes the data storage device in the above-mentioned device embodiment.
[0143] Alternatively, the data storage device includes a memory 501 and a processor 502. The memory is used to store executable instructions, and the instructions are used to control the processor to execute the method according to any one of the above method embodiments.
[0144] <Computer Storage Media>
[0145] The present invention also provides a computer storage medium, wherein the storage medium stores computer instructions. When the computer instructions in the storage medium are executed by a processor, the method described in any one of the above method embodiments is implemented.
[0146] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0147] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0148] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0149] The computer program instructions for performing the operation of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present invention.
[0150] Various aspects of the present invention are described herein with reference to the flow charts and / or block diagrams of the methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each box of the flow chart and / or block diagram and the combination of each box in the flow chart and / or block diagram can be implemented by computer-readable program instructions.
[0151] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0152] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0153] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a part of a module, a program segment or an instruction, and a part of the module, a program segment or an instruction contains one or more executable instructions for realizing the specified logical function. 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 consecutive boxes 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 by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.
[0154] Embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present invention is defined by the appended claims.
Claims
1. A data storage method, characterized in that: The method comprises: Get the row data to be stored; Determining data attributes of the row data; storing the row data in a data storage structure according to a storage rule corresponding to the data attribute, wherein different data attributes correspond to different storage rules; The data attributes include fixed-length attributes, null-value attributes, and variable-length attributes; The data storage structure includes, in sequence, a second field, a first field, a compression control bitmap field, a fixed-length attribute field, a null-value attribute field, and a variable-length attribute field; The first field stores the offset length of each variable-length attribute data, and the offset length is the sum of the byte lengths of each variable-length attribute data after the variable-length attribute data is removed according to the arrangement order of the variable-length attribute data stored in the variable-length attribute field; The second field stores the number of variable-length attribute data whose offset length exceeds a preset length; When accessing certain variable-length attribute data subsequently, it is only necessary to determine the offset length of the variable-length attribute data to be accessed based on the quantity stored in the second field and the sorting of the offset lengths of the variable-length attribute data in the first field, and then obtain the offset length from the first field. Finally, the variable-length attribute data to be accessed is directly found in the variable-length attribute field based on the offset length.
2. The method according to claim 1, characterized in that: Determining data attributes of the row data includes: Determining fixed-length attribute data included in the row data; Storing the row data according to the storage rule corresponding to the data attribute includes: Merge fixed-length attribute data that does not exceed the preset byte length; The merged fixed-length attribute data and other fixed-length attribute data are stored together in the fixed-length attribute field.
3. The method according to claim 2, characterized in that Determining the data attribute of the row data further includes: Determining the null value attribute data included in the row data; Storing the row data according to the storage rule corresponding to the data attribute includes: Establishing an identification of the null value attribute data; The identifier of the null-value attribute data is added to any blank storage unit in the null-value attribute field.
4. The method according to claim 3, characterized in that The method further comprises: Generate a first compression bitmap according to the combined fixed-length attribute data, other fixed-length attribute data and the null-value attribute data, wherein the data in each storage unit in the first compression bitmap corresponds to at least two fixed-length attribute data and / or at least two null-value attribute data; The first compression bitmap is stored in a compression control bitmap field.
5. The method according to claim 4, characterized in that Generate a first compressed bitmap according to the merged fixed-length attribute data, other fixed-length attribute data and the null value attribute data, including: Obtaining a first-level compression bitmap according to the combined fixed-length attribute data, other fixed-length attribute data and the null-value attribute data; According to the first-level compression bitmap, a second-level compression bitmap is obtained; The first compression bitmap includes the first-level compression bitmap and the second-level compression bitmap.
6. The method according to claim 1, characterized in that Determining the data attribute of the row data further includes: Determining variable-length attribute data included in the row data; Storing the row data according to the storage rule corresponding to the data attribute includes: For each of the variable-length attribute data, generate a second compressed bitmap corresponding to the variable-length attribute data, and obtain the length of the second compressed bitmap; Determine the specified type of characters in the variable-length attribute data; Remove all characters of the specified type; Placing the second compressed bitmap length and the compressed bitmap before the variable-length attribute data after the characters are removed, to obtain a variable-length attribute data block corresponding to the variable-length attribute data; According to a preset storage order, the variable-length attribute data block corresponding to each variable-length attribute data is stored in the variable-length attribute field.
7. The method according to claim 1, characterized in that Determining the data attribute of the row data further includes: Determining variable-length attribute data included in the row data; Storing the row data according to the storage rule corresponding to the data attribute includes: For each of the variable-length attribute data, determining the characters of a specified type and the number thereof in the tail of the variable-length attribute data; Remove all characters of the specified type; Placing the number of characters of the specified type before the variable-length attribute data after the characters are removed, to obtain a variable-length attribute data block corresponding to the variable-length attribute data; According to a preset storage order, the variable-length attribute data block corresponding to each variable-length attribute data is stored in the variable-length attribute field.
8. The method according to claim 6 or 7, characterized in that: The method further comprises: Get the character length of each variable-length attribute data after removing the characters; Determine the offset length of each variable-length attribute data according to the character length of each variable-length attribute data after the characters are removed; Counting the number of variable-length attribute data whose offset length exceeds a preset length; Storing the offset length in a first field; The counted quantity is stored in the second field.
9. A data storage device, characterized in that: include: An acquisition module, used to acquire row data to be stored; A determination module, used to determine the data attribute of the row data; A storage module, used for storing the row data in a data storage structure according to a storage rule corresponding to the data attribute, wherein different data attributes correspond to different storage rules; The data attributes include fixed-length attributes, null-value attributes, and variable-length attributes; The data storage structure includes, in sequence, a second field, a first field, a compression control bitmap field, a fixed-length attribute field, a null-value attribute field, and a variable-length attribute field; The first field stores the offset length of each variable-length attribute data, and the offset length is the sum of the byte lengths of each variable-length attribute data after the variable-length attribute data is removed according to the arrangement order of the variable-length attribute data stored in the variable-length attribute field; The second field stores the number of variable-length attribute data whose offset length exceeds a preset length; When accessing certain variable-length attribute data subsequently, it is only necessary to determine the offset length of the variable-length attribute data to be accessed based on the quantity stored in the second field and the sorting of the offset lengths of the variable-length attribute data in the first field, and then obtain the offset length from the first field. Finally, the variable-length attribute data to be accessed is directly found in the variable-length attribute field based on the offset length.
10. A data storage device, characterized in that: include: Processor and memory; The memory is used to store executable instructions, and the instructions are used to control the processor to execute the method according to any one of claims 1-8.
11. A computer storage medium, characterized in that: The storage medium stores computer instructions. When the computer instructions in the storage medium are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
