CN111488341B - Database index management method and device and electronic equipment - Google Patents

Database index management method and device and electronic equipment Download PDF

Info

Publication number
CN111488341B
CN111488341B CN202010231579.8A CN202010231579A CN111488341B CN 111488341 B CN111488341 B CN 111488341B CN 202010231579 A CN202010231579 A CN 202010231579A CN 111488341 B CN111488341 B CN 111488341B
Authority
CN
China
Prior art keywords
data
target
database
subtree
index
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010231579.8A
Other languages
Chinese (zh)
Other versions
CN111488341A (en
Inventor
邱海港
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202010231579.8A priority Critical patent/CN111488341B/en
Publication of CN111488341A publication Critical patent/CN111488341A/en
Application granted granted Critical
Publication of CN111488341B publication Critical patent/CN111488341B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention relates to a database index management method, a database index management device and electronic equipment, and relates to the field of cloud computing, wherein the method comprises the following steps: acquiring newly added data of a database; determining whether a target node exists in an initial index of a database, wherein the initial index comprises a first keyword; when the condition that the target node exists in the initial index is determined, determining a target subtree according to the target node and the newly-added data, wherein the target subtree is used for storing the newly-added data, and the target subtree comprises a second keyword which is a unique identifier of the newly-added data; determining an update index of the database according to the initial index and the target subtree; and managing the data in the database according to the updated index of the database. The method improves the speed of processing the database such as adding, changing, deleting, checking and the like, and saves the performance cost of equipment.

Description

Database index management method and device and electronic equipment
Technical Field
The present invention relates to the field of database technologies, and in particular, to a method for managing a database index, a device for managing a database index, and an electronic device.
Background
A database is a repository that organizes, stores, and manages data according to a data structure, and is an organized, shared, uniformly managed collection of data stored in a computer for a long period of time. The database usually stores massive data, and in order to quickly and conveniently manage the data, a database index establishing mode is generally adopted. An index is a structure that orders the values of one or more columns in a database table, with which specific information in the database table can be accessed quickly.
The index is built based on the particular key. In some scenarios, there are instances where the keywords of a large amount of data are identical, while the keywords of other data are relatively discrete. Accordingly, the key in the index may be repeated in large numbers. Because the data corresponding to the repeated keywords needs to be traversed one by one, the speed of processing such as adding, modifying and deleting the database can be reduced, and the performance cost of the equipment can be increased.
Therefore, a new technical solution for managing database indexes is needed.
Disclosure of Invention
It is an object of the present invention to provide a new solution for managing database indexes.
According to a first aspect of the present invention, there is provided a method for managing a database index, the database establishing a data index and storing data using a red-black tree rule, the method comprising:
acquiring newly added data of the database;
determining whether a target node corresponding to the newly added data exists in an initial index of the database, wherein the initial index comprises a first keyword;
when the target node exists in the initial index, determining a target subtree according to the target node and the newly-added data, wherein the target subtree is used for storing the newly-added data, and the target subtree comprises a second keyword which is a unique identifier of the newly-added data;
determining an update index of the database according to the initial index and the target subtree;
and managing the data in the database according to the update index of the database.
Optionally, the determining whether the target node exists in the initial index of the database includes:
judging whether the current stored data in the database has data which is repeated with the newly added data or not;
and when the database is determined to have the data which is repeated with the newly added data, taking the node corresponding to the data which is repeated with the newly added data as a target node.
Optionally, when determining that the target node exists in the initial index, determining a target subtree according to the target node and the new data includes:
when the target node exists in the initial index and the corresponding target subtree does not exist in the target node, a corresponding red-black tree subtree is established under the target node so as to store the newly added data.
Optionally, when determining that the target node exists in the initial index, determining a target subtree according to the target node and the new data includes:
when the target node exists in the initial index, and under the condition that the target node exists a corresponding target subtree, adding a child node corresponding to the newly added data into the target subtree so as to store the newly added data.
Optionally, the determining the update index of the database according to the initial index and the target subtree includes:
and connecting the target node in the initial index with the root node of the target subtree to obtain the updated index.
Optionally, the managing the data in the database according to the update index of the database includes:
when the data in the database is queried, determining the corresponding target subtree according to a first keyword of the data to be queried;
and acquiring the data in the target subtree as data to be queried, and taking the data as a query result.
Optionally, the managing the data in the database according to the update index of the database includes:
when deleting the data in the database, determining a subtree where the data to be deleted is positioned according to a first keyword of the data to be deleted, and taking the subtree as a target subtree;
determining a node corresponding to the data to be deleted from the target subtree according to the second key word, and taking the node as a target child node;
and deleting the target child node to delete the data to be deleted.
Optionally, the method further comprises: when the target subtree only comprises one node, after deleting the target subtree, updating the initial index of the database.
According to a second aspect of the present invention, there is provided a database index management apparatus comprising:
the acquisition module is used for acquiring the newly-added data of the database;
a first processing module, configured to determine whether a target node corresponding to the newly added data exists in an initial index of the database, where the initial index includes a first key;
the second processing module is used for determining a target subtree according to the target node and the newly-added data under the condition that the target node exists in the initial index, wherein the target subtree is used for storing the newly-added data, and the target subtree comprises a second keyword which is a unique identifier of the newly-added data;
the updating module is used for determining an updating index of the database according to the initial index and the target subtree;
and the management module is used for managing the data in the database according to the update index of the database.
According to a third aspect of the present invention there is provided an electronic device comprising a processor and a memory for storing machine executable instructions, the processor being for implementing a method according to the first aspect of the present invention under control of the machine executable instructions.
According to the management method for the data index, the corresponding target subtree is established under the condition that the repeated key words exist in the index, the database index is updated based on the target subtree to store newly added data, the target subtree can be processed as a whole when the data is searched and read, one-to-one traversal when the data corresponding to the repeated key words is inquired is avoided, the speed of processing such as adding, modifying and deleting the database is improved, and the performance cost of equipment is saved.
Other features of the present invention and its advantages will become apparent from the following detailed description of exemplary embodiments of the invention, which proceeds with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a schematic diagram of an electronic device that may be used to implement an embodiment of the invention.
Fig. 2 is a flowchart of a method of managing database indexes according to an embodiment of the present invention.
FIG. 3 is a schematic diagram of a database index according to an embodiment of the invention.
Detailed Description
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 the components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless it is specifically stated otherwise.
The following description of at least one exemplary embodiment is merely exemplary in nature and is in no way intended to limit the invention, its application, or uses.
Techniques, methods, and apparatus known to one of ordinary skill in the relevant art may not be discussed in detail, but where appropriate, the techniques, methods, and apparatus should be considered part of the specification.
In all examples shown and discussed herein, any specific values should be construed as merely illustrative, and not a limitation. Thus, other examples of exemplary embodiments may have different values.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further discussion thereof is necessary in subsequent figures.
< hardware configuration >
Fig. 1 shows a hardware configuration of an electronic device that may be used to implement an embodiment of the invention.
Referring to fig. 1, the electronic apparatus 1000 includes a processor 1100, a memory 1200, an interface device 1300, a communication device 1400, a display device 1500, and an input device 1600. The processor 1100 may be, for example, a central processing unit CPU, a micro control unit MCU, or the like. The memory 1200 includes, for example, ROM (read only memory), RAM (random access memory), nonvolatile memory such as a hard disk, and the like. The interface device 1300 includes, for example, a USB interface, a serial interface, and the like. The communication device 1400 is, for example, a wired network card or a wireless network card. The display device 1500 is, for example, a liquid crystal display. The input device 1600 includes, for example, a touch screen, keyboard, mouse, microphone, etc.
In an embodiment applied to this description, the memory 1120 of the electronic device 1000 is used to store instructions for controlling the processor 1110 to operate in support of implementing a method according to any embodiment of this description. The skilled person can design instructions according to the solution disclosed in the present specification. How the instructions control the processor to operate is well known in the art and will not be described in detail here.
It will be appreciated by those skilled in the art that although a plurality of devices of the electronic device 1000 are shown in fig. 1, the electronic device 1000 of the embodiments of the present description may refer to only some of the devices thereof, for example, only the processor 1110, the memory 1120, and the communication device 1140.
The hardware configuration shown in fig. 1 is merely illustrative and is in no way intended to limit the invention, its applications or uses.
< method example >
The present embodiment provides a method for managing database indexes, which is implemented by, for example, the electronic device 1000 shown in fig. 1. As shown in fig. 2, the method includes the following steps S1100-S1400.
In step S1100, newly added data of the database is acquired.
In this embodiment, the newly added data is data added to the database. Each piece of data may have multiple fields. A field may be designated as a key to build an index.
An index is a separate, physical storage structure that orders the values of one or more columns in a database table, which is a collection of one or more columns of values in a table and corresponding logical pointer lists that point to pages of data in the table that physically identify the values. The index function is equivalent to the catalogue of books, and the needed content can be quickly found according to the page numbers in the catalogue.
The index of the database may be a tree structure, such as a binary tree, a red-black tree, etc. A tree is an important nonlinear data structure, intuitively, that is a structure in which data elements (called nodes in the tree) are organized in branching relationships, as in a tree in nature.
In this embodiment, the database uses the rule of red-black tree to build the data index and store the data.
In step S1200, it is determined whether there is a target node corresponding to the newly added data in an initial index of the database, wherein the initial index includes a first key.
In this embodiment, the initial index is an index that the database has prior to adding the data. It will be readily appreciated that if the database was previously empty, then the initial index is also empty.
In this embodiment, the initial index includes a first key. Each node in the initial index corresponds to a certain first key.
The first key may be a unique identification of the data, or may be other non-unique fields.
In the case where the first key is a non-unique field, different data may correspond to the same first key. Thus, there are the following cases: the first key corresponding to the newly added data is the same as the first key corresponding to the existing node in the initial index, namely, the repeated first key appears. In this embodiment, the node in the above case is referred to as a target node, that is, a first key in which the target node corresponds to the newly added data and is repeated.
In one example, determining whether a target node exists in an initial index of a database includes: judging whether the current stored data in the database has data which is repeated with the newly added data or not; and when the data repeated with the newly added data is determined to exist in the database, the node corresponding to the data repeated with the newly added data is taken as a target node.
In the above example, two data are repeated, meaning that the two data have the same key.
In step S1300, when it is determined that the target node exists in the initial index, a target subtree is determined according to the target node and the new data, where the target subtree is used to store the new data, and the target subtree includes a second key, and the second key is a unique identifier of the new data.
In this embodiment, the target subtree is a tree structure other than the initial index, and the data (or nodes) in the target subtree all correspond to the same first key. The target subtree is built from the second key. The second key is a unique identification of the data, i.e. the second key does not overlap.
In one example, the target subtree is a red-black tree. Red-black trees are a specific type of binary tree, a data structure used in computer science, typically for implementing associative arrays. By adopting the red black tree, the self-balancing of the tree structure is maintained, and the query efficiency is ensured.
In one example, the second key is a storage location rowid of the data. In this way, the uniqueness of the second key can be ensured. In addition, the storage position of the data can be rapidly determined according to rowid, and the speed of data processing such as inquiring, modifying and the like can be improved.
And when the condition that the target node exists in the initial index is determined, determining a target subtree according to the target node and the newly-added data, wherein the condition at least comprises the following two conditions.
In the first case, when it is determined that a target node exists in the initial index, and in the case that the target node does not exist a corresponding target subtree, a corresponding red-black tree subtree is established under the target node to store the newly added data.
In the second case, when it is determined that the target node exists in the initial index, and in the case that the target node exists in the corresponding target sub-tree, a child node corresponding to the newly added data is added to the target sub-tree to store the newly added data.
The above two cases can be summarized as follows: under the condition that the target node does not have a corresponding target subtree, the target subtree is built according to the target node and the newly-added data; and under the condition that the target node has a corresponding target subtree, updating the target subtree according to the newly-added data.
And establishing the target subtree, namely creating a tree structure which accords with the tree structure rule and comprises the newly added data and the data corresponding to the target node as the target subtree. And the updated target subtree is that the child nodes corresponding to the newly added data are added in the existing target subtree according to the rule of the tree structure.
In step S1400, an update index of the database is obtained based on the initial index and the target subtree.
In this embodiment, obtaining the update index according to the initial index and the target subtree includes: and connecting the target node in the initial index with the root node of the target subtree to obtain the updated index.
The update index includes an initial index and a target sub-tree, the target sub-tree corresponding to a target node in the initial index.
According to the management method for the data index, the corresponding target subtree is established under the condition that the repeated key words exist in the index, the database index is updated based on the target subtree to store newly added data, the target subtree can be processed as a whole when the data is searched and read, one-to-one traversal when the data corresponding to the repeated key words is inquired is avoided, the speed of processing such as adding, modifying and deleting the database is improved, and the performance cost of equipment is saved.
Fig. 3 is a specific example of implementation of the management method of data indexes in this embodiment. The database in this example is used to manage telephone numbers in the business. Each enterprise has a unique enterprise account, and a plurality of telephone numbers exist under each enterprise account. Thus, with each phone number as one piece of data, each piece of data has two fields, namely "business account number" and "phone number". The value of the "enterprise account number" is, for example, 1, 2, 3, … …, etc., and there may be a case of repetition. The values of the "telephone number" are, for example, n1, n2, n3 … …, etc., and there is no duplication. When adding data to the database, assume that the "enterprise account" corresponding to the newly added data is 9 and the "phone number" corresponding to the newly added data is n50. As shown in fig. 3, an initial index is shown above fig. 3, and the initial index is established according to the "enterprise account number", that is, the "enterprise account number" is used as a first keyword. It can be seen that there is already a node in the initial index with the first key of "9", i.e. the node corresponds to the same target node as the newly added data and is therefore the target node. And under the condition that the target node exists in the initial index, acquiring a target subtree according to the target node and the newly added data. Below fig. 3 is an already existing target subtree, the nodes in which all correspond to the same first key "9", and which is built up from "phone numbers", i.e. the "phone numbers" as second keys. Therefore, the nodes corresponding to the newly added data are added in the existing target subtree according to the tree structure rule, and the updated target subtree is obtained. And finally, obtaining the updated index according to the initial index and the updated target subtree. The update index has a similar structure to that of fig. 3, with an initial index above and a target subtree corresponding to the target node below, wherein the dashed line represents the mapping relationship between the target subtree and the target node.
In one example, the method for managing database indexes further includes: when data in a database is queried, determining a corresponding target subtree according to a first keyword of the data to be queried; and acquiring data in the target subtree as data to be queried, and taking the data as a query result.
For example, in the example shown in fig. 3, if the first keyword of the data to be queried is "9", the subtree corresponding to "9" in fig. 3 may be determined accordingly. Since the key corresponding to each node in the subtree is "9", the subtree can be returned to the user as a query result without further searching in the subtree.
By the method, when the keyword of the query corresponds to the target subtree, each node in the target subtree is not required to be processed one by one, and the whole tree is read through the mode of reading the whole tree, so that the search efficiency is improved.
In one example, the method for managing database indexes further includes: when deleting the data in the database, determining a subtree where the data to be deleted is positioned according to a first keyword of the data to be deleted, and taking the subtree as a target subtree; determining a node corresponding to the data to be deleted from the target subtree according to the second keyword to serve as a target child node; and deleting the target child node to delete the data to be deleted.
In the above example, the process of deleting data further includes: when only one node is included in the target subtree, the initial index of the database is updated after the target subtree is deleted.
In the above example, the process of deleting data can be divided into at least the following two cases.
In the first case, where the target subtree includes only one node, deleting the target subtree means that the target subtree is deleted, and the corresponding target node in the initial index of the target subtree is also deleted, in which case the initial index of the database needs to be updated.
In the second case, the target subtree includes a plurality of nodes, and after deleting the target subtree, other subtrees still exist, which means that the target subtree still exists, and the corresponding target node of the target subtree in the initial index also exists, so that the initial index of the database does not need to be changed in this case.
By the method, when deleting data, if the target subtree still comprises at least one node, the structure of the initial index does not need to be changed, so that the stability of the structure of the initial index can be kept.
< device example >
The embodiment provides a database index management device, which comprises an acquisition module, a first processing module, a second processing module and an updating module.
The acquisition module is used for acquiring the newly added data of the database.
And the first processing module is used for determining whether a target node exists in an initial index of the database, wherein the initial index comprises a first keyword.
And the second processing module is used for determining a target subtree according to the target node and the newly-added data under the condition that the target node exists in the initial index, wherein the target subtree is used for storing the newly-added data, and the target subtree comprises a second keyword which is a unique identifier of the newly-added data.
And the updating module is used for determining the updating index of the database according to the initial index and the target subtree.
And the management module is used for managing the data in the database according to the update index of the database.
In one example, the first processing module is to: judging whether the current stored data in the database has data which is repeated with the newly added data or not; and when the data repeated with the newly added data is determined to exist in the database, the node corresponding to the data repeated with the newly added data is taken as a target node.
In one example, the second processing module is to: when it is determined that the target node exists in the initial index, and when the target node does not exist a corresponding target subtree, a corresponding red-black tree subtree is established under the target node to store the newly added data.
In one example, the second processing module is to: when it is determined that the target node exists in the initial index, and when the target node exists in the corresponding target subtree, adding a child node corresponding to the newly added data into the target subtree to store the newly added data.
In one example, the update module is to: and mapping the target nodes in the initial index to the target subtrees to obtain the updated index.
In one example, the database index management apparatus further includes a query module configured to: when data in a database is queried, determining a corresponding target subtree according to a first keyword of the data to be queried; and acquiring data in the target subtree as data to be queried, and taking the data as a query result.
In one example, the database index management apparatus further includes a deletion module configured to: when deleting the data in the database, determining a subtree where the data to be deleted is positioned according to a first keyword of the data to be deleted, and taking the subtree as a target subtree; determining a node corresponding to the data to be deleted from the target subtree according to the second keyword to serve as a target child node; and deleting the target child node to delete the data to be deleted.
In one example, the deletion module is further to: when only one node is included in the target subtree, the initial index of the database is updated after the target subtree is deleted.
< electronic device embodiment >
The embodiment provides an electronic device, which comprises a processor and a memory, wherein the memory stores machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to realize the database index management method described in the method embodiment of the invention.
< machine-readable storage Medium embodiment >
The present embodiments provide a machine-readable storage medium storing machine-executable instructions that, when invoked and executed by a processor, cause the processor to implement a method of managing database indexes as described in the method embodiments of the present invention.
The present invention may be a system, apparatus, device, method and/or computer program product. The computer program product may include a computer readable storage medium having computer readable program instructions embodied thereon for causing a processor to implement aspects of the present invention.
The computer readable storage medium may be a tangible device that can hold and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic 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 (a non-exhaustive list) of the computer-readable storage medium would include the following: portable computer disks, hard disks, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static Random Access Memory (SRAM), portable compact disk read-only memory (CD-ROM), digital Versatile Disks (DVD), memory sticks, floppy disks, mechanical coding devices, punch cards or in-groove structures such as punch cards or grooves having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media, as used herein, are not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., optical pulses through fiber optic cables), or electrical signals transmitted through wires.
The computer readable program instructions described herein may be downloaded from a computer readable storage medium to a respective computing/processing device or to an external computer or external storage device over a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers and/or edge servers. The network interface card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium in the respective computing/processing device.
Computer program instructions for carrying out operations of the present invention may be assembly instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, c++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, aspects of the present invention are implemented by personalizing electronic circuitry, such as programmable logic circuitry, field Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs), with state information for computer readable program instructions, which can execute the computer readable program instructions.
Various aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus, devices, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable medium having the instructions stored therein includes an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. It is well known to those skilled in the art that implementation by hardware, implementation by software, and implementation by a combination of software and hardware are all equivalent.
The foregoing description of embodiments of the invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described. The terminology used herein was chosen in order to best explain the principles of the embodiments, the practical application, or the technical improvements in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the invention is defined by the appended claims.

