CN111176857A - Method and device for intelligently providing data - Google Patents
Method and device for intelligently providing data Download PDFInfo
- Publication number
- CN111176857A CN111176857A CN201811339932.3A CN201811339932A CN111176857A CN 111176857 A CN111176857 A CN 111176857A CN 201811339932 A CN201811339932 A CN 201811339932A CN 111176857 A CN111176857 A CN 111176857A
- Authority
- CN
- China
- Prior art keywords
- independent
- node
- data
- nodes
- data structure
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 66
- 230000001419 dependent effect Effects 0.000 claims abstract description 85
- 238000012545 processing Methods 0.000 claims abstract description 15
- 230000005540 biological transmission Effects 0.000 claims abstract description 7
- 230000008569 process Effects 0.000 claims description 17
- 238000010276 construction Methods 0.000 claims description 8
- 230000006870 function Effects 0.000 description 31
- 238000011161 development Methods 0.000 description 7
- 238000012360 testing method Methods 0.000 description 4
- 230000004044 response Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 230000014509 gene expression Effects 0.000 description 2
- 239000000126 substance Substances 0.000 description 2
- 238000012356 Product development Methods 0.000 description 1
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000001174 ascending effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000000977 initiatory effect Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/541—Client-server
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The invention discloses a method and a device for intelligently providing data, wherein the method comprises the following steps: setting independent root nodes and dependent nodes; the non-independent nodes comprise at least one independent root node and/or at least one other non-independent node; a first party receives a data request, wherein the data request is a request for acquiring specific contents of at least one independent root node and/or at least one non-independent node; the first party determines a data structure; the data structure comprises the identification of the independent root node and/or the identification of the non-independent node which are required to be acquired by the data request; the first party constructs an acquisition function comprising a data structure and calls the acquisition function; and after the second party learns that the first party calls the acquisition function, analyzing the data structure in the acquisition function layer by layer, finally determining the contents of all the independent root nodes in the data structure of the acquisition function and returning to the first party. The invention reduces the network transmission of redundant data, and effectively reduces the number of data source interfaces and the concurrent processing of an upper layer or a front end.
Description
Technical Field
The invention relates to the technical field of internet, in particular to a method and a device for intelligently providing data.
Background
In the prior art, when acquiring bottom layer system data or service data, the following characteristics are specified:
first, the data output of the upper layer or the front end is determined by the lower layer or the back end, and when the lower layer or the back end learns a small amount of or individual fields from the upper layer or the front end, the lower layer or the back end generally returns a large amount of data except for the fields which the upper layer or the front end needs to learn.
Secondly, when a lower layer or a back end requests data to an upper layer or a front end, the explanation of the data return situation is not clear enough, because the content of a single field or node is limited by the initial setting of the back end or the system, and then the front end or the client needs to check whether the content of each field of the data exists, the type of the field, the data range of the field and the like after requesting the data.
Thirdly, the existing interfaces are classified according to the service units or the requesting entities or the upper layer requirements, that is, each unit or classification or entity has one or more interface expressions. For example, in a blog system, a blog list page may need to call a blog text list interface, need to obtain each blog comment data interface, need to obtain each category data interface of the blog, and so on, that is, when a user accesses the page, multiple interfaces need to be called, and part of content in each interface is obtained to jointly improve the service presentation of the page. Thus, for a simple blog system, there may be tens of interface lists with similar or overlapping data fields and content
Aiming at the first characteristic, along with the rapid development of internet services and the continuous iteration of development technologies, under the condition that the requirements of users are met as soon as possible, the change frequency of products is continuously improved, but the storage or collection of bottom layer service data is relatively slow in iteration speed, so that the original data output mode of determining an upper layer at a lower layer and determining a front end at a rear end cannot meet the product development requirements of high-speed iteration. Meanwhile, since a large amount of the same service data needs to be reflected in different product locations, a large amount of repeated calls and useless data transmission to the network are caused. The useless data not only causes the front end or the upper layer to need to be processed once, but also can cause the problems of low response speed of data request, poor product user experience and bandwidth waste under the conditions of large flow, large data volume and complex network condition.
For the second characteristic, the existing data acquisition mode mostly depends on the improvement of the meanings of all the fields by the bottom layer or the rear end, the existence of the hard-coded writing field, and the data type of the field is converted to meet the requirements of the front end or the upper layer, but in practical application, the data type, the range and other contents of each field are rarely and forcibly required, so that the front end or the upper layer needs to repeatedly check the fields to avoid the problem of display. If a plurality of products or modules use the same data source interface at the same time, the problem of repeated similar codes of the plurality of products or modules is caused, the complexity of front-end or upper-layer logic is increased, and the readability and the maintainability are reduced.
For the third characteristic, the classification of the data sources in the prior art is suitable for mature traditional products, the data content of the products is relatively fixed, so that the number of data source interfaces is relatively small, but the actual internet products have relatively more displayed content and relatively high change frequency, and in addition, the problems of history leaving and the like are that a new interface for acquiring the data sources has to be developed along with new functions at a lower development layer or a rear end in a vertically compatible manner, so that more and more interfaces are generated, and the maintenance cost is more and more important.
Disclosure of Invention
In order to solve the technical problem, the invention provides a method and a device for intelligently providing data.
The method for intelligently providing data provided by the invention comprises the following steps:
setting at least one independent root node and at least one dependent node; the non-independent nodes comprise at least one independent root node and/or at least one other non-independent node;
a first party receives a data request, wherein the data request is a request for acquiring specific contents of at least one independent root node and/or at least one non-independent node;
the first party determines a data structure; the data structure comprises an identifier of an independent root node and/or an identifier of a non-independent node which are/is required to be acquired by the data request;
the first party constructs an acquisition function comprising the data structure and calls the acquisition function;
and after the second party learns that the first party calls the acquisition function, analyzing the data structure in the acquisition function layer by layer, finally determining the contents of all the independent root nodes in the data structure of the acquisition function and returning to the first party.
The method also has the following characteristics:
when the number of dependent nodes that need to be acquired in the data request is greater than 1, the first party constructing the data structure includes: and setting the reference relation of the non-independent nodes in the data structure according to the reference relation of the non-independent nodes.
The method also has the following characteristics:
the data request also comprises a current page display indication, wherein the current page display indication comprises a starting identifier, an identifier interval value and an arrangement mode of at least one independent root node;
the method further comprises the following steps: and the second party determines the content required to be displayed on the current page according to the current page display indication and displays the content according to the arrangement mode.
The method also has the following characteristics:
the dependent nodes also comprise a reference permission attribute, and the value of the reference permission attribute is a value which represents that the dependent nodes can be referenced by other dependent nodes or a value which represents that the dependent nodes can not be referenced by other dependent nodes;
the first party building a data structure comprises: when the current dependent node needs to be referred to by another dependent node, the reference permission attribute of the current dependent node is judged, when the value of the reference permission attribute is a value which indicates that the current dependent node can be referred to by other dependent nodes, the reference is executed, and when the value of the reference permission attribute is a value which indicates that the current dependent node cannot be referred to by other dependent nodes, the reference is abandoned.
The method also has the following characteristics:
the second party analyzing the data structure in the acquisition function layer by layer comprises: inquiring whether the content of the independent root node included in the to-be-analyzed non-independent node is cached or not, if so, directly acquiring the content of the cached independent root node, and when the to-be-analyzed non-independent node includes more than one other non-independent nodes in parallel relation, performing parallel analysis on the other non-independent nodes in parallel relation in the to-be-analyzed non-independent node by using multithreading, multi-corollary or multi-process, and caching the content of all the independent root nodes in the to-be-analyzed non-independent node in the analysis process.
The method also has the following characteristics:
the method further comprises the following steps: the method comprises the steps that a plurality of data structure templates are built in advance, and different data structure templates which are built in advance are matched with different data requests for obtaining specific contents of at least one independent root node and/or at least one non-independent node;
the first party determining data structure comprises: and inquiring whether a pre-constructed data structure template corresponding to the data request exists according to the received data request, if so, determining a data structure corresponding to the data request by using the pre-constructed data structure template, and if not, compiling the data structure meeting the data request according to the received data request.
The invention provides a device for intelligently providing data, which comprises:
the system comprises a setting module, a first party module and a second party module;
the setting module is used for setting at least one independent root node and at least one dependent node; the non-independent nodes comprise at least one independent root node and/or at least one other non-independent node;
the first party module comprises:
a receiving module, configured to receive a data request, where the data request is a request for obtaining specific content of at least one independent root node and/or at least one non-independent node;
a determining module for constructing a data structure; the data structure comprises an identifier of an independent root node and/or an identifier of a non-independent node which are/is required to be acquired by the data request;
a construction module for constructing an acquisition function comprising the data structure;
the calling module is used for calling the acquisition function;
the second square module comprises:
the acquisition module is used for acquiring that the first party calls the acquisition function;
the analysis module is used for analyzing the data structure in the acquisition function layer by layer after the acquisition module learns that the first party calls the acquisition function, and finally determining the content of all independent root nodes in the data structure of the acquisition function;
and the returning module is used for returning the contents of all independent root nodes in the data structure of the acquisition function determined by the analyzing module to the first party module.
The device also has the following characteristics:
when the number of dependent nodes that need to be acquired in the data request is greater than 1, the first party constructing the data structure includes: and setting the reference relation of the non-independent nodes in the data structure according to the reference relation of the non-independent nodes.
The device also has the following characteristics:
the data request also comprises a current page display indication, wherein the current page display indication comprises a starting identifier, an identifier interval value and an arrangement mode of at least one independent root node;
the second module also comprises a display processing module, and the display processing module is used for determining the content required to be displayed on the current page according to the display indication of the current page and displaying the content according to the arrangement mode.
The device also has the following characteristics:
the dependent nodes also comprise a reference permission attribute, and the value of the reference permission attribute is a value which represents that the dependent nodes can be referenced by other dependent nodes or a value which represents that the dependent nodes can not be referenced by other dependent nodes;
the determination module is further configured to construct a data structure using the following method: when the current dependent node needs to be referred to by another dependent node, the reference permission attribute of the current dependent node is judged, when the value of the reference permission attribute is a value which indicates that the current dependent node can be referred to by other dependent nodes, the reference is executed, and when the value of the reference permission attribute is a value which indicates that the current dependent node cannot be referred to by other dependent nodes, the reference is abandoned.
The device also has the following characteristics:
the query unit is used for querying whether the content of the independent root node included in the non-independent node to be analyzed is cached or not, and directly acquiring the cached content of the independent root node if the content of the independent root node is cached;
the parallel analysis unit is used for carrying out parallel analysis on other non-independent nodes in parallel relation in the non-independent nodes to be analyzed by using multiple threads, multiple coroutines or multiple processes when the non-independent nodes to be analyzed comprise more than one other non-independent nodes in parallel relation;
and the cache unit caches the contents of all independent root nodes in the to-be-analyzed non-independent nodes in the analysis process.
The device also has the following characteristics:
the parsing module further comprises:
the system comprises a pre-construction module, a data acquisition module and a data transmission module, wherein the pre-construction module is used for pre-constructing a plurality of data structure templates, and different pre-constructed data structure templates are matched with different data requests for acquiring specific contents of at least one independent root node and/or at least one non-independent node;
the determining module is further configured to determine the data structure using: and inquiring whether a pre-constructed data structure template corresponding to the data request exists according to the received data request, if so, determining a data structure corresponding to the data request by using the pre-constructed data structure template, and if not, compiling the data structure meeting the data request according to the received data request.
The invention has the following advantages:
a) the method comprises the following steps The network transmission of redundant data is reduced, and the network response speed can be effectively accelerated and the user experience is improved under the condition that the data nodes are large or the contents are more, such as information blogs, the texts are huge but the text full-text contents do not need to be returned most of the time.
b) The method comprises the following steps The number of data source interfaces is effectively reduced, because the scheme fixedly uses the uniform entrance, different contents are only limited by transmitted parameter values, only one interface is provided for the outside, the interface condition does not need to be considered at the upper layer or the front end, and only data composition of request parameter values needs to be made
c) The method comprises the following steps The concurrent processing of the upper layer or the front end is reduced, and all data content format requirements are acquired at one time through the request parameter values, so that the upper layer or the front end does not need to consider the problem of data combination during the multi-interface concurrent, and the code complexity of the upper layer or the front end is reduced.
d) The method comprises the following steps The expansibility of the data source interface is more flexible, and because the upper layer or the front-end caller can freely combine nodes according to the requirements, as long as the lower layer or the back-end developer formulates a data structure and an explanation, the user can freely combine data requests required by any product or service, and other developers do not need to do any operation or development in the whole process, thereby greatly reducing the communication and development cost of the whole front-end or the upper-layer and the lower-layer.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate an embodiment of the invention and, together with the description, serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a flowchart of a method of intelligently providing data in an embodiment;
fig. 2 is a block diagram of an apparatus for intelligently providing data according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
As shown in fig. 1, the method for intelligently providing data includes:
102, a first party receives a data request, wherein the data request is a request for acquiring specific contents of at least one independent root node and/or at least one non-independent node;
103, the first party constructs a data structure; the data structure comprises an identifier of an independent root node and/or an identifier of a non-independent node which are/is required to be acquired by a data request;
step 104, the first party constructs an acquisition function comprising the data structure and calls the acquisition function;
and 105, after the second party learns that the first party calls the acquisition function, analyzing the data structure in the acquisition function layer by layer, and finally determining and returning the contents of all independent root nodes in the data structure of the acquisition function to the first party.
In the method, the first party is an upper layer or a front end and is a party initiating the request, and for example, the first party may be a client, a requester or a browser. The second party is the lower layer or backend and is the party receiving the request, which may be a background processor, for example.
In order to clearly indicate the display mode of the second party, the data request further comprises a current page display indication, and the current page display indication comprises a starting identifier, an identifier interval value and an arrangement mode of at least one independent root node; step 105 is followed by: and the first party determines the content required to be displayed on the current page according to the current page display indication and displays the content according to the arrangement mode.
The dependent nodes further include a reference permission attribute whose value is a value indicating that it can be referenced by other dependent nodes or a value indicating that it cannot be referenced by other dependent nodes. The step 103 of the first party constructing the data structure comprises: when the current dependent node needs to be referred to by another dependent node, the reference permission attribute of the current dependent node is judged, when the value of the reference permission attribute is a value which indicates that the current dependent node can be referred to by other dependent nodes, the reference is executed, and when the value of the reference permission attribute is a value which indicates that the current dependent node cannot be referred to by other dependent nodes, the reference is abandoned.
In order to improve the analysis efficiency of the second party, the layer-by-layer analysis of the data structure in the acquisition function by the second party includes: inquiring whether the content of the independent root node included in the to-be-analyzed non-independent node is cached or not, if so, directly acquiring the content of the cached independent root node, and when the to-be-analyzed non-independent node includes more than one other non-independent nodes in parallel relation, performing parallel analysis on the other non-independent nodes in parallel relation in the to-be-analyzed non-independent node by using multiple threads, multiple coroutines or multiple processes, and caching the content of all the independent root nodes in the to-be-analyzed non-independent node in the analysis process. When the multi-protocol or multi-thread is used for parallel analysis, data of different protocol or threads can be shared without additional processing, but when the multi-process is used for parallel analysis, a processing process for processing data information transmission contents among multiple processes needs to be added.
In order to reduce the operation of repeatedly processing the same kind of data requests, the method further comprises the following steps: a plurality of data structure templates are pre-constructed, and different pre-constructed data structure templates are matched with different data requests for acquiring specific contents of at least one independent root node and/or at least one non-independent node. Wherein the first party determining data structure in step 103 comprises: and inquiring whether a pre-constructed data structure template corresponding to the data request exists according to the received data request, if so, determining a data structure corresponding to the data request by using the pre-constructed data structure template, and if not, compiling the data structure meeting the data request according to the received data request.
Specific examples are as follows:
detailed description of the preferred embodiment
The application scene is a blog application, and information in the blog application comprises: information of the author, the content of the article, comments of the article, whether the reviewer is interested in the author of the blog.
Wherein the content of the first and second substances,
the author's information includes: author identification (user _ id), author name (name), author registration identification (e.g., mailbox (email)).
The contents of the article include: article identification (post _ id), article content (post _ content), article title (title).
The content of the comment includes: comment identification (comment _ id), comment content (comment _ content), and comment title (comment _ title).
Information for indicating whether or not the reviewer is interested in this blog author: an array (follow [ ]) for indicating whether the reviewer is interested in the author of this blog.
Three data tables are stored in the database, a data table of information about an author, a data table of contents about an article, and a data table about a comment (the data tables include the contents of the comment and information indicating whether a commentator pays attention to the blog author).
If the data is acquired by using the traditional method in the prior art, the following interfaces are needed to be arranged:
an interface for obtaining information of a blog author;
an interface for obtaining content of an article;
an interface for obtaining content of the comment;
an interface for obtaining information whether the commentator is interested in the blog author.
When a certain interface is called by using a traditional mode in the prior art, the upper layer returns the contents of all parameters contained in the dependent node corresponding to the interface, wherein the contents of a part of parameters may not be obtained by a requester, so that the data is not provided accurately enough. Moreover, if all the contents of a blog need to be displayed, all the four interfaces need to be called to obtain the required data, and the calling process is complicated.
When the scheme of the invention is used, the independent root nodes are defined as follows: user _ id, name, email, content, post _ id, comment _ id.
Non-independent nodes are defined as follows: user, Post, Comment.
Specifically, the method comprises the following steps:
wherein, a fixed expression is established for explaining whether the node exists or not, and whether the node exists necessarily or not is represented by an array form of a returned xxx node, for example, "[ xxx ]"; using "xxx! "indicates that the xxx node cannot be empty; use "[ xxx! | A! "indicates that the array cannot be empty and the node xxx in the array cannot be empty at the same time; "! "when initialized in the internal field indicates that this node must be present when requested.
After the above node definition is performed, the page requirement is to obtain all the contents of the article identifier 778800 identified by the user identifier ABC, and the request data structure is written according to the page requirement as follows:
and when the number of the dependent nodes needing to be acquired in the data request is more than 1, setting the reference relation of the dependent nodes in the data structure according to the reference relation of the dependent nodes. For example:
in the data request, the email parameter with user id ABC and the blog content with blog id 778800, all comment content and basic blogger information under the user id need to be acquired, and the constructed data structure is as follows:
in the above, the data structure satisfying all the requirements is constructed, and then the acquisition function including the data structure is constructed as follows:
GET/api?query={User(user_id:ABC){email,follower,Post(post_id:778800){title,content,Comment{comment_id,title,content,User{user_id,email}}}}}
and calling the acquisition function.
Thus, the first party constructs a completed data structure, and by means of this data structure, it is possible to know which parameters the second party is specifically required to return.
And the second party analyzes layer by layer after receiving the request, firstly, the first layer of User nodes define that the User nodes are non-independent nodes, so that the system automatically calls a node analyzer of the User, and obtains the data of the User nodes according to the id transmitted by the User nodes. Analyzing the email node after entering, and directly acquiring the value of the email because the email node is an independent root node; processing the follower nodes in parallel in the same way as the email; the Post nodes are processed in parallel, and each field in the Post nodes is processed recursively like the User nodes because the Post fields in the User nodes use the predefined Post nodes. And analogizing in turn, processing each node layer by layer, and finally completing the data acquisition of the whole request.
In order to clearly indicate the display mode of the second party, the data request further includes a current page display indication, and the current page display indication includes a start identifier, an identifier interval value, and an arrangement mode of at least one independent root node. And the second party determines the content required to be displayed on the current page according to the current page display instruction and displays the content according to the arrangement mode.
For example: the current page display indication in the data request includes: ShowPost (_ from:10, _ size:20, _ order: id: desc), where ShowPost represents an instruction to display blog articles, _ from:10 represents a number labeled 10 from the blog, _ size:20 represents a total of 20 articles displayed, and _ order: id: desc represents an arrangement to be displayed in descending order of blog identification.
For another example: the current page display indication in the data request includes: ShowCommment (_ from:10, _ size:5, _ order: id: asc), wherein ShowCommment represents an instruction to display comments, _ from:10 represents a number of symbols identified from the comments by 10, _ size:5 represents a total of 20 displayed comments, and _ order: id: asc represents an arrangement in which the comments are displayed in ascending order of their identifications.
The specific embodiment further comprises: and pre-constructing a data structure template, wherein the pre-constructed different data structure templates are matched with the obtained email parameter with the user ID being a certain user ID, and the blog ID under the user ID is the blog content, all comment content and the basic information data request of the blogger of the certain blog ID.
For example, the data structure template is:
when the first party determines the data structure, and receives a request for acquiring an email parameter with a user ID being a certain user ID and blog content, all comment content and basic blog information data of which the blog ID under the user ID is a certain blog ID, the first party can query a pre-constructed data structure template corresponding to the data request according to the request, so that the pre-constructed data structure template is used for determining the data structure corresponding to the data request.
Detailed description of the invention
The application scene is the background abnormal examination result display of the simple internal examination system.
What this applies is that the information includes: the information of the examiner includes, for example, information of a company employee, examination paper information, and question information.
Wherein, the information of the company staff comprises: employee identification (staff _ id), employee name (staff _ name), employee mailbox (staff _ email).
Topic information: topic identification (query _ id), topic title (query _ title), topic content (query _ content), and topic author (query _ author _ id).
And (3) examination paper information: test paper identification (exam _ id), test paper title (exam _ title), title (query), staff identification (staff _ id), score (score).
Three data tables are maintained in the database:
the stabf table includes three fields: the staff _ id, the staff _ name and the staff _ email.
The query table, includes four fields: a query _ id, a query _ title, a query _ content, and a query _ author _ id.
The exam table, includes five fields: exam _ id, exam _ title, query _ ids, staff _ id, score. Where, query _ ids is an array.
If the data is acquired by using the traditional method in the prior art, the following interfaces are needed to be arranged:
an interface for obtaining employee information;
an interface for obtaining topic information;
and the interface is used for acquiring the test paper information.
When a certain interface is called by using a traditional mode in the prior art, the upper layer returns the contents of all parameters contained in the dependent node corresponding to the interface, wherein the contents of a part of parameters may not be obtained by a requester, so that the data is not provided accurately enough. Moreover, if the content of the examination page needs to be displayed, all three interfaces need to be called to obtain the required data, and the calling process is complicated.
When the scheme of the invention is used, the independent root nodes are defined as follows: status _ id, status _ name, status _ email, queue _ id, queue _ title, queue _ content, queue _ author _ id, exam _ title, queue _ ids, score.
Non-independent nodes are defined as follows: staff, Question, Exam.
After the above nodes are defined, the page requirement is to obtain the relevant information of the employee identifier ABC under all the questions with the test paper identifier 123, and a request data structure needs to be compiled according to the page requirement as follows:
the above is the data field and data structure that satisfy all the requirements of the page, and then the acquisition function including the above data structure is constructed as follows: GET/api? query (Exam _ id:123) { Exam _ title, Qestion { query _ id, query _ title, query _ content, Staff (Staff _ id: ABC) { email, name } }, extension (Staff _ id: ABC) { name, email }, score } }
This get function is invoked.
Thus, the first party constructs a completed data structure, and by means of this data structure, it is possible to know which parameters the second party is specifically required to return.
And the second party analyzes layer by layer after receiving the request, processes each node layer by layer and finally completes the data acquisition of the whole request.
As shown in fig. 2, the apparatus for intelligently providing data includes: the device comprises a setting module, a first party module and a second party module.
A setting module for setting at least one independent root node and at least one dependent node; the non-independent nodes comprise at least one independent root node and/or at least one other non-independent node;
the first party module includes:
a receiving module, configured to receive a data request, where the data request is a request for obtaining specific content of at least one independent root node and/or at least one non-independent node;
a determining module for constructing a data structure; the data structure comprises an identifier of an independent root node and/or an identifier of a non-independent node which are/is required to be acquired by the data request;
a construction module for constructing an acquisition function comprising the data structure;
the calling module is used for calling the acquisition function;
the second square module comprises:
the acquisition module is used for acquiring that the first party calls the acquisition function;
and the analysis module is used for analyzing the data structure in the acquisition function layer by layer after the acquisition module learns that the first party calls the acquisition function, and finally determining the content of all independent root nodes in the data structure of the acquisition function.
And the returning module is used for returning the contents of all independent root nodes in the data structure of the acquisition function determined by the analyzing module to the first party module.
Wherein the content of the first and second substances,
when the number of dependent nodes that need to be acquired in the data request is greater than 1, the first party constructing the data structure includes: and setting the reference relation of the non-independent nodes in the data structure according to the reference relation of the non-independent nodes.
The data request also comprises a current page display indication, wherein the current page display indication comprises a starting identifier, an identifier interval value and an arrangement mode of at least one independent root node. The second module also comprises a display processing module, and the display processing module is used for determining the content required to be displayed on the current page according to the display indication of the current page and displaying the content according to the arrangement mode.
The dependent nodes further include a reference permission attribute whose value is a value indicating that it can be referenced by other dependent nodes or a value indicating that it cannot be referenced by other dependent nodes. The determination module is further configured to construct the data structure using the following method: when the current dependent node needs to be referred to by another dependent node, the reference permission attribute of the current dependent node is judged, when the value of the reference permission attribute is a value which indicates that the current dependent node can be referred to by other dependent nodes, the reference is executed, and when the value of the reference permission attribute is a value which indicates that the current dependent node cannot be referred to by other dependent nodes, the reference is abandoned.
The analysis module further comprises:
the query unit is used for querying whether the content of the independent root node included in the non-independent node to be analyzed is cached or not, and directly acquiring the cached content of the independent root node if the content of the independent root node is cached;
the parallel analysis unit is used for carrying out parallel analysis on other non-independent nodes in parallel relation in the non-independent nodes to be analyzed by using multiple threads, multiple coroutines or multiple processes when the non-independent nodes to be analyzed comprise more than one other non-independent nodes in parallel relation;
and the cache unit caches the contents of all independent root nodes in the to-be-analyzed non-independent nodes in the analysis process.
The parsing module further comprises a pre-construction module for pre-constructing a plurality of data structure templates, different pre-constructed data structure templates matching different data requests for obtaining specific content of at least one independent root node and/or at least one non-independent node.
The determining module is further configured to determine the data structure using: and inquiring whether a pre-constructed data structure template corresponding to the data request exists according to the received data request, if so, determining a data structure corresponding to the data request by using the pre-constructed data structure template, and if not, compiling the data structure meeting the data request according to the received data request.
The method is carried out in a mode that the upper layer or the front end dominates the lower layer or the rear end. The upper layer or the front end specifies the content to be returned according to the product or module requirements, and the content is combined into a complete request statement through a specific data structure and then sent to the lower layer or the rear end. The lower layer or the back end analyzes according to the request statement, acquires the required content from the memory or the storage system and returns the content to the upper layer or the front end, and the data which is not returned in the field or the node required by the request statement.
The lower layer or the back end analyzes the request designated node, obtains the nodes required by the request, and analyzes each node one by one. And if the node is the independent root node, directly acquiring corresponding content. If the node is a non-independent node, the contents of each non-independent node or independent root node in the node need to be recursively acquired, and finally the value of each node is combined according to the requested data structure to form a final return value, and the final return value is returned to an upper layer or a front end.
In the method, a uniform request entry mode is used, the entries of all request interfaces are unique, and the difference of different data requests is only in the data structure content of the fixed node, so that a plurality of data source interfaces cannot be generated, and the lower layer or the back end only needs to pay attention to the description of the nodes supported by the system.
Compared with the prior art, the method has the technical advantages that:
a) the method comprises the following steps The network transmission of redundant data is reduced, and the network response speed can be effectively accelerated and the user experience is improved under the condition that the data nodes are large or the contents are more, such as information blogs, the texts are huge but the text full-text contents do not need to be returned most of the time.
b) The method comprises the following steps The number of data source interfaces is effectively reduced, because the scheme fixedly uses the uniform entrance, different contents are only limited by transmitted parameter values, only one interface is provided for the outside, the interface condition does not need to be considered at the upper layer or the front end, and only data composition of request parameter values needs to be made
c) The method comprises the following steps The concurrent processing of the upper layer or the front end is reduced, and all data content format requirements are acquired at one time through the request parameter values, so that the upper layer or the front end does not need to consider the problem of data combination during the multi-interface concurrent, and the code complexity of the upper layer or the front end is reduced.
d) The method comprises the following steps The expansibility of the data source interface is more flexible, and because the upper layer or the front-end caller can freely combine nodes according to the requirements, as long as the lower layer or the back-end developer formulates a data structure and an explanation, the user can freely combine data requests required by any product or service, and other developers do not need to do any operation or development in the whole process, thereby greatly reducing the communication and development cost of the whole front-end or the upper-layer and the lower-layer.
The above-described aspects may be implemented individually or in various combinations, and such variations are within the scope of the present invention.
It will be understood by those skilled in the art that all or part of the steps of the above methods may be implemented by instructing the relevant hardware through a program, and the program may be stored in a computer readable storage medium, such as a read-only memory, a magnetic or optical disk, and the like. Alternatively, all or part of the steps of the foregoing embodiments may also be implemented by using one or more integrated circuits, and accordingly, each module/unit in the foregoing embodiments may be implemented in the form of hardware, and may also be implemented in the form of a software functional module. The present invention is not limited to any specific form of combination of hardware and software.
It is to be noted that, in this document, the terms "comprises", "comprising" or any other variation thereof are intended to cover a non-exclusive inclusion, so that an article or apparatus including a series of elements includes not only those elements but also other elements not explicitly listed or inherent to such article or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of additional like elements in the article or device comprising the element.
The above embodiments are merely to illustrate the technical solutions of the present invention and not to limit the present invention, and the present invention has been described in detail with reference to the preferred embodiments. It will be understood by those skilled in the art that various modifications and equivalent arrangements may be made without departing from the spirit and scope of the present invention and it should be understood that the present invention is to be covered by the appended claims.
Claims (12)
1. A method for intelligently providing data, comprising:
setting at least one independent root node and at least one dependent node; the non-independent nodes comprise at least one independent root node and/or at least one other non-independent node;
a first party receives a data request, wherein the data request is a request for acquiring specific contents of at least one independent root node and/or at least one non-independent node;
the first party determines a data structure; the data structure comprises an identifier of an independent root node and/or an identifier of a non-independent node which are/is required to be acquired by the data request;
the first party constructs an acquisition function comprising the data structure and calls the acquisition function;
and after the second party learns that the first party calls the acquisition function, analyzing the data structure in the acquisition function layer by layer, finally determining the contents of all the independent root nodes in the data structure of the acquisition function and returning to the first party.
2. The method for intelligently providing data as recited in claim 1,
when the number of dependent nodes that need to be acquired in the data request is greater than 1, the first party constructing the data structure includes: and setting the reference relation of the non-independent nodes in the data structure according to the reference relation of the non-independent nodes.
3. The method for intelligently providing data as recited in claim 1,
the data request also comprises a current page display indication, wherein the current page display indication comprises a starting identifier, an identifier interval value and an arrangement mode of at least one independent root node;
the method further comprises the following steps: and the second party determines the content required to be displayed on the current page according to the current page display indication and displays the content according to the arrangement mode.
4. The method for intelligently providing data as recited in claim 1,
the dependent nodes also comprise a reference permission attribute, and the value of the reference permission attribute is a value which represents that the dependent nodes can be referenced by other dependent nodes or a value which represents that the dependent nodes can not be referenced by other dependent nodes;
the first party building a data structure comprises: when the current dependent node needs to be referred to by another dependent node, the reference permission attribute of the current dependent node is judged, when the value of the reference permission attribute is a value which indicates that the current dependent node can be referred to by other dependent nodes, the reference is executed, and when the value of the reference permission attribute is a value which indicates that the current dependent node cannot be referred to by other dependent nodes, the reference is abandoned.
5. The method for intelligently providing data as recited in claim 1,
the second party analyzing the data structure in the acquisition function layer by layer comprises: inquiring whether the content of the independent root node included in the to-be-analyzed non-independent node is cached or not, if so, directly acquiring the content of the cached independent root node, and when the to-be-analyzed non-independent node includes more than one other non-independent nodes in parallel relation, performing parallel analysis on the other non-independent nodes in parallel relation in the to-be-analyzed non-independent node by using multithreading, multi-corollary or multi-process, and caching the content of all the independent root nodes in the to-be-analyzed non-independent node in the analysis process.
6. The method for intelligently providing data as recited in claim 1,
the method further comprises the following steps: the method comprises the steps that a plurality of data structure templates are built in advance, and different data structure templates which are built in advance are matched with different data requests for obtaining specific contents of at least one independent root node and/or at least one non-independent node;
the first party determining data structure comprises: and inquiring whether a pre-constructed data structure template corresponding to the data request exists according to the received data request, if so, determining a data structure corresponding to the data request by using the pre-constructed data structure template, and if not, compiling the data structure meeting the data request according to the received data request.
7. An apparatus for intelligently providing data, comprising:
the system comprises a setting module, a first party module and a second party module;
the setting module is used for setting at least one independent root node and at least one dependent node; the non-independent nodes comprise at least one independent root node and/or at least one other non-independent node;
the first party module comprises:
a receiving module, configured to receive a data request, where the data request is a request for obtaining specific content of at least one independent root node and/or at least one non-independent node;
a determining module for constructing a data structure; the data structure comprises an identifier of an independent root node and/or an identifier of a non-independent node which are/is required to be acquired by the data request;
a construction module for constructing an acquisition function comprising the data structure;
the calling module is used for calling the acquisition function;
the second square module comprises:
the acquisition module is used for acquiring that the first party calls the acquisition function;
the analysis module is used for analyzing the data structure in the acquisition function layer by layer after the acquisition module learns that the first party calls the acquisition function, and finally determining the content of all independent root nodes in the data structure of the acquisition function;
and the returning module is used for returning the contents of all independent root nodes in the data structure of the acquisition function determined by the analyzing module to the first party module.
8. The apparatus for intelligently providing data according to claim 7,
when the number of dependent nodes that need to be acquired in the data request is greater than 1, the first party constructing the data structure includes: and setting the reference relation of the non-independent nodes in the data structure according to the reference relation of the non-independent nodes.
9. The apparatus for intelligently providing data according to claim 7,
the data request also comprises a current page display indication, wherein the current page display indication comprises a starting identifier, an identifier interval value and an arrangement mode of at least one independent root node;
the second module also comprises a display processing module, and the display processing module is used for determining the content required to be displayed on the current page according to the display indication of the current page and displaying the content according to the arrangement mode.
10. The apparatus for intelligently providing data according to claim 7,
the dependent nodes also comprise a reference permission attribute, and the value of the reference permission attribute is a value which represents that the dependent nodes can be referenced by other dependent nodes or a value which represents that the dependent nodes can not be referenced by other dependent nodes;
the determination module is further configured to construct a data structure using the following method: when the current dependent node needs to be referred to by another dependent node, the reference permission attribute of the current dependent node is judged, when the value of the reference permission attribute is a value which indicates that the current dependent node can be referred to by other dependent nodes, the reference is executed, and when the value of the reference permission attribute is a value which indicates that the current dependent node cannot be referred to by other dependent nodes, the reference is abandoned.
11. The apparatus for intelligently providing data according to claim 7,
the query unit is used for querying whether the content of the independent root node included in the non-independent node to be analyzed is cached or not, and directly acquiring the cached content of the independent root node if the content of the independent root node is cached;
the parallel analysis unit is used for carrying out parallel analysis on other non-independent nodes in parallel relation in the non-independent nodes to be analyzed by using multiple threads, multiple coroutines or multiple processes when the non-independent nodes to be analyzed comprise more than one other non-independent nodes in parallel relation;
and the cache unit caches the contents of all independent root nodes in the to-be-analyzed non-independent nodes in the analysis process.
12. The apparatus for intelligently providing data according to claim 7,
the parsing module further comprises:
the system comprises a pre-construction module, a data acquisition module and a data transmission module, wherein the pre-construction module is used for pre-constructing a plurality of data structure templates, and different pre-constructed data structure templates are matched with different data requests for acquiring specific contents of at least one independent root node and/or at least one non-independent node;
the determining module is further configured to determine the data structure using: and inquiring whether a pre-constructed data structure template corresponding to the data request exists according to the received data request, if so, determining a data structure corresponding to the data request by using the pre-constructed data structure template, and if not, compiling the data structure meeting the data request according to the received data request.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811339932.3A CN111176857B (en) | 2018-11-12 | 2018-11-12 | Method and device for intelligently providing data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811339932.3A CN111176857B (en) | 2018-11-12 | 2018-11-12 | Method and device for intelligently providing data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111176857A true CN111176857A (en) | 2020-05-19 |
CN111176857B CN111176857B (en) | 2024-06-11 |
Family
ID=70649916
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811339932.3A Active CN111176857B (en) | 2018-11-12 | 2018-11-12 | Method and device for intelligently providing data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111176857B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6466983B1 (en) * | 1999-09-30 | 2002-10-15 | Steven Paul Strazza | Systems and methods for controlling access to data maintained in a repository |
CN104252339A (en) * | 2013-06-25 | 2014-12-31 | 腾讯科技(深圳)有限公司 | Method and device for developing interface layers and realizing data interaction of interface layers |
CN107451050A (en) * | 2017-06-20 | 2017-12-08 | 阿里巴巴集团控股有限公司 | Function acquisition methods and device, server |
CN107818127A (en) * | 2017-09-09 | 2018-03-20 | 国网浙江省电力公司 | A kind of querying method and system for multi-source data |
CN108052590A (en) * | 2017-12-11 | 2018-05-18 | 四川新网银行股份有限公司 | The dynamic application method and system of a kind of structural data |
-
2018
- 2018-11-12 CN CN201811339932.3A patent/CN111176857B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6466983B1 (en) * | 1999-09-30 | 2002-10-15 | Steven Paul Strazza | Systems and methods for controlling access to data maintained in a repository |
CN104252339A (en) * | 2013-06-25 | 2014-12-31 | 腾讯科技(深圳)有限公司 | Method and device for developing interface layers and realizing data interaction of interface layers |
CN107451050A (en) * | 2017-06-20 | 2017-12-08 | 阿里巴巴集团控股有限公司 | Function acquisition methods and device, server |
CN107818127A (en) * | 2017-09-09 | 2018-03-20 | 国网浙江省电力公司 | A kind of querying method and system for multi-source data |
CN108052590A (en) * | 2017-12-11 | 2018-05-18 | 四川新网银行股份有限公司 | The dynamic application method and system of a kind of structural data |
Non-Patent Citations (1)
Title |
---|
芋道源码: "从客户端的角度设计后端的接口", pages 1 - 10, Retrieved from the Internet <URL:https://cloud.tencent.com/developer/article/1358912> * |
Also Published As
Publication number | Publication date |
---|---|
CN111176857B (en) | 2024-06-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4920023B2 (en) | Inter-object competition index calculation method and system | |
US8812505B2 (en) | Method for recommending best information in real time by appropriately obtaining gist of web page and user's preference | |
JP6906419B2 (en) | Information providing equipment, information providing method, and program | |
WO2017024553A1 (en) | Information emotion analysis method and system | |
US20060271535A1 (en) | Method and system for assessing relevant properties of work contexts for use by information services | |
CN108268450B (en) | Method and apparatus for generating information | |
CN109840298B (en) | Multi-information-source acquisition method and system for large-scale network data | |
CN106095842B (en) | Online course searching method and device | |
CN110232126B (en) | Hot spot mining method, server and computer readable storage medium | |
US11423096B2 (en) | Method and apparatus for outputting information | |
CN108090228B (en) | Method and device for interaction through cultural cloud platform | |
JP2015135668A (en) | Computing devices and methods of connecting people based on content and relational distance | |
US20220121668A1 (en) | Method for recommending document, electronic device and storage medium | |
CN115659008B (en) | Information pushing system, method, electronic equipment and medium for big data information feedback | |
JP2021163473A (en) | Method and apparatus for pushing information, electronic apparatus, storage medium, and computer program | |
CN109508441A (en) | Data analysing method, device and electronic equipment | |
CN108280081B (en) | Method and device for generating webpage | |
CN111914079A (en) | Topic recommendation method and system based on user tags | |
CN109409419B (en) | Method and apparatus for processing data | |
CN110245357A (en) | Principal recognition methods and device | |
CN117909560A (en) | Search method, training device, training equipment, training medium and training program product | |
CN114328947A (en) | Knowledge graph-based question and answer method and device | |
CN116910374B (en) | Knowledge graph-based health care service recommendation method, device and storage medium | |
JP2013109513A (en) | Information display control device, information display control method, and program | |
KR100844265B1 (en) | Method and system for providing POI searching services by semantic web |
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 |