Be on October 21st, 2014 this application claims the applying date, application No. is 201410561983.6, it is entitled《One
The method of kind inquiry dsc data》Chinese invention patent application priority.
Specific implementation mode
With reference to the attached drawing in the embodiment of the present invention, technical solution in the embodiment of the present invention carries out clear, complete
Ground describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Based on this
The embodiment of invention, every other implementation obtained by those of ordinary skill in the art without making creative efforts
Example, belongs to protection scope of the present invention.
The method of the embodiment of the present invention is directed to real-time monitoring system, and the query time section of client is to pass
Increase, and the query context one of time was scheduled in the period of dsc data life cycle.Below in conjunction with attached drawing to of the invention real
It applies example to be described in further detail, the method flow for providing inquiry dsc data by the embodiment of the present invention as shown in Figure 1 is illustrated
Figure, the method includes:
Step 11:Under real-time monitoring system, server end inquires dsc data in advance, and the dsc data inquired is buffered in
In the memory of server end;
In this step, server end can also may be used by structured query language SQL in advance to data query dsc data
To use other query language to inquire database;Here the dsc data being buffered in server end memory can be sequence and according to
Time incremental data queue, referred to as buffer queue, buffer queue are buffered in the form of cache table in server end memory,
One cache table corresponds to one business unit of storage;And the buffer queue includes having time field, business dimension and index, wherein
Time field is accurate to the second.
Step 12:When client carries out dsc data inquiry, the server end executes number in the data cached in advance
According to inquiry operation;
In this step, when client carries out dsc data inquiry, the server end receives the client hair first
The dsc data inquiry request come contains various query arguments, such as query time, the business unit of inquiry in the inquiry request
And filter condition etc. (such as the data of specific dimension, or whole data);
Then, the server end parses the inquiry request, and determines inquiry plan;
The server end inquires data according to the inquiry plan in buffer queue;
The query result of acquisition is returned to the client again.
In aforesaid operations, the process that server end inquires data according to the inquiry plan in buffer queue can be with
It is:
Server end determines business unit according to the inquiry request first;
Corresponding cache table is determined in the buffer queue according to the business unit;
Then cache table determined by the business unit is screened according to time range, if there is filter condition then according to
Filter condition screens, and filters out unwanted data, and query result will be used as after the data summarization of same time identical dimensional.
Step 13:Query result is returned to the client.
Pass through above-mentioned operating procedure, so that it may to improve the search efficiency and response speed of client, and reduce database
Inquiry pressure.
For example, above-mentioned query process is illustrated with specific example below:
First, the inquiry request that received server-side client is sent contains query argument in the inquiry request, such as
Can be query time, the business unit of inquiry and filter condition etc., filter condition can be specific dimension data or
It is whole data;
Then, server end parses the inquiry request, determines inquiry plan;
Data, that is, the business according to inquiry are inquired from the buffer queue of the server end further according to inquiry plan
Unit determines corresponding cache table, and is screened according to time range to cache table;Here if there is filter condition is then according to filtering
Conditional filtering filters unwanted data, and query result will be finally used as after the data summarization of same time identical dimensional;
The query result is finally returned into client.
In addition, in the concrete realization, the server end can be with timed maintenance buffer area, by the cold data of failure from institute
It states in buffer area and removes, such client query is just not necessarily to access database, is illustrated in figure 2 described in the embodiment of the present invention and services
The flow diagram of device end timed maintenance buffer area, process are specially:
Step 21:Server end starts a background thread first, periodically executes following steps operation;
It executes frequency and is set as needed, usually several seconds or 10 seconds.
Step 22:The timestamp for inquiring the last item data in the server end buffer queue, the timestamp is subtracted
Remove the start time that a polling cycle is inquired;
Here, in order to reduce the last inquiry incomplete situation of data, the timestamp is subtracted into a polling cycle
The start time that (enquiry frequency) is inquired;And if not having data in buffer queue, the starting point of query time if is system
Time subtracts a time cycle.
Step 23:SQL query statement is generated according to the start time, inquiry request is sent to database, from the number
According to obtaining business datum in library;
Step 24:The business datum is put into the buffer queue;
In this step, if the data of same time identical dimensional have existed in buffer queue, by the industry
In data update to buffer queue of being engaged in, otherwise it is inserted into buffer queue;According to the rule, the data in buffer queue are suitable
Sequence and according to time incremental data queue.
Step 25:The life cycle of dsc data is obtained according to business demand, and the life cycle of caching is set as than institute
The life cycle for stating dsc data is long;
For example, if the life cycle of dsc data is 1 hour, consider the redundancy of data, and the life cached
Period is longer than the life cycle of dsc data, then the life cycle cached can be set as 30 minutes 1 hour.
Step 26:The timestamp is subtracted institute by the timestamp for obtaining the last item data in the buffer queue again
The life cycle for stating caching obtains the end time of cold data;
In this step, the obtained time is also the start time of dsc data.
Step 27:Total data before deleting the end time in the buffer queue, makes the buffer queue
Middle reservation is dsc data entirely.
Based on above-mentioned querying method, the embodiment of the present invention additionally provides a kind of device of inquiry dsc data, as shown in Figure 3
The apparatus structure schematic diagram of inquiry dsc data is provided by the embodiment of the present invention, described device includes:
Data buffer storage unit 31, under real-time monitoring system, inquiring dsc data, and the dsc data that will be inquired in advance
It is cached in advance;
Data query unit 32, for when client carries out dsc data inquiry, delaying in advance in the data buffer storage unit
Data query operation is executed in the data deposited;
Query result transmission unit 33, for returning to query result to client.
It is illustrated in figure 4 another structural schematic diagram for the inquiry dsc data device that the embodiment of the present invention is provided, is counted in Fig. 4
Further comprise having according to query unit 32:
Inquiry request receiving module 321, the dsc data inquiry request sent for receiving client;
Inquiry plan determining module 322 for parsing the inquiry request, and determines inquiry plan;
Data module 323 is inquired, the caching team in the data buffer storage unit 31 according to identified inquiry plan is used for
Data are inquired in row.
Inquiring data module 323 may include:
First determination sub-module, for determining business unit according to the inquiry request;
Second determination sub-module, for determining corresponding cache table in the buffer queue according to the business unit;
Submodule is screened, for being screened according to time range to cache table determined by the business unit, if there is mistake
Filter condition is then screened according to filter condition, filters out unwanted data, and will be after the data summarization of same time identical dimensional
As query result.
And described device may also include:
Cache maintenance unit 34, for the buffer area of data buffer storage unit 31 described in timed maintenance, by the cold data of failure
It is removed from the buffer area.
The cache maintenance unit 34 may include:
Maintenance module periodically executes following operation for starting a background thread:
The timestamp is subtracted a polling cycle and obtained by the timestamp for inquiring the last item data in the buffer queue
To the start time of inquiry;
According to the start time generating structure query language SQL query statement, inquiry request is sent to database, from
Business datum is obtained in the database;
The business datum is put into the buffer queue, if the business datum of same time identical dimensional is in caching team
It has existed in row, then by the service data updating to the buffer queue, is otherwise inserted into the buffer queue;
The life cycle of dsc data is obtained according to business demand, and the life cycle of caching is set as than the dsc data
Life cycle it is long;
The timestamp is subtracted the caching by the timestamp for obtaining the last item data in the buffer queue again
Life cycle obtains the end time of cold data;
Total data before deleting the end time in the buffer queue makes to retain in the buffer queue
It is dsc data entirely.
The specific implementation process of each unit and module is as described in above method embodiment in above-mentioned apparatus.
In conclusion the method, can in server end caching and timed maintenance dsc data through the embodiment of the present invention
The search efficiency and response speed of client are improved, and reduces the inquiry pressure of database.
The foregoing is only a preferred embodiment of the present invention, but scope of protection of the present invention is not limited thereto,
Any one skilled in the art is in the technical scope of present disclosure, the change or replacement that can be readily occurred in,
It should be covered by the protection scope of the present invention.Therefore, protection scope of the present invention should be with the protection model of claims
Subject to enclosing.