Claims (8)

1. A method for managing database indexes, wherein the database adopts a red-black tree rule to establish data indexes and store data, the method comprising:
acquiring newly added data of the database;
determining whether a target node corresponding to the newly added data exists in an initial index of the database, wherein the initial index comprises a first keyword;
when the target node exists in the initial index, determining a target subtree according to the target node and the newly-added data, wherein the target subtree is used for storing the newly-added data, and the target subtree comprises a second keyword which is a unique identifier of the newly-added data and is a storage position rowid of the newly-added data;
determining an update index of the database according to the initial index and the target subtree;
managing data in the database according to the update index of the database;
wherein the determining whether the target node corresponding to the newly added data exists in the initial index of the database includes:
judging whether the current stored data in the database has data which is repeated with the newly-added data or not, wherein the current stored data is repeated with the newly-added data under the condition that the keywords of the current stored data are the same as the keywords of the newly-added data;
when the database is determined to have the data which is repeated with the newly added data, taking the node corresponding to the data which is repeated with the newly added data as a target node;
wherein the managing the data in the database according to the update index of the database includes:
when the data in the database is queried, determining the corresponding target subtree according to a first keyword of the data to be queried;
and acquiring the data in the target subtree as data to be queried, and taking the data as a query result.
2. The method of claim 1, wherein the determining a target sub-tree from the target node and the newly added data when it is determined that the target node is present in the initial index comprises:
when the target node exists in the initial index and the corresponding target subtree does not exist in the target node, a corresponding red-black tree subtree is established under the target node so as to store the newly added data.
3. The method of claim 1, wherein the determining a target sub-tree from the target node and the newly added data when it is determined that the target node is present in the initial index comprises:
when the target node exists in the initial index, and under the condition that the target node exists a corresponding target subtree, adding a child node corresponding to the newly added data into the target subtree so as to store the newly added data.
4. The method of claim 1, wherein the determining the update index of the database from the initial index and the target subtree comprises:
and connecting the target node in the initial index with the root node of the target subtree to obtain the updated index.
5. The method of claim 1, wherein managing data in the database according to the update index of the database comprises:
when deleting the data in the database, determining a subtree where the data to be deleted is positioned according to a first keyword of the data to be deleted, and taking the subtree as a target subtree;
determining a node corresponding to the data to be deleted from the target subtree according to the second key word, and taking the node as a target child node;
and deleting the target child node to delete the data to be deleted.
6. The method of claim 5, wherein the method further comprises: when the target subtree only comprises one node, after deleting the target subtree, updating the initial index of the database.
7. A database index management apparatus, comprising:
the acquisition module is used for acquiring the newly-added data of the database;
a first processing module, configured to determine whether a target node corresponding to the newly added data exists in an initial index of the database, where the initial index includes a first key;
the second processing module is used for determining a target subtree according to the target node and the new data under the condition that the target node exists in the initial index, wherein the target subtree is used for storing the new data, the target subtree comprises a second keyword, the second keyword is a unique identifier of the new data, and the second keyword is a storage position rowid of the new data;
the updating module is used for determining an updating index of the database according to the initial index and the target subtree;
the management module is used for managing the data in the database according to the update index of the database;
the first processing module is specifically configured to: judging whether the current stored data in the database has data which is repeated with the newly-added data or not, wherein the current stored data is repeated with the newly-added data under the condition that the keywords of the current stored data are the same as the keywords of the newly-added data; when the database is determined to have the data which is repeated with the newly added data, the node corresponding to the data which is repeated with the newly added data is taken as a target node;
the management module is specifically configured to: when the data in the database is queried, determining the corresponding target subtree according to a first keyword of the data to be queried; and acquiring data in the target subtree as data to be queried to serve as a query result.
8. An electronic device comprising a processor and a memory for storing machine executable instructions, the processor for implementing the method of any of claims 1-6 under control of the machine executable instructions.
CN202010231579.8A 2020-03-27 2020-03-27 Database index management method and device and electronic equipment Active CN111488341B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010231579.8A CN111488341B (en) 2020-03-27 2020-03-27 Database index management method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010231579.8A CN111488341B (en) 2020-03-27 2020-03-27 Database index management method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN111488341A CN111488341A (en) 2020-08-04
CN111488341B true CN111488341B (en) 2023-08-22

