CN110022341B - Data transmission method and related equipment - Google Patents

Data transmission method and related equipment Download PDF

Info

Publication number
CN110022341B
CN110022341B CN201810025236.9A CN201810025236A CN110022341B CN 110022341 B CN110022341 B CN 110022341B CN 201810025236 A CN201810025236 A CN 201810025236A CN 110022341 B CN110022341 B CN 110022341B
Authority
CN
China
Prior art keywords
storage area
data
shared storage
identification information
client
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810025236.9A
Other languages
Chinese (zh)
Other versions
CN110022341A (en
Inventor
王勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201810025236.9A priority Critical patent/CN110022341B/en
Publication of CN110022341A publication Critical patent/CN110022341A/en
Application granted granted Critical
Publication of CN110022341B publication Critical patent/CN110022341B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a data transmission method and related equipment, comprising a client side applying for a shared storage area from a system memory and establishing a mapping relation between the shared storage area and identification information; the client writes application data into the shared storage area; and the client sends data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area. By adopting the embodiment of the invention, the data transmission efficiency can be improved.

Description

Data transmission method and related equipment
Technical Field
The present invention relates to the field of electronic technologies, and in particular, to a data transmission method and related devices.
Background
With the popularization of smart phones, the application programs applied to smart phone terminals are on the coming layer, and the appearance of a large number of application programs brings great convenience to the life of users. In the running process, a large amount of data interaction is required between the front-end page of the application program and the client, and particularly when the video editing and picture processing functions of the application program are used, the generated data volume is huge, so the running speed of the application program and the use experience of a user are directly influenced by the efficiency of data transmission. At present, for the situation that a client transmits data to a front end, a mode of firstly encoding the data into a binary data stream by a Base64 encoding method and then transmitting the binary data to the front end is generally adopted, and the front end still uses a mode of directly transmitting the data to the client. However, when a large binary data stream is transmitted, data transmission takes a long time and is inefficient, which seriously affects user experience.
Disclosure of Invention
The embodiment of the invention provides a data transmission method and related equipment, which improve the efficiency of data transmission.
In a first aspect, an embodiment of the present invention provides a method for data transmission, including:
the client applies for a shared storage area from a system memory and establishes a mapping relation between the shared storage area and the identification information;
the client writes application data into the shared storage area;
and the client sends data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area.
Wherein, the client applies for the shared storage area from the system memory comprises:
the client acquires the data size of the application data;
and the client applies for the shared storage area from the system memory according to the data size.
Wherein, the client applies for the shared storage area from the system memory comprises:
and the client calls a dynamic memory allocation function to apply for the shared storage area from the system memory.
Wherein the shared memory region includes a start address and a memory region size.
Wherein the data information further comprises the data size.
The client comprises a Java end or a kotlin end, and the Web end comprises a Javascript end.
In a second aspect, an embodiment of the present invention provides a data transmission method, including:
the Web end receives data information sent by a client, wherein the data information comprises identification information of a shared storage area;
and the Web terminal reads the application data written by the client terminal from the shared storage area according to the identification information.
The step of the Web end reading the application data written by the client from the shared storage area according to the identification information includes:
the Web end searches the shared storage area from a system memory according to the identification information;
and the Web end reads the application data from the searched shared storage area.
The step of searching the shared storage area from the system memory by the Web end according to the identification information comprises:
the Web terminal searches for the initial address of the shared storage area corresponding to the identification information from a mapping table, wherein the mapping table comprises the mapping relation between the identification information and the initial address;
and the Web end searches the shared storage area from the system memory according to the initial address.
Wherein the data information further comprises a data size of the application data;
the step of the Web end reading the application data written by the client from the shared storage area according to the identification information includes:
and the Web end reads the application data from the shared storage area according to the identification information and the data size.
Wherein, the reading, by the Web side, the application data from the shared storage area according to the identification information and the data size includes:
the Web terminal searches for the initial address of the shared storage area corresponding to the identification information from a mapping table, wherein the mapping table comprises the mapping relation between the identification information and the initial address;
and the Web end reads the application data with the data size from the shared storage area according to the starting address.
In a third aspect, the present invention provides a client, including:
the memory application module is used for applying for a shared storage area from a system memory and establishing a mapping relation between the shared storage area and the identification information;
the data writing module is used for writing application data into the shared storage area;
and the information sending module is used for sending data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area.
The memory application module is specifically configured to:
acquiring the data size of the application data;
and applying for the shared storage area from the system memory according to the data size.
The memory application module is specifically configured to:
and calling a dynamic memory allocation function to apply for the shared memory area from the system memory.
Wherein the shared memory region includes a start address and a memory region size.
Wherein the data information further comprises the data size.
In a fourth aspect, the present invention provides a Web side, including:
the information receiving module is used for receiving data information sent by a client, wherein the data information comprises identification information of a shared storage area;
and the data reading module is used for reading the application data written by the client from the shared storage area according to the identification information.
Wherein the data reading module is specifically configured to:
searching the shared storage area from a system memory according to the identification information;
and reading the application data from the searched shared storage area.
Wherein the data reading module is specifically configured to:
searching a starting address of the shared storage area corresponding to the identification information from a mapping table, wherein the mapping table comprises a mapping relation between the identification information and the starting address;
and searching the shared storage area from the system memory according to the initial address.
Wherein the data information further comprises a data size of the application data;
the data reading module is specifically configured to:
and reading the application data from the shared storage area according to the identification information and the data size.
Wherein the data reading module is specifically configured to:
searching a starting address of the shared storage area corresponding to the identification information from the mapping table, wherein the mapping table comprises a mapping relation between the identification information and the starting address;
and reading the application data with the data size from the shared storage area according to the starting address.
In a fifth aspect, the present invention provides a data transmission device, including: the data transmission method comprises a processor, a memory and a communication bus, wherein the communication bus is used for realizing connection communication between the processor and the memory, and the processor executes a program stored in the memory for realizing the steps in the data transmission method provided by the first aspect.
In a sixth aspect, the present invention provides a data transmission device, including: the data transmission method comprises a processor, a memory and a communication bus, wherein the communication bus is used for realizing connection communication between the processor and the memory, and the processor executes a program stored in the memory for realizing the steps in the data transmission method provided by the second aspect.
In one possible design, the data transmission device provided by the present invention may include a module for performing the corresponding operations in the method described above. The modules may be software and/or hardware.
Yet another aspect of the present invention provides a computer-readable storage medium having stored thereon a plurality of instructions adapted to be loaded by a processor and to perform the method of the above-described aspects.
Yet another aspect of the present invention provides a computer program product containing instructions which, when run on a computer, cause the computer to perform the method of the above aspects.
By implementing the embodiment of the invention, a client applies for a shared storage area from a system memory and establishes a mapping relation between the shared storage area and identification information; the client writes application data into the shared storage area; and the client sends data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area. The client sends the identification information to the Web end, and the Web end reads the application data from the shared storage area according to the identification information, so that the data transmission amount between the client and the Web end is reduced, and the data transmission efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments or the background art of the present invention, the drawings required to be used in the embodiments or the background art of the present invention will be described below.
Fig. 1 is a schematic structural diagram of a data transmission system according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a data transmission method according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a method for allocating a shared memory area according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating another method for allocating a shared memory area according to an embodiment of the present invention;
fig. 5 is a schematic flow chart of another data transmission method according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a client according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a Web end according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of another client according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of another Web end according to the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a data transmission system according to an embodiment of the present invention, where the data transmission system includes a client, a Web and a shared storage area, where the client may include a Java end or a kotlin end, and the Web may include a Javascript end. For example, the Java side may be a system layer of an application program developed by using a Native method in Java, the Java side has functions of storing offline and issuing a network request, the Javascript side may be a logic layer of an application program developed by using Javascript, and the Javascript side may provide services such as program registration and page registration. The Java terminal can provide locally offline stored pictures and user data for the Javascript terminal and send a webpage browsing request to the Javascript terminal, and the Javascript terminal can provide services such as application program entry and page registration for the Java terminal. The method for transmitting the data from the Java end to the Javascript end is the same as the method for transmitting the data from the Javascript end to the Java end, for example, when the Java end transmits an offline stored picture to the Javascript end, the Java end firstly applies for the shared storage area from a system memory and establishes a mapping relation between the shared storage area and the identification information; then writing application data corresponding to the picture into the shared storage area according to the identification information; and finally, sending data information to the Javascript terminal, wherein the data information comprises identification information, and the identification information is used for the Javascript terminal to read the application data from the shared storage area. Based on the above data transmission system, the embodiments of the present invention provide the following solutions.
Referring to fig. 2, fig. 2 is a schematic flow chart of a data transmission method according to an embodiment of the present invention, where the method includes, but is not limited to, the following steps:
s201, the client applies for a shared storage area from a system memory, and establishes a mapping relation between the shared storage area and the identification information.
In a specific implementation, a client may first obtain a data size of the application data, then call a dynamic memory allocation function to apply for the shared storage area from the system memory according to the data size, and simultaneously establish a mapping relationship between the shared storage area and the identification information, where the identification information may be allocated to the shared storage area through a related application program interface, and the shared storage area may include a start address and a storage area size.
For example: firstly, the Java end calculates to obtain the data size of application data to be transmitted as 2M, then the Java end allocates an identity Identification number (ID) "1" as Identification information of a shared storage region by using a GetNativeBufferId, then the Java end calls a dynamic memory allocation function malloc in a C + + programming language through an application program interface SetNativeBuffer to apply for a 2M continuous storage region from a system memory as the shared storage region, the malloc function returns the initial address of the shared storage region through a pointer, as shown in FIG. 3, the initial address of the shared storage region is 0x00000010, and establishes a mapping relation between the initial address of the shared storage region 0x00000010 and Identification information "1", further a mapping table can be generated, the mapping table comprises the mapping relation between the Identification information and the initial address of the shared storage region, as shown in Table 1, the mapping table comprises the Identification information and the initial address, wherein, the start address corresponding to the identification information "1" is 0x 00000010.
TABLE 1 mapping table-1
Identification information Starting address
1 0x00000010
Optionally, the client may first obtain the data size of the application data, then divide the application data into a plurality of blocks, and then call a dynamic memory allocation function to apply for the shared storage area from the system memory according to the size of each block of application data. And meanwhile, establishing a mapping relation between the shared storage area and the identification information. Further, a mapping table may be generated, which includes a mapping relationship between the identification information of the shared memory area and the start address.
For example: the Java terminal firstly calculates the data size of the application data to be transmitted to be 2M, and then divides the 2M application data into a piece of application data with the size of 1.5M and a piece of application data with the size of 0.5M. For application data with the size of 1.5M, the Java end uses an application program interface getnative Buffer ID to allocate an ID number "1" as identification information of a shared storage area, and calls a dynamic memory allocation function malloc in a C + + programming language through an application program interface SetNative-Buffer to apply for a 1.5M continuous storage area from a system memory as the shared storage area, and the malloc function returns a start address of the shared storage area through a pointer, as shown in fig. 4, the start address of the shared storage area is 0x00000010, and then a mapping relationship between the start address of the shared storage area 0x00000010 and the identification information "1" is established. For application data with a size of 0.5M, the Java side repeats the above process, and allocates an ID number "2" as identification information of a shared storage area by using an application program interface getnativebuffer ID, applies for a continuous storage area of 0.5M as the shared storage area, as shown in fig. 4, the start address of the shared storage area is 0x00000040, establishes a mapping relationship between the start address 0x00000040 and the identification information "2", and further generates a mapping table, as shown in table 2, the mapping table includes the identification information and the start address, where the start address corresponding to the identification information "1" is 0x00000010, and the start address corresponding to the identification information "2" is 0x 00000040.
TABLE 2 mapping Table-2
Identification information Starting address
1 0x00000010
2 0x00000040
Optionally, the client may first determine whether to transmit data to the Web end for the first time, and if so, execute an operation of applying for a shared storage area from a system memory and establishing a mapping relationship between the shared storage area and the identification information. If the data is not transmitted to the Web end for the first time, firstly judging whether the shared storage area used for the last data transmission is released by a memory release function (such as free) corresponding to the dynamic memory allocation function, if so, executing the operation of applying for the shared storage area from the system memory and establishing the mapping relation between the shared storage area and the identification information; if the shared storage area is not released, judging whether the data size of the application data is smaller than the size of the shared storage area or not, if the data size is not larger than the size of the shared storage area, skipping the step, directly executing the following operation steps, and if the data size is larger than the size of the shared storage area, executing the operation of applying for the shared storage area from a system memory and establishing the mapping relation between the shared storage area and the identification information.
S202, the client writes application data into the shared storage area.
In a specific implementation, the client may write the application data to be transmitted to the shared storage area through a related application program interface (e.g., setnative buffer).
For example, after the Java terminal applies for a 2M shared storage area through the setnative buffer, and establishes a mapping relationship between the identifier "1" and the start address 0x00000010 of the shared storage area, the setnative buffer writes the data to be transmitted into the shared storage area corresponding to the identifier "1".
S203, the client sends data information to the Web end.
In a specific implementation, the client may send data information to the Web end through a related application program interface (e.g., SetIdtoJs), where the data information may include identification information of one or more shared storage areas, and the identification information is used for the Web end to read application data written by the client from the shared storage area.
For example, as shown in fig. 4, if the Java side writes 1.5M of application data into the shared storage area 1 and writes 0.5M of application data into the shared storage area 2, the Java side may send the identification information "1" of the shared storage area 1 and the identification information "2" of the shared storage area 2 to the Javascript side through the SetIdtoJs.
Optionally, the data information may further include a data size of the application data to be transmitted,
in the embodiment of the invention, a client applies for a shared storage area from a system memory and establishes a mapping relation between the shared storage area and identification information; then writing application data to the shared memory area; and finally, sending data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area. The client sends the identification information to the Web end, and the Web end reads the application data from the shared storage area according to the identification information, so that the data transmission amount between the client and the Web end is reduced, and the data transmission efficiency is improved.
Referring to fig. 5, fig. 5 is a schematic flow chart of another data transmission method according to an embodiment of the present invention, where the method includes, but is not limited to, the following steps:
s501, the client applies for a shared storage area from the system memory, and establishes a mapping relationship between the shared storage area and the identification information, which is the same as S201 in the previous embodiment and is not repeated here.
S502, the client writes the application data into the shared storage area, and this step is the same as S202 in the previous embodiment, and is not described again.
S503, the client sends data information to the Web end, and this step is the same as S203 in the previous embodiment, and is not described again.
And S504, the Web terminal reads the application data written by the client terminal from the shared storage area according to the identification information.
In a specific implementation, the Web end may search, according to the identification information in the received data information, a start address of the shared storage area in the mapping table, then search, according to the start address, the shared storage area from the system memory, and finally read application data written by the client from the searched shared storage area.
For example, if the identification information of the shared storage area in the data information received by the Javascript terminal is "1", the Javascript terminal may find, according to the identification information "1", that the start address corresponding to the identification information "1" is 0x00000010 in the mapping table shown in table 1, then may find, according to the start address 0x00000010, the shared storage area in the system memory shown in fig. 3, and finally, the Javascript terminal reads the application data written by the Java terminal from the shared storage area.
For another example, the received data information includes identification information "1" and identification information "2" of the shared storage area, the Javascript terminal may find, according to the identification information "1", that the start address corresponding to the identification information "1" is 0x00000010 in the mapping table shown in table 2, then may find, according to the start address 0x00000010, the shared storage area 1 in the system memory shown in fig. 4, and similarly, according to the identification information "2", may find the shared storage area 2 in the system memory shown in fig. 4, and finally, the Javascript terminal reads the application data written by the Java terminal from the shared storage area 1 and the shared storage area 2 in sequence.
Optionally, the client may read the application data from the shared storage area by using a related application program interface according to the identification information, for example, the application data in the shared storage area corresponding to the identification information "ID" may be read by using a getnative buffer (ID).
Optionally, the data information may further include a data size of the application data. And the Web end reads the application data from the shared storage area according to the identification information and the data size. Further, the Web end may search the mapping table for the start address of the shared storage area corresponding to the identification information; and then the Web end reads the application data with the data size from the shared storage area according to the initial address. The following two cases are included:
in the first case, after the Web end finds the start address according to the identification information and further finds the shared storage area from the system memory, the Web end reads the application data with the data size from the found shared storage area according to the start address, for example, if the identification information included in the data information received by the Javascript end is "1" and the data size is 1.5M, the Javascript end can find the start address corresponding to the identification information "1" in the mapping table shown in table 1 according to the identification information "1" as 0x00000010, then can find the shared storage area in the system memory shown in fig. 3 according to the start address 0x00000010, and then starts to read the application data of 1.5M from the shared storage area from the start address 0x 00000010.
In the second case, after the Web end finds the start address according to the identification information and further finds the multiple shared storage areas from the system memory, the application data is read from the multiple shared storage areas according to the start address, and the total amount of the application data read from the multiple shared storage areas is equal to the data size. For example, the data information received by the Javascript terminal includes identification information "1" and identification information "2", and the data size is 1.8M, then the Javascript terminal may find the start address corresponding to the identification information "1" in the mapping table shown in table 2 as 0x00000010 according to the identification information "1", then find the shared storage area 1 in the system memory shown in fig. 4, and similarly, may find the shared storage area 2 with the start address of 0x00000040 according to the identification information "2", then the Javascript terminal reads 1.5M of application data from the shared storage area 1 starting from the start address of 0x00000010 of the shared storage area 1, and reads 0.3M of application data from the shared storage area 2 starting from the start address of 0x00000040 of the shared storage area 2.
The data transmission method provided by the embodiment of the invention can be applied to the application program of the smart phone terminal. For example, in a wechat applet, when a system layer developed by using a Native method of Java sends a locally offline stored picture to a logic layer developed by using Javascript, a Java terminal (system layer) first calculates the data size of application data corresponding to the picture to be sent to be 2M, and allocates an ID number "1" as identification information of a shared storage area through an application program interface GetNative-buffer ID; then, a Java end (system layer) calls a dynamic memory allocation function malloc in a C + + programming language through an application program interface SetNativeBuffer to allocate a 2M continuous storage space from a system memory as a shared storage area, the malloc returns the start address 0x00000010 of the shared storage area through a pointer, a mapping relation between identification information '1' and the start address 0x00000010 is established, and 2M application data corresponding to the picture is written into the shared storage area corresponding to the identification information '1'; secondly, the Java terminal (system layer) sends the identification information '1' to the Javascript terminal (logic layer) through an application program interface SetIdtoJs; then, the Javascript terminal (logic layer) receives the identification information '1'; and finally, the Javascript end (logic layer) obtains the initial address according to the identification information '1', finds the shared area in the system according to the initial address, and reads the application data corresponding to the picture from the found shared area.
It should be noted that, the foregoing embodiment mainly introduces the application data transmission from the client to the Web end, and the method for transmitting the application data from the Web end to the client is the same as that in the foregoing embodiment, and the embodiment of the present invention is not described again.
In the embodiment of the invention, a client applies for a shared storage area from a system memory and establishes a mapping relation between the shared storage area and identification information; then writing application data to the shared memory area; and the client sends data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area. The client sends the identification information to the Web end, and the Web end reads the application data from the shared storage area according to the identification information, so that the data transmission amount between the client and the Web end is reduced, and the data transmission efficiency is improved.
The method of embodiments of the present invention is set forth above in detail and the apparatus of embodiments of the present invention is provided below.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a client according to an embodiment of the present invention, where the client may include:
the memory application module 601 is configured to apply for a shared storage region from a system memory, and establish a mapping relationship between the shared storage region and identification information.
In a specific implementation, the data size of the application data may be first obtained, then a dynamic memory allocation function is called to apply for the shared storage area from the system memory according to the data size, and meanwhile, a mapping relationship between the shared storage area and the identification information is established, where the identification information may be allocated to the shared storage area through a related application program interface, and the shared storage area may include a start address and a storage area size.
For example: firstly, the data size of application data to be transmitted is calculated to be 2M, then an application program interface GetNativeBufferId is used for distributing an ID number of '1' as identification information of a shared storage area, then calling a dynamic memory allocation function malloc in the C + + programming language through an application program interface setnative buffer to apply for a 2M continuous storage area from the system memory as a shared storage area, and returning the starting address of the shared storage area to the malloc function through a pointer, as shown in fig. 3, the start address of the shared memory area is 0x00000010, and a mapping relation between the start address 0x00000010 of the shared memory area and the identification information "1" is established, further a mapping table can be generated, the mapping table includes a mapping relationship between identification information and a start address of a shared storage area, as shown in table 1, the mapping table includes the identification information and the start address, where the start address corresponding to the identification information "1" is 0x 00000010.
Optionally, the data size of the application data may be first obtained, then the application data is divided into a plurality of blocks, and then a dynamic memory allocation function is called to apply for the shared storage area from the system memory according to the size of each block of application data. And meanwhile, establishing a mapping relation between the shared storage area and the identification information. Further, a mapping table may be generated, which includes a mapping relationship between the identification information of the shared memory area and the start address.
For example: firstly, the data size of application data to be transmitted is calculated to be 2M, and then the 2M application data is divided into a piece of application data with the size of 1.5M and a piece of application data with the size of 0.5M. For application data with the size of 1.5M, an application program interface getnative Buffer ID is used to allocate an ID number "1" as identification information of a shared storage area, a 1.5M continuous storage area is applied from a system memory as the shared storage area by calling a dynamic memory allocation function malloc in a C + + programming language through an application program interface SetNative-Buffer, the malloc function returns a start address of the shared storage area through a pointer, the start address of the shared storage area is 0x00000010 as shown in fig. 4, and a mapping relationship between the start address 0x00000010 of the shared storage area and the identification information "1" is established. For application data with a size of 0.5M, the above process is repeated, an application program interface getnativebuffer ID is used to allocate an ID number "2" as identification information of a shared storage area, a continuous storage area of 0.5M is applied as the shared storage area, as shown in fig. 4, the start address of the shared storage area is 0x00000040, a mapping relation between the start address of the shared storage area 0x00000040 and the identification information "2" is established, a mapping table is further generated, as shown in table 2, the mapping table includes identification information and a start address, where the start address corresponding to the identification information "1" is 0x00000010, and the start address corresponding to the identification information "2" is 0x 00000040.
Optionally, it may be determined whether data is transmitted to the Web end for the first time, and if data is transmitted to the Web end for the first time, an operation of applying for a shared storage area from a system memory and establishing a mapping relationship between the shared storage area and the identification information is performed. If the data is not transmitted to the Web end for the first time, firstly judging whether the shared storage area used for the last data transmission is released by a memory release function (such as free) corresponding to the dynamic memory allocation function, if so, executing the operation of applying for the shared storage area from the system memory and establishing the mapping relation between the shared storage area and the identification information; if the shared storage area is not released, judging whether the data size of the application data is smaller than the size of the shared storage area or not, if the data size is not larger than the size of the shared storage area, skipping the step, directly executing the following operation steps, and if the data size is larger than the size of the shared storage area, executing the operation of applying for the shared storage area from a system memory and establishing the mapping relation between the shared storage area and the identification information.
A data writing module 602, configured to write application data into the shared storage area.
In a specific implementation, the application data to be transmitted may be written into the shared memory area through an associated application program interface (e.g., setnative buffer).
For example, after the Java terminal applies for a 2M shared storage area through the setnative buffer, and establishes a mapping relationship between the identifier "1" and the start address 0x00000010 of the shared storage area, the setnative buffer writes the data to be transmitted into the shared storage area corresponding to the identifier "1".
And an information sending module 603, configured to send data information to the Web end.
In a specific implementation, data information may be sent to the Web end through a related application program interface (e.g., SetIdtoJs), where the data information may include identification information of one or more shared storage areas, and the identification information is used for the Web end to read application data written by the data writing module 602 from the shared storage area.
For example: as shown in fig. 4, if the data writing module 602 writes 1.5M of application data into the shared storage area 1 and writes 0.5M of application data into the shared storage area 2, the information sending module 603 may send the identification information "1" of the shared storage area 1 and the identification information "2" of the shared storage area 2 to the Web end through the SetIdtoJs.
Optionally, the data information may further include a data size of the application data to be transmitted.
In the embodiment of the invention, a client applies for a shared storage area from a system memory and establishes a mapping relation between the shared storage area and identification information; the client writes application data into the shared storage area; and the client sends data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area. The client sends the identification information to the Web end, and the Web end reads the application data from the shared storage area according to the identification information, so that the data transmission amount between the client and the Web end is reduced, and the data transmission efficiency is improved.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a Web end according to an embodiment of the present invention, where the Web end includes:
the information receiving module 701 is configured to receive data information sent by a client, where the data information includes identification information of a shared storage area.
A data reading module 702, configured to read, according to the identification information, application data written by the client from the shared storage area.
In a specific implementation, the start address of the shared storage area may be searched in the mapping table according to the identification information in the received data information, then the shared storage area is searched from the system memory according to the start address, and finally the application data written by the client is read from the searched shared storage area.
For example, if the identification information of the shared storage area in the received data information is "1", the start address corresponding to the identification information "1" may be found in the mapping table shown in table 1 according to the identification information "1" to be 0x00000010, then the shared storage area may be found in the system memory shown in fig. 3 according to the start address 0x00000010, and finally the application data written by the client is read from the shared storage area.
For another example, if the received data information includes identification information "1" and identification information "2" of the shared storage area, the start address corresponding to the identification information "1" may be found in the mapping table shown in table 2 according to the identification information "1" to be 0x00000010, then the shared storage area 1 may be found in the system memory shown in fig. 4 according to the start address 0x00000010, and similarly, the shared storage area 2 may be found in the system memory shown in fig. 4 according to the identification information "2", and finally, the application data written by the client is sequentially read from the shared storage area 1 and the shared storage area 2.
Optionally, the application data may be read from the shared storage area by using an associated application program interface according to the identification information, for example, the application data in the shared storage area corresponding to the identification information "ID" may be read through getnative buffer (ID).
Optionally, the data information may further include a data size of the application data. And reading the application data from the shared storage area according to the identification information and the data size. Further, the starting address of the shared storage area corresponding to the identification information is searched from the mapping table, and then the application data with the data size is read from the shared storage area according to the starting address. The following two cases are included:
in the first case, after the start address is found according to the identification information and the shared storage area is found from the system memory, the application data with the data size is read from the found shared storage area according to the start address, for example, if the received data information includes the identification information "1" and the data size is 1.5M, the start address corresponding to the identification information "1" can be found in the mapping table shown in table 1 according to the identification information "1" and is 0x00000010, then the shared storage area can be found in the system memory shown in fig. 3 according to the start address 0x00000010, and then the application data of 1.5M is read from the shared storage area from the start address 0x 00000010.
In the second case, after finding the start address according to the identification information and further finding the multiple shared storage areas from the system memory, the application data is read from the multiple shared storage areas according to the start address, the total amount of the application data read from the multiple shared storage areas is equal to the data size, for example, the received data information includes identification information "1" and identification information "2", the data size is 1.8M, the start address corresponding to the identification information "1" can be found in the mapping table shown in table 2 according to the identification information "1" to be 0x00000010, then the shared storage area 1 is found in the system memory shown in fig. 4, similarly, the shared storage area 2 with the start address of 0x00000040 can be found according to the identification information "2", then the application data of 1.5M is read from the shared storage area 1 starting from the start address of 0x00000010 of the shared storage area 1, 0.3M of application data is read from the shared memory area 2 starting from the start address 0x00000040 of the shared memory area 2.
In the embodiment of the invention, a client applies for a shared storage area from a system memory and establishes a mapping relation between the shared storage area and identification information; the client writes application data into the shared storage area; and the client sends data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area. The client sends the identification information to the Web end, and the Web end reads the application data from the shared storage area according to the identification information, so that the data transmission amount between the client and the Web end is reduced, and the data transmission efficiency is improved.
Referring to fig. 8, fig. 8 is a schematic structural diagram of another client according to an embodiment of the present invention. As shown, the client may include: at least one processor 801, at least one communication interface 802, at least one memory 803, and at least one communication bus 804.
The processor 801 may be, among other things, a central processing unit, a general purpose processor, a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, transistor logic, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor may also be a combination of computing functions, e.g., comprising one or more microprocessors, a digital signal processor and a microprocessor, or the like. The communication bus 804 may be a peripheral component interconnect standard PCI bus or an extended industry standard architecture EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 8, but this is not intended to represent only one bus or type of bus. A communication bus 804 is used to enable communications among the components. The communication interface 802 of the device in the embodiment of the present invention is used for performing signaling or data communication with other node devices. The Memory 803 may include a volatile Memory, such as a Nonvolatile dynamic Random Access Memory (NVRAM), a Phase Change Random Access Memory (PRAM), a Magnetoresistive Random Access Memory (MRAM), and the like, and may further include a Nonvolatile Memory, such as at least one magnetic Disk Memory device, an Electrically Erasable Programmable Read-Only Memory (EEPROM), a flash Memory device, such as a NOR flash Memory (NOR flash Memory) or a NAND flash Memory (EEPROM), a semiconductor device, such as a Solid State Disk (SSD), and the like. The memory 803 may optionally be at least one memory device located remotely from the processor 801 as previously described. A set of program codes is stored in the memory 803 and the processor 801 executes the programs in the memory 803.
Applying for a shared storage area from a system memory, and establishing a mapping relation between the shared storage area and identification information;
writing application data to the shared storage area;
and sending data information to a Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area.
Optionally, the processor 801 is further configured to perform the following operation steps:
acquiring the data size of the application data;
and applying for the shared storage area from the system memory according to the data size.
Optionally, the processor 801 is further configured to perform the following operation steps:
and calling a dynamic memory allocation function to apply for the shared memory area from the system memory.
Further, the processor may cooperate with the memory and the communication interface to perform the operations of the client in the above-described embodiments of the invention.
Referring to fig. 9, fig. 9 is a schematic structural diagram of another Web end according to an embodiment of the present disclosure. As shown, the Web end may include: at least one processor 901, at least one communication interface 902, at least one memory 903, and at least one communication bus 904.
The processor 901 may be any of the various types of processors mentioned above. The communication bus 904 may be a peripheral component interconnect standard PCI bus or an extended industry standard architecture EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 9, but this does not indicate only one bus or one type of bus. A communication bus 904 is used to enable connective communication between these components. The communication interface 902 of the device in this embodiment of the present application is used for performing signaling or data communication with other node devices. The memory 903 may be various types of memories as mentioned earlier. The memory 903 may optionally be at least one storage device located remotely from the processor 901. A set of program codes is stored in the memory 903 and executed by the processor 901 for the communication devices described above in the memory 903.
Receiving data information sent by a client, wherein the data information comprises identification information of a shared storage area;
and reading the application data written by the client from the shared storage area according to the identification information.
Optionally, the processor 901 is further configured to perform the following operation steps:
searching the shared storage area from a system memory according to the identification information;
and reading the application data from the searched shared storage area.
Optionally, the processor 901 is further configured to perform the following operation steps:
searching a starting address of the shared storage area corresponding to the identification information from a mapping table, wherein the mapping table comprises a mapping relation between the identification information and the starting address;
and searching the shared storage area from the system memory according to the initial address.
Optionally, the processor 901 is further configured to perform the following operation steps:
and reading the application data from the shared storage area according to the identification information and the data size.
Optionally, the processor 901 is further configured to perform the following operation steps:
searching a starting address of the shared storage area corresponding to the identification information from a mapping table, wherein the mapping table comprises a mapping relation between the identification information and the starting address;
and reading the application data with the data size from the shared storage area according to the starting address.
Further, the processor may also cooperate with the memory and the communication interface to perform the operations of the Web side in the above embodiments of the invention.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
The above-mentioned embodiments further explain the objects, technical solutions and advantages of the present invention in detail. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A method of data transmission, the method comprising:
the client side judges whether data are transmitted to the Web side for the first time;
if the client transmits data to the Web end for the first time to obtain the data size of the application data, the client comprises a Java end or a kotlin end, the Web end comprises a Javascript end, the Java end is a system layer of an application program developed by using a Native method in Java, and the JavaScript end is a logic layer of the application program developed by using JavaScript;
the client applies for a shared storage area from a system memory according to the size of the data, and establishes a mapping relation between the shared storage area and the identification information;
if the client does not transmit data to the Web end for the first time, judging whether the shared storage area used for data transmission at the last time is released;
if the shared storage area used for last data transmission is not released and is smaller than the data size of the application data, applying for the shared storage area from a system memory, and establishing a mapping relation between the shared storage area and the identification information; the client writes the application data into the shared storage area;
and the client sends data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area.
2. The method of claim 1, wherein the client applying for the shared storage area from the system memory comprises:
and the client calls a dynamic memory allocation function to apply for the shared storage area from the system memory.
3. The method of claim 1, wherein the shared memory region comprises a starting address and a memory region size.
4. The method of claim 1, wherein the data information further comprises the data size.
5. A method of data transmission, the method comprising:
the Web end receives data information sent by a client, wherein the data information comprises identification information of a shared storage area;
the Web end reads the application data written by the client from the shared storage area according to the identification information;
the shared storage area is applied from a system memory according to the data size of the application data when the client judges that the data are transmitted to the Web end for the first time or the shared storage area used for data transmission for the last time is not released and is smaller than the data size of the application data, the client comprises a Java end or a kotlin end, the Web end comprises a Javascript end, the Java end is a system layer of an application program developed by using a Native method in Java, and the JavaScript end is a logic layer of the application program developed by using JavaScript.
6. The method of claim 5, wherein the Web end reading the application data written by the client from the shared storage area according to the identification information comprises:
the Web end searches the shared storage area from a system memory according to the identification information;
and the Web end reads the application data from the searched shared storage area.
7. The method of claim 6, wherein the Web side searching the shared storage area from a system memory according to the identification information comprises:
the Web terminal searches for the initial address of the shared storage area corresponding to the identification information from a mapping table, wherein the mapping table comprises the mapping relation between the identification information and the initial address;
and the Web end searches the shared storage area from the system memory according to the initial address.
8. The method of claim 5, wherein the data information further includes a data size of the application data;
the step of the Web end reading the application data written by the client from the shared storage area according to the identification information includes:
and the Web end reads the application data from the shared storage area according to the identification information and the data size.
9. The method of claim 8, wherein the Web side reading the application data from the shared storage area according to the identification information and the data size comprises:
the Web terminal searches for the initial address of the shared storage area corresponding to the identification information from a mapping table, wherein the mapping table comprises the mapping relation between the identification information and the initial address;
and the Web end reads the application data with the data size from the shared storage area according to the starting address.
10. A client, the client comprising:
the memory application module is used for applying for a shared storage area from a system memory and establishing a mapping relation between the shared storage area and the identification information;
the memory application module is specifically configured to determine whether to transmit data to the Web end for the first time in the aspect of applying for the shared storage area from the system memory, and acquire the data size of the application data if the client transmits data to the Web end for the first time; applying for the shared storage area from the system memory according to the data size; if the client does not transmit data to the Web end for the first time, judging whether a shared storage area used for last data transmission is released or not, if the shared storage area used for last data transmission is not released and is smaller than the data size of the application data, applying for the shared storage area from a system memory, and establishing a mapping relation between the shared storage area and the identification information; the client comprises a Java end or a kotlin end, the Web end comprises a Javascript end, the Java end is a system layer of an application program developed by using a Native method in Java, and the JavaScript end is a logic layer of the application program developed by using JavaScript;
a data writing module, configured to write the application data into the shared storage area;
and the information sending module is used for sending data information to the Web end, wherein the data information comprises the identification information, and the identification information is used for the Web end to read the application data from the shared storage area.
11. A Web end, characterized in that the Web end comprises:
the information receiving module is used for receiving data information sent by a client, wherein the data information comprises identification information of a shared storage area;
the data reading module is used for reading the application data written by the client from the shared storage area according to the identification information;
the shared storage area is applied from a system memory according to the data size of the application data when the client judges that the data are transmitted to the Web end for the first time or the shared storage area used for data transmission for the last time is not released and is smaller than the data size of the application data, the client comprises a Java end or a kotlin end, the Web end comprises a Javascript end, the Java end is a system layer of an application program developed by using a Native method in Java, and the JavaScript end is a logic layer of the application program developed by using JavaScript.
12. A computer-readable storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the method according to any one of claims 1 to 9.
CN201810025236.9A 2018-01-10 2018-01-10 Data transmission method and related equipment Active CN110022341B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810025236.9A CN110022341B (en) 2018-01-10 2018-01-10 Data transmission method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810025236.9A CN110022341B (en) 2018-01-10 2018-01-10 Data transmission method and related equipment

Publications (2)

Publication Number Publication Date
CN110022341A CN110022341A (en) 2019-07-16
CN110022341B true CN110022341B (en) 2022-01-25

Family

ID=67188217

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810025236.9A Active CN110022341B (en) 2018-01-10 2018-01-10 Data transmission method and related equipment

Country Status (1)

Country Link
CN (1) CN110022341B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113961485A (en) * 2021-10-26 2022-01-21 西安广和通无线通信有限公司 Memory optimization method, device, terminal and storage medium
CN114553931B (en) * 2022-02-23 2024-03-08 广州小鹏汽车科技有限公司 Processing method, device, vehicle and system for shared storage space of vehicle

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1740978A (en) * 2004-08-23 2006-03-01 华为技术有限公司 Method for realing sharing internal stored data base and internal stored data base system
CN102184226A (en) * 2011-05-09 2011-09-14 河海大学 Method for constructing real-time database and data searching method
CN102945169A (en) * 2012-12-05 2013-02-27 江苏鸿信系统集成有限公司 Native APP fused Web APP development system based on Android
CN105677491A (en) * 2015-12-31 2016-06-15 杭州华为数字技术有限公司 Method and device for transmitting data
CN106412466A (en) * 2016-07-18 2017-02-15 国家新闻出版广电总局广播科学研究院 Smart television system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060230118A1 (en) * 2005-04-12 2006-10-12 Digi Chain Information Co., Ltd. Share memory service system and method of web service oriented applications
US10353718B2 (en) * 2012-07-23 2019-07-16 Vmware, Inc. Providing access to a remote application via a web client
US9292359B2 (en) * 2012-07-27 2016-03-22 Intel Corporation System and method for memory management
CN103067502A (en) * 2012-12-31 2013-04-24 博彦科技(上海)有限公司 Hardware system for cloud development and testing

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1740978A (en) * 2004-08-23 2006-03-01 华为技术有限公司 Method for realing sharing internal stored data base and internal stored data base system
CN102184226A (en) * 2011-05-09 2011-09-14 河海大学 Method for constructing real-time database and data searching method
CN102945169A (en) * 2012-12-05 2013-02-27 江苏鸿信系统集成有限公司 Native APP fused Web APP development system based on Android
CN105677491A (en) * 2015-12-31 2016-06-15 杭州华为数字技术有限公司 Method and device for transmitting data
CN106412466A (en) * 2016-07-18 2017-02-15 国家新闻出版广电总局广播科学研究院 Smart television system

Also Published As

Publication number Publication date
CN110022341A (en) 2019-07-16

Similar Documents

Publication Publication Date Title
CN108737325B (en) Multi-tenant data isolation method, device and system
US20220121495A1 (en) Memory reclamation method, electronic device and storage medium
CN105550345A (en) File operation method and apparatus
WO2020259289A1 (en) Resource allocation method and apparatus, electronic device and storage medium
CN110727607B (en) Memory recovery method and device and electronic equipment
CN112667405B (en) Information processing method, device, equipment and storage medium
CN110022341B (en) Data transmission method and related equipment
CN113032105A (en) Kubernetes cluster access control method, system and related equipment
CN116028455A (en) Data processing method and device, storage medium and electronic equipment
CN111803917A (en) Resource processing method and device
CN115470156A (en) RDMA-based memory use method, system, electronic device and storage medium
CN111694639A (en) Method and device for updating address of process container and electronic equipment
CN108228842B (en) Docker mirror image library file storage method, terminal, device and storage medium
CN112269665B (en) Memory processing method and device, electronic equipment and storage medium
CN110489356B (en) Information processing method, information processing device, electronic equipment and storage medium
CN116303126B (en) Caching method, data processing method and electronic equipment
CN111708715B (en) Memory allocation method, memory allocation device and terminal equipment
CN115562871A (en) Memory allocation management method and device
CN113849311B (en) Memory space management method, device, computer equipment and storage medium
CN113011607B (en) Resource recycling method, device, equipment and storage medium
CN112395245B (en) Access device and method of processor and computer equipment
CN109857719B (en) Distributed file processing method, device, computer equipment and storage medium
CN115934585A (en) Memory management method and device and computer equipment
CN112839071A (en) Training system, training data access method and device, electronic device and medium
CN113391882A (en) Virtual machine memory management method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant