CN112836093A - Data query method and device, electronic equipment and storage medium - Google Patents

Data query method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112836093A
CN112836093A CN202110152798.1A CN202110152798A CN112836093A CN 112836093 A CN112836093 A CN 112836093A CN 202110152798 A CN202110152798 A CN 202110152798A CN 112836093 A CN112836093 A CN 112836093A
Authority
CN
China
Prior art keywords
data
hierarchical structure
target
hierarchy
field
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.)
Granted
Application number
CN202110152798.1A
Other languages
Chinese (zh)
Other versions
CN112836093B (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 Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao 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 Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to CN202110152798.1A priority Critical patent/CN112836093B/en
Publication of CN112836093A publication Critical patent/CN112836093A/en
Application granted granted Critical
Publication of CN112836093B publication Critical patent/CN112836093B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/907Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
    • 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)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Library & Information Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the disclosure provides a data query method and device, electronic equipment and a storage medium. The method comprises the following steps: receiving a data query request, wherein the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure; acquiring a hierarchical structure field of the target data according to the target data identification information, wherein the hierarchical structure field is a metadata field used for indicating the hierarchical relationship of the target data in the target hierarchical structure; building a hierarchy tree of the target hierarchy based on the hierarchy field; and performing data query according to the hierarchical structure tree to generate a query result. By adopting the technical scheme, the embodiment of the disclosure can avoid the situation that more similar code logics appear when a plurality of hierarchical structures exist in the system, reduce the redundancy of codes and improve the expansion capability of the system.

Description

