Index creation methods, apparatus and storage media
By dividing the database data range into multiple index tuples, the problem of large storage space consumption during index creation is solved, and more efficient queries are achieved.
Patent Information
- Application Number
- CN202211656559.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-22
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2042-12-22
AI Technical Summary
General-purpose indexing techniques tend to consume a large amount of storage space when creating indexes, and their query efficiency is relatively low.
By dividing the storage area of the target data into multiple data ranges and creating index tuples that correspond one-to-one with the data ranges, the index size is reduced and the storage space usage is decreased.
This effectively reduces the storage space occupied by the index and improves query efficiency.
Smart Images

Figure CN116226118B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and in particular relates to an index creation method, apparatus and storage medium. Background Technology
[0002] Currently, when storing data in a database, indexes are typically created to facilitate fast data retrieval. However, common indexing techniques can consume significant storage space when dealing with large datasets. For example, multi-way search tree indexes generally use linked lists, which require substantial storage and consume numerous input / output channels during data retrieval, resulting in low efficiency. Summary of the Invention
[0003] This application provides an index creation method, apparatus, and storage medium to solve the technical problem that indexes created using general techniques tend to occupy a large amount of storage space.
[0004] To achieve the above objectives, this application adopts the following technical solution:
[0005] Firstly, an index creation method is provided, comprising: obtaining a storage range of target data; the target data includes multiple data tuples; the storage range includes data block information corresponding to the multiple data tuples; dividing the storage range into multiple data intervals; each data interval includes a preset number of data blocks; creating multiple index tuples that correspond one-to-one with the multiple data intervals; and using the multiple index tuples to form an index corresponding to the target data.
[0006] Optionally, after creating multiple index tuples that correspond one-to-one with multiple data ranges, the index creation method further includes: receiving a query request message carrying query conditions; identifying the index tuples that correspond to the query conditions among the multiple index tuples as the target index tuple; adding the data range corresponding to the target index tuple to the data bitmap; and determining the data tuples that correspond to the query conditions based on the data bitmap.
[0007] Optionally, the method for determining the target index tuple from multiple index tuples that corresponds to the query conditions specifically includes: determining the scan information corresponding to the query conditions; and scanning multiple index tuples based on the scan information to obtain the target index tuple.
[0008] Optionally, after creating multiple index tuples that correspond one-to-one with multiple data ranges, the index creation method further includes: when there is updated data in the target data, creating an index tuple to be updated corresponding to the updated data; and updating the index tuple to be updated in the index corresponding to the target data.
[0009] Secondly, an index creation apparatus is provided, comprising: an acquisition unit and a processing unit;
[0010] The acquisition unit is used to acquire the storage area of the target data; the target data includes multiple data tuples; the storage area includes data block information corresponding to the multiple data tuples.
[0011] The processing unit is used to divide the storage area obtained by the acquisition unit into multiple data areas; each data area includes a preset number of data blocks.
[0012] The processing unit is also used to create multiple index tuples that correspond one-to-one with multiple data ranges; the multiple index tuples are used to form an index corresponding to the target data.
[0013] Optionally, the acquisition unit is also used to receive a query request message carrying query conditions;
[0014] The processing unit is also used to determine the index tuple that corresponds to the query conditions among multiple index tuples as the target index tuple;
[0015] The processing unit is also used to add the data range corresponding to the target index tuple to the data bitmap;
[0016] The processing unit is also used to determine the data tuples corresponding to the query conditions based on the data bitmap.
[0017] Optionally, the processing unit is specifically used for:
[0018] Determine the scan information corresponding to the query conditions;
[0019] The target index tuple is obtained by scanning multiple index tuples based on the scanning information.
[0020] Optionally, the processing unit is also configured to create an index tuple to be updated corresponding to the updated data when there is updated data in the target data;
[0021] The processing unit is also used to update the index tuple to be updated in the index corresponding to the target data.
[0022] Thirdly, an index creation apparatus is provided, including a memory and a processor; the memory is used to store computer-executable instructions, and the processor is connected to the memory via a bus; when the index creation apparatus is running, the processor executes the computer-executable instructions stored in the memory to cause the index creation apparatus to perform the index creation method as described in the first aspect.
[0023] The index creation apparatus may be a network device or a component of a network device, such as a chip system within the network device. The chip system supports the network device in implementing the functions involved in the first aspect and any possible implementation thereof, such as receiving, determining, and routing the data and / or information involved in the aforementioned index creation method. The chip system includes a chip, but may also include other discrete devices or circuit structures.
[0024] Fourthly, a computer-readable storage medium is provided, including computer-executable instructions that, when executed on a computer, cause the computer to perform an index creation method as described in the first aspect.
[0025] It should be noted that the aforementioned computer instructions may be stored, in whole or in part, on the first computer-readable storage medium. The first computer-readable storage medium may be packaged together with the processor of the indexing device, or it may be packaged separately from the processor of the indexing device; this application does not impose any limitations on this.
[0026] In this application, the name of the aforementioned index creation apparatus does not limit the device or functional module itself. In actual implementation, these devices or functional modules may appear under other names. As long as the function of each device or functional module is similar to that of this application, it falls within the scope of the claims of this application and its equivalents.
[0027] These or other aspects of this application will become more readily apparent in the following description.
[0028] The technical solution provided in this application brings at least the following beneficial effects:
[0029] Based on any of the above aspects, in this application, the index creation device can obtain the storage range of the target data and divide the storage range into multiple data ranges, thereby further creating multiple index tuples that correspond one-to-one with the multiple data ranges, thus obtaining an index corresponding to the target data. Since the data range corresponding to one index tuple can include multiple data blocks, this application, by establishing index tuples through data ranges, only needs to store the maximum and minimum value information at both ends of each consecutive set of data blocks, thereby reducing the size of the index and lowering the storage space occupied. Therefore, this application can be used to solve the technical problem that general technologies tend to occupy a large amount of storage space when creating indexes. Attached Figure Description
[0030] Figure 1 This is a schematic diagram of the structure of an index creation system provided in an embodiment of this application;
[0031] Figure 2 A schematic diagram of the hardware structure of an index creation device provided in an embodiment of this application;
[0032] Figure 3 A flowchart illustrating an index creation method provided in this application embodiment. Figure 1 ;
[0033] Figure 4 A schematic diagram of a function execution process provided in this application embodiment. Figure 1 ;
[0034] Figure 5 This application provides a schematic diagram of the structure of a data range as an embodiment.
[0035] Figure 6 A schematic diagram of a function execution process provided in this application embodiment. Figure 2 ;
[0036] Figure 7 A schematic diagram of the structure of an index provided in an embodiment of this application;
[0037] Figure 8 This is a schematic diagram of the structure of a range mapping page provided in an embodiment of this application;
[0038] Figure 9 This is a schematic diagram of the structure of an index tuple provided in an embodiment of this application;
[0039] Figure 10 A flowchart illustrating an index creation method provided in this application embodiment. Figure 2 ;
[0040] Figure 11 A schematic diagram of a function execution process provided in this application embodiment. Figure 3 ;
[0041] Figure 12 A flowchart illustrating an index creation method provided in this application embodiment. Figure 3 ;
[0042] Figure 13 A schematic diagram of a function execution process provided in this application embodiment. Figure 4 ;
[0043] Figure 14 A flowchart illustrating an index creation method provided in this application embodiment. Figure 4 ;
[0044] Figure 15 A schematic diagram of a function execution process provided in this application embodiment. Figure 5 ;
[0045] Figure 16 This is a schematic diagram of the structure of an index creation device provided in an embodiment of this application. Detailed Implementation
[0046] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0047] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0048] To facilitate a clear description of the technical solutions of the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish the same or similar items with essentially the same function and effect. Those skilled in the art can understand that the terms "first" and "second" are not intended to limit the quantity or execution order.
[0049] Furthermore, the terms "comprising" and "having" in the embodiments, claims, and drawings of this application are not exclusive. For example, a process, method, system, product, or device that includes a series of steps or modules is not limited to the listed steps or modules, but may also include steps or modules not listed.
[0050] To facilitate understanding of this application, the relevant elements involved in this application are described below.
[0051] Database technology is the study of the fundamental theories and implementation methods of database structure, storage, design, management, and application, and the use of these theories to process, analyze, and understand data within databases. Database technology specifically includes relational database technology and non-relational database technology. Examples include relational database technologies such as MySQL, PostgreSQL, and Oracle, and non-relational database technologies such as Redis (remote dictionary server) and MongoDB.
[0052] Indexing technology refers to establishing the logical order of tuples based on certain key attributes or expressions in a data table, storing this logical order in an index file. An index is a list of identifiers for a series of table tuples; it does not change the physical order of the tuples in the table and can be used to achieve fast access to tuples. The base table is the table being indexed.
[0053] Indexing methods include unique indexes, primary key indexes, multi-attribute indexes, partial indexes, and expression indexes. Under a unique index, multiple tuples with the same index value are not allowed. Under a primary key index, if a primary key attribute is defined on a table, a unique index is created on that attribute to implement the primary key constraint. A primary key index is a special type of unique index. A multi-attribute index is an index defined on multiple attributes, used for combined queries. A partial index is an index built on a subset of a table. This subset is defined by a conditional expression. The conditional expression can be considered the predicate of the partial index. A partial index only includes tuples in the table that satisfy this predicate. Expression indexes can be built on a function or on a title expression calculated from one or more attributes of a table.
[0054] Index types include B-trees, hash indexes, and generalized inverted indexes (GINs). B-tree indexes use a B+ tree-like structure to store data keys, enabling fast index lookups. B-tree indexes support comparison queries and range queries. Hash indexes use a hash function to hash the index keys. Hash indexes typically handle simple equality comparisons. GIN indexes can be used to handle values containing multiple keys (such as arrays).
[0055] A heap table refers to a table that uses row-based storage and stores tuples in an unordered manner.
[0056] Currently, when storing data in a database, indexes are typically created to facilitate fast data retrieval. However, common indexing techniques can consume significant storage space when dealing with large datasets, and are inefficient when querying data stored in a dispersed manner. For example, multi-way search tree indexes generally use linked lists, which consume considerable storage space and tend to require numerous input and output channels, resulting in low efficiency.
[0057] To address the aforementioned problems, this application provides an index creation method. In this method, the index creation device can obtain the storage range of the target data and divide the storage range into multiple data intervals. This allows for the creation of multiple index tuples that correspond one-to-one with each data interval, resulting in an index corresponding to the target data. Since a data interval corresponding to one index tuple can include multiple data blocks, this application uses data intervals to create index tuples, enabling the storage of maximum and minimum value information at both ends of each consecutive data block. This reduces the size of the index and lowers storage space usage. Therefore, this application can solve the technical problem of general techniques consuming large amounts of storage space when creating indexes.
[0058] This index creation method is applicable to index creation systems. Figure 1 This illustrates one structure of the index creation system 100. For example... Figure 1 As shown, the index creation system 100 includes an electronic device 101 and an index creation device 102. The electronic device 101 and the index creation device 102 can be communicatively connected.
[0059] In practical applications, the index creation device 102 can also communicate with multiple electronic devices 101.
[0060] For ease of understanding, this application uses the communication connection between an index creation device 102 and an electronic device 101 as an example for illustration.
[0061] Figure 1 The electronic device 101 can be configured with functional modules such as a data processing module and a data transmission module. The data processing module can be used to generate or edit various types of data. The data transmission module can be used to send various types of data to the index creation device 102.
[0062] Optionally, Figure 1 The electronic device 101 can be a terminal, a server, or other electronic devices with data processing and data editing functions.
[0063] Optionally, when Figure 1 When the electronic device 101 is a terminal, the terminal 101 can be a device that provides voice and / or data connectivity to a user, a handheld device with wireless connectivity, or other processing devices connected to a wireless modem. The wireless terminal can communicate with one or more core networks via a radio access network (RAN). The wireless terminal can be a mobile terminal, such as a computer with a mobile terminal, or a portable, pocket-sized, handheld, or computer-embedded mobile device that exchanges voice and / or data with the radio access network, such as a mobile phone, tablet computer, laptop computer, netbook, or personal digital assistant (PDA). This application does not impose any limitations on this.
[0064] Figure 1 The index creation device 102 can be a database. This database can be configured with functional modules such as a storage module and an index creation module. The storage module can be used to store various types of data. The index creation module can be used to create indexes for these various types of data.
[0065] Optionally, the index creation module configured in the index creation device 102 can be implemented based on a block range index (BRIN). The index creation module can be pre-configured with various resource files such as functions and operators for creating indexes.
[0066] Specifically, to manage various types of indexing, the database system defines relevant system tables for recording index-related information. The access method (AM) system table in the index creation module can be pre-configured with tuples corresponding to BRIN indexes, used to record the access functions and characteristic information of the BRIN indexes. The access functions can reference functions already registered in the PROC system table. Characteristic information indicates some characteristics of the index, such as whether it supports multi-attribute indexes.
[0067] Furthermore, the OPCLASS and OPFAMILY system tables in the index creation module can be pre-configured with the operator classes related to the data types supported by BRIN indexes, as well as the operator sets to which the operators belong. The OPCLASS system table manages the data types that each type of index operates on and indicates the set of operations that the indexing method needs to use when operating on specific data types. A tuple in the OPFAMILY system table defines a set of operators. In the OPCLASS system table, each operator class references a tuple in the OPFAMILY system table, indicating the set of operators for that operator class.
[0068] Furthermore, the AMOP and AMPROC system tables in the index creation module can be pre-configured with the mapping between the relevant operators and functions for the data types supported by the BRIN index and the sets of index operators. In the database system, the specific operation function information for various data types using the indexing method is stored in the AMOP and AMPROC system tables. The AMOP system table stores the association information between each set of index operators and the specific operators. If an operator belongs to a set in the OPFAMILY system table, a tuple is created in the AMOP system table to record this mapping. The AMPROC system table stores the association information between each set of index operators and the associated supporting procedures or functions. If a function in the PROC system table belongs to an operator set in the OPFAMILY system table, a tuple is created in the AMPROC system table to record this mapping.
[0069] Optionally, Figure 1 The index creation device 102 in the middle can be a server. When Figure 1When the electronic device 101 is a server, both the electronic device 101 and the index creation device 102 can be a single server, or a server cluster consisting of multiple servers. In some embodiments, the server cluster can also be a distributed cluster. This application does not impose any limitations on this.
[0070] like Figure 2 The diagram shown illustrates a hardware structure of an index creation device 102 provided in an embodiment of this application. The index creation device 102 includes a processor 21, a memory 22, a communication interface 23, and a bus 24. The processor 21, memory 22, and communication interface 23 are connected via the bus 24.
[0071] Processor 21 is the control center of index creation device 102. It can be a single processor or a collective term for multiple processing elements. For example, processor 21 can be a CPU or other general-purpose processors. Among them, general-purpose processors can be microprocessors or any conventional processors.
[0072] As one embodiment, processor 21 may include one or more CPUs, for example Figure 2 CPU0 and CPU1 are shown in the diagram.
[0073] The memory 22 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.
[0074] In one possible implementation, the memory 22 can exist independently of the processor 21. The memory 22 can be connected to the processor 21 via a bus 24 and is used to store instructions or program code. When the processor 21 calls and executes the instructions or program code stored in the memory 22, it can implement the index creation method provided in the following embodiments of this application.
[0075] In another possible implementation, the memory 22 can also be integrated with the processor 21.
[0076] Communication interface 23 is used for the index creation device 102 to connect with other devices via a communication network, which may be Ethernet, wireless access network, wireless local area network (WLAN), etc. Communication interface 23 may include a receiving unit for receiving data and a sending unit for sending data.
[0077] Bus 24 can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 2 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0078] It should be pointed out that, Figure 2 The structure shown does not constitute a limitation on the index creation device 102, except... Figure 2 In addition to the components shown, the index creation device 102 may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0079] like Figure 3 The diagram shown is a flowchart illustrating an index creation method provided in an embodiment of this application. This index creation method is applied to... Figure 1 The index creation device 102 in the index creation system 100 shown. The index creation method includes: S301-S303.
[0080] S301, The index creation device obtains the storage area of the target data.
[0081] The target data consists of multiple data tuples. The storage area includes data block information corresponding to each of the multiple data tuples, that is, multiple data block information that corresponds one-to-one with each of the multiple data tuples.
[0082] In one possible approach, the target data can be data used to record specific business information. This specific business information could be food delivery order information, online store order information, or logistics and delivery information, etc. The target data can be a single data table or multiple data tables. When the target data is a single data table, the multiple data tuples included in the target data constitute that single data table. When the target data comprises multiple data tables, the multiple data tuples included in the target data can each belong to one of those multiple data tables.
[0083] In one possible approach, a data tuple can occupy one data block or multiple data blocks.
[0084] In one possible approach, combining Figure 1 When an electronic device needs to store target data in an indexing device, it can send the target data to the indexing device. Correspondingly, the indexing device can receive the target data sent by the electronic device and store it using its configured storage module. In this case, the indexing device can obtain the storage range of the target data to create an index corresponding to the target data, thereby enabling rapid retrieval of the target data when needed.
[0085] In one possible approach, the index creation device can be pre-configured with summary functions. These summary functions can be used to summarize a range of specified data (e.g., target data), determining the minimum and maximum page ranges for each data tuple within the specified data to generate corresponding storage intervals. Based on this, the index creation device can invoke the summary functions to obtain the storage intervals for the target data.
[0086] In one possible example, such as Figure 4 The diagram illustrates the execution process of a summary function according to an embodiment of this application. After the index creation device starts the summary function, it can initialize the index building state and record the building state as the running state. Next, the index creation device can build index information in a preset storage location to store the index corresponding to the target data. Then, the index creation device can perform range summarization, that is, summarize the minimum and maximum values of the page range of each data tuple within the target data to generate the storage range of the target data. Once this operation is complete, the index creation device can release resources, that is, release the running state.
[0087] S302, The index creation device divides the storage area into multiple data areas.
[0088] Each data interval includes a preset number of data blocks.
[0089] Optionally, the preset quantity can be pre-set by staff in the index creation device. The preset quantity can be 100 or 128, etc. For example, ... Figure 5 As shown, when the preset quantity is 128, data block 0, data block 1, ..., data block 127 can form the first data interval, and the minimum value of the first data interval is data block 0, and the maximum value is data block 127. Data block 128, data block 129, ..., data block 255 can form the second data interval, and the minimum value of the second data interval is data block 128, and the maximum value is data block 255.
[0090] In one possible approach, after obtaining the storage area of the target data, the index creation device can divide the storage area into multiple data areas sequentially based on the address segment order.
[0091] Furthermore, the index creation device can also calculate the address range of each data interval based on range configuration parameters (e.g., 8 to 256), that is, the address range of each data block within the data interval. A data interval can support multiple address ranges. For example, the address range of a data interval can consist of (1, 100), (500, 600), and (900, 1000). Subsequently, when searching for data, the index creation device will traverse these address ranges, excluding data intervals that are not within the range.
[0092] S303, The index creation device creates multiple index tuples that correspond one-to-one with multiple data ranges.
[0093] Among them, multiple index tuples are used to form an index corresponding to the target data.
[0094] In one possible approach, the index creation device can create multiple index tuples that correspond one-to-one with multiple data ranges and add the multiple index tuples to the index file corresponding to the target data.
[0095] In one possible approach, the index creation device can be pre-configured with a build function. This build function can be used to generate index tuples and populate them into an index file to create a new index. Based on this, the index creation device can call the build function to create multiple index tuples that correspond one-to-one with multiple data ranges, resulting in an index corresponding to the target data.
[0096] In one possible example, such as Figure 6 The diagram illustrates the execution process of a construction function according to an embodiment of this application. After the index creation device starts the construction function, it can initialize the metadata pages of the index and initialize the construction state, recording the construction state as the running state. Next, the index creation device can perform an index construction scan, scanning each data interval to obtain data tuple information within each data interval. Then, the index creation device can further create index tuples corresponding to each data interval based on the data tuple information within each data interval. Upon completion of the construction, the index creation device can release resources, i.e., release the running state.
[0097] In one possible approach, the index creation device can store the index corresponding to the target data in pages as the basic unit. For example... Figure 7 As shown, the index can have three types of pages: metadata pages, range mapping pages, and regular pages.
[0098] Metadata pages can be used to store metadata about the index. This metadata can include identifier information, version number information, the number of original data pages contained in each range mapping page, and the page number of the last range mapping page.
[0099] The range mapping page, immediately following the metadata page, stores multiple item pointers to facilitate quick retrieval of index data based on the metadata. Combined with... Figure 5 ,like Figure 8 As shown, summary information is calculated every 128 data blocks. A range-mapped page can store multiple item pointers (e.g., item pointer 1, item pointer 2, item pointer 3, and item pointer 4) and the storage locations of multiple index tuples (e.g., index tuple 1, index tuple 2, index tuple 3, and index tuple 4). Item pointers can be used to point to the storage locations of index tuples.
[0100] Regular pages are used to store index tuples. For example... Figure 9 As shown, in a regular page, the index tuple consists of a block number and block information. The block number points to the first block of the corresponding data range. The block information can be a uint8 type data. The first four bits of the block information can be used to represent the offset of the value, and the eighth bit can be used to indicate whether it contains a null value.
[0101] In one embodiment, after the index creation device creates multiple index tuples that correspond one-to-one with multiple data ranges, such as Figure 10 As shown, the index creation method provided in this application embodiment further includes: S401-S404.
[0102] S401, The index creation device receives a query request message carrying query conditions.
[0103] The query request message can be used to request data that matches the query criteria. The query criteria can consist of information such as data name, data type, or data attributes.
[0104] In one possible way, combining Figure 1 Users can edit query criteria and perform data query operations (e.g., clicking a query button) using electronic devices. In response to the user's data query operation, the electronic device can send a query request message carrying the query criteria to the indexing device. Accordingly, the indexing device can receive the query request message carrying the query criteria and parse it to obtain the query criteria.
[0105] S402, The index creation device determines the index tuple that corresponds to the query condition among multiple index tuples as the target index tuple.
[0106] In one possible approach, to determine whether the target data meets the query criteria, or whether the target data includes data that meets the query criteria, the index creation device, after determining the query criteria, can determine scanning information based on the query criteria and scan multiple index tuples that make up the target data based on the scanning information. Based on this, the index creation device can identify the index tuple that corresponds to the query criteria from among the multiple index tuples as the target index tuple.
[0107] S403, The index creation device adds the data range corresponding to the target index tuple to the data bitmap.
[0108] In one possible approach, to improve query efficiency, the index creation device can add the data range corresponding to all target index tuples to the data bitmap to further obtain data that meets the query conditions based on the data bitmap.
[0109] In one possible approach, the index creation device can be pre-configured with a bitmap scan function. The bitmap scan function can be used for index scanning. For example... Figure 11 As shown, after the index creation device initiates the bitmap scan function, it can obtain index tuples, that is, read each item pointer from the range-mapped page and obtain the index tuples pointed to by each item pointer. Next, the index creation device can perform index tuple conversion, converting the index tuples into their memory representations. Then, the index creation device can perform index tuple comparison, comparing the summary values in the index tuples with the scan information, thereby adding the data range corresponding to the index tuples that match the scan information to the data bitmap.
[0110] S404. The index creation device determines the data tuples corresponding to the query conditions based on the data bitmap.
[0111] In one possible approach, after completing the combination of the data bitmap, the index creation device can read the data tuples in each data range of the data bitmap from the configured storage module based on the data bitmap to determine the data tuples corresponding to the query conditions.
[0112] In one embodiment, during S402 above, when the index creation device determines the index tuple corresponding to the query condition from among multiple index tuples as the target index tuple, such as... Figure 12 As shown, this application embodiment provides an optional implementation method, including: S501-S502.
[0113] S501, The index creation device determines the scan information corresponding to the query conditions.
[0114] In one possible approach, the index creation device can be pre-configured with a start scan function. This start scan function can be used to construct a new scan message (also called a scan operator), and then use that message to perform the scan. For example... Figure 13 As shown, after the index creation device starts the start scan function, it can construct description information and return scan information after successful construction.
[0115] S502, The index creation device scans multiple index tuples based on the scanning information to obtain the target index tuple.
[0116] In one possible approach, the index creation device can scan multiple index tuples based on scan information, compare the summary value in the index tuples with the scan information, and then add the data range corresponding to the index tuple that matches the scan information to the data bitmap to obtain the target index tuple.
[0117] In one embodiment, after the index creation device creates multiple index tuples that correspond one-to-one with multiple data ranges, such as Figure 14 As shown, the index creation method provided in this application embodiment further includes: S601-S602.
[0118] S601, When there is updated data in the target data, the index creation device creates an index tuple to be updated corresponding to the updated data.
[0119] The updated data is used to represent newly added data in the target data.
[0120] In one possible approach, the index creation device can determine in real time or periodically whether updated data exists in the target data. If updated data exists, the index creation device can determine the data range corresponding to the updated data, and further create an index tuple to be updated based on the data range corresponding to the updated data.
[0121] S602, the index creation device updates the index tuple to be updated in the index corresponding to the target data.
[0122] In one possible approach, after creating the index tuple to be updated corresponding to the updated data, the index creation device can add the index tuple to be updated to a regular page in the index corresponding to the target data, thereby updating the index corresponding to the target data.
[0123] In one possible approach, the index creation device can be pre-configured with an insertion function. This insertion function can be used to insert a new index tuple into an existing index. For example... Figure 15As shown, after the index creation device initiates the insertion function, it can determine whether updated data exists in the target data. If not, it returns directly. If updated data exists in the target data, the index creation device can construct an index tuple to create an index tuple to be updated corresponding to the updated data. Next, the index creation device can update the index tuple to update the index corresponding to the target data. After the update is complete, the index creation device can release resources and return.
[0124] In one possible approach, the index creation device may also be pre-configured with a deletion function. This deletion function can be used to remove index tuples from the index. For block-range indexes, deleting index tuples requires no further processing and does not affect the correctness of the indexing operations.
[0125] In this embodiment, the index creation device can obtain the storage range of the target data and divide the storage range into multiple data ranges, thereby creating multiple index tuples that correspond one-to-one with the multiple data ranges, thus obtaining an index corresponding to the target data. Since the data range corresponding to one index tuple can include multiple data blocks, this application uses the method of establishing index tuples based on data ranges to store the maximum and minimum value information at both ends of each consecutive set of data blocks, thereby reducing the size of the index and lowering the storage space occupied. Therefore, this application can be used to solve the technical problem that general technologies tend to occupy a large amount of storage space when creating indexes.
[0126] The foregoing mainly describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the above functions, it includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0127] This application embodiment can divide the index creation device into functional modules according to the above method example. For example, each function can be divided into a separate functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. Optionally, the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0128] like Figure 16The diagram shown is a structural schematic of an index creation apparatus provided in an embodiment of this application. This index creation apparatus can be used to perform tasks such as... Figure 3 , Figure 10 , Figure 12 and Figure 14 The index creation method shown is illustrated. The index creation apparatus includes: an acquisition unit 701 and a processing unit 702;
[0129] Acquisition unit 701 is used to acquire the storage area of the target data; the target data includes multiple data tuples; the storage area includes data block information corresponding to the multiple data tuples; for example, combined with Figure 3 The acquisition unit 701 can be used to execute S301.
[0130] Processing unit 702 is used to divide the storage area acquired by acquisition unit 701 into multiple data areas; each data area includes a preset number of data blocks; for example, combined with Figure 3 The processing unit 702 can be used to execute S302.
[0131] Processing unit 702 is also used to create multiple index tuples that correspond one-to-one with multiple data ranges; the multiple index tuples are used to form an index corresponding to the target data. For example, combined with Figure 3 The processing unit 702 can be used to execute S303.
[0132] Optionally, the acquisition unit 701 is further configured to receive a query request message carrying query conditions; for example, in conjunction with Figure 10 The processing unit 702 can be used to execute S401.
[0133] Processing unit 702 is further configured to determine the index tuple corresponding to the query conditions from among multiple index tuples as the target index tuple; for example, combining... Figure 3 The processing unit 702 can be used to execute S402.
[0134] Processing unit 702 is also used to add the data range corresponding to the target index tuple to the data bitmap; for example, in combination with Figure 10 The processing unit 702 can be used to execute S403.
[0135] Processing unit 702 is also used to determine the data tuples corresponding to the query conditions based on the data bitmap. For example, combined with Figure 10 The processing unit 702 can be used to execute S404.
[0136] Optionally, the processing unit 702 is specifically used for:
[0137] Determine the scan information corresponding to the query conditions; for example, combine Figure 12 The processing unit 702 can be used to execute S501.
[0138] The target index tuple is obtained by scanning multiple index tuples based on the scan information. For example, combining... Figure 12 The processing unit 702 can be used to execute S502.
[0139] Optionally, the processing unit 702 is further configured to create an index tuple to be updated corresponding to the updated data when updated data exists in the target data; for example, in combination with Figure 14 The processing unit 702 can be used to execute S601.
[0140] Processing unit 702 is also configured to update the index tuple to be updated in the index corresponding to the target data. For example, combined with Figure 14 The processing unit 702 can be used to execute S602.
[0141] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in this application can be implemented using hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer-readable storage media and communication media, wherein communication media include any medium that facilitates the transmission of a computer program from one place to another. Storage media can be any available medium accessible to a general-purpose or special-purpose computer.
[0142] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0143] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and other division methods may exist in actual implementation. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms. Units described as separate components may or may not be physically separate; components shown as units may be one physical unit or multiple physical units, i.e., they may be located in one place or distributed in multiple different places. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0144] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An index creation method, characterized in that, include: Obtain the storage area of the target data; the target data includes multiple data tuples; the storage area includes data block information corresponding to the multiple data tuples; The storage area is divided into multiple data areas; each data area includes a preset number of data blocks; the data areas are obtained by dividing the storage area sequentially based on address segment order; each storage area is generated by summarizing the minimum and maximum values of the page range of each data tuple within the target data; each data area supports multiple address ranges, that is, the address range of each data block within the data area. Create multiple index tuples that correspond one-to-one with the multiple data ranges; the multiple index tuples are used to form an index corresponding to the target data; An index tuple corresponds to a data range consisting of multiple data blocks, with each consecutive set of data blocks storing the maximum and minimum values at both ends.
2. The index creation method according to claim 1, characterized in that, After creating multiple index tuples that correspond one-to-one with the multiple data ranges, the method further includes: Receive query request messages carrying query conditions; The index tuple that corresponds to the query condition among the multiple index tuples is determined as the target index tuple; Add the data range corresponding to the target index tuple to the data bitmap; Based on the data bitmap, determine the data tuple corresponding to the query conditions.
3. The index creation method according to claim 2, characterized in that, The step of determining the index tuple corresponding to the query condition among the multiple index tuples as the target index tuple includes: Determine the scan information corresponding to the query conditions; Based on the scanning information, multiple index tuples are scanned to obtain the target index tuple.
4. The index creation method according to any one of claims 1-3, characterized in that, After creating multiple index tuples that correspond one-to-one with the multiple data ranges, the method further includes: When updated data exists in the target data, create an index tuple to be updated corresponding to the updated data; Update the index tuple to be updated in the index corresponding to the target data.
5. An index creation apparatus, characterized in that, include: Acquisition unit and processing unit; The acquisition unit is used to acquire the storage area of the target data; The target data includes multiple data tuples; the storage area includes data block information corresponding to the multiple data tuples. The processing unit is used to divide the storage area obtained by the acquisition unit into multiple data areas; the data area includes a preset number of data blocks; the data area is obtained by dividing the storage area sequentially based on the address segment order; the storage area is generated by summarizing the minimum and maximum values of the page range of each data tuple in the target data; the data area supports multiple address ranges, that is, the address range of each data block in the data area; The processing unit is further configured to create multiple index tuples that correspond one-to-one with the multiple data intervals; the multiple index tuples are used to form an index corresponding to the target data; An index tuple corresponds to a data range consisting of multiple data blocks, with each consecutive set of data blocks storing the maximum and minimum values at both ends.
6. The index creation apparatus according to claim 5, characterized in that, The acquisition unit is also used to receive a query request message carrying query conditions; The processing unit is further configured to determine the index tuple corresponding to the query condition among the plurality of index tuples as the target index tuple; The processing unit is also used to add the data range corresponding to the target index tuple to the data bitmap; The processing unit is further configured to determine, based on the data bitmap, the data tuple corresponding to the query condition.
7. The index creation apparatus according to claim 6, characterized in that, The processing unit is specifically used for: Determine the scan information corresponding to the query conditions; Based on the scanning information, multiple index tuples are scanned to obtain the target index tuple.
8. The index creation apparatus according to any one of claims 5-7, characterized in that, The processing unit is further configured to create an index tuple to be updated corresponding to the updated data when there is updated data in the target data; The processing unit is further configured to update the index tuple to be updated in the index corresponding to the target data.
9. An index creation apparatus, characterized in that, It includes a memory and a processor; the memory is used to store computer execution instructions, and the processor is connected to the memory via a bus; when the index creation device is running, the processor executes the computer execution instructions stored in the memory, so that the index creation device performs the index creation method as described in any one of claims 1-4.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes computer-executable instructions that, when executed on a computer, cause the computer to perform the index creation method as described in any one of claims 1-4.
Citation Information
Patent Citations
Brin index construction method and device of column type storage data, and data retrieval method and device
CN110704433A
Database index creation method and device, computer equipment and storage medium
CN111782659A