Embodiment
The embodiment of the present application provides a kind of data processing method and device.
In order that those skilled in the art more fully understand the technical scheme in the application, it is real below in conjunction with the application
The accompanying drawing in example is applied, the technical scheme in the embodiment of the present application is clearly and completely described, it is clear that described implementation
Example only some embodiments of the present application, rather than whole embodiments.Based on the embodiment in the application, this area is common
The every other embodiment that technical staff is obtained under the premise of creative work is not made, should all belong to the application protection
Scope.
The generation for situations such as flowing the interim card in sliding process for existing Feed, it is contemplated that some can be compared to consumption
When operation place asynchronous thread in handled, for main thread, acquisition be processing after data, it is only necessary to carry out
Last renders display process, so as to effectively reduce the generation of interim card situation.I.e., it is possible to pass through asynchronous thread pair
Card time-consuming operation is pre-processed, so that Card render time is reduced, with the sliding capability for Feed streams of deducting a percentage, so as to carry
Rise Consumer's Experience.
Based on this, in the embodiment of the present application there is provided a kind of data processing method, as shown in figure 1, can include as follows
Step:
Step 101:The data that main thread is asked are obtained by asynchronous thread;
Above-mentioned main thread can be the thread just created by operating system when program starts, and the thread is being built
Run at once after vertical, i.e. main thread is carried out when program starts.For each process, at least there is a master
Thread.For main thread, some operations must be performed by main thread, for example:Perform various shutoff operations.
In one embodiment, main thread not directly obtains data, but will obtain after request is initiated by main thread
Asynchronous thread is transferred in the work of access evidence.For example, it may be obtaining the data needed from server.In this example, for main line
The request of data of journey, the operation that data are obtained from server is performed by asynchronous thread.
I.e., it is possible to be after main thread initiates request, by request of data of the asynchronous thread in response to main thread, to service
Device sends RPC (Remote Procedure Call Protocol, remote procedure call protocol) requests, please to obtain main thread
The data asked.
For example:User logs on the wechat friend circle of oneself, it is intended to update to browse (the drop-down behaviour of the state in friend circle
Make), at this moment main thread initiates to obtain the request of Feed flow datas, and asynchronous thread is i.e. to server request data, and server is returned
Data also received by asynchronous thread.
Step 102:The data of the request are pre-processed by asynchronous thread;
In order that obtaining main thread when data display is carried out, speed faster, reduces interim card sense when user browses.
Asynchronous thread is not directly to return data to main thread after the data of server return are got, but first to data
Pre-processed.Wherein, pretreatment can be that the relatively time-consuming operation of contrast is first completed in asynchronous thread, for example:Picture conversion,
Data Format Transform, replacement placeholder and rich text parsing etc..Because these operations are all than relatively time-consuming, if all in main line
Handled in journey, then can increase the possibility of interim card appearance.Pre-processed therefore, first passing through asynchronous thread, so as to get main
The data of thread are pretreated data, rather than the initial data obtained from server.Because asynchronous thread enters to data
Gone pretreatment, so that main thread no longer needs to carry out these data processings, directly rendered so that render with
The used time of displaying is greatly shortened, so as to effectively reduce interim card sense, to lift the viewing experience of user.
It should be noted, however, that the concrete operations of above-mentioned cited several pretreatments, merely to being better described
The application, when actually realizing, which specific operation is completed in asynchronous thread, can be selected according to actual needs, this
Application is not construed as limiting to this., can be with and to be also not necessarily limited to the above several for the operation of pretreatment, can also there is other pretreatment operations
Selected according to the need for actual process object.
In order to realize the pretreatment of the data to being obtained from server, multiple pretreated models can be pre-established.Because
Different types of service can correspond to different pretreatment operations, therefore, it can set up different pre- according to the difference of type of service
Handle model (can also turn into and preload model).Asynchronous thread is by calling the corresponding model that preloads of business to carry out data
Processing, to obtain pretreated data.In one embodiment, asynchronous thread is by preloading model to the request
Data are pre-processed, wherein, preload model be with ask that the type of service of the business of the data of the request matches it is pre-
Stress model.The different preloading model of different type of service correspondences.
For example:In wechat friend circle, the state of good friend's hair and the reply of the good friend type of service that to be two kinds different, therefore,
It correspond to different pretreated models.
Step 103:Pretreated data are back to the main thread, by the main thread to the pretreatment after
Data carry out Rendering operations.
That is, after the completion of asynchronous thread has all been handled the time-consuming operation in data, pretreated data can be obtained, will
These data are supplied to main thread, and main thread avoids the need for carrying out these time-consuming operations again, and directly data are carried out to render displaying
.
In one embodiment, by the main thread the pretreated data are carried out Rendering operations it
Afterwards, it can also include:The data after Rendering operations are shown in the way of Feed flows.
As shown in Fig. 2 being the schematic diagram shown after rendering, the figure shows the Feed of the wealth community in financing software
Flow display schematic diagram.As shown in Fig. 2 the information of an information completely can be shown just as a Card file in figure
It is two Card.Other information are may browse through by sliding up and down.As shown in Fig. 2 for each Card, can have not
Same type, for example, the state of the small A funds issue of correspondence is an article, small B financings issue is word+video.By right
The advanced processing of word content either video, picture etc. so that the operating time of main thread shortens, so as to effectively reduce card
, improve Consumer's Experience.
Above-mentioned data processing method is handled with reference to a specific embodiment, it is important to note, however, that the tool
Body embodiment does not constitute the improper restriction to the application merely to the application is better described.
Illustrated by taking Sina weibo either wechat friend circle as an example.
When there is a large amount of parallel displayings of contents needs in APP, Feed streams are a kind of common interactive forms.In example
In Sina weibo either these community's scenes of wechat friend circle, it is more common that Feed flows this interactive form.In Feed streams
In, a complete content is (for example:One complete friend circle state, or a complete microblogging), it is properly termed as one
Card (Card).
Abundant with Card contents, the structure of card also becomes increasingly complex, and occurs in that expression, rich text, picture, regards
The multiple elements such as frequency, this also causes Card rendering efficiency to be greatly reduced.If while being rendered to Card, to data
Handled, often cause rendering speed excessively slow for complicated Card, so as to cause the page interim card occur in slip.
In this example, by preheating technology, original Feed flow datas are pre-processed, before complicated time-consuming operation
Put in asynchronous thread, so as to reduce every kind of Card render time, improve rendering speed, effectively improve Feed streams
The fluency of slip.
As shown in figure 3, be the general handling process of Feed flow datas, including:
S1:Main thread initiates request;
S2:Asynchronous thread performs network RPC request operations, obtains initial data (being assumed to be raw-data) and returns to master afterwards
Thread;
S3:Main thread performs Card rendering intents (getView) after taking data, renders after completion, shows use
Family.
Wherein, both needed to raw-data processing (for example in getView methods:Replace placeholder, reconstructed picture chi
Very little, processing rich text etc.), need to carry out rendering for Card again, this will increase getView processing time, so as to result in
Feed flows the interim card in sliding process.
In this example there is provided a kind of Feed method for stream processing, as shown in figure 4, can include:
S1:Main thread initiates request;
S2:Asynchronous thread performs network RPC request operations, obtains initial data (raw-data) and returns immediately afterwards
Return main thread;
S3:Data are stayed in into asynchronous thread, asynchronous thread carries out pretreatment operation to raw-data;
S4:After completion to be pre-treated, then the data (being assumed to be warmup-data) after pretreatment are returned into main line
Journey;
S5:Main thread carries out Rendering operations (getView) to Card again.
The processing time of raw-data data is saved through the above way, is effectively reduced time-consuming in getView
Operation, so as to effectively improve the slip efficiency of Feed streams.
When realizing, the pretreatment operation of data can be carried out by WarmUp devices, to lift sliding capability.Tool
Body, it may include steps of:
S1:Client is initiated to obtain the RPC requests of Feed flow datas;
S2:Service end receives client and obtains the request of Feed flow datas, and Feed flow datas are returned into client;
S3:Client receives the original Feed flow datas (raw-data) of service end return;
S4:Client is parsed and model conversion at warmup layers, as required to raw-data, and is exported
warmup-data;
S5:Client completes rendering for view according to the warmup-data obtained after conversion.
Wherein, step S3 to S5 can be realized in WarmUp devices, the WarmUp devices can with as shown in figure 5,
Including multiple Warmup interfaces, Warmup interfaces can correspondingly be increased and decreased according to specific business.For example, in such as Fig. 2 institutes
In the wealth community shown, viewpoint (comment) is different with the model for replying (reply), then corresponds to two different preloadings
Model.WarmUp layers as shown in Figure 5, can mainly carry out the functions such as the preloading and pretreatment of data, for completing complexity
Time-consuming data processing logic, for example:Placeholder, rich text parsing etc. are replaced, and externally exports pretreated warmup-
data.As shown in Figure 5, preheating factory therein may be considered a factory class, the conversion for carrying out data model, example
Such as:Rich text conversion, placeholder replacement etc..
That is, pretreatment unit logic of the raw-data data to warmup-data data conversions is realized by WarmUp layers,
And WarmUp layers be configurable to dynamic, interface flexibly preloaded, more to be extended to business, and can basis
The model set up the need for business needed for matching business.The mode that original data processing and Rendering operations are all realized in main thread
In data processing operation be advanced to asynchronous thread and handled so that main thread only needs to complete light-weighted Rendering logic,
So as to effectively reduce render time, Consumer's Experience is improved.
Based on same inventive concept, a kind of data processing equipment is additionally provided in the embodiment of the present invention, such as following implementation
Example is described.Because the principle that data processing equipment solves problem is similar to data processing method, therefore the reality of data processing equipment
The implementation that may refer to data processing method is applied, part is repeated and repeats no more.It is used below, term " unit " or " mould
Block " can realize the combination of the software and/or hardware of predetermined function.Although the device described by following examples is preferably with soft
Part is realized, but hardware, or the realization of the combination of software and hardware is also that may and be contemplated.Fig. 6 is of the invention real
A kind of structured flowchart of the data processing equipment of example is applied, as shown in fig. 6, can include:Acquisition module 601, pretreatment module 602
With rendering module 603, the structure is illustrated below.
Acquisition module 601, for obtaining the data that main thread is asked by asynchronous thread;
Pretreatment module 602, for being pre-processed by asynchronous thread to the data of the request;
Rendering module 603, for pretreated data to be back into the main thread, by the main thread to described
Pretreated data carry out Rendering operations.
In one embodiment, pretreatment module 602 specifically can be used for by the asynchronous thread to the request
Data carry out but be not limited to it is following operation at least one:Picture conversion, Data Format Transform, replacement placeholder and rich text solution
Analysis.
In one embodiment, pretreatment module 602 specifically can be used for using by the asynchronous thread and pre-add
Model is carried to pre-process the data of the request, wherein, the model that preloads is the data with asking the request
The preloading model of the type of service matching of business.
Acquisition module 601 can include in one embodiment:Transmitting element, for being responded by the asynchronous thread
In the request of data of main thread, RPC requests are sent to server;Receiving unit, for receiving described by the asynchronous thread
Data of the server in response to the RPC requests for asking to return.
In one embodiment, above-mentioned data processing equipment can also include:Display module, for passing through the master
Thread is carried out to the pretreated data after Rendering operations, and the data after Rendering operations are carried out in the way of Feed flows
Displaying.
As can be seen from the above description, the embodiment of the present invention realizes following technique effect:The embodiment of the present application is led to
Cross after the data that asynchronous thread gets main thread request, be not to be immediately sent to main thread, but first data are carried out
After pretreatment, then pretreated data are sent to main thread.Main thread is based on pretreated data and carries out rendering behaviour
Make, so that the processing procedure of data is put into asynchronous thread, reduce the load of main thread, effectively shorten main thread
Render time so that solve existing data processing and render all in main thread perform caused by sliding process occur
The technical problem of interim card, has reached the technique effect of the probability that effective reduction interim card occurs, lifting sliding capability and Consumer's Experience.
In the 1990s, for a technology improvement can clearly distinguish be on hardware improvement (for example,
Improvement to circuit structures such as diode, transistor, switches) or software on improvement (for the improvement of 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 is 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, PLD
(Programmable Logic Device, PLD) (such as field programmable gate array (Field Programmable Gate
Array, FPGA)) it is exactly such a integrated circuit, its logic function is determined by user to device programming.By designer
Voluntarily programming comes a digital display circuit " integrated " on a piece of PLD, without asking chip maker to design and make
Special IC chip.Moreover, nowadays, substitution manually makes IC chip, and 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 have many kinds, 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 should
This understands, it is only necessary to slightly programming in logic and be programmed into method flow in integrated circuit with above-mentioned several hardware description languages,
The hardware circuit for realizing the logical method flow can be just readily available.
Controller can be implemented in any suitable manner, for example, controller can take such as microprocessor or processing
Device and storage can by the computer of the computer readable program code (such as software or firmware) of (micro-) computing device
Read medium, 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 is 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 except with
Pure computer readable program code mode is realized beyond controller, can be made completely by the way that method and step is carried out into programming in logic
Obtain controller and come real in the form of gate, switch, application specific integrated circuit, programmable logic controller (PLC) and embedded microcontroller etc.
Existing identical function.Therefore this controller is considered a kind of hardware component, and various for realizing to including in it
The device of function can also be considered as the structure in hardware component.Or even, can be by for realizing that the device of various functions is regarded
For that not only can be the software module of implementation method but also can be the structure in hardware component.
System, device, module or unit that above-described embodiment is illustrated, can specifically be realized by computer chip or entity,
Or 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, cell phone, camera phone, smart phone, personal digital assistant, media play
It is any in device, navigation equipment, electronic mail equipment, game console, tablet PC, wearable device or these equipment
The combination of equipment.
For convenience of description, it is divided into various units during description apparatus above with function to describe respectively.Certainly, this is being implemented
The function of each unit can be realized in same or multiple softwares and/or hardware during application.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or computer program
Product.Therefore, the present invention can be using the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Apply the form of example.Moreover, the present invention can be used in one or more computers for wherein including computer usable program code
The computer program production that usable storage medium is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.)
The form of product.
The present invention is the flow with reference to method according to embodiments of the present invention, equipment (system) and computer program product
Figure and/or block diagram are described.It should be understood that can be by every first-class in computer program instructions implementation process figure and/or block diagram
Journey and/or the flow in square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be provided
The processor of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce
A raw machine so that produced by the instruction of computer or the computing device of other programmable data processing devices for real
The device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which is produced, to be included referring to
Make the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram or
The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that in meter
Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, thus in computer or
The instruction performed 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 individual square frame or multiple square frames.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net
Network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only storage (ROM) or flash memory (flash RAM).Internal 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 come realize information store.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), moved
State random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electric erasable
Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage (CD-ROM),
Digital versatile disc (DVD) or other optical storages, magnetic cassette tape, the storage of tape magnetic rigid disk or other magnetic storage apparatus
Or any other non-transmission medium, the information that can be accessed by a computing device available for storage.Define, calculate according to herein
Machine computer-readable recording 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, term " comprising ", "comprising" or its any other variant are intended to nonexcludability
Comprising so that process, method, commodity or equipment including a series of key elements are not only including those key elements, but also wrap
Include other key elements being not expressly set out, or also include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that wanted including described
Also there is other identical element in process, method, commodity or the equipment of element.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer program product.
Therefore, the application can be using the embodiment in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Form.Deposited moreover, the application can use to can use in one or more computers for wherein including computer usable program code
The shape for the computer program product that storage media is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.)
Formula.
The application can be described in the general context of computer executable instructions, such as program
Module.Usually, program module includes performing particular task or realizes routine, program, object, the group of particular abstract data type
Part, data structure etc..The application can also be put into practice in a distributed computing environment, in these DCEs, by
Remote processing devices connected by communication network perform task.In a distributed computing environment, program module can be with
Positioned at including in the local and remote computer-readable storage medium including storage device.
Each embodiment in this specification is described by the way of progressive, identical similar portion between each embodiment
Divide mutually referring to what each embodiment was stressed is the difference with other embodiment.It is real especially for system
Apply for example, because it is substantially similar to embodiment of the method, so description is fairly simple, related part is referring to embodiment of the method
Part explanation.
Embodiments herein is the foregoing is only, the application is not limited to.For those skilled in the art
For, the application can have various modifications and variations.It is all any modifications made within spirit herein and principle, equivalent
Replace, improve etc., it should be included within the scope of claims hereof.