Data query method and device, electronic equipment and storage medium
Technical Field
The embodiment of the disclosure relates to the technical field of data query, and in particular, to a data query method and apparatus, an electronic device, and a storage medium.
Background
With the gradual maturity of cloud technology and the gradual improvement of cloud services, Software-as-a-Service (SaaS) cloud system applications are gradually approved by more and more small and medium-sized enterprises and large-sized enterprises in the field of enterprise-level business systems.
The hierarchical structure object is a business object with an upper and lower hierarchical relationship, such as an organization structure of a department, a reporting relationship between different persons, a hierarchical relationship between different brands, or a product line structure subdivided layer by layer, and the like. Such a structure having a hierarchical relationship is referred to as a hierarchical structure in the SaaS system. Due to the complexity and specificity of the hierarchical structure, in the SaaS system, the hierarchical structure is generally implemented by fixing the table structure of the hierarchical structure and implementing the code logic of the hierarchical structure by hard coding.
However, when the SaaS system has multiple hierarchies, the hard-coded implementation may cause multiple similar code logics in the system, the code redundancy is high, and the expansion capability of the SaaS system is limited.
Disclosure of Invention
The disclosed embodiments provide a data query method, device, electronic device and storage medium, so as to reduce code redundancy of a system and improve expansion capability of the system.
In a first aspect, an embodiment of the present disclosure provides a data query method, including:
receiving a data query request, wherein the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure;
acquiring a hierarchical structure field of the target data according to the target data identification information, wherein the hierarchical structure field is a metadata field used for indicating the hierarchical relationship of the target data in the target hierarchical structure;
building a hierarchy tree of the target hierarchy based on the hierarchy field;
and performing data query according to the hierarchical structure tree to generate a query result.
In a second aspect, an embodiment of the present disclosure further provides a data query apparatus, including:
a request receiving module, configured to receive a data query request, where the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure;
a field obtaining module, configured to obtain, according to the target data identification information, a hierarchical structure field of the target data, where the hierarchical structure field is a metadata field used for indicating a hierarchical relationship of the target data in the target hierarchical structure;
a building module to build a hierarchy tree of the target hierarchy based on the hierarchy field;
and the first data query module is used for performing data query according to the hierarchical structure tree to generate a query result.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, including:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the data query method according to the embodiment of the disclosure.
In a fourth aspect, the disclosed embodiment also provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the data query method according to the disclosed embodiment.
The data query method, the data query device, the electronic device and the storage medium provided by the embodiments of the present disclosure receive a data query request carrying target data identification information of target data in a target hierarchical structure, acquire a hierarchical structure field of the target data according to the target data identification information, where the hierarchical structure field is a metadata field for indicating a hierarchical relationship of the target data in the target hierarchical structure, construct a hierarchical structure tree of the target hierarchical structure based on the hierarchical structure field, and further perform data query according to the hierarchical structure tree to generate a query result. By adopting the technical scheme, the hierarchical relationship of the data in the hierarchical structure is indicated through the hierarchical structure field, the table structure of the hierarchical structure is not required to be fixed, and the hierarchical relationship of the data in the hierarchical structure is not required to be defined by using hard coding code logic, so that the condition that more similar code logics occur when a plurality of hierarchical structures exist in the system can be avoided, the redundancy of the code is reduced, and the expansion capability of the system is improved. In addition, since the hierarchical relation of the data in the hierarchical structure is not required to be defined by hard code logic, the mutual calling between the metadata in the system and the hierarchical structure realized by solidification is not required to be realized, and the self-defining capability of the metadata in the system can be further improved.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
Fig. 1 is a schematic flow chart of a data query method provided in an embodiment of the present disclosure;
fig. 2 is a schematic flow chart of another data query method provided in the embodiment of the present disclosure;
fig. 3 is a block diagram of a data query device according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Fig. 1 is a schematic flowchart of a data query method according to an embodiment of the present disclosure. The method may be performed by a data query apparatus, wherein the apparatus may be implemented by software and/or hardware, may be configured in an electronic device, and may typically be configured in a server. The data query method provided by the embodiment of the disclosure is suitable for a data query scene, and is particularly suitable for a scene of querying the hierarchical relationship of data in a hierarchical structure. As shown in fig. 1, the data query method provided in this embodiment may include:
s101, receiving a data query request, wherein the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure.
The target data identification information may be understood as data identification information carried in a data query request received by the server, such as a data name or a data ID; accordingly, the target data may be data corresponding to the target data identification information, and may be data whose data content or hierarchical relationship is to be queried by the user through the data query request, and the target data may be uniquely determined through the target data identification information. The target hierarchy may be the hierarchy in which the target data is located.
Illustratively, when a user wants to query the data content or the hierarchical relationship of a certain piece of data in a certain hierarchical structure, the user can send a data query request carrying data identification information of the data to a server through a user terminal; correspondingly, after receiving a data query request sent by a user terminal, a server can determine whether data identification information carried in the data query request is data identification information of data in a hierarchical structure, and when the data identification information is data identification information of data in the hierarchical structure, the server takes the data identification information as target data identification information, takes the data as target data, and takes a hierarchical structure to which the target data belongs as a target hierarchical structure, and performs data query by using the data query method provided by the embodiment of the disclosure.
S102, obtaining a hierarchical structure field of the target data according to the identification information of the target data, wherein the hierarchical structure field is a metadata field used for indicating the hierarchical relationship of the target data in the target hierarchical structure.
Specifically, each piece of data in the hierarchical structure may be provided with a hierarchical structure field for indicating the hierarchical relationship of the piece of data in the hierarchical structure, so that, after receiving a data query request for data in a target hierarchical structure, the server may obtain target data identification information carried in the data query request, and obtain the hierarchical structure field of the target data according to the target data identification information.
In this embodiment, when a developer designs a certain Hierarchy, the hierarchical relationship between pieces of data in the Hierarchy may be described by a Hierarchy (Hierarchy) field, that is, the developer may abstract a data object type of the Hierarchy in the system into a new specific Hierarchy field type and define it as a general field type in the metadata technology, and the hierarchical relationship of the data in the Hierarchy is described by the field instead of the hard coded code logic in the prior art, and may be used in the metadata as with other metadata field types. Here, the Hierarchy field may be a reference field type that refers to its own object, that is, the Hierarchy field may be a reference field that refers to its own object (such as department, person, brand, or product line), that is, a value of a reference object id (reference object id) attribute of the Hierarchy field type may be set to an object id (objectid) of a Hierarchy to which the Hierarchy field itself belongs, and a field type (field type) of the Hierarchy object may be set to a Hierarchy type.
In the metadata, besides the basic field type, a lookup field type which is relatively complex has the capability of referencing data of other objects, but the reference relationship is relatively simple and belongs to point-to-point reference, only one layer of association relationship exists, and the lookup field cannot reference the object to which the lookup field belongs, namely the lookup field on one object cannot reference the object, otherwise the reference logic of the lookup field falls into dead loop. For example, in a certain scenario, a field hrbp (i.e., the human resource manager responsible for the employee) exists on an employee object, the field is a mandatory field in a certain list, when a first employee record is created, if the first employee record happens to be the human resource manager and his hrbp is self, the lookup field cannot refer to the record unless the record is stored in the database, but if the record is stored in the database, the value of the hrbp field needs to be selected first, and at this time, the reference of the log falls into a dead loop; even if the hrbp is set as an unnecessary field, the employee record needs to be saved first, the hrbp field of the employee record is set to be empty during saving, and after the saving is completed, the employee record is edited to fill the value of the hrbp field, at this time, at least two steps of operations are needed, which causes the creation process of the record to become cumbersome, and therefore, the prior art generally adopts a hard coding mode to realize a hierarchical structure. However, the hierarchical structure field in the present application can refer to the object itself, so that all data in the hierarchical structure can be found up and/or down according to the built-in hierarchical relationship, that is, all data on the object can be referred to, and therefore, the present application can describe the hierarchical structure without setting a fixed table structure of the hierarchical structure and without defining the hierarchical relationship in the data of the hierarchical structure by using hard coded code logic, can avoid the situation that more similar code logics occur when a plurality of hierarchical structures exist in a system, reduce redundancy of codes, and can ensure that when the hierarchical structure needs to be expanded, hard coded codes in the hierarchical structure do not need to be changed, thereby improving the expansion capability of the system.
The field of the hierarchical structure is a field describing a hierarchical relationship of data in the hierarchical structure, and the field may be a metadata field, that is, the field is a field in metadata for describing a hierarchical relationship of data in the hierarchical structure, for example, a field of the hierarchical structure corresponding to a certain piece of data in the hierarchical structure may be used to indicate directly higher data of the data in the hierarchical structure, all higher data of the data in the hierarchical structure, directly lower data of the data in the hierarchical structure, all lower data of the data in the hierarchical structure, directly higher data and directly lower data of the data in the hierarchical structure, or all higher data and all lower data of the data in the hierarchical structure, and the like, and this embodiment is not limited thereto.
In view of the simplicity of the hierarchically structured data, preferably, a hierarchically structure field corresponding to a certain piece of data in the hierarchy can be used to indicate that the data is directly superior or directly inferior to the data in the hierarchy. In the following, taking an example that the hierarchical structure field corresponding to a certain piece of data in the hierarchical structure is used to indicate the directly higher data in the hierarchical structure, in this case, it is preferable that the hierarchical structure field is used to indicate the data identification information of the directly higher data in the target hierarchical structure of the target data, that is, the hierarchical structure field of the target data is used to record the data identification information of the directly higher data in the target hierarchical structure of the target data.
In this embodiment, the number of the data identification information recorded in the hierarchical structure field of a certain piece of data in the hierarchical structure may be zero, one, or more, depending on the number of the data directly above in the hierarchical structure, for example, when the data does not have direct above data in the hierarchical structure, that is, when the data is the highest layer data in the hierarchical structure, no data identification information may be recorded in the hierarchical structure field of the data; when there is only one piece of directly upper data in the hierarchy of the data, only one piece of data identification information may be recorded in the hierarchy field of the data; when there are a plurality of pieces of directly upper data in the hierarchy field of the data, a plurality of pieces of data identification information may be recorded in the hierarchy field of the data.
Considering that a piece of data in the hierarchical structure usually has at most one piece of directly superior data, in order to make it easier for the outside to call or query the hierarchical relationship logic of the hierarchical structure, i.e. when the outside calls or queries the hierarchical structure, it is not necessary to additionally specify which hierarchical structure field recorded in the hierarchical structure field is to be queried, and it is ensured that when querying the data according to the data identification information of a certain piece of data, a unique hierarchical structure tree can be constructed, each piece of data in the hierarchical structure preferably has only one piece of directly superior data, and correspondingly, at most one piece of data identification information is preferably recorded in the hierarchical structure field of each piece of data in the hierarchical structure. At this time, it is preferable that each piece of data in the target hierarchy has at most one directly superior piece of data.
S103, constructing a hierarchical structure tree of the target hierarchical structure based on the hierarchical structure field.
The hierarchical tree of the target hierarchical structure may be a tree structure corresponding to the target hierarchical structure.
In this embodiment, since a complete tree structure can be formed when only one root node exists in the hierarchical structure, the tree structure corresponding to the target hierarchical structure can be constructed according to the hierarchical structure field of the target data, so that the hierarchical relationship of the target data, such as all upper-level data, all lower-level data, or all lower-level data of the target data, can be searched for by searching for a matching logic based on the tree structure in the following process, and traversing upwards and/or downwards on the tree structure, thereby further simplifying the operation required for querying the hierarchical relationship.
In this step, a hierarchy tree of the target hierarchy may be constructed according to the hierarchy fields of the pieces of data in the target hierarchy. Specifically, since the hierarchical structure field of each piece of data in the target hierarchical structure records the data identification information of the direct upper-level data of the piece of data, the direct upper-level data and/or the direct lower-level data of each piece of data in the hierarchical structure can be sequentially acquired from the target data, and the direct upper-level data and/or the direct lower-level data are assembled according to the upper-level and lower-level relationships indicated in the hierarchical structure field, so that the hierarchical structure tree of the target hierarchical structure can be obtained.
Taking the direct upper-level data and the direct lower-level data of the target data as an example, when the direct upper-level data of the target data is obtained, the direct upper-level data of the target data can be obtained according to the data identification information of the direct upper-level data of the target data in the target hierarchical structure, which is recorded in the hierarchical structure field of the target data; when acquiring direct lower-level data of target data, the hierarchical structure field of each piece of data in the target structure may be first acquired according to the object identification information of the target structure, then it is determined whether the data identification information recorded in the acquired hierarchical structure field is data identification information of the target data, and data corresponding to the hierarchical structure field of the data identification information of the target data recorded in the hierarchical structure field is determined as the direct lower-level data of the target data.
In this step, the position of the hierarchical structure tree for constructing the target hierarchical structure can be selected as required, for example, the server can construct the hierarchical structure tree of the target hierarchical structure in its own memory, and delete the hierarchical structure tree from the memory after generating the query result; or a hierarchical structure tree of a target hierarchical structure may be built in its own cache, and according to an expiration policy of the cache, when a storage condition of the hierarchical structure tree in the cache meets the expiration policy of the cache, the hierarchical structure tree is deleted from the cache, which is not limited in this embodiment.
And S104, performing data query according to the hierarchical structure tree to generate a query result.
In this embodiment, it is possible to search upwards or downwards according to the hierarchical relationship in the hierarchical structure tree of the target hierarchical structure, for example, to search for who is the direct upper level of a certain person, who is all the upper levels thereof, who is the direct lower level thereof, and who is the person or the person reported thereto in a certain organizational structure, and obtain the data requested to be queried by the data query request, so as to generate a query result, and further return the query result to the user terminal that sent the data query request. When data query is performed according to the hierarchical structure tree of the target hierarchical structure, all data on the hierarchical structure tree of the target hierarchical structure can be traversed, or whether each piece of data to be queried is data meeting the query condition in the data query request is sequentially judged according to the query sequence corresponding to the query condition in the data query request, if the data meets the query condition, the data is marked, and after the query is completed, all data with marks on the hierarchical structure tree of the target hierarchical structure are obtained, so that a query result is generated.
In one embodiment, said building a hierarchy tree of said target hierarchy based on said hierarchy fields comprises: acquiring data identification information and a hierarchical structure field of each data in the target hierarchical structure; determining the hierarchical relationship of each data according to a hierarchical structure field, and constructing a hierarchical structure tree of the target hierarchical structure according to the hierarchical relationship of each data, wherein nodes in the hierarchical structure tree correspond to each data in the target hierarchical structure one by one, and data identification information of the corresponding data is recorded in each node.
Specifically, when constructing a hierarchical structure tree of a target hierarchical structure, a service object to which target data belongs may be determined according to target data identification information of the target data carried in a data query request, and data identification information and a hierarchical structure field of other data belonging to the same service object as the target data are obtained, so as to obtain data identification information and an acquisition structure field of all data (including the target data) contained in the service object to which the target data belongs; then, according to the hierarchical structure field of each data contained in the service object, determining the hierarchical relationship of each data in the target hierarchical structure (i.e. the upper and lower hierarchical relationships of each data in the target hierarchical structure), and according to the hierarchical relationship, adopting a preset assembly algorithm, such as a Deep First Search (DFS) algorithm or a broad First Search (break First Search) algorithm, etc., to sequentially connect the nodes corresponding to each data recorded with the data identification information of the corresponding data as the child nodes of the upper node thereof, so that after the connection of each node is completed, the hierarchical structure tree of the target hierarchical structure can be obtained.
In the foregoing embodiment, the performing a data query according to the hierarchical structure tree to generate a query result may include: sequentially judging whether each node in the hierarchical structure tree is matched with a query condition carried in a data query request according to a preset traversal rule, and marking the node matched with the query condition as a matched node; and when the traversal is completed, generating a query result according to the data identification information recorded in each matching node.
The traversal rule of the hierarchical structure tree of the target hierarchical structure may be set by a developer according to needs, for example, the traversal rule is a depth-first search or a breadth-first search.
Exemplarily, after a hierarchical structure tree of a target hierarchical structure is constructed, a traversal path of each node in the hierarchical structure tree may be determined according to a preset traversal rule, a first node (e.g., root node) in the traversal path is determined as a current node, whether the current node meets a query condition carried in a data query request is determined, if yes, the current node is marked as a matching node, a next node in the traversal path is determined as the current node, and an operation of determining whether the current node meets the query condition carried in the data query request is performed in a return manner until the next node does not exist; if not, determining the next node in the traversal path as the current node, and returning to execute the operation of judging whether the current node meets the query condition carried in the data query request until the next node does not exist. When the next node does not exist, namely when traversal is completed, the data identification information recorded in each matching node in the hierarchical structure tree can be acquired, a result return rule which is pre-agreed with a sender of the data query request is defined, and when only the data identification information needs to be returned, a data query result carrying the data identification information recorded in each node marked as a matching node is generated and sent to the sender of the data query request; and when the result return rule needs to return corresponding data, acquiring the data corresponding to each matching node from the database according to the data identification information recorded in each matching node, generating a query result carrying the data corresponding to each matching node, and sending the data query result to a sender of the data query request. The data query method provided in this embodiment receives a data query request carrying target data identification information of target data in a target hierarchical structure, obtains a hierarchical structure field of the target data according to the target data identification information, where the hierarchical structure field is a metadata field used for indicating a hierarchical relationship of the target data in the target hierarchical structure, constructs a hierarchical structure tree of the target hierarchical structure based on the hierarchical structure field, and further performs data query according to the hierarchical structure tree to generate a query result. By adopting the technical scheme, the hierarchical relationship of the data in the hierarchical structure is indicated by the hierarchical structure field, a table structure of the hierarchical structure is not required to be fixed, and the hierarchical relationship of the data in the hierarchical structure is not required to be defined by hard coding code logic, so that the situation that a plurality of similar code logics occur when a plurality of hierarchical structures exist in the system can be avoided, the redundancy of the code is reduced, and the expansion capability of the system is improved. In addition, since the hierarchical relation of the data in the hierarchical structure is not required to be defined by hard code logic, the mutual calling between the metadata in the system and the hierarchical structure realized by solidification is not required to be realized, and the self-defining capability of the metadata in the system can be further improved.
Fig. 2 is a schematic flow chart of another data query method provided in the embodiment of the present disclosure, and the scheme in the embodiment may be combined with one or more of the alternatives in the above embodiments. Optionally, the building a hierarchical tree of the target hierarchical structure based on the hierarchical structure field includes: building a hierarchy tree of the target hierarchy in a cache based on the hierarchy field.
Optionally, the obtaining the hierarchical structure field of the target data according to the target data identification information includes: if the hierarchical structure tree of the target hierarchical structure is not stored in the cache, acquiring a hierarchical structure field of the target data according to the target data identification information; the method further comprises the following steps: and if the hierarchical structure tree of the target hierarchical structure is stored in the cache, performing data query according to the hierarchical structure tree to generate a query result.
Optionally, before the obtaining the hierarchical structure field of the target data according to the target data identification information, the method further includes: determining the data query request to be a hierarchical relationship query request comprising a hierarchical relationship lookup match.
Optionally, the data query method provided in this embodiment further includes: and if the data query request is a non-hierarchical relationship query request, querying the data requested to be queried by the data query request from a database according to the target data identification information, and generating a query result.
Correspondingly, as shown in fig. 2, the data query method provided in this embodiment may include:
s201, receiving a data query request, wherein the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure.
S202, judging that the hierarchical structure tree of the target hierarchical structure is not stored in the cache, and if the hierarchical structure tree of the target hierarchical structure is not stored in the cache, executing S206; if not, go to S203.
In this embodiment, after receiving a data query request for data in a hierarchical structure, it may be determined whether a hierarchical structure tree of the hierarchical structure is stored in a cache first, so that when the hierarchical structure tree of the hierarchical structure is stored in the cache, a data query is directly performed based on the hierarchical structure tree, and the data query speed of a server is further improved.
Specifically, the structure identification information of the target hierarchical structure to which the target data belongs may be determined according to the target data identification information of the target data carried in the target data query request, and then, according to the structure identification information, it may be queried whether the hierarchical structure tree of the target hierarchical structure is stored in the cache.
S203, judging that the data query request is a hierarchical relationship query request containing a hierarchical relationship search matching character, if so, executing S204; if not, go to S207.
In this embodiment, when the hierarchical structure tree of the target hierarchical structure is not stored in the cache, it may be further determined whether the received data query request requests to query the hierarchical relationship of the target data in the target hierarchical structure, for example, whether the received data query request queries the upper-level data, the lower-level data, or the horizontal-level data of the target data in the target hierarchical structure, or queries one or more layers of data in the target hierarchical structure, and when the received data query request does not request to query the hierarchical relationship of the target data in the target hierarchical structure, directly queries the data requested to be queried by the data query request from the database, so as to avoid the influence on the query speed of the current non-hierarchical relationship query request caused by constructing the hierarchical structure tree of the target hierarchical structure.
Specifically, a hierarchical relationship search matching symbol for searching a hierarchical relationship may be preset, so that when it is determined whether the data query request is a hierarchical relationship search request, it is directly determined whether the data query request includes the hierarchical relationship search matching symbol, and if the data query request includes the hierarchical relationship search matching symbol, it is determined that the data query request is a hierarchical relationship query request; otherwise, the data query request is judged not to be the hierarchical relationship query request. Here, the hierarchical relationship lookup matches may include, but are not limited to, HierarchyUpAll, HierarchyDownAll, HierarchyLevelN, and HierarchyLevelNAll. The hierarchy tree comprises a hierarchy tree, a hierarchy level N and a hierarchy level NAll, wherein the hierarchy Upall is used for inquiring all upper-level data of certain data in a hierarchy structure to which the certain data belongs, the hierarchy DownAll is used for inquiring all lower-level data of the certain data in the hierarchy structure to which the certain data belongs, the hierarchy level N is used for inquiring the Nth-level data (assuming that data corresponding to a root node of the hierarchy tree is first-level data) of the certain data on a path containing the data in the hierarchy structure to which the certain data belongs, and the hierarchy level NAll is used for inquiring the Nth-level data on all paths in the hierarchy structure to which the certain data belongs.
S204, acquiring a hierarchical structure field of the target data according to the identification information of the target data, wherein the hierarchical structure field is a metadata field used for indicating the hierarchical relationship of the target data in the target hierarchical structure.
S205, constructing a hierarchical structure tree of the target hierarchical structure in a cache based on the hierarchical structure field.
In this embodiment, the hierarchical structure tree of the target hierarchical structure may be constructed in the cache according to the hierarchical structure field of the target data, that is, the hierarchical structure tree of the target hierarchical structure may be stored in the cache, so that when a data query request for the data in the target hierarchical structure is received again, data query is directly performed based on the hierarchical structure tree of the target hierarchical structure stored in the cache, data query from the database according to the data query request is not required, and the hierarchical structure tree of the target hierarchical structure is not required to be constructed again, which further improves the processing speed of the server for the data query request for the data in the target hierarchical structure, avoids the burden on the database caused by frequent database queries, and further improves the performance of the system.
For example, the server may obtain the direct upper-level data and/or the direct lower-level data of the target data in the target hierarchy according to the hierarchy field of the target data, store the target data and the direct upper-level data/the direct lower-level data in the cache according to the hierarchy relationship, and continue to obtain the direct upper-level data and/or the direct lower-level data of the direct upper-level data/the direct lower-level data according to the hierarchy field of the direct upper-level data/the direct lower-level data, and so on, thereby generating the hierarchy tree of the target hierarchy in the cache.
It can be understood that, in order to avoid that an excessive number of hierarchical trees occupy an excessive amount of cache space, an expiration policy for the hierarchical trees may be set for the cache, for example, an expiration time of the hierarchical tree is set, and when a storage condition of a certain hierarchical tree in the cache satisfies the expiration policy, the hierarchical tree satisfying the expiration policy may be deleted from the cache. In addition, when the server updates the data in the target hierarchical structure stored in the database according to the operation of the user or the developer, if the hierarchical structure tree of the target hierarchical structure is stored in the buffer, the server may further update the hierarchical structure tree of the target hierarchical structure stored in the buffer, so as to ensure the consistency between the hierarchical structure tree stored in the buffer and the corresponding hierarchical structure in the database, and avoid obtaining an erroneous query result when subsequently and directly querying the data according to the hierarchical structure tree stored in the buffer.
And S206, performing data query according to the hierarchical structure tree, generating a query result, and ending the operation.
S207, inquiring the data requested to be inquired by the data inquiry request from a database according to the target data identification information, and generating an inquiry result.
Specifically, when the data query request is a non-hierarchical relationship query request, for example, when the data query request is used for querying data content of the target data itself or content of other non-hierarchical relationships, data corresponding to the query condition in the data query request may be queried from the database directly according to the query condition in the data query request, and a query result including the queried data is generated, and an operation of constructing a hierarchical structure tree of the target hierarchical structure is not required, so that the speed of processing the non-hierarchical relationship query request by the server is prevented from being affected by constructing the hierarchical structure tree.
According to the data query method provided by the embodiment, when the hierarchical structure tree of the target hierarchical structure is stored in the cache, data caching is directly carried out on the basis of the hierarchical structure tree; when the hierarchical structure tree of the target hierarchical structure is not stored in the cache, whether the data query request is the hierarchical relationship query request is judged, when the data query request is the hierarchical relationship query request, the hierarchical structure tree of the target hierarchical structure is built in the cache, and when the data query request is not the hierarchical relationship query request, the data is directly queried from the database, so that the data query speed of the server can be further improved, and the waiting time of a user is reduced.
Fig. 3 is a block diagram of a data query device according to an embodiment of the present disclosure. The device can be implemented by software and/or hardware, can be configured in an electronic device, and can be typically configured in a server, and can perform data query by executing a data query method. As shown in fig. 3, the data query apparatus provided in this embodiment may include: a request receiving module 301, a field obtaining module 302, a building module 303, and a first data querying module 304, wherein,
a request receiving module 301, configured to receive a data query request, where the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure;
a field obtaining module 302, configured to obtain, according to the target data identification information, a hierarchical structure field of the target data, where the hierarchical structure field is a metadata field used for indicating a hierarchical relationship of the target data in the target hierarchical structure;
a building module 303 for building a hierarchical tree of the target hierarchical structure based on the hierarchical structure field;
the first data query module 304 is configured to perform data query according to the hierarchical structure tree, and generate a query result.
The data query device provided in this embodiment receives, by a request receiving module, a data query request carrying target data identification information of target data in a target hierarchical structure, and obtains, by a field obtaining module, a hierarchical structure field of the target data according to the target data identification information, where the hierarchical structure field is a metadata field used for indicating a hierarchical relationship of the target data in the target hierarchical structure, and a hierarchical structure tree of the target hierarchical structure is built by a building module based on the hierarchical structure field, and then, a first data query module performs data query according to the hierarchical structure tree, so as to generate a query result. By adopting the technical scheme, the hierarchical relationship of the data in the hierarchical structure is indicated by the hierarchical structure field, a table structure of the hierarchical structure is not required to be fixed, and the hierarchical relationship of the data in the hierarchical structure is not required to be defined by hard coding code logic, so that the situation that a plurality of similar code logics occur when a plurality of hierarchical structures exist in the system can be avoided, the redundancy of the code is reduced, and the expansion capability of the system is improved. In addition, since the hierarchical relation of the data in the hierarchical structure is not required to be defined by hard code logic, the mutual calling between the metadata in the system and the hierarchical structure realized by solidification is not required to be realized, and the self-defining capability of the metadata in the system can be further improved.
Optionally, the hierarchy field is used to indicate data identification information of data immediately above the target data in the target hierarchy.
Optionally, each piece of data in the target hierarchy has at most one directly superior piece of data.
Optionally, the building module 303 is configured to: building a hierarchy tree of the target hierarchy in a cache based on the hierarchy field.
Optionally, the field obtaining module 302 is configured to: if the hierarchical structure tree of the target hierarchical structure is not stored in the cache, acquiring a hierarchical structure field of the target data according to the target data identification information; the device further comprises: the second data query module is used for: and if the hierarchical structure tree of the target hierarchical structure is stored in the cache, performing data query according to the hierarchical structure tree to generate a query result.
Optionally, the building module 303 includes: an obtaining unit, configured to obtain data identification information and a hierarchical structure field of each data in the target hierarchical structure; the construction unit is used for determining the hierarchical relationship of each data according to the hierarchical structure field and constructing the hierarchical structure tree of the target hierarchical structure according to the hierarchical relationship of each data, wherein nodes in the hierarchical structure tree correspond to each data in the target hierarchical structure one by one, and data identification information of the corresponding data is recorded in each node.
Optionally, the first data query module 304 includes: a matching node marking unit, configured to sequentially judge whether each node in the hierarchical structure tree matches a query condition carried in a data query request according to a preset traversal rule, and mark a node matching the query condition as a matching node; and the result generating unit is used for generating a query result according to the data identification information recorded in each matching node when the traversal is completed.
Optionally, the data query apparatus provided in this embodiment may further include: a request determining module, configured to determine that the data query request is a hierarchical relationship query request including a hierarchical relationship lookup matching symbol before the hierarchical structure field of the target data is obtained according to the target data identification information.
Optionally, the data query apparatus provided in this embodiment may further include: and the third data query module is used for querying the data requested to be queried by the data query request from a database according to the target data identification information when the data query request is a non-hierarchical relationship query request, and generating a query result.
The data query device provided by the embodiment of the disclosure can execute the data query method provided by any embodiment of the disclosure, and has the corresponding functional module and beneficial effect of executing the data query method. For technical details that are not described in detail in this embodiment, reference may be made to a data query method provided in any embodiment of the present disclosure.
Referring now to FIG. 4, a block diagram of an electronic device (e.g., server) 400 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 4, the electronic device 400 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 401 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage device 406 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic apparatus 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 406 including, for example, magnetic tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate wirelessly or by wire with other devices to exchange data. While fig. 4 illustrates an electronic device 400 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 409, or from the storage means 406, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving a data query request, wherein the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure; acquiring a hierarchical structure field of the target data according to the target data identification information, wherein the hierarchical structure field is a metadata field used for indicating the hierarchical relationship of the target data in the target hierarchical structure; building a hierarchy tree of the target hierarchy based on the hierarchy field; and performing data query according to the hierarchical structure tree to generate a query result.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, 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.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the names of the modules do not in some cases constitute a limitation of the unit itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Example 1 provides, in accordance with one or more embodiments of the present disclosure, a data query method including:
receiving a data query request, wherein the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure;
acquiring a hierarchical structure field of the target data according to the target data identification information, wherein the hierarchical structure field is a metadata field used for indicating the hierarchical relationship of the target data in the target hierarchical structure;
building a hierarchy tree of the target hierarchy based on the hierarchy field;
and performing data query according to the hierarchical structure tree to generate a query result.
Example 2 the method of example 1, the hierarchy field to indicate data identification information of data immediately above the target data in the target hierarchy.
Example 3 in accordance with the method of example 2, each piece of data in the target hierarchy has at most one immediate superior piece of data, in accordance with one or more embodiments of the present disclosure.
Example 4 the method of example 1, the building a hierarchical tree of the target hierarchy based on the hierarchy fields, comprising:
building a hierarchy tree of the target hierarchy in a cache based on the hierarchy field.
Example 5 the method of example 4, the obtaining the hierarchy field of the target data according to the target data identification information, according to one or more embodiments of the present disclosure, comprising:
if the hierarchical structure tree of the target hierarchical structure is not stored in the cache, acquiring a hierarchical structure field of the target data according to the target data identification information;
the method further comprises the following steps:
and if the hierarchical structure tree of the target hierarchical structure is stored in the cache, performing data query according to the hierarchical structure tree to generate a query result.
Example 6 the method of any of examples 1-5,
the building a hierarchy tree of the target hierarchy based on the hierarchy fields, comprising:
acquiring data identification information and a hierarchical structure field of each data in the target hierarchical structure;
determining the hierarchical relationship of each data according to a hierarchical structure field, and constructing a hierarchical structure tree of the target hierarchical structure according to the hierarchical relationship of each data, wherein nodes in the hierarchical structure tree correspond to each data in the target hierarchical structure one by one, and data identification information of the corresponding data is recorded in each node.
Example 7 the method of example 6, the querying data according to the hierarchical structure tree to generate query results, comprising:
sequentially judging whether each node in the hierarchical structure tree is matched with a query condition carried in a data query request according to a preset traversal rule, and marking the node matched with the query condition as a matched node;
and when the traversal is completed, generating a query result according to the data identification information recorded in each matching node.
Example 8 the method of any of examples 1-5, further comprising, prior to the obtaining the hierarchical structure field of the target data according to the target data identification information, according to one or more embodiments of the present disclosure:
determining the data query request to be a hierarchical relationship query request comprising a hierarchical relationship lookup match.
Example 9 the method of example 8, in accordance with one or more embodiments of the present disclosure, further comprising:
and if the data query request is a non-hierarchical relationship query request, querying the data requested to be queried by the data query request from a database according to the target data identification information, and generating a query result.
Example 10 provides, in accordance with one or more embodiments of the present disclosure, a data query apparatus, including:
a request receiving module, configured to receive a data query request, where the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure;
a field obtaining module, configured to obtain, according to the target data identification information, a hierarchical structure field of the target data, where the hierarchical structure field is a metadata field used for indicating a hierarchical relationship of the target data in the target hierarchical structure;
a building module to build a hierarchy tree of the target hierarchy based on the hierarchy field;
and the first data query module is used for performing data query according to the hierarchical structure tree to generate a query result.
Example 11 provides, in accordance with one or more embodiments of the present disclosure, an electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the data query method of any of examples 1-9.
Example 12 provides a computer-readable storage medium having stored thereon a computer program that, when executed by a processor, implements the data query method of any of examples 1-9.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (12)