Family

ID=71794609

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010231579.8A Active CN111488341B (en) 2020-03-27 2020-03-27 Database index management method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN111488341B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984649A (en) * 2020-08-20 2020-11-24 北京金山云网络技术有限公司 Data index searching method and device and related equipment
CN113448969B (en) * 2021-08-30 2022-02-18 阿里云计算有限公司 Data processing method, device and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB8822419D0 (en) * 1987-10-30 1988-10-26 Ibm Concurrent record access database system
CN101286160A (en) * 2008-05-30 2008-10-15 同济大学 Data base indexing process
WO2009084145A1 (en) * 2007-12-28 2009-07-09 S.Grants Co., Ltd. Database index key update method and program
CN103150404A (en) * 2013-03-28 2013-06-12 北京大学 Hybrid relational-extensible markup language (XML) data keyword searching method
CN104216962A (en) * 2014-08-22 2014-12-17 南京邮电大学 Mass network management data indexing design method based on HBase
CN110019211A (en) * 2017-11-27 2019-07-16 北京京东尚科信息技术有限公司 The methods, devices and systems of association index
CN110309137A (en) * 2018-02-28 2019-10-08 贵州白山云科技股份有限公司 A kind of data managing method and device
CN110471916A (en) * 2019-07-03 2019-11-19 平安科技(深圳)有限公司 Querying method, device, server and the medium of database
CN110807028A (en) * 2018-08-03 2020-02-18 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for managing a storage system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100418092C (en) * 2006-02-20 2008-09-10 南京联创科技股份有限公司 Grid and T-tree index method for rapid positioning in main memory database
US8429133B2 (en) * 2007-12-13 2013-04-23 Oracle International Corporation Partial key indexes
US8799315B2 (en) * 2009-01-30 2014-08-05 International Business Machines Corporation Selective construction of data search result per search request specifying path information
CN102651007A (en) * 2011-02-28 2012-08-29 国际商业机器公司 Method and device for managing database indexes

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB8822419D0 (en) * 1987-10-30 1988-10-26 Ibm Concurrent record access database system
WO2009084145A1 (en) * 2007-12-28 2009-07-09 S.Grants Co., Ltd. Database index key update method and program
CN101286160A (en) * 2008-05-30 2008-10-15 同济大学 Data base indexing process
CN103150404A (en) * 2013-03-28 2013-06-12 北京大学 Hybrid relational-extensible markup language (XML) data keyword searching method
CN104216962A (en) * 2014-08-22 2014-12-17 南京邮电大学 Mass network management data indexing design method based on HBase
CN110019211A (en) * 2017-11-27 2019-07-16 北京京东尚科信息技术有限公司 The methods, devices and systems of association index
CN110309137A (en) * 2018-02-28 2019-10-08 贵州白山云科技股份有限公司 A kind of data managing method and device
CN110807028A (en) * 2018-08-03 2020-02-18 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for managing a storage system
CN110471916A (en) * 2019-07-03 2019-11-19 平安科技(深圳)有限公司 Querying method, device, server and the medium of database

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于分簇的B~+树数据库索引优化算法;胡廷波;钟俊;;计算机应用(第09期);全文 *

