Summary of the invention
In view of the above problems, the present invention has been proposed in order to a kind of a kind of method and apparatus for downloading data that overcomes the problems referred to above or address the above problem at least in part is provided.
According to one aspect of the present invention, a kind of device for downloading data is provided, this device comprises: Database Unit, display unit, new data download unit, database maintenance unit and Tip element;
Described new data download unit is suitable for sending the request of downloading new data, the data that reception server returns to server;
Described database maintenance unit, be suitable for judging whether the described data of returning can be connected with the data with existing in the Database Unit, if be connected, the described data of returning are saved in the Database Unit, and the show tags of the described data of returning is set to effectively, if divergence, existing show tags in the Database Unit is that the show tags of active data all is set to invalid, then the described data of returning are saved in the Database Unit, and the show tags of the described data of returning is set to effectively;
Described Database Unit is suitable for the show tags of save data and data;
Described display unit is suitable for showing that the show tags in the described Database Unit is active data;
Described Tip element, the number that is suitable for the data returned at server is 0, the latest data in user's reminder-data storehouse is the latest data on the server.
Alternatively, comprise in the request of the described download new data that sends to described server of described new data download unit: the data number that request is downloaded and downloaded to the sign of the up-to-date data in the Database Unit;
Described database maintenance unit, be judged as linking when being further adapted for the number of the data of downloading less than described request in the number of the described data of returning, be judged as divergence during the number of the data of downloading more than or equal to described request in the number of the described data of returning.
Alternatively, this device further comprises maintenance unit between the fault zone;
Maintenance unit between described fault zone is suitable for when the described data of returning and the data with existing divergence in the Database Unit, is kept between will the fault zone corresponding with the layer data of divergence between the fault zone of safeguarding in the Database Unit in the set.
Alternatively, maintenance unit between described fault zone, be further adapted for the sign of the oldest data in the described data of returning and the described sign that has downloaded to the up-to-date data in the Database Unit and form an array that represents between the fault zone, and this array is saved in the array set of gathering between expression fault zone in the Database Unit.
Alternatively, set is to be realized by the array list in the JAVA class libraries between the described fault zone in the described Database Unit.
According to a further aspect in the invention, provide a kind of method for downloading data, the method comprises:
Send the request of downloading new data, the data that reception server returns to server;
Judge whether the described data of returning can be connected with the data with existing in the database;
If be connected, the described data of returning be saved in the database, and the show tags of the described data of returning is set to effectively;
If divergence is with existing show tags in the database that the show tags of active data all is set to invalid, then the described data of returning is saved in the database, and the show tags of the described data of returning is set to effectively;
Wherein, only having show tags is that active data can be shown;
If the number of the data that the server that receives returns is 0, the latest data in user's reminder-data storehouse is the latest data on the server.
Alternatively, comprise in the request of described download new data: ask the data number of download, and downloaded to the sign of the up-to-date data in the database;
Describedly judge whether the described data of returning can be connected with the data with existing in the database and comprise: when the data number that the number of the described data of returning is downloaded less than described request, be judged as linking, when the data number that the number of the described data of returning is downloaded more than or equal to described request, be judged as divergence.
Alternatively, the method further comprises:
If divergence is saved between also will the fault zone corresponding with the layer data of divergence between the fault zone of safeguarding in the set.
Alternatively, described being saved between the fault zone of safeguarding between will the fault zone corresponding with the layer data of divergence comprises in the set:
Sign and the described sign that has downloaded to the up-to-date data in the database with the oldest data in the described data of returning form an array that represents between the fault zone, and this array is saved in the array set of gathering between the expression fault zone.
Alternatively, the method further comprises: adopt the array list in the JAVA class libraries to realize gathering between described fault zone.
According to this request of downloading new data that sends to server of the present invention, the data that reception server returns, judge whether the described data of returning can be connected with the data with existing in the database, if be connected, the described data of returning are saved in the database, and the show tags of the described data of returning is set to effectively, if divergence, existing show tags in the database is that the show tags of active data all is set to invalid, then the described data of returning are saved in the database, and the show tags of the described data of returning is set to effectively, only having show tags when showing is the technical scheme that active data can be shown, can behind each request new data, judge whether new data and existing data are connected, illustrate then that when divergence data have produced tomography, by arranging and safeguarding that show tags only shows up-to-date continuous data when showing, the user sees that data are continuous data like this, wherein there is not layer data, solved thus the user and can not know the problem that whether has layer data in the shown data.
Above-mentioned explanation only is the general introduction of technical solution of the present invention, for can clearer understanding technological means of the present invention, and can be implemented according to the content of instructions, and for above and other objects of the present invention, feature and advantage can be become apparent, below especially exemplified by the specific embodiment of the present invention.
Embodiment
Exemplary embodiment of the present disclosure is described below with reference to accompanying drawings in more detail.Although shown exemplary embodiment of the present disclosure in the accompanying drawing, yet should be appreciated that and to realize the disclosure and the embodiment that should do not set forth limits here with various forms.On the contrary, it is in order to understand the disclosure more thoroughly that these embodiment are provided, and can with the scope of the present disclosure complete convey to those skilled in the art.
Fig. 1 shows a kind of according to an embodiment of the invention process flow diagram of the method for downloading data.As shown in Figure 1, the method comprises:
Step S110 sends the request of downloading new data, the data that reception server returns to server.
In one embodiment of the invention, comprise in the request of the download new data that this user end to server sends: ask the data number of download, and downloaded to the sign of the up-to-date data in the database.Like this, server end thinks that data that client is asked are the data till the Data Identification that comprises from the current up-to-date data of server end to described request, and the data number of request is the number that comprises in the described request.Here, " newly " and " old " relatively be the generation time of data, " newly " be generation time after data, " old " is generation time data formerly.
Step S120 judges whether the data that server returns can be connected with the data with existing in the database, if execution in step S130, if not execution in step S140.
In one embodiment of the invention, be judged as linking during data number that the number of the data of returning at server is downloaded less than request, be judged as divergence during data number that the number of the data of returning at server is downloaded more than or equal to request.This is the data number of downloading because of the request that comprises in the request of server end with the download new data of client transmission, and has downloaded to the result of the foundation that is designated return data of the up-to-date data in the database.
Increase progressively successively as example take the sign of the data sequencing according to its generation time: what client had downloaded to up-to-date data in the database is designated 1000,20 data of current request.When if server end receives the request of client, the sign of up-to-date data of server end is to 1050, and then server can return to client and be designated 20 data of 1031 ~ 1050, and client can be judged as divergence.When if server end receives the request of client, the sign of up-to-date data of server end is to 1015, and then server can return to client and be designated 15 data of 1001 ~ 1015, and client can be judged as linking.
Step S130, the data that server is returned are saved in the database, and the show tags of these data of returning is set to effectively.Execution in step S150.
Step S140 is with existing show tags in the database that the show tags of active data all is set to invalid, and the data of then server being returned are saved in the database, and the show tags of the data that server is returned is set to effectively.Execution in step S150.
Step S150 only shows that the show tags in the database is active data.
In the technical scheme shown in Figure 1, behind new data, all judge whether new data and existing data are connected in each request, illustrate then that when divergence data have produced tomography, show tags by setting and service data, and when showing, only show up-to-date continuous data, the user sees that data are continuous data like this, does not wherein have layer data, has solved thus the user and can not know the problem that whether has layer data in the shown data.
When method shown in Figure 1 can also be judged as divergence in step S 120, be saved between further will the fault zone corresponding with the layer data of divergence between the fault zone of safeguarding in the set.Be specially: the sign of the oldest data in the data of returning with server and the sign that has downloaded to the up-to-date data in the database form an array that represents between the fault zone, and this array is saved in the array set of gathering between the expression fault zone.For example, be designated 1000 with what aforesaid client had downloaded to up-to-date data in the database, 20 data of current request, when server end receives the request of client, the sign of up-to-date data of server end is to 1050, server returns to client and is designated 20 data instances of 1031 ~ 1050, is [1031,1000] for array between fault zone corresponding to the layer data of this divergence.Two of [1031,1000] end-point datas 1000 and 1031 are not included in the layer data between the fault zone, and namely corresponding layer data is 1001 ~ 1030.
For making technical scheme of the present invention clearer, below technical scheme of the present invention is further described.
Fig. 2 shows the process flow diagram that is used for according to an embodiment of the invention the method for downloading data.Fig. 3 shows the data variation schematic diagram of client in the data downloading process according to an embodiment of the invention.Below in conjunction with Fig. 3 method shown in Figure 2 is described, as shown in Figure 2, the flow process of a new data of client-requested comprises:
Step S202, user end to server sends the request of downloading new data.
In one embodiment of the invention, comprise in the request of the download new data that this user end to server sends: ask the data number of download, and downloaded to the sign of the up-to-date data in the database.
At first, client need be determined will " ask download data number ", as being 20 generally speaking.In addition, client also needs to obtain the sign of up-to-date data that (namely download in the client database) in the data with existing, such as the lines 310 among Fig. 3.Above-mentioned " request download data number " and " signs of the up-to-date data in the data with existing " saved as a variable for subsequent use.Then, client is spliced into a URL with " the data number that request is downloaded " and " signs of the up-to-date data in the data with existing ", to the data of server request down loading updating.
Step S204, the data that the client server returns.
Here, server can judge to return how many record certificates according to " signs of the up-to-date data in the data with existing ", and returns which data.Generally, " signs of the up-to-date data in the data with existing " form of expression on server is " request is arrived till this Data Identification " (such as lines among Fig. 3 310), also be, the interval that obtains the scope of data is " signs of just infinite up-to-date data in data with existing ", formula is: (∞, the sign of the up-to-date data in the data with existing), the specified data of sign that do not comprise the up-to-date data in this data with existing in its scope.Simultaneously, " request download data number " also will be as a kind of condition restriction, and namely server end " the data number of returning " is less than or equals this restriction.Finally, the condition of the return data of server end is: one, the number of return data is less than or equals " request download data number "; Two, the scope of obtaining data is (∞, the sign of the up-to-date data in the data with existing), two conditions become " with " relation.
Step S206, client judges whether the data number that server returns is less than or equal to 0, is execution in step S208 then, otherwise execution in step S210.
Step S208, if the data number that server returns is less than or equal to 0, represent that then Data Identification up-to-date in the client has been that the latest data of server end has identified, the data that are client have been up-to-date, server end does not have the data of renewal, client is latest data on the server to the latest data in user's reminder-data storehouse, need not to ask again, and transmission course stops.
Step S210, if the data number that server returns is greater than 0, then represent also new data of the existing latest data than client of server end, therefore continue to judge whether the data that server returns can be connected with the data with existing in the database, be specially and judge that data number that server returns is whether less than the data number downloaded of ask, execution in step S212 then, otherwise execution in step S214.
Step S212, if the data number that server returns is less than the data number of ask download, represent that then the data that server returns can be connected with the data of client terminal local, client is saved in the data that server returns in the database, and the show tags of the data that server is this time returned is set to effectively.For example, in one embodiment of the invention, can realize the data that server returns are inserted in the database with the SQL statement of an INSERT.Process ends.
Step S214, if the data number that server returns is more than or equal to the data number of ask download, represent that then the data that server returns can not be connected with the data of client terminal local, client has layer data, in then will be saved in and gather between the fault zone of safeguarding between fault zone corresponding to this layer data.
In one embodiment of the invention, the identification record of the oldest data in the data that client is at first returned server gets off, and saves as a variable, in the present embodiment, can be described as " signs of the oldest data in the server return data ", shown in lines among Fig. 3 320.Then, client shown in the lines 310 among Fig. 3, saves as a variable with " signs of the up-to-date data in the data with existing ", and is for subsequent use.Again then, from database, take out " the interval set of tomography " (in Fig. 3, have between fault zone, two places to be labeled as respectively 331 and 332, then these two is exactly " the interval set of tomography " altogether)." gather " the scope interval that is mainly used to record each tomography between the fault zone, these tomographies all also do not download in the client, but again can be to server request when client needs.And the purpose of taking out " gathering between the fault zone " is to add between new fault zone in this set.
In one embodiment of the invention, adopt the array list ArrayList in the JAVA class libraries to realize gathering between the fault zone.And be by the SQLite statement set between the fault zone to be taken out specific to the way in the Android client.Because what take out is Bytes type (also between available characters string descriptor fault zone), client can be passed through unserializing technology (de-serialize), also be the readObject method of the ObjectInputStream class of Android, this record is converted into an ArrayList object.And in the middle of the ArrayList, each all is made of the one-dimension array of Integer, and each array has two elements, is used for respectively representing two borders between this fault zone.What client will be done is as two borders between the fault zone with previously mentioned " signs of the oldest data in the data that server returns " and " signs of the up-to-date data in the data with existing ", insert respectively in the one-dimension array of new Integer, then it is added in the ArrayList object, at last, be a Bytes object with its serializing (serialize) again, also be the toByteArray () of the ObjectOutputStream of Android, finally, again it is deposited back in the middle of the database.So far, set is with between many new fault zones between the fault zone, and 333 among Fig. 3 is between this fault zone that newly increases.
Step S216 is with existing show tags in the database that the show tags of active data all is set to invalid.
The value that is about to existing data (such as the data segment 311 among Fig. 3) show tags in the client shows from 1() change 0(into and hide), can not be presented in the display interface of client to guarantee the data with existing section 311 before the tomography 333.Specific practice is: by a SQL statement, the value of the show tags of all data with existing is shown from 1() change 0(into and hide).
Step S218, the data of then server being returned are saved in the database, and the show tags of the data that server is returned is set to effectively.
Client can all be inserted into those data 333 of being returned by server end before in the database, and the value of its show tags is set to the 1(demonstration).So far, whole transmission course finishes.
By as seen above-mentioned, in the technical scheme of the present invention, by arranging and safeguard show tags, only show up-to-date continuous data, the user sees that data are continuous data like this, recorded in addition tomography interval, like this when the user wants to ask layer data, can be according to the corresponding layer data of tomography interval requests that records.
Fig. 4 shows a kind of according to an embodiment of the invention structural drawing of the device for downloading data.As shown in Figure 4, the device 400 of this downloading data comprises: Database Unit 401, display unit 402, new data download unit 403 and database maintenance unit 404;
New data download unit 403 is suitable for sending the request of downloading new data, the data that reception server returns to server.In one embodiment of the invention, new data download unit 403 comprises in the request of the download new data of server transmission: ask the data number of download, and downloaded to the sign of the up-to-date data in the database.
Database maintenance unit 404, be suitable for judging whether the data that server returns can be connected with the data with existing in the Database Unit 401, if be connected, the data that server is returned are saved in the Database Unit 401, and the show tags of the data that server is returned is set to effectively, if divergence, existing show tags in the Database Unit 401 is that the show tags of active data all is set to invalid, then the data of server being returned are saved in the Database Unit, and the show tags of the data that server is returned is set to effectively.
Database Unit 401 is suitable for the show tags of save data and data;
Display unit 402 is suitable for showing that the show tags in the Database Unit 401 is active data.
Device shown in Figure 4, behind each request new data, judge whether new data and existing data are connected, illustrate then that when divergence data have produced tomography, by arranging and safeguarding that show tags only shows up-to-date continuous data when showing, the user sees that data are continuous data like this, wherein there is not layer data, solved thus the user and can not know the problem that whether has layer data in the shown data.
Fig. 5 shows the structural drawing that is used for according to an embodiment of the invention the device of downloading data.As shown in Figure 5, the device 500 of this downloading data comprises: maintenance unit 505 and Tip element 506 between Database Unit 501, display unit 502, new data download unit 503, database maintenance unit 504, fault zone.
New data download unit 503 is suitable for sending the request of downloading new data, the data that reception server returns to server.In one embodiment of the invention, new data download unit 503 comprises in the request of the download new data of server transmission: ask the data number of download, and downloaded to the sign of the up-to-date data in the database.
Database maintenance unit 504, be suitable for judging whether the data that server returns can be connected with the data with existing in the Database Unit 501, if be connected, the data that server is returned are saved in the Database Unit 501, and the show tags of the data that server is returned is set to effectively, if divergence, existing show tags in the Database Unit 501 is that the show tags of active data all is set to invalid, then the data of server being returned are saved in the Database Unit, and the show tags of the data that server is returned is set to effectively.
Database Unit 501 is suitable for the show tags of save data and data;
Display unit 502 is suitable for showing that the show tags in the Database Unit 501 is active data.
In one embodiment of the invention, comprise in the request of the download new data that sends to server of new data download unit 503: the data number that request is downloaded and downloaded to the sign of the up-to-date data in the Database Unit 501.The condition of the return data of server end is: one, the return data number is less than or equals " request download data number "; Two, the scope of obtaining data is (∞ has downloaded to the sign of the up-to-date data in the Database Unit 501), two conditions become " with " relation.Then the database maintenance unit 504, are judged as linking during the number of the data that the number that is suitable for the data returned at server is downloaded less than request, are judged as divergence during the number of the data of downloading more than or equal to described request in the number of the described data of returning.
Maintenance unit 505 between the fault zone, are suitable for when data that server returns and the data with existing divergence in the Database Unit 501, are kept between will the fault zone corresponding with the layer data of divergence between the fault zone of safeguarding in the Database Unit 501 in the set.Specifically, the sign of the oldest data in the data that maintenance unit 505 usefulness servers return between the fault zone and the sign that has downloaded to the up-to-date data in the Database Unit 501 form an array that represents between the fault zone, and this array is saved in the array set of gathering between expression fault zone in the Database Unit 501.
In one embodiment of the invention, set is to be realized by the array list in the JAVA class libraries between the fault zone in the Database Unit 501.
Tip element 506, the number that is suitable for the data returned at server is 0, the latest data in user's reminder-data storehouse is the latest data on the server.
In sum, device shown in Figure 5, by arranging and safeguard show tags, only show up-to-date continuous data, the user sees that data are continuous data like this, recorded in addition tomography interval, like this when the user wants to ask layer data, can be according to the corresponding layer data of tomography interval requests that records.
Need to prove:
Intrinsic not relevant with any certain computer, virtual system or miscellaneous equipment with demonstration at this algorithm that provides.Various general-purpose systems also can be with using based on the teaching at this.According to top description, it is apparent constructing the desired structure of this type systematic.In addition, the present invention is not also for any certain programmed language.Should be understood that and to utilize various programming languages to realize content of the present invention described here, and the top description that language-specific is done is in order to disclose preferred forms of the present invention.
In the instructions that provides herein, a large amount of details have been described.Yet, can understand, embodiments of the invention can be in the situation that there be these details to put into practice.In some instances, be not shown specifically known method, structure and technology, so that not fuzzy understanding of this description.
Similarly, be to be understood that, in order to simplify the disclosure and to help to understand one or more in each inventive aspect, in the description to exemplary embodiment of the present invention, each feature of the present invention is grouped together in single embodiment, figure or the description to it sometimes in the above.Yet the method for the disclosure should be construed to the following intention of reflection: namely the present invention for required protection requires the more feature of feature clearly put down in writing than institute in each claim.Or rather, as following claims reflected, inventive aspect was to be less than all features of the disclosed single embodiment in front.Therefore, follow claims of embodiment and incorporate clearly thus this embodiment into, wherein each claim itself is as independent embodiment of the present invention.
Those skilled in the art are appreciated that and can adaptively change and they are arranged in one or more equipment different from this embodiment the module in the equipment among the embodiment.Can be combined into a module or unit or assembly to the module among the embodiment or unit or assembly, and can be divided into a plurality of submodules or subelement or sub-component to them in addition.In such feature and/or process or unit at least some are mutually repelling, and can adopt any combination to disclosed all features in this instructions (comprising claim, summary and the accompanying drawing followed) and so all processes or the unit of disclosed any method or equipment make up.Unless in addition clearly statement, disclosed each feature can be by providing identical, being equal to or the alternative features of similar purpose replaces in this instructions (comprising claim, summary and the accompanying drawing followed).
In addition, those skilled in the art can understand, although embodiment more described herein comprise some feature rather than further feature included among other embodiment, the combination of the feature of different embodiment means and is within the scope of the present invention and forms different embodiment.For example, in the following claims, the one of any of embodiment required for protection can be used with array mode arbitrarily.
All parts embodiment of the present invention can realize with hardware, perhaps realizes with the software module of moving at one or more processor, and perhaps the combination with them realizes.It will be understood by those of skill in the art that and to use in practice microprocessor or digital signal processor (DSP) to realize according to some of the device that is used for downloading data of the embodiment of the invention or all some or repertoire of parts.The present invention can also be embodied as be used to part or all equipment or the device program (for example, computer program and computer program) of carrying out method as described herein.Such realization program of the present invention can be stored on the computer-readable medium, perhaps can have the form of one or more signal.Such signal can be downloaded from internet website and obtain, and perhaps provides at carrier signal, perhaps provides with any other form.
It should be noted above-described embodiment the present invention will be described rather than limit the invention, and those skilled in the art can design alternative embodiment in the situation of the scope that does not break away from claims.In the claims, any reference symbol between bracket should be configured to limitations on claims.Word " comprises " not to be got rid of existence and is not listed in element or step in the claim.Being positioned at word " " before the element or " one " does not get rid of and has a plurality of such elements.The present invention can realize by means of the hardware that includes some different elements and by means of the computing machine of suitably programming.In having enumerated the unit claim of some devices, several in these devices can be to come imbody by same hardware branch.The use of word first, second and C grade does not represent any order.Can be title with these word explanations.