1. A method for querying data, comprising:
receiving a data query request, wherein the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure;
acquiring a hierarchical structure field of the target data according to the target data identification information, wherein the hierarchical structure field is a metadata field used for indicating the hierarchical relationship of the target data in the target hierarchical structure;
building a hierarchy tree of the target hierarchy based on the hierarchy field;
and performing data query according to the hierarchical structure tree to generate a query result.
2. The method of claim 1, wherein the hierarchy field is used to indicate data identification information of data immediately above the target data in the target hierarchy.
3. The method of claim 2, wherein each piece of data in the target hierarchy has at most one directly superior piece of data.
4. The method of claim 1, wherein said building a hierarchy tree of the target hierarchy based on the hierarchy fields comprises:
building a hierarchy tree of the target hierarchy in a cache based on the hierarchy field.
5. The method of claim 4, wherein the obtaining the hierarchical structure field of the target data according to the target data identification information comprises:
if the hierarchical structure tree of the target hierarchical structure is not stored in the cache, acquiring a hierarchical structure field of the target data according to the target data identification information;
the method further comprises the following steps:
and if the hierarchical structure tree of the target hierarchical structure is stored in the cache, performing data query according to the hierarchical structure tree to generate a query result.
6. The method of any of claims 1-5, wherein said building a hierarchy tree of said target hierarchy based on said hierarchy fields comprises:
acquiring data identification information and a hierarchical structure field of each data in the target hierarchical structure;
determining the hierarchical relationship of each data according to a hierarchical structure field, and constructing a hierarchical structure tree of the target hierarchical structure according to the hierarchical relationship of each data, wherein nodes in the hierarchical structure tree correspond to each data in the target hierarchical structure one by one, and data identification information of the corresponding data is recorded in each node.
7. The method of claim 6, wherein performing a data query according to the hierarchical tree to generate a query result comprises:
sequentially judging whether each node in the hierarchical structure tree is matched with a query condition carried in a data query request according to a preset traversal rule, and marking the node matched with the query condition as a matched node;
and when the traversal is completed, generating a query result according to the data identification information recorded in each matching node.
8. The method according to any one of claims 1-5, further comprising, before said obtaining the hierarchical structure field of the target data according to the target data identification information:
determining the data query request to be a hierarchical relationship query request comprising a hierarchical relationship lookup match.
9. The method of claim 8, further comprising:
and if the data query request is a non-hierarchical relationship query request, querying the data requested to be queried by the data query request from a database according to the target data identification information, and generating a query result.
10. A data query apparatus, comprising:
a request receiving module, configured to receive a data query request, where the data query request carries target data identification information of target data, and the target data is data in a target hierarchical structure;
a field obtaining module, configured to obtain, according to the target data identification information, a hierarchical structure field of the target data, where the hierarchical structure field is a metadata field used for indicating a hierarchical relationship of the target data in the target hierarchical structure;
a building module to build a hierarchy tree of the target hierarchy based on the hierarchy field;
and the first data query module is used for performing data query according to the hierarchical structure tree to generate a query result.
11. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the data query method of any one of claims 1-9.
12. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a data query method as claimed in any one of claims 1 to 9.
CN202110152798.1A 2021-02-03 2021-02-03 Data query method, device, electronic equipment and storage medium Active CN112836093B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110152798.1A CN112836093B (en) 2021-02-03 2021-02-03 Data query method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110152798.1A CN112836093B (en) 2021-02-03 2021-02-03 Data query method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112836093A true CN112836093A (en) 2021-05-25
CN112836093B CN112836093B (en) 2023-11-21