Also Published As

Publication number Publication date
CN111488341A (en) 2020-08-04

Similar Documents

Publication Publication Date Title
CN106970936B (en) Data processing method and device and data query method and device
CN108228817B (en) Data processing method, device and system
CN107526777B (en) Method and equipment for processing file based on version number
US20150293958A1 (en) Scalable data structures
CN107704202B (en) Method and device for quickly reading and writing data
US11030242B1 (en) Indexing and querying semi-structured documents using a key-value store
US10248680B2 (en) Index management
US10423608B2 (en) Dynamic directory of objects based on logical attributes
CN105930390B (en) Relational database expansion method and system
US20190310978A1 (en) Supporting a join operation against multiple nosql databases
CN111488341B (en) Database index management method and device and electronic equipment
US20180181581A1 (en) Systems and methods for implementing object storage and fast metadata search using extended attributes
Belazzougui et al. Fully dynamic de Bruijn graphs
CN110807028B (en) Method, apparatus and computer program product for managing a storage system
US11232025B2 (en) Method, device and computer program product for storage management
US10936640B2 (en) Intelligent visualization of unstructured data in column-oriented data tables
US9916360B2 (en) Joining operations in document oriented databases
CN114579561A (en) Data processing method and device, and storage medium
US11487707B2 (en) Efficient file path indexing for a content repository
US11734241B2 (en) Efficient spatial indexing
US11080332B1 (en) Flexible indexing for graph databases
CN113742332A (en) Data storage method, device, equipment and storage medium
CN113590543A (en) Method, apparatus and computer program product for information processing
CN111666278A (en) Data storage method, data retrieval method, electronic device and storage medium
CN114138815A (en) Multi-database compatibility implementation method, device and medium for application program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant