Specific implementation mode
To keep the purpose, technical scheme and advantage of the application clearer, below in conjunction with the application specific embodiment and
Technical scheme is clearly and completely described in corresponding attached drawing.Obviously, described embodiment is only the application one
Section Example, instead of all the embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not doing
Go out the every other embodiment obtained under the premise of creative work, shall fall in the protection scope of this application.
Just it has been observed that for cloud storage business scenario, it can lead between client and cloud server terminal used by a user
The mode for crossing inputstream inlet flows carries out the transmission of data.But the mode of inputstream inlet flows is typically to be directed to certain
One file to be transmitted, carries out the transmission of byte-by-byte, it is clear that, should in the case where executing the shorter business scenario of time requirement to business
There are bottlenecks for the efficiency of transmission of mode.In addition, being required between client and server-side by the way of inputstream inlet flows
It is always maintained at connection status, it is generally the case that server will can not be carried out due to the connecting detection mechanism of itself in certain time length
The connection of data transmission disconnects, so, time longer business scenario is executed for business, using inputstream inlet flows
Mode may result in connection disconnect, to need reconnection, increase link cost.
Therefore in order to which the above situation is reduced or avoided as far as possible, a kind of file process side is provided in this specification embodiment
Method, by executing fragment read operation to file, multiple threads is called disposably to read multiple file fragmentations and caching to client
End is local, so that user reads the file of caching, promotes the reading efficiency to file.
Meanwhile for ease of understanding, it in one or more embodiments of this specification, is stored in cloud server terminal and waits locating
It can be such as to manage file:(suffix is for executable file (suffix .exe), compressed file (suffix .rar), system file
.dll), data file (suffix .csv .xls etc.) and all kinds of images, audio-video document etc., no longer arrange one by one here
It lifts.And if using OSS cloud storage services above-mentioned, pending file can also be stored as unified file format, that is,
OSS files.Certainly, the restriction to the application should not be constituted here.
Fragment processing (File Split) is carried out for pending file involved in this specification embodiment, can will be passed through
Obtained partial document is known as after fragment processing:File fragmentation.Wherein, to pending file carry out split blade type read, under
The processing modes such as load also are understood as the fragment processing described in this specification embodiment.In subsequent embodiment, by client
File is obtained from cloud server terminal split blade type, referred to as fragment is read, and is not construed as the restriction to the application here.
Framework as shown in Figure 1 may be used in document handling method described in this specification embodiment, in the framework
At least it may include:Client and cloud server terminal (may be simply referred to as below:Server-side).
Specifically, the client, it is believed that be the application program provided by cloud storage business provider
(Application, APP), the client operate in terminal used by a user.In addition, the client can be in its operation
Multiple slicing files are created in terminal reads thread, which reads thread and is used to establish the connection between server-side,
And the file fragmentation after fragment is buffered in the container in terminal memory for specified pending file, so that user passes through
The client is read out.
The server-side, it is believed that be the service server for providing cloud storage business, certainly, service server into
The frameworks such as single server, cluster server or distributed server may be used in one step, here and are not especially limited.
Based on above-mentioned framework as described in Figure 1, the technical side provided in this specification embodiment will be detailed below
Case.
A kind of document handling method is provided in this specification embodiment, as described in Figure 2, specifically includes following steps:
Step S201:Client determines the pending file for being stored in server-side.
As previously mentioned, pending file is stored in server-side, if user needs to read pending file, need to pass through
Client selects and determines the required pending file read.
Certainly, in a kind of possible embodiments of this specification, user may browse through in server-side by client and be deposited
The file of storage, on this basis, user can select a certain/certain file by client.For client, record is used
The selected file identification in family is (such as:Filename, file serial number, store path etc.), corresponding pending file is determined with this.
Subsequently it can also read according to file identification and be stored in corresponding file in server-side.
For client, the selection operation that user is sent out is considered as a kind of file and reads instruction, except this it
Outside, it can also send out file by corresponding service/program according to the rule of setting from trend client and read instruction, so,
In a kind of possible embodiments of this specification, client determines the pending file for being stored in server-side, so that it may to include:Visitor
Family terminates message in-coming part and reads instruction, and the pending file for being stored in server-side is determined according to file reading instruction.
Step S203:Fragment reading is carried out for the pending file, obtains multiple file fragmentations.
In general, it is stored in server-side in the business scenario involved by section Example in the present specification
File is typically larger file, such as:The GB of several GB~hundreds of, even up to TB ranks.Thus, to be directed to above-mentioned file
It is read out, efficiency of transmission will be caused relatively low using existing inputstream inlet flows.
Therefore, in this specification embodiment, the pending file progress split blade type for being stored in server-side can be directed to
It reads, and fragment reading can be parallel, that is to say, that this document can be read for the same pending file in parallel
In different content, obtain multiple file fragmentations.
It is understood that file content included in each file fragmentation is only a part for pending file,
In some business scenarios, multiple file fragmentations that fragment is read contain the full content of pending file.And it is waiting for
Handle file it is excessive in the case of, obtained multiple file fragmentations after fragment is read, it is also possible to only be one of pending file
Point.
As a kind of feasible pattern in this specification embodiment, the size for the file fragmentation that fragment is read can also
It is pre-set, e.g., setting fragment size is 100MB, that is, each file fragmentation that fragment is read in the case
Size be 100MB.Certainly, it can be specifically configured according to the needs of practical application, not constitute the limit to the application here
It is fixed.
In addition it should also be noted that, fragment reading is regarded as client and establishes corresponding network connection with server-side,
And read by the fragment that network connection is carried out for the pending file in server-side, which may be used hypertext
Transport protocol (Hyper Text Transfer Protocol, HTTP), Secure Hypertext Transfer Protocol (Hyper Text
Transfer Protocol over Secure Socket, HTTPS) etc. realizations, here and be not especially limited.
In general, client can create or call corresponding thread in the terminal operating system of its operation, realize
Above-mentioned fragment read operation, that is, the process for carrying out fragment reading for the pending file specifically may include:Client tune
With or create the fragment of setting quantity and read thread, read thread by the fragment carries out fragment for the pending file
It reads.
Step S205:Part or all of the multiple file fragmentation is cached in the client local, so that user reads
Take the file fragmentation of caching.
In this specification embodiment, for multiple file fragmentations, the terminal memory that client is run can be buffered in
In.So, user can quickly and easily read the file fragmentation of caching in memory by client.
Work as energy, in practical applications, memory capacity is limited in by memory, for the multiple file fragmentations read,
May there was only partial document fragment priority cache in memory, subsequently as the data cached in memory are eliminated or memory headroom
Release, remaining partial document fragment can cache into memory therewith.Certainly, the limit to the application is not constituted here
It is fixed.
Through the above steps, it for using client reading to be stored in server-side for the scene of file, is determining
It is stored in after the pending file of server-side, it can fragment reads corresponding pending text from server-side by client
Part, to obtain multiple file fragmentations, and can be by caching that fragment is read to client local.Obviously, it exactly uses and divides
The mode that piece is read, can read to concurrent type frog the different content of same pending file within the same time, compared to
The reading manner of the transmission modes such as inputstream inlet flows, split blade type can obtain enough file datas in a short time
And it is buffered in client local, efficiency of transmission is effectively promoted.
For aforementioned method as shown in Figure 2, typically, executive agent can be client, in certain applications field
Jing Zhong, it is also possible to the terminal operating system that client is run on, specifically, if client has enough permissions,
Corresponding thread can be then created and called by the client, complete above-mentioned steps, and if client does not obtain enough
Permission, then can be by the corresponding function in client request terminal operating system/service execution above-mentioned steps.Also, it is executing
During above-mentioned steps, executive agent can change, such as:It can be by client executing above-mentioned steps S201, then by end
Operating system is held to execute above-mentioned steps S203 and S205.Certainly, it will be specifically determined according to the needs of practical application, here simultaneously
The restriction to the application is not constituted.
For the above method it should be noted that in practical application scene, to pending file carry out fragment read and
The process of caching has different processing modes, will be made below being described in detail:
Mode one, orderly fragment are read
Orderly fragment, which is read, usually requires that multiple file fragmentations that reading obtains are tactic, certainly, is buffered in interior
When depositing middle, similarly cached according to corresponding sequence.
Specifically, as shown in figure 3, being the principle schematic executed when orderly fragment is read.In fig. 3, it is assumed that needing
Orderly fragment reading is carried out for the pending file A being stored in server-side, then, it can perform following steps:
Step S1:Client reads according to file and instructs, and determines the pending file A for needing to read.
In this example, file reads instruction and can be sent out by user, and in other words, client can provide a user accordingly
File selection interface, by the interface, user is browsable to the corresponding document being stored in server-side.And it can be in the choosing
It selects in interface and sends out file reading instruction by modes such as control, options.Equally, as previously mentioned, client is according to file
Instruction is read, can know corresponding file identification, and can further determine pending file A according to this document mark.It should
Process no longer excessively repeats.
Step S3:It creates or calls the fragment of setting quantity to read thread, thread is read for described by the fragment
Pending file A executes fragment and reads.
Client can create or call a certain number of fragments to read thread, and each fragment reading thread is mutual indepedent,
Also, each fragment reading thread can be established voluntarily establishes network connection with server-side.As in this specification embodiment
A kind of feasible pattern, fragment reads thread can read file identification entrained in instruction based on file, from server-side fragment
Read pending file A.
What needs to be explained here is that in figure 3, pending file A, which is divided into 7, by several fragments reading thread has
Sequence file fragmentation (it should be noted that division style in Fig. 3 is merely to the fragment of pending file A is read in expression, and
It is non-that the pending file A of storage is split as 7 parts).
Step S5:Multiple order file fragments that fragment is handled are stored in the memory container of client local.
In this example, Map containers can be used in memory container, which is suitable for orderly storage.It is interior under a kind of mode
One Map container of middle setting is deposited, container size (capacity) can be consistent with memory size (memory space of memory), also may be used
To be less than memory size.
Multiple Map containers can be set under another way, in memory, the total sizes of multiple Map containers can with it is interior
It is consistent to deposit size.The quantity of Map containers can be consistent with the fragment reading quantity of thread, can not also be consistent, specifically can root
It is configured according to the needs of practical application, just no longer excessively repeats here.
Meanwhile in caching, corresponding segmental identification is generated for different file fragmentations, that is, fragment key, to shape
At a kind of structure of key-value pair:
Fragment key- file fragmentations
Here fragment key can play the role of serial number, to be stored in sorted order in Map containers.
Step S7:For the order file fragment carry out sequence reading being stored in memory container.
In this example, user can be directed to file carry out sequence reading by client.
For the above process, client is generally based on scheduling or the wound of the usage degree control thread of memory container
Build, specifically, container size reach the upper limit will not scheduling thread go to read pending file A, not reaching the upper limit can be automatic
Read subsequent fragment data, user deletes data in container after running through the data of a fragment.
Mode two, unordered fragment are read
It is different from orderly fragment above-mentioned to read, whether unordered fragment reading is not required for multiple file fragmentations orderly, more
A fragment read thread can read arbitrary portion in pending file (it should be understood that either read using orderly fragment or
Unordered fragment is read, and the obtained file content corresponding to each file fragmentation should be different)
As shown in figure 4, for the principle schematic for executing when unordered fragment is read.In conjunction with Fig. 4, read with aforementioned orderly fragment
The same or similar part of process no longer excessively repeats, difference lies in:
Memory storage structure in Fig. 4 may be used bounded obstruction queue, block queue by bounded, can control point
The speed that piece is read, to prevent file fragmentation from accumulating in memory.
Further, in this specification embodiment, it may be used and wrapped in the calculating bounded obstruction queue of fragment counter
The quantity of the file fragmentation contained, and finished with this to judge whether the file fragmentation in bounded obstruction queue is read.
When user by client read bounded block queue in file fragmentation when, by according to the mechanism of first in first out into
Row is read, meanwhile, after user has read a file fragmentation, then client can block in queue in bounded and delete this document fragment
It removes, calls fragment above-mentioned to read thread automatically and obtain next file fragmentation, and cache to bounded and block in queue.
From above-mentioned content as it can be seen that larger file can be carried out split blade type reading by this programme, multiple file fragmentations are obtained.
User obtains the process asynchronization of file fragmentation to the reading process of the file fragmentation of caching and from server-side, specifically,
Before user reads the file fragmentation of caching, client can obtain multiple file fragmentations simultaneously, be read for user, and work as user
After reading, new file fragmentation can be obtained again.User is pure internal memory operation by the operation that client reads file fragmentation, and
Not remote acquisition can slow down while promoting file transmission efficiency or avoid connecting time-out between client and server-side
File is caused to read the case where interrupting.
It is the document handling method that this specification embodiment provides above, is based on same thinking, this specification embodiment
Corresponding document handling apparatus is also provided.
Specifically, the document handling apparatus provided in this specification embodiment is as shown in figure 5, described device includes:
File determining module 501 determines the pending file for being stored in server-side;
Fragment read module 502 carries out fragment reading for the pending file, obtains multiple file fragmentations;
Part or all of the multiple file fragmentation is cached in the client local, so as to user by cache module 503
Read the file fragmentation of caching.
Further, file determining module 501 receives file and reads instruction, reads instruction determination according to the file and deposits
It is stored in the pending file of server-side.
Further, fragment read module 502, the fragment for calling or creating setting quantity read thread, pass through described point
Piece reads thread and carries out fragment reading for the pending file.
Further, fragment read module 502 reads thread according to the file fragmentation size of setting by the fragment
Fragment reading is carried out for the pending file.
Further, fragment read module 502 reads thread by the fragment, is carried out for the pending file
Orderly fragment is read, and obtains multiple order file fragments.
Further, cache module 503 cache all or part of the multiple order file fragment in sequence
In the Map containers of memory.
Wherein, the quantity of the Map containers is one or more, and the capacity of Map containers is not more than the appearance of the content
Amount.
Further, cache module 503 will be all or part of the multiple orderly according to the capacity of the Map containers
File fragmentation is cached in sequence in the Map containers of memory.
Further, fragment read module 502 reads thread by the fragment, is carried out for the pending file
Unordered fragment is read, and obtains multiple unordered file fragments.
Further, cache module 503, by all or part of the multiple unordered file fragment, caching to memory
Bounded is blocked in queue.
Further, described device further includes:Data dump module 504 is deleted after user reads the file fragmentation of caching
Except this document fragment of caching.
Based on device shown in fig. 5, in practical applications can by entity equipment (such as:Terminal device) it is realized, specifically
For, which includes:Processor, memory, wherein
The memory, storage file processing routine;
The processor calls the file process sequence stored in memory, and executes:
Determine the pending file for being stored in server-side;
Fragment reading is carried out for the pending file, obtains multiple file fragmentations;
Part or all of the multiple file fragmentation is cached in the text that the client is local, is cached so as to user's reading
Part fragment.
Each embodiment in this specification is described in a progressive manner, identical similar portion between each embodiment
Point just to refer each other, and each embodiment focuses on the differences from other embodiments.Especially for device,
For equipment and medium class embodiment, since it is substantially similar to the method embodiment, so description is fairly simple, related place
Illustrate referring to the part of embodiment of the method, just no longer repeats one by one here.
So far, the specific embodiment of this theme is described.Other embodiments are in the appended claims
In range.In some cases, the action recorded in detail in the claims can execute and still in a different order
Desired result may be implemented.In addition, the process described in the accompanying drawings not necessarily requires the particular order shown or continuous suitable
Sequence, to realize desired result.In some embodiments, multitasking and parallel processing can be advantageous.
In the 1990s, the improvement of a technology can be distinguished clearly be on hardware improvement (for example,
Improvement to circuit structures such as diode, transistor, switches) or software on improvement (improvement for method flow).So
And with the development of technology, the improvement of current many method flows can be considered as directly improving for hardware circuit.
Designer nearly all obtains corresponding hardware circuit by the way that improved method flow to be programmed into hardware circuit.Cause
This, it cannot be said that the improvement of a method flow cannot be realized with hardware entities module.For example, programmable logic device
(Programmable Logic Device, PLD) (such as field programmable gate array (Field Programmable Gate
Array, FPGA)) it is exactly such a integrated circuit, logic function determines device programming by user.By designer
Voluntarily programming comes a digital display circuit " integrated " on a piece of PLD, designs and makes without asking chip maker
Dedicated IC chip.Moreover, nowadays, substitution manually makes IC chip, this programming is also used instead mostly " patrols
Volume compiler (logic compiler) " software realizes that software compiler used is similar when it writes with program development,
And the source code before compiling also write by handy specific programming language, this is referred to as hardware description language
(Hardware Description Language, HDL), and HDL is also not only a kind of, but there are many kind, such as ABEL
(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description
Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL
(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby
Hardware Description Language) etc., VHDL (Very-High-Speed are most generally used at present
Integrated Circuit Hardware Description Language) and Verilog.Those skilled in the art also answer
This understands, it is only necessary to method flow slightly programming in logic and is programmed into integrated circuit with above-mentioned several hardware description languages,
The hardware circuit for realizing the logical method flow can be readily available.
Controller can be implemented in any suitable manner, for example, controller can take such as microprocessor or processing
The computer for the computer readable program code (such as software or firmware) that device and storage can be executed by (micro-) processor can
Read medium, logic gate, switch, application-specific integrated circuit (Application Specific Integrated Circuit,
ASIC), the form of programmable logic controller (PLC) and embedded microcontroller, the example of controller includes but not limited to following microcontroller
Device:ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, are deposited
Memory controller is also implemented as a part for the control logic of memory.It is also known in the art that in addition to
Pure computer readable program code mode is realized other than controller, can be made completely by the way that method and step is carried out programming in logic
Controller is obtained in the form of logic gate, switch, application-specific integrated circuit, programmable logic controller (PLC) and embedded microcontroller etc. to come in fact
Existing identical function.Therefore this controller is considered a kind of hardware component, and to including for realizing various in it
The device of function can also be considered as the structure in hardware component.Or even, it can will be regarded for realizing the device of various functions
For either the software module of implementation method can be the structure in hardware component again.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.It is a kind of typically to realize that equipment is computer.Specifically, computer for example may be used
Think personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
It is any in device, navigation equipment, electronic mail equipment, game console, tablet computer, wearable device or these equipment
The combination of equipment.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, implementing this
The function of each unit is realized can in the same or multiple software and or hardware when application.
It should be understood by those skilled in the art that, the embodiment of the present invention can be provided as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention
Apply the form of example.Moreover, the present invention can be used in one or more wherein include computer usable program code computer
The computer program production implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
The form of product.
The present invention be with reference to according to the method for the embodiment of the present invention, the flow of equipment (system) and computer program product
Figure and/or block diagram describe.It should be understood that can be realized by computer program instructions every first-class in flowchart and/or the block diagram
The combination of flow and/or box in journey and/or box and flowchart and/or the block diagram.These computer programs can be provided
Instruct the processor of all-purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine so that the instruction executed by computer or the processor of other programmable data processing devices is generated for real
The device for the function of being specified in present one flow of flow chart or one box of multiple flows and/or block diagram or multiple boxes.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that instruction generation stored in the computer readable memory includes referring to
Enable the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one box of block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device so that count
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, in computer or
The instruction executed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in a box or multiple boxes.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include computer-readable medium in volatile memory, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology realizes information storage.Information can be computer-readable instruction, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storages, magnetic tape cassette, tape magnetic disk storage or other magnetic storage apparatus
Or any other non-transmission medium, it can be used for storage and can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
Including so that process, method, commodity or equipment including a series of elements include not only those elements, but also wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that wanted including described
There is also other identical elements in the process of element, method, commodity or equipment.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer program product.
Therefore, complete hardware embodiment, complete software embodiment or embodiment combining software and hardware aspects can be used in the application
Form.It is deposited moreover, the application can be used to can be used in the computer that one or more wherein includes computer usable program code
The shape for the computer program product implemented on storage media (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
Formula.
The application can describe in the general context of computer-executable instructions executed by a computer, such as program
Module.Usually, program module includes routine, program, object, the group for executing particular transaction or realizing particular abstract data type
Part, data structure etc..The application can also be put into practice in a distributed computing environment, in these distributed computing environments, by
Affairs are executed by the connected remote processing devices of communication network.In a distributed computing environment, program module can be with
In the local and remote computer storage media including storage device.
Each embodiment in this specification is described in a progressive manner, identical similar portion between each embodiment
Point just to refer each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality
For applying example, since it is substantially similar to the method embodiment, so description is fairly simple, related place is referring to embodiment of the method
Part explanation.
Above is only an example of the present application, it is not intended to limit this application.For those skilled in the art
For, the application can have various modifications and variations.It is all within spirit herein and principle made by any modification, equivalent
Replace, improve etc., it should be included within the scope of claims hereof.