Family

ID=75932073

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110152798.1A Active CN112836093B (en) 2021-02-03 2021-02-03 Data query method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112836093B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113420050A (en) * 2021-06-28 2021-09-21 平安普惠企业管理有限公司 Data query management method and device, computer equipment and readable storage medium
CN115033608A (en) * 2022-08-12 2022-09-09 广东采日能源科技有限公司 Energy storage system information grading processing method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105205104A (en) * 2015-08-26 2015-12-30 成都布林特信息技术有限公司 Cloud platform data acquisition method
US20160034700A1 (en) * 2014-07-31 2016-02-04 Infotrax Systems, L.C. Search permissions within hierarchically associated data
US20160179921A1 (en) * 2014-12-22 2016-06-23 Amazon Technologies, Inc. Identifying join relationships based on transactional access patterns
CN108628915A (en) * 2017-07-26 2018-10-09 北京视联动力国际信息技术有限公司 A kind of record queries method and device
CN111742308A (en) * 2018-02-22 2020-10-02 北京嘀嘀无限科技发展有限公司 System and method for data storage and query
CN111858601A (en) * 2020-07-23 2020-10-30 中国平安财产保险股份有限公司 Tree structure data query method, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160034700A1 (en) * 2014-07-31 2016-02-04 Infotrax Systems, L.C. Search permissions within hierarchically associated data
US20160179921A1 (en) * 2014-12-22 2016-06-23 Amazon Technologies, Inc. Identifying join relationships based on transactional access patterns
CN105205104A (en) * 2015-08-26 2015-12-30 成都布林特信息技术有限公司 Cloud platform data acquisition method
CN108628915A (en) * 2017-07-26 2018-10-09 北京视联动力国际信息技术有限公司 A kind of record queries method and device
CN111742308A (en) * 2018-02-22 2020-10-02 北京嘀嘀无限科技发展有限公司 System and method for data storage and query
CN111858601A (en) * 2020-07-23 2020-10-30 中国平安财产保险股份有限公司 Tree structure data query method, device, equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
衣明华;王天骄;江伟仙;: "动车产品结构树的设计与应用", 铁路计算机应用, no. 10, pages 17 - 21 *
赵正扬: "网络仿真应用云化平台的设计与实现", 中国优秀硕士学位论文全文数据库信息科技辑, no. 03, pages 139 - 54 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113420050A (en) * 2021-06-28 2021-09-21 平安普惠企业管理有限公司 Data query management method and device, computer equipment and readable storage medium
CN113420050B (en) * 2021-06-28 2023-08-25 深圳华科讯通科技有限公司 Data query management method, device, computer equipment and readable storage medium
CN115033608A (en) * 2022-08-12 2022-09-09 广东采日能源科技有限公司 Energy storage system information grading processing method and system
CN115033608B (en) * 2022-08-12 2022-11-04 广东采日能源科技有限公司 Energy storage system information grading processing method and system

