Summary of the invention
The application provides a kind of processing method and device of message data, to solve the problem of waste computational resource in the existing message data sequencer procedure.
In order to address the above problem, the application discloses a kind of processing method of message data, comprising:
Be respective user account creation message queue, and the message data of user's issue and reception is put into corresponding message queue;
Reception is for the message data query requests of certain user account, and the execution following steps:
Step 1, obtain a plurality of orderly message queue that need sort according to described message data query requests, the a plurality of orderly message queue that described need sort comprises the message queue of this user account, and the message queue of the popular user account related with this user account;
Step 2 reads respectively a message data according to the order of sequence from each orderly message queue, and a plurality of message datas that read are put into ordered set;
Step 3 sorts to all message datas in the described ordered set, obtains ranking results, and selects a message data output from described ranking results;
Step 4 reads a message data more according to the order of sequence the message queue under the message data of described output, and the message data that reads is put into described ordered set;
Repeating step 3 and step 4 are until all message datas of output satisfy the described request requirement.
Preferably, before the circulation cut-off, also comprise: in a plurality of orderly message queue that need sort, when only having a message queue not for sky, repeat described not for the message data in the empty message queue reads according to the order of sequence and exports, until all message data numbers of output satisfy the quantity that described request requires.
Preferably, the message data in the described orderly message queue is to arrange according to the time inverted order; Describedly from message queue, read according to the order of sequence a message data and comprise: from message queue, read first message data according to the time inverted order;
Described all message datas in the ordered set are sorted comprises: all message datas in the ordered set are sorted according to the time inverted order;
Describedly from ranking results, select a message data output to comprise: from according to selecting first message data output the ranking results of time inverted order.
Preferably, the size of described ordered set equals the number of the orderly message queue that need sort.
Preferably, described method also comprises: all message datas that will export are showed.
The application also provides a kind of processing unit of message data, comprising:
The formation creation module is used to respective user account creation message queue, and the message data of user's issue and reception is put into corresponding message queue;
The formation acquisition module, be used for receiving the message data query requests for certain user account, and the described message data query requests of foundation is obtained a plurality of orderly message queue that need sort, the a plurality of orderly message queue that described need sort comprises the message queue of this user account, and the message queue of the popular user account related with this user account;
The message data read module is used for reading according to the order of sequence respectively a message data from each orderly message queue, and a plurality of message datas that read is put into ordered set;
The ordering output module is used for all message datas of described ordered set are sorted, and obtains ranking results, and selects a message data output from described ranking results;
The recursive call module, be used for repeating to call described message data read module and ordering output module, read according to the order of sequence again a message data the message queue under the message data of described output, and the message data that reads put into the output of sorting of described ordered set, until all message datas of output satisfy the described request requirement.
Preferably, described device also comprises: the special processing module, be used for when a plurality of orderly message queue that need sort, when only having a message queue not for sky, repeat described not for the message data in the empty message queue reads according to the order of sequence and exports, until all message data numbers of output satisfy the quantity that described request requires.
Preferably, the message data in the described orderly message queue is to arrange according to the time inverted order; Described message data read module is to read first message data according to the time inverted order respectively from each orderly message queue;
Described ordering output module is that all message datas in the ordered set are sorted according to the time inverted order, obtains ranking results, and selects first message data output from described ranking results.
Preferably, the size of described ordered set equals the number of the orderly message queue that need sort.
Preferably, described device also comprises: display module, all message datas that are used for exporting are showed.
Compared with prior art, the application comprises following advantage:
The application is the ordered queue characteristics of (as sequencing order according to the time) by means of each message queue (such as the Feed formation), only the part data that satisfy user's request (being really needs of user) are sorted, and do not need each message queues that all participations sorted to sort, thereby improved the utilization of computational resource, and then the response time when having promoted user's query message data.
Embodiment
For above-mentioned purpose, the feature and advantage that make the application can become apparent more, below in conjunction with the drawings and specific embodiments the application is described in further detail.
In the application system (being designated hereinafter simply as system) of message data, the message data that can see in order to obtain a user needs a plurality of different message queues are sorted sometimes.With the Feed data instance, concrete a kind of application scenarios is as follows:
In the Feed application systems such as microblogging website, friend-making interaction platform, each user has the Feed formation of oneself.For domestic consumer, because its good friend's limited amount, so domestic consumer's issue and the Feed data volume that receives are also not too large, therefore, system is generally domestic consumer a Feed formation is set, and is used for storing the Feed data of this user's issue and reception, that is: whenever this user issues Feed data, or the Feed data of friend place reception of catering one's wishes, system all can be with these Feed data copies in this user's Feed formation.Like this, if obtain all Feed data that this user can see, the Feed formation of directly reading this user gets final product.
But for popular user, its bean vermicelli number is very many, hundreds of thousands even up to a million may be arranged, if a Feed data copy of popular user issue in the Feed formation of each bean vermicelli, will be expended very many workload and time, bring very large pressure to system.Be head it off, system is generally popular user two Feed formations is set, Feed data that are used for storing popular user oneself issue, and another is used for storing the Feed data that popular user receives from other users (such as the good friend).Like this, when obtaining all Feed data that a user can see, the popular user's that just need to pay close attention to Feed formation and this user of this user Feed formation (formations of the Feed data of storing received) is sorted.
The application proposes a kind of processing method and device of message data, can sort to a plurality of different message queues, and the message data after will sorting is presented to the user.For example, with reference to shown in Figure 1, the Feed formation of user A, the Feed formation of user B, the Feed formation of user C and the Feed formation of user D can be merged, and the Feed data after being combined sort, then will present to user's Feed data output.
Below by embodiment the realization flow of the described method of the application is elaborated.
With reference to Fig. 2, it is the process flow figure of the described a kind of message data of the embodiment of the present application.Still with the Feed data instance, flow process is as follows:
Step S1 is respective user account creation message queue, and the message data of user's issue and reception is put into corresponding message queue;
As previously mentioned, in the application system of message data, each user has the message queue of oneself, and also namely: system can create for the user account of each registration one or more null message formations.If domestic consumer then creates a null message formation, this user every issue a piece of news data and every reception a piece of news data all can be put into this null message formation.But for the popular user who has a large amount of good friends or bean vermicelli, system can be for two null message formations of account creation of this hot topic user, one of them null message formation is used for depositing each bar message data of this hot topic user issue, and another null message formation is used for depositing each bar message data that this hot topic user receives.
Step S2 receives the message data query requests for certain user account, and carries out following steps:
Step 1, obtain a plurality of orderly message queue that need sort according to described message data query requests, the a plurality of orderly message queue that described need sort comprises the message queue of this user account, and the message queue of the popular user account related with this user account;
In the Feed application systems such as microblogging website, friend-making interaction platform, all good friends of a user can be described as this user's associated user.In these associated users, some is domestic consumer, and some is popular user.If the some users' of requesting query Feed data, and comprised popular user among this user's the good friend, the Feed formation that then is used for sorting not only comprises this user's oneself Feed formation, also comprises the Feed formation (mainly being that formation of depositing the Feed data of issue) of popular user among this user's the good friend.
For example, certain user A is domestic consumer, and the popular user of its concern has user B and user C.When user A shows the Feed data that can see to system request, the Feed formation B of the popular user B that system can pay close attention to according to Feed formation A, the user A of this acquisition request user A and the Feed formation C of popular user C.
Wherein, described each Feed formation can be an orderly formation.According to the difference of practical application, described " in order " can be according to time sequencing, or according to the order of size of data, or according to the order of Data Identification, etc. sortord sort.In a word, described Feed formation is an orderly formation, i.e. all Feed elements in the Feed formation have sequenced order according to certain mode.
For Feed application systems such as microblogging website, friend-making interaction platforms, because the user generally only pays close attention to the Feed in nearest a period of time, so the element in the system in each Feed formation can be arranged according to the time inverted order, be about to the up-to-date Feed element of issuing time and come formation foremost.
Step 2 reads respectively a message data according to the order of sequence from each orderly message queue, and a plurality of message datas that read are put into ordered set;
Still take the Feed application system as example, described ordered set is used for Feed data to a plurality of Feed formations and merges and sort, and the size of ordered set equals the number of the orderly Feed formation that need sort.For example, the orderly Feed formation that need sort has 3, and then corresponding ordered set can be deposited 3 Feed data.
Because each Feed formation is orderly, so the Feed data that read in turn from formation also are orderly.If the Feed formation is according to the time Bit-reversed, just can from the Feed formation, read first Feed data according to the time inverted order when reading so, described first Feed data refer to come formation Feed data foremost, also are the up-to-date Feed data of issuing time.
Certainly, in other are used, for described Feed formation of arranging according to the time inverted order, also can begin to read the Feed data from tail of the queue, the Feed data that at this moment read out are exactly issuing time Feed data the earliest.That is to say that the order of above-mentioned " reading according to the order of sequence " not necessarily must be consistent with putting in order of " in order Feed formation " middle Feed data.
Step 3 sorts to all message datas in the described ordered set, obtains ranking results, and selects a message data output from described ranking results;
Still take the Feed application system as example, because the Feed data in the ordered set are from different Feed formations, and out-of-order, just can select the Feed data output that meets application requirements after need to sorting.When all the Feed data in the ordered set are sorted, need to select sortord according to application requirements, sortord not necessarily must with above-mentioned steps 1 in " in order Feed formation " Feed data put in order unanimously, but to be consistent with the order of " reading according to the order of sequence " in the above-mentioned steps 2.
For example, if application requirements is exported the Feed in nearest a period of time, then " reading according to the order of sequence " is to read Feed in the formation according to the time inverted order in the above-mentioned steps 2, and in step 3, all Feed data in the ordered set also are according to the time Bit-reversed, and first Feed data output in the selection ranking results, namely export the up-to-date Feed data of issuing time in the ranking results.
Step 4 reads a message data more according to the order of sequence the Feed formation under the message data of described output, and the message data that reads is put into described ordered set;
Step S3, repeating step 3 and step 4 are until all message datas of output satisfy the described request requirement.
Wherein, it can be quantitative that described request requires, and shows quantity etc. such as current screen; Also can be temporal, such as the same day, the message data of this week etc., the perhaps combination of the various conditions such as quantity, time.
For example, the Feed data of step 3 output belong to Feed formation A, then continue to read according to the order of sequence Feed data from Feed formation A and put into described ordered set again, the Feed data of the Feed formation B that again originally deposited in ordered set and Feed formation C sort.Repetitive cycling in this manner, until all Feed data amount checks of output satisfy the quantity that described request requires, the Feed data amount check that every one page displaying is set such as system is 10, when the Output rusults of user's acquisition request first page, 10 Feed data of ordered set output namely stop described circulation; When the user clicked the Output rusults of " lower one page " continuation acquisition request second page, system began to carry out from step 1 again.
It should be noted that in the above-mentioned circulation implementation that each sortord needs unanimously in the step 3, the order that at every turn reads according to the order of sequence the Feed data in the step 4 needs consistent.
Optionally, if described request is the request of Feed data query, system can also with all Feed data displays of satisfying the request number on subscription client, browse for the user.Certainly, according to the difference of practical application, can also carry out other subsequent treatment to the Feed data of output, as carry out statistical analysis or send other application systems etc. to.
Below by two examples to the explanation that makes an explanation of above-mentioned flow process.
Example 1:
With reference to Fig. 3, it is the schematic diagram that in the application's example 1 two Feed formations is carried out ordering by merging.
Suppose that user A is domestic consumer, user A pays close attention to popular user B, when user A sends query requests to the Feed application system, during the Feed data of the first page that acquisition request user A can see, system at first obtains the Feed formation of user A, and the Feed formation of the popular user B that pays close attention to of user A, and these two Feed formations are carried out following processing:
S1 respectively takes out first Feed data respectively from the Feed formation of the Feed formation of user A and user B, then these two Feed data are put in the ordered set;
For example, read A0 respectively and B0 puts into ordered set;
S2 sorts to two Feed data putting in the ordered set, obtains a result who arranges according to the time inverted order;
Suppose according to the result that the time inverted order is arranged to be: B0, A0;
S3, external Output rusults, when from ordered set, taken out one come top Feed data after, take out again next Feed data meeting that Feed formation under these Feed data and be put in the ordered set, and again all the Feed data in this ordered set are sorted;
For example, with B0 output, and then read B1 and put into ordered set from the Feed formation of user B, the Feed data in the ordered set are A0 and B1 at this moment, to A0 and B1 ordering;
S4, ordered set is Output rusults constantly, constantly repeats the action among the S3, finishes until satisfy the Feed quantity of search request.
If output A0 then repeats S3, from the Feed formation of user A, read A1 and put into ordered set, the Feed data in the ordered set are A1 and B1 at this moment, to A1 and B1 ordering ..., circulation finishes until satisfy the Feed quantity of search request according to this.
It more than is the execution in step that the described method of the application has been described under the scene of two user Feed formation, for the situation that surpasses two user Feed formation, only need to enlarge ordered set, it is just passable to make its size equal to carry out the Feed number of queues of merge sort, specifically referring to example 2.
Example 2:
With reference to Fig. 4, it is the schematic diagram that in the application's example 2 three Feed formations is carried out ordering by merging.
S1 respectively takes out first Feed data A0, B0 and C0 respectively from the Feed formation of the Feed formation of the Feed formation of user A, user B and user C, then these three Feed data are put in the ordered set;
S2 sorts to three Feed data putting in the ordered set, obtains a result who arranges according to the time inverted order;
Suppose according to the result that the time inverted order is arranged to be: C0, A0, B0;
S3 externally exports C0, and takes out next Feed data C1 the Feed formation of the user C under C0 again and be put in the ordered set, and again all the Feed data in this ordered set is sorted;
At this moment, the Feed data in the ordered set are A0, B0 and C1;
S4, ordered set is Output rusults constantly, constantly repeats the action among the S3, finishes until satisfy the Feed quantity of search request.
If output A0 then repeats S3, from the Feed formation of user A, read A1 and put into ordered set, the Feed data in the ordered set are A1, B0 and C1 at this moment ..., circulation finishes until satisfy the Feed quantity of search request according to this.
In addition, also need to prove based on example 1 and example 2, before above-mentioned circulation cut-off, also may have following special circumstances:
In a plurality of orderly Feed formation that need sort, only has a Feed formation not for empty, when all the other Feed formations are sky (being that the Feed data amount check is zero), repeat described not for the Feed data in the empty Feed formation read according to the order of sequence and export, until all Feed data amount checks of output satisfy the quantity that described request requires.
For example, in the sequencer procedure of two Feed formations shown in Figure 3, the situation of more Feed data can appear not having in certain user's the Feed formation.Suppose the Feed formation weak point of the user B of Feed platoon ratio of user A, and during certain is once inquired about, the Feed formation of finding user A in the implementation is depleted, this time, Feed data in the ordered set can be deleted by system, that is to say in the ordered set in this time just only to have remained next Feed data, the output of back has not just had the process of ordering, directly the Feed data in the Feed formation of user B is externally exported.
Equally, for the sequencer procedure of three Feed formations shown in Figure 4, the situation of more Feed data can appear also not having in certain user's the Feed formation.In supposing that certain once inquires about, the Feed formation of finding user A and user B is depleted, this moment, two Feed data in the ordered set can be deleted by system, and the output of back has not just had the process of ordering, directly the Feed data in the Feed formation of user C is externally exported.But, if only have the Feed formation of user A depleted in the implementation, Feed data in the ordered set can be deleted by system, so that only remaining two Feed data in the ordered set, this moment, ordered set also can be according to aforesaid method, to the output of sorting of the Feed data in the Feed formation of the Feed formation of user B and user C.
In sum, the described method of the embodiment of the present application is the ordered queue characteristics of (as sequencing order according to the time) by means of each message queue, only the part data that satisfy user's request (being really needs of user) are sorted, and do not need each Feed formations of all participations being sorted to sort, thereby improved the utilization of computational resource, and then the response time when having promoted user's query messages.
Need to prove, for aforesaid each embodiment of the method, for simple description, so it all is expressed as a series of combination of actions, but those skilled in the art should know, the application is not subjected to the restriction of described sequence of movement, because according to the application, some step can adopt other orders or carry out simultaneously.Secondly, those skilled in the art also should know, the embodiment described in the specification all belongs to preferred embodiment, and related action might not be that the application is necessary.
Based on the explanation of said method embodiment, the application also provides corresponding device embodiment, realizes the described content of said method embodiment.
With reference to Fig. 5, it is the processing unit structure chart of the described a kind of message data of the embodiment of the present application.
Described Feed data processing equipment can comprise formation creation module 10, formation acquisition module 20, message data read module 30, ordering output module 40 and recursive call module 50, wherein,
Formation creation module 10 is used to respective user account creation message queue, and the message data of user's issue and reception is put into corresponding message queue;
Formation acquisition module 20, be used for receiving the message data query requests for certain user account, and the described message data query requests of foundation is obtained a plurality of orderly message queue that need sort, the a plurality of orderly message queue that described need sort comprises the message queue of this user account, and the message queue of the popular user account related with this user account;
Message data read module 30 is used for reading according to the order of sequence respectively a message data from each orderly message queue, and a plurality of message datas that read is put into ordered set;
Ordering output module 40 is used for all message datas of described ordered set are sorted, and obtains ranking results, and selects a message data output from described ranking results;
Recursive call module 50, be used for repeating to call described message data read module 30 and ordering output module 40, read according to the order of sequence again a message data the message queue under the message data of described output, and the message data that reads put into the output of sorting of described ordered set, until all message datas of output satisfy the described request requirement.
Wherein, the size of described ordered set equals the number of the orderly message queue that need sort.
Optionally, the message data in the described orderly message queue is to arrange according to the time inverted order;
And described message data read module 30 is to read first message data according to the time inverted order respectively from each orderly message queue;
Described ordering output module 40 is that all message datas in the ordered set are sorted according to the time inverted order, obtains ranking results, and selects first message data output from described ranking results.
In another device embodiment of the application, with reference to shown in Figure 6, described message data processing unit can also comprise:
Special processing module 60, be used for when a plurality of orderly message queue that need sort, when only having a message queue not for sky, repeat described not for the message data in the empty message queue reads according to the order of sequence and exports, until all message data numbers of output satisfy the quantity that described request requires.
In another device embodiment of the application, with reference to shown in Figure 6, described message data processing unit can also comprise:
Display module 60, all message datas that are used for exporting are showed.
For above-mentioned message data processing unit embodiment because itself and embodiment of the method basic simlarity, so describe fairly simple, relevant part gets final product referring to the part explanation of embodiment of the method.
Each embodiment in this specification all adopts the mode of going forward one by one to describe, and what each embodiment stressed is and the difference of other embodiment that identical similar part is mutually referring to getting final product between each embodiment.
More than processing method and the device of a kind of message data that the application is provided, be described in detail, used specific case herein the application's principle and execution mode are set forth, the explanation of above embodiment just is used for helping to understand the application's method and core concept thereof; Simultaneously, for one of ordinary skill in the art, the thought according to the application all will change in specific embodiments and applications, and in sum, this description should not be construed as the restriction to the application.