Invention content
For inquiry velocity is excessively slow when handling a large amount of historical behavior data in the relevant technologies, lead to database pressure mistake
Greatly, the problem of server performance is poor, and propose the application, for this purpose, the main purpose of the application is to provide a kind of place of data
Method, apparatus and system are managed, to solve the above problems.
To achieve these goals, according to the one side of the application, a kind of processing method of data, this method are provided
Including:Server receives one or more groups of operation datas of client output;Server is according to preset time window length pair
Data in every group of operation data are screened, to obtain one or more groups of Backup Datas;By all Backup Datas preserve to
In the memory of server.
Further, the attribute of every group of Backup Data includes:Keyword, data field, time window and calculating function,
And every group of Backup Data corresponds to unique a kind of calculating function, calculates function and includes general mathematical function, ratio according to Type division
Compared with function and statistical function, wherein, after all Backup Datas are preserved in the memory to server, method is also wrapped
It includes:The querying condition for inquiry is received, querying condition includes:Query time, querying attributes pair and complicated calculations function, are looked into
Attribute is ask to including keyword and data field;Type according to function is calculated divides complicated calculations function, obtains one
Class or multiclass calculate function;Function is calculated according to querying attributes pair and currently available every class and carries out inquiry behaviour in memory
Make, to obtain N group Backup Datas;The every group of Backup Data got is carried out according to its corresponding a kind of function that calculates at calculating
Reason, and result of calculation is merged to obtain result of calculation.
Further, calculation processing is carried out, and right according to its corresponding calculating function to the every group of Backup Data got
Result of calculation is merged to be included with obtaining result of calculation:Step A obtains the time window of each data in first group of Backup Data
Mouthful;Step B divides query time according to time window, to obtain one or more continuous time intervals as having
Imitate time interval;Step C, by the corresponding data calculated in function pair each effective time section of first group of Backup Data into
Row calculation processing, and the result of calculation of each data is added up to obtain the first handling result of first group of Backup Data;Step
Rapid D performs step A to step C, to obtain the handling result of every group of Backup Data, by institute to the every group of Backup Data got
Some handling results obtain result of calculation after merging.
Further, before being divided according to time window to query time, method further includes:Judge query time
Whether first threshold is less than or equal to, wherein, in the case where query time is less than or equal to first threshold, perform according to time window
Query time is divided;In the case where query time is more than first threshold, query result is returned as sky.
Further, server screens the data in every group of operation data according to preset time window length,
Included with obtaining one or more groups of Backup Datas:Judge whether is time difference in every group of operation data between continuous two data
Within preset time window length, wherein, in the case where the time difference is within preset time window length, really
Fixed two data are the corresponding Backup Data of this group of operation data;The feelings except preset time window length are in the time difference
Under condition, two data are abandoned.
Further, after all Backup Datas to be preserved to the memory to server, method further includes:Judge backup
Whether the number of data is more than second threshold, wherein, in the case where the number of Backup Data is more than second threshold, server is pressed
According to the holding time of Backup Datas all in memory, holding time earliest Backup Data is deleted successively, until being preserved in memory
Backup Data number be less than or equal to second threshold;In the case where the number of Backup Data is less than or equal to second threshold, protect
Hold the invariable number of Backup Data in memory.
To achieve these goals, according to the another aspect of the application, a kind of processing unit of data, the device are provided
Including:First receiving module, for receiving one or more groups of operation datas of client output;First processing module, for pressing
The data in every group of operation data are screened according to preset time window length, to obtain one or more groups of Backup Datas;
Preserving module, for preserving all Backup Datas into the memory of server.
Further, the attribute of every group of Backup Data includes:Keyword, data field, time window and calculating function,
And every group of Backup Data corresponds to unique a kind of calculating function, calculates function and includes general mathematical function, ratio according to Type division
Compared with function and statistical function, wherein, device further includes:Second receiving module for receiving the querying condition for inquiry, is looked into
Inquiry condition includes:Query time, querying attributes pair and complicated calculations function, querying attributes are to including keyword and data word
Section;First division module for being divided according to the type for calculating function to complicated calculations function, obtains a kind of or multiclass meter
Calculate function;Enquiry module is inquired in memory for calculating function according to querying attributes pair and currently available every class
Operation, to obtain N group Backup Datas;Second processing module, for the every group of Backup Data got according to its corresponding one
Class calculates function and carries out calculation processing, and result of calculation is merged to obtain result of calculation.
Further, Second processing module includes:Acquisition module, for obtaining each data in first group of Backup Data
Time window;Second division module, it is one or more continuous to obtain for being divided according to time window to query time
Time interval as effective time section;Computing module, it is every for passing through the corresponding calculating function pair of first group of Backup Data
Data in a effective time section carry out calculation processing, and the result of calculation of each data is added up to obtain first group it is standby
First handling result of part data;Execution module is recycled, for performing acquisition module, second to the every group of Backup Data got
Division module and computing module, to obtain the handling result of every group of Backup Data, after all handling results are merged
Obtain result of calculation.
Further, device further includes:First judgment module, for judging whether query time is less than or equal to the first threshold
Value;First execution module in the case of being less than or equal to first threshold in query time, is performed according to time window to inquiry
Time is divided;Module is returned, in the case of being more than first threshold in query time, returns to query result as sky.
Further, first processing module includes:Second judgment module, for judging continuous two in every group of operation data
Whether the time difference between a data is within preset time window length;Second execution module, at the time difference
In the case of within the preset time window length, it is the corresponding Backup Data of this group of operation data to determine two data;It loses
Module is abandoned, in the case of being in except preset time window length in the time difference, abandons two data.
Further, device further includes:Third judgment module, for judging whether the number of Backup Data is more than the second threshold
Value;Third execution module, in the case of being more than second threshold in the number of Backup Data, server owns according in memory
The holding time of Backup Data deletes holding time earliest Backup Data successively, until the Backup Data preserved in memory
Number is less than or equal to second threshold;Module is kept, in the case of being less than or equal to second threshold in the number of Backup Data, is protected
Hold the invariable number of Backup Data in memory.
To achieve these goals, according to the another aspect of the application, a kind of processing system of data, the system are provided
Including:Client, for exporting one or more groups of operation datas;Server zone, for receiving one group or more of client output
Group operation data, the data in every group of operation data are screened according to preset time window length, with obtain one group or
Multigroup Backup Data, and all Backup Datas are preserved into the memory of server.
Further, server zone is additionally operable to receive the querying condition of client output, and looking into querying condition
It askes attribute pair and calculates function and carry out inquiry operation in memory, to obtain one or more groups of Backup Datas, to getting
Every group of Backup Data carry out calculation processing, and looked into after being merged to result of calculation according to its corresponding calculating function
Ask result.
By the application, one or more groups of operation datas of client output are received using server;Server is according to pre-
If time window length the data in every group of operation data are screened, to obtain one or more groups of Backup Datas;By institute
Some Backup Datas are preserved into the memory of server, and said program can be to the function that data are cached based on memory, will
The historical operating data that client generates is stored in the memory of server so that server is in the operation data for handling magnanimity
Can quickly read operation data, and carry out relevant inquiry and calculation processing, quickly obtain handling result, at this time database
Pressure greatly reduce, so as to solve in related art the inquiry velocity mistake when handling a large amount of historical behavior data
Slowly, lead to the problem of database pressure is excessive, server performance is poor, and then realize the process that server handles operation data
In, data processing speed is greatly accelerated, so as to reach the processing pressure for reducing database, improves the property of server system
The effect of energy.In addition, database can be as the means of data backup, to improve the availability of system.
Specific embodiment
It should be noted that in the absence of conflict, the feature in embodiment and embodiment in the application can phase
Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 is the structure diagram according to the processing system of the data of the embodiment of the present application.
As shown in Figure 1, the processing system of the data includes:Client 1, for exporting one or more groups of operation datas;Clothes
Be engaged in device group 2, for receiving one or more groups of operation datas of the output of client 1, according to preset time window length to every group
Data in operation data are screened, and to obtain one or more groups of Backup Datas, and all Backup Datas are preserved to clothes
Business device.Here the not limited to of server.
In above-described embodiment of the application, the function that data are cached can be generated client 1 based on memory
Historical operating data be stored in the memory of server so that server handle magnanimity operation data when can be quick
Read operation data, and carry out relevant inquiry and calculation processing, quickly obtain handling result, and the pressure of database is significantly at this time
It reduces, so as to solve in related art, when handling a large amount of historical behavior data, inquiry velocity is excessively slow, leads to data
The problem of library pressure is excessive, server performance is poor, so realize server to operation data processing during, greatly accelerate
Data processing speed so as to reach the processing pressure for reducing database, improves the effect of the performance of server system.Together
When, the application utilizes time window and rational data switching mode, and the data stored in memory are minimized by,
Prevent the situation of low memory.In addition, database can be as the means of data backup, to improve the availability of system.
Preferably, server zone 2 is additionally operable to receive the querying condition that client 1 exports, and looking into querying condition
It askes attribute pair and calculates function and carry out inquiry operation in memory, to obtain one or more groups of Backup Datas, to getting
Every group of Backup Data carry out calculation processing, and looked into after being merged to result of calculation according to its corresponding calculating function
Ask result.In above-described embodiment, due to backup data store in memory so that read and calculate the speed ratio database of data
It is fast very much, so as to reduce the time of inquiry and calculating.
Specifically, the storage mode of binary tree may be used in the storage mode of data in the above embodiments of the present application, utilize
The design feature of binary tree anticipates required data when inquiry and calculating, inquired really needing and
When calculating, it is only necessary to the intermediate result calculated be carried out simple calculations, from greatly enhancing
Treatment effeciency.
The above embodiments of the present application can be applied in e-commerce field and other necks for needing to analyze user behavior data
Domain realizes the optimization to data handling procedure.
From the foregoing, it will be observed that the processing system for the historical behavior data that the application provides mainly includes data insertion and data query
(and calculating) two steps.Insertion refers to that server preserves the behavioral data that client 1 generates, and can be new number
Its corresponding data storage of establishment according to set or the content update according to data.Inquiry and calculation processing refer to
It sets after querying condition (including time window, corresponding keyword key and data field value etc.), server is according to looking into
Inquiry condition is inquired to obtain query result and corresponding calculating is done to query result in saved all operation datas, is obtained
To final calculation result.In the Data processing of reality, the two steps may be independently of each other, it is also possible to have certain relationship.This
The tupe for applying being related to can include trace back mode and free schema.Free schema refers to be inserted into and inquire (and calculating)
Completely self-contained pattern;Trace back mode refer to data be inserted into after immediately on the basis of current data data to the past promote one section
The pattern that time is inquired.Only have trace back mode to support that duplicate removal function rather than duplicate removal function are both of which in this application
All support.
Fig. 2 is according to the flow chart of the processing method of the data of the embodiment of the present application, and this method as shown in Figure 2 includes as follows
Step:
Step S102 receives one or more groups of operation datas that client 1 exports by the server shown in Fig. 1.
Step S104, server screen the data in every group of operation data according to preset time window length,
To obtain one or more groups of Backup Datas.
Step S106 preserves all Backup Datas into the memory of server.
In above-described embodiment of the application, server can be to the function that data are cached, by client based on memory
The historical operating data that end 1 generates is stored in the memory of server so that server can in the operation data for handling magnanimity
With quick read operation data, and relevant inquiry and calculation processing are carried out, quickly obtain handling result, at this time database
Pressure greatly reduces, and so as to solve in related art, when handling a large amount of historical behavior data, inquiry velocity is excessively slow,
Lead to the problem of database pressure is excessive, server performance is poor, and then during realizing server to operation data processing, greatly
Data processing speed is accelerated greatly, so as to reach the processing pressure for reducing database, improves the performance of server system
Effect.Meanwhile the data stored in memory are reduced to most by the application using time window and rational data switching mode
Low degree prevents the situation of low memory.In addition, database can be as the means of data backup, to improve system
Availability.
In above-described embodiment, the operation data for characterizing historical behavior can include time field and several data words
Section.The application is described in detail with the data instance shown in table 1:
Table 1:
Time in table is time field, user_id (User ID), bill_amount (transaction amount), ip (IP
Location) it is data field.Under normal conditions, operation data can be handled in a certain order, but time field is not necessarily
Orderly.
Client 1 produces multigroup operation data in the application, they are preserved with historical behavior data to server
In memory, as shown in table 1, the processing of the historical behavior data that are arrived involved in the application can include storage and the data of data
Statistics calculates.Wherein, there are several concepts during statistical disposition:Key, value, time window calculate function.
Key is the benchmark field of statistics, and value is the aiming field of statistics, and time window is the time range of statistics, is counted
Calculate the computational methods that function refers to the desired value to coming out.For example, the use that ID number is 111111111 is counted in table 1
Family is 19:50 to 20:Transaction amount summation between 00, then key is user_id=111111111, and value is transaction amount,
Time window is (19:50 to 20:00) it is summing function, to calculate function:F=sum ().In statistic processes, key can not refer to
Fixed, that is, the object counted is all value;Key can also be multi-C vector, such as key=(user_id, ip).
Value is generally divided into successive value (such as transaction amount) and centrifugal pump (such as IP address).For successive value and from
Value is dissipated, it is different to calculate function.The calculating function of successive value usually has sum (summation), square_sum (quadratic sum),
Max (maximum value), min (minimum value), count (quantity) etc..The calculating function of centrifugal pump usually has count (quantity),
Distinct_count (quantity after duplicate removal) etc..The application divides operation data according to type function is calculated as a result,
Every group of operation data correspond to it is unique it is a kind of calculate function, i.e. each data in every group of operation data all calculate letter using a kind of
Number is handled.It is preserved during server preserves operation data and according to the form of every group of operation data.
In general, calculating function can include following several:General mathematical function, comparison function, statistical function.Its
In, the functions such as sum (summation) and square_sum (quadratic sum) are general mathematical function (hereinafter referred to as A class functions), and max is (most
Big value) and min (minimum value) etc. be comparison function (hereinafter referred to as B class functions), count (quantity) and distinct_count
(quantity after duplicate removal) etc. is statistical function (hereinafter referred to as C class functions).All calculating functions can be included under normal conditions
In this three classes.In addition, it has great significance in statistics whether duplicate removal, so can also will calculate function is divided into duplicate removal function
With non-two class of duplicate removal function.
Specifically, in the above embodiments of the present application server preserve Backup Data in memory with the structure of binary tree into
Row storage, specific storage organization are described in detail as follows:Assuming that there are one value key by some key0, then it is specific for one
(key0, value, calculating function) triple, it is corresponding with one group of complete binary tree.Such as (User ID -111111118, transaction
The amount of money, summing function) this triple, represent a binary tree group, each of which binary tree is all used to calculate
The transaction amount of 111111118 this user, and be all served only for calculating the sum of amount of money.It should be noted key0It is one specific
Value and value be a field title.The size of each tree in each group of binary tree is identical with structure, and difference is only
It is that the time interval represented is different, and all time intervals are continuous.Each leaf node of every binary tree represents
One time window base unit.The size tw of this base unit is depending on the needs of accuracy.Such as be set as 1 second, and
The time range that some node represents can be 2011-01-01 00:00:00 arrives 2011-01-01 00:00:01, etc..Two
The height of tree is pitched by twAnd maximum time window determines.Highly it is set to:ceil(ln(Wmax/tw)/ln2), wherein WmaxFor maximum
The size of time window, ceil are the function that rounds up.Whole all nodal values of tree are 0 under original state.When tree is established,
The time of first leaf node is just it has been determined that subsequent each leaf node is once toward one t of pusherw.If for example,
twIt it is 1 second, and the initial time of first leaf node is 2011-01-01 00:00:00, then second leaf node rise
Time beginning is 2011-01-0100:00:01, and so on.
In the above embodiments of the present application, server is according to preset time window length to the data in every group of operation data
It is screened, to obtain one or more groups of Backup Datas the step of can include:Continuous two are judged in every group of operation data
Whether the time difference between data is within preset time window length, wherein, it is in preset time window in the time difference
In the case of within mouth length, it is the corresponding Backup Data of this group of operation data to determine two data;It is in default in the time difference
Time window length except in the case of, abandon two data.The above embodiments of the present application realize server to be stored
Operation data carry out the process of brush choosing, be more than predetermined time window in the time difference for two operation datas that client 1 generates
During mouth length, server can determine that the two operation datas do not have practical significance, therefore, by the two operations to be stored
Data are considered as invalid data and abandon, and only preserve the operation data for the condition that meets as Backup Data.Specifically, such as table
Shown in 1, the choosing of the time optimal of operation data is ordered into incremental or allows to have a degree of out of order, but needs adjacent
The time difference of two datas must be in (- Wmax,Wmax) in, wherein WmaxRepresent preset time window length.
In the above embodiments of the present application, after all Backup Datas to be preserved to the memory to server, method may be used also
To include:Judge whether the number of Backup Data is more than second threshold, wherein, it is more than second threshold in the number of Backup Data
In the case of, server deletes holding time earliest Backup Data according to the holding time of Backup Datas all in memory successively,
Until the number of Backup Data preserved in memory is less than or equal to second threshold;It is less than or equal to the second threshold in the number of Backup Data
In the case of value, the invariable number of Backup Data in memory is kept.It is realized in the above embodiments of the present application with the propulsion of time
Old Backup Data was constantly deleted, ensure that memory occupancy volume remains at a stable value, be not in memory
Situation about increasing without limitation improves the treatment effeciency of server.
Specifically, the implementation of the application is described in detail for being inserted into the operation data of the generation of client 1 in the server
Example, wherein, data are preserved in the form of binary tree:
The record of the operation data of insertion can be there are one time window and several data fields.It needs according to demand,
Being determined in advance needs which (key preserved0, value, calculating function) combination, to determine to establish how many a binary tree groups, i.e.,
Establish how many groups of operation datas.It is inserted into an operation data every time, needs similarly to operate all binary tree groups.With
Lower step is assumed to be for some binary tree group G0It is operated, and the corresponding key of this group of binary tree0For K0, value V0。
Assuming that the time of this data is t.
Some time interval G0It inside might have more trees to exist, it is assumed that set and arrange from small to large by initial time, altogether
There are m tree, T1,T2,..,Tm, the initial time of each tree is t1,t2,…,tm.It is recommended that the height of each tree is set as h=ceil
(ln(Wmax/tw)/ln2), then each tree has 2h leaf node, the length W of the time interval representedtree=2h*twThis
The height of the tree set in application can adjust, and not do stringent limitation.Obvious W hereintree=t2-t1=t3-t2=...
To G0Operating procedure it is as follows.
Step 1, if G0Interior one tree does not all have, then is G0Newly-built one tree, the initial time of this tree are set as t,
Remaining leaf node and so on.Perform step 3.
Step 2, if G0Inside there is tree, then perform following steps:
Step a, if t is just fallen in the time range of certain tree, then directly perform insertion operation in this tree
.Perform step 3.
Step b, if including t, and t without one tree<t1, then:
(b1) t is enabledb=t1-Wtree。
(b2) one tree, initial time t are createdb。
(b3) if tb<T is then inserted into this tree, terminated by=t;Otherwise, step (b1) is continued to execute to (b3), until tb
<=t performs step 3.
Step c, if t is unsatisfactory for the condition of step a or step b, then:
(c1) t is enabledb=tm+Wtree。
(c2) one tree, initial time t are createdb。
(c3) if tb<=t<tb+Wtree, then t is inserted into this tree, terminated;Otherwise, (c1)-(c3) is continued to execute, directly
To tb<=t<tb+Wtree, perform step 3.
Step 3, according to the height h of each tree, G is enabled0The maximum number of middle tree is m, then m must meet m>=ceil (Wmax0/
(2h*tw))+1, wherein ceil is the function that rounds up.Here general m takes theoretical minimum value.The number of if tree is more than
M then removes several earliest trees of initial time, until the number of remaining tree is equal to m.
Have operation a data being inserted into one tree in (a), (b3) and (c3) in above step.It is specific to insert
Enter to operate shown in following steps A to step D, it is assumed that it is B to need the tree being inserted into0:
Step A searches out B according to t0In corresponding leaf node.Assuming that two adjacent leaves node N1And N2Time point
It Wei not tN1And tN2, and tN1<=t<tN2, then this record corresponding node N1。
Step B if it is duplicate removal function to calculate function, is also meaned that and has been used trace back mode.It is needed at this time for y-bend
Tree group G0The position that a Hash table H stores each value last time and occurs is established in advance.The key of H is the value values occurred, H
Value be the node location occurred the value last time, such as node N1Deng.
Step C, it is assumed that the corresponding leaf node found in step A is Nt, including following situation.
(a), if it is non-duplicate removal function to calculate function, to NtIts value is updated with function is calculated.If calculate function
For A class function f=A (), existing nodal value is a, and the value of new record is b, then NtNew value be A (a, b);It is if calculating function
B class function f=B (), existing nodal value are a, and the value of new record is b, then NtNew value be B (a, b);If calculating function is C
Class function f=C (), existing nodal value are a, then new value is a+1.Then step D is directly performed.
(b), if it is duplicate removal function to calculate function, firstly the need of update binary tree group G0Subsidiary Hash table H.It is if new
The value of record is v0.Wherein, (b1) is if it is v that H, which does not include a value,0Key, then directly update NtValue, by its+1, directly
It connects and performs step D;(b2) otherwise, it is assumed that the v in H0Corresponding node location is N0.If current binary tree group G0The inside is not
Including N0(illustrate N0The tree at place has been removed), then without any operation;Otherwise to N0Value perform -1 operation, and
To N0All father nodes carry out recursive -1 operation of value, until root node.Turn (b3).(b3) by NtValue perform+1 operation, connect
Execution step D.
Step D, update finish NtAfterwards, from NtStart, the value that each father node is recalculated in following operation is performed, including such as
Lower step:
Step (D1), enables NtFor NtFather node, if N at this timetFor B0Root node, then terminate, otherwise perform (b).
Step (D2), if calculating function is A class function f=A (), the value of left child is a, and the value of right child is b, then Nt
New value be (a+b);If calculating function is B class function f=B (), the value of left child is a, and the value of right child is b, then Nt's
New value is B (a, b);If calculating function is C class function f=C (), the value of left child is a, and the value of right child is b, then NtIt is new
It is worth for (a+b).It continues to execute (a).
In the above embodiments of the present application, the attribute of every group of Backup Data can include:Keyword, data field, time window
Mouth and calculating function, and every group of Backup Data corresponds to unique a kind of calculating function, calculating function includes according to Type division
General mathematical function, comparison function and statistical function, wherein, in all Backup Datas to be preserved to the memory to server
Later, method further includes:The querying condition for inquiry is received, querying condition includes:Query time, querying attributes pair and multiple
Miscellaneous calculating function, querying attributes are to including keyword and data field;According to calculate function type to complicated calculations function into
Row divides, and obtains a kind of or multiclass and calculates function;Function is calculated in memory according to querying attributes pair and currently available every class
Middle carry out inquiry operation to obtain N group Backup Datas, realizes and all Backup Datas is returned according to querying condition herein
Trace back query result obtained from query processing;The every group of Backup Data got is carried out according to its corresponding a kind of function that calculates
Calculation processing, and result of calculation is merged to obtain result of calculation.
The above-mentioned each embodiment of the application can realize the inquiry of free schema or trace back mode, in the inquiry of free schema
In the process, a time window (t can be given1,t2), querying attributes (keyword key0, data field value) and right, Yi Jishi
Border is inquired after required complicated calculations function (such as variance), can obtain query result.In addition, for trace back mode
Inquiry is similar with the inquiry of free schema, insertion operation has been performed before only inquiring, therefore in the several conditions inquired,
It is other all just to be had determined that when being inserted into other than calculating function.
Specifically, the step of inquiry and calculating, is as follows:
First, it splits and calculates function.Function will be calculated and split into basic A classes, B classes, C class functions.For example calculate standard
Difference,Wherein ∑ x2For quadratic sum (i.e. square_sum, A class function), ∑ x
For with (i.e. sum, A class function), n for count (i.e. count, C class function).After fractionation, it is one corresponding that each calculates function
(key0, value, calculating function) combination, that is, correspond to a determining binary tree group.
Then, according to (key0, value, calculate function) combination find corresponding binary tree group, to each binary tree group into
It row inquiry and calculates, the query result that each binary tree group obtains will be inquired respectively and brought into the calculating functional expression after splitting, meter
Obtained result is to inquire the final result of (and calculating).Such as the example in above formula, it is assumed that the corresponding binary tree groups of sum
As a result it is Rsum, the corresponding binary tree group results of count are Rcount, the corresponding binary tree group results of square_sum are
Rsquare_sum, then final query result be
Further, in above-described embodiment, the every group of Backup Data got is carried out according to its corresponding calculating function
Calculation processing, and result of calculation is merged and is included with obtaining result of calculation:Step A is obtained every in first group of Backup Data
The time window of a data;Step B divides query time according to time window, one or more continuous to obtain
Time interval is as effective time section;Step C calculates function pair each effective time by the way that first group of Backup Data is corresponding
Data in section carry out calculation processing, and are added up to obtain the of first group of Backup Data to the result of calculation of each data
One handling result;Step D performs step A to step C to every group of Backup Data getting, to obtain every group of Backup Data
Handling result obtains result of calculation after all handling results are merged.
Above-described embodiment can realize the method for being inquired each binary tree group (and calculating).Specifically, each two
The method that fork tree group is inquired (and calculating) is as follows:
First, time window is split, according to the time window of each tree, by (T1,T2) multiple continuums are split into, make
Each section is obtained only to fall in a specific tree, and each tree at most only corresponds to a section.If (T1,T2) in have part
Section is not belonging to any one tree, then updates (T1,T2), invalid interval is abandoned, it is made, which only to retain effective section, (can belong to
The section of certain one tree).
Then, to each tree perform single tree calculating step, respectively obtain result of calculation, finally by each result into
Row is total.Assuming that the result that each tree calculates is respectively R1,R2,…Rn.It is because corresponding same in same binary tree group
One calculating function), if it is A class functions or C class functions to calculate function, the result of calculation of the binary tree group is (R1+R2+…
+Rn);If calculating function is B class function f=B (), the result of calculation of the binary tree group is B (R1,R2,…,Rn)。
It is following (assuming that being in the time inquiring section of this tree for the calculating step of single tree in above-described embodiment
(t1, t2)):
Step S1, according to time window (t in this tree1, t2) find corresponding leaf node section.Assuming that t1It is corresponding
Start node N1, t2Corresponding end node is N2.Corresponding method herein is the same as above to G0Tree performs the step 1 when being inserted into.It connects
It and continues to execute step S2.
Step S2 defines a function v (N), as a result the value of node N.Re-define a function F (V1, V2), it is used for
To two values V1And V2It is calculated.If it is A class functions or C class functions to calculate function, the value of F is (V1+V2);If
Calculating function is B class function f=B (), then the value of F is B (V1, V2).Continue to execute step S3.
Step S3 defines two values variable R1And R2, enable R1=v (N1), R2=v (N2)。
Step S4, if N1There is right brotgher of node N1r, enable R1=F (R1, v (N1r));Otherwise R1It is constant.If N2There is left brother
Younger brother's node N2l, enable R2=F (R2, v (N2l));Otherwise R2 is constant.Continue to execute step S5.
Step S5, N1It is set to N1Father node, N2It is set to N2Father node.If N1And N2Father node be it is same or
Person N1 and N2Father node be brotgher of node relationship and N1It is the right child N of its father node2It is the left child of its father node, enables R=
F(R1, R2) and as the result of calculation return of this tree, terminate.Otherwise step S4 is continued to execute.
Preferably, in the above embodiments of the present application, before being divided according to time window to query time, method is also
It can include:Judge whether query time is less than or equal to first threshold, wherein, it is less than or equal to the feelings of first threshold in query time
Under condition, perform and query time is divided according to time window;In the case where query time is more than first threshold, return is looked into
Result is ask as sky.Above example implements the sizes to query time window used in inquiry to be defined, for example, can be with
Query time is determined into a maximum value Wmax(such as one month), during data processing, the data of current processed mistake
Its time maximum value (is assumed to be tmax) with time of currently pending record (it is assumed to be t0), difference (i.e. tmax-t0) should
There are one determining maximum Wmax0(such as two months), it is impossible to more than this value.From the foregoing, it will be observed that made in the application for inquiring
T is not to be exceeded in time window, the upper limitmax, lower limit should be no more than (tmax-Wmax0)。
Fig. 3 is the structure diagram according to the processing unit of the data of the embodiment of the present application.
The processing unit of data as shown in Figure 3 can include:First receiving module 10, for receiving client output
One or more groups of operation datas;First processing module 30, for according to preset time window length in every group of operation data
Data screened, to obtain one or more groups of Backup Datas;Preserving module 50, for by all Backup Datas preserve to
In the memory of server.
In above-described embodiment of the application, server can be to the function that data are cached, by client based on memory
The historical operating data that end generates is stored in the memory of server so that can when server is in the operation data for handling magnanimity
With quick read operation data, and relevant inquiry and calculation processing are carried out, quickly obtain handling result, at this time database
Pressure greatly reduces, and so as to solve in related art, when handling a large amount of historical behavior data, inquiry velocity is excessively slow,
Lead to the problem of database pressure is excessive, server performance is poor, and then during realizing server to operation data processing, greatly
Data processing speed is accelerated greatly, so as to reach the processing pressure for reducing database, improves the performance of server system
Effect.Meanwhile the data stored in memory are reduced to most by the application using time window and rational data switching mode
Low degree prevents the situation of low memory.In addition, database can be as the means of data backup, to improve system
Availability.
The attribute of every group of Backup Data in the above embodiments of the present application can include:Keyword, data field, time window
Mouth and calculating function, and every group of Backup Data corresponds to unique a kind of calculating function, calculating function includes according to Type division
General mathematical function, comparison function and statistical function, wherein, device further includes:Second receiving module 70 is used for for receiving
The querying condition of inquiry, querying condition include:Query time, querying attributes pair and complicated calculations function, the querying attributes
To including keyword and data field;First division module 90, for according to calculate function type to complicated calculations function into
Row divides, and obtains a kind of or multiclass and calculates function;Enquiry module 110, for according to querying attributes pair and currently available every
Class calculates function and carries out inquiry operation in memory, to obtain N group Backup Datas;Second processing module 130, for getting
Every group of Backup Data carry out calculation processing, and result of calculation is merged to obtain according to its corresponding a kind of function that calculates
Result of calculation.This embodiment achieves perform inquiry according in querying condition in memory saved Backup Data by the application
Operation, specifically, in given time window (t1,t2) in, querying attributes are to (keyword key0, data field value) and it is real
Border is inquired after required complicated calculations function (such as variance), can obtain query result.Wherein, in inquiry complicated function
In the case of, complicated function can be divided into it is simple calculate function, then to every class calculating function for being obtained after division into
Row inquiry operation, finally merges query result, substantially increases search efficiency.
Preferably, the Second processing module 130 in the above embodiments of the present application can include:Acquisition module, for obtaining
The time window of each data in first group of Backup Data;Second division module, for according to time window to query time into
Row divides, to obtain one or more continuous time intervals as effective time section;Computing module, for passing through first group
The corresponding data calculated in each effective time section of function pair of Backup Data carry out calculation processing, and to the meter of each data
Result is calculated to be added up to obtain the first handling result of first group of Backup Data;Execution module is recycled, for every to what is got
Group Backup Data performs acquisition module, the second division module and computing module, to obtain the handling result of every group of Backup Data,
Query result is obtained after all handling results are merged.The embodiment has been implemented to every group of Backup Data (y-bend
Tree group) process of (and calculate) is inquired, due to being further determined as effective time section to time interval, mitigate
The computational burden of system, improves search efficiency.
Preferably, the device in the above embodiments of the present application can also include:First judgment module, when being inquired for judgement
Between whether be less than or equal to first threshold;First execution module in the case of being less than or equal to first threshold in query time, is held
Row divides query time according to time window;Module is returned, in the case of being more than first threshold in query time,
Query result is returned as sky.Above example implements between being divided to query time, to the big of query time window
Small further to be limited, the query time for not meeting restriction is considered as ineffective time, and obtained query result does not have
Practical significance, therefore the step of being divided to query time is not entered to the query time for being unsatisfactory for qualifications, it improves
Search efficiency so that query result is more accurate.
First processing module 30 in the above embodiments of the present application can include:Second judgment module 301, it is every for judging
Whether the time difference in group operation data between continuous two data is within preset time window length;Second performs
Module 302 in the case of being within preset time window length in the time difference, determines that two data are operated for the group
The corresponding Backup Data of data;Discard module 303, for being in the situation except preset time window length in the time difference
Under, abandon two data.The above embodiments of the present application by first processing module 30 realize to operation data to be stored into
The process of row brush choosing, when the time difference for two operation datas that client 1 generates being more than predetermined time length of window, service
Device can determine that the two operation datas do not have practical significance, and therefore, the two operation datas to be stored are considered as in vain
Data and abandon, only the operation data for the condition that meets is preserved as Backup Data.Specifically, as shown in table 1, operand
According to time optimal choosing be ordered into it is incremental or allow to have it is a degree of out of order, but need adjacent two datas when
Between difference must be in (- Wmax,Wmax) in, wherein WmaxRepresent preset time window length.
Preferably, the device in the above embodiments of the present application can also include:Third judgment module, for judging backup number
According to number whether be more than second threshold;Third execution module, for being more than the situation of second threshold in the number of Backup Data
Under, server deletes holding time earliest Backup Data according to the holding time of Backup Datas all in memory successively, until
The number of the Backup Data preserved in memory is less than or equal to second threshold;Module is kept, is less than for the number in Backup Data
In the case of second threshold, the invariable number of Backup Data in memory is kept.In the above embodiments of the present application realize with
Old Backup Data was constantly deleted in the propulsion of time, ensure that memory occupancy volume remains at a stable value, no
It will appear the situation that memory increases without limitation, improve the treatment effeciency of server.
It should be noted that step shown in the flowchart of the accompanying drawings can be in such as computer executable instructions
It is performed in computer system, although also, show logical order in flow charts, it in some cases, can be with not
The sequence being same as herein performs shown or described step.
It can be seen from the above description that the application realizes following technique effect:The application is delayed based on internal storage data
It deposits, historical data is deposited to the speed in memory, greatly accelerating data processing.Meanwhile database can be used as data backup
Means, to improve the availability of system.Since data are deposited in memory, database pressure greatly reduces, and is adapted to magnanimity
The processing of data.Meanwhile the application is subtracted the data stored in memory using time window and rational data switching mode
It is small to arrive minimum level, prevent the situation of low memory.It is in addition, old due to can constantly be deleted with the propulsion of time
Binary tree ensure that memory occupancy volume remains at a stable value, be not in the situation that memory increases without limitation.
Obviously, those skilled in the art should be understood that each module of above-mentioned the application or each step can be with general
Computing device realize that they can concentrate on single computing device or be distributed in multiple computing devices and be formed
Network on, optionally, they can be realized with the program code that computing device can perform, it is thus possible to which they are stored
In the storage device by computing device come perform either they are fabricated to respectively each integrated circuit modules or by they
In multiple modules or step be fabricated to single integrated circuit module to realize.In this way, the application be not limited to it is any specific
Hardware and software combines.
The foregoing is merely the preferred embodiments of the application, are not limited to the application, for the skill of this field
For art personnel, the application can have various modifications and variations.It is all within spirit herein and principle, made any repair
Change, equivalent replacement, improvement etc., should be included within the protection domain of the application.