Also Published As

Publication number Publication date
CN112836093B (en) 2023-11-21

Similar Documents

Publication Publication Date Title
JP6243524B2 (en) Determination of location information using location data points provided by a computing device
US11120458B2 (en) Group-based sequential recommendations
CN107103011B (en) Method and device for realizing terminal data search
JP2020502610A (en) Allow Semantic Mashups on the Internet of Things
CN107092623B (en) Interest point query method and device
CN112836093B (en) Data query method, device, electronic equipment and storage medium
CN111291103A (en) Interface data analysis method and device, electronic equipment and storage medium
CN111240767A (en) Component and page loading method and device, electronic equipment and storage medium
CN111950857A (en) Index system management method and device based on service indexes and electronic equipment
CN111241137A (en) Data processing method and device, electronic equipment and storage medium
CN110852720A (en) Document processing method, device, equipment and storage medium
CN114461247A (en) Hot update method, device, electronic equipment and computer readable medium
CN113704291A (en) Data query method and device, storage medium and electronic equipment
CN111597403A (en) Method and device for constructing graph index, electronic equipment and storage medium
CN116226189A (en) Cache data query method, device, electronic equipment and computer readable medium
CN114629951A (en) Address service switching method and device, computer equipment and storage medium
CN112507676B (en) Method and device for generating energy report, electronic equipment and computer readable medium
CN110941683A (en) Method, device, medium and electronic equipment for acquiring object attribute information in space
CN116483808B (en) Data migration method, device, electronic equipment and computer readable medium
CN114297157B (en) File processing method, device, equipment and medium
CN116820354B (en) Data storage method, data storage device and data storage system
CN113342837B (en) Data transmission method, device, electronic equipment and computer readable medium
CN110716885B (en) Data management method and device, electronic equipment and storage medium
CN108322380B (en) Method and device for calling data and method and device for pushing information
CN114036321A (en) Request processing method and device, electronic equipment and computer readable medium

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