CN114385146A - Simple object transmission serialization method and device - Google Patents

Simple object transmission serialization method and device Download PDF

Info

Publication number
CN114385146A
CN114385146A CN202210008892.4A CN202210008892A CN114385146A CN 114385146 A CN114385146 A CN 114385146A CN 202210008892 A CN202210008892 A CN 202210008892A CN 114385146 A CN114385146 A CN 114385146A
Authority
CN
China
Prior art keywords
class
serialization
byte sequence
memory
reduced
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.)
Pending
Application number
CN202210008892.4A
Other languages
Chinese (zh)
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.)
Wuhan Wuyi Yuntong Network Technology Co ltd
Original Assignee
Wuhan Wuyi Yuntong Network Technology 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 Wuhan Wuyi Yuntong Network Technology Co ltd filed Critical Wuhan Wuyi Yuntong Network Technology Co ltd
Priority to CN202210008892.4A priority Critical patent/CN114385146A/en
Publication of CN114385146A publication Critical patent/CN114385146A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]

Abstract

The invention discloses a simple object transmission serialization method and a device, wherein the method comprises the following steps: constructing a reduced object serialization format, wherein the reduced object serialization format comprises the following steps: serializing class numbers, variable length character lengths and class attributes; wherein the class attributes include a plurality of: extracting meta-information, namely extracting the meta-information of the serialized classes to a memory in advance according to the annotations of the serialized classes; a mapping table of a serialization class exists in the memory; generating an object byte sequence, and reflecting the information of the analysis class by a network sender according to a mapping table of the serialization class to generate the object byte sequence; and analyzing the object byte sequence, analyzing the received object byte sequence by the network receiver, and inversely encoding the object byte sequence into an object. The invention has the beneficial effects that: the transmission efficiency of the java object network is improved.

Description

Simple object transmission serialization method and device
Technical Field
The invention relates to the field of java object transmission, in particular to a simple object transmission serialization method and device.
Background
The existing high-efficiency serialization frameworks protobuf, thrift, fastjson and the like in the market comprise the Jdk self-contained serialization. The purpose of serialization is to solve the problem of object transmission on the network, wherein a sender converts an object into a byte sequence to send, and a receiver receives the byte sequence and then encodes the byte sequence into the object in an inverse mode, and the whole process is serialization and deserialization.
Because these frameworks need to consider the universality, various object descriptions, version descriptions and attribute descriptions can be added during object serialization, which has the advantages of more universality and cross-language, but has the disadvantages of larger byte space of the serialized objects, slower transmission efficiency, and no need of a very general protocol in a specific application scene.
Disclosure of Invention
In order to solve the problems that the byte space of an object coded by the existing framework is too large, excessive data bodies are arranged in the structure, inverse analysis is not crisp enough, and the transmission efficiency of the java object is too low, the invention aims to provide a simple object transmission serialization method and a device, which are used for simplifying the transmission process of the java object serialization.
The technical scheme of the invention provides a simple object transmission serialization method and a device, and the method comprises the following steps:
s1: constructing a reduced object serialization format, wherein the reduced object serialization format comprises the following steps: serializing class numbers, variable length character lengths and class attributes; wherein the class attribute comprises a plurality;
s2: extracting meta-information, namely extracting the meta-information of the serialized classes to a memory in advance according to the annotations of the serialized classes; a mapping table of a serialization class exists in the memory;
s3: generating an object byte sequence, and reflecting the information of the analysis class by a network sender according to a mapping table of the serialization class to generate the object byte sequence;
s4: and analyzing the object byte sequence, analyzing the received object byte sequence by the network receiver, and inversely encoding the object byte sequence into an object.
Further, in step S4, the specific process of inversely encoding the object byte sequence into the object is as follows: acquiring a serialized class number in a first byte in an object byte sequence, and acquiring metadata of a corresponding class through a memory according to the serialized intra-class number; and analyzing attribute data of the class in sequence according to the class attribute and the metadata, and inversely coding the object byte sequence into the object.
Further, when attribute data of a class is analyzed, if attribute variable-length data of a string class is encountered, the size of the attribute variable-length data and other basic types of attribute data are obtained through metadata and byte array header data. Reading is performed according to the basic type length specified by the java specification.
A reduced object transmission serialization apparatus, the apparatus comprising:
the simplified object serialization format construction module comprises: the reduced object serialization format includes: serializing class numbers, variable length character lengths and class attributes; wherein the class attribute comprises a plurality;
the meta-information extraction module: according to the annotation of the serialization class, extracting the meta information of the serialization class to a memory in advance; a mapping table of a serialization class exists in the memory;
an object byte sequence generation module: the network sender reflects the information of the analysis class according to the mapping table of the serialization class and generates an object byte sequence;
an object byte sequence analysis module: the network receiver analyzes the received object byte sequence and reversely encodes the object byte sequence into an object.
A computer device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, said processor implementing the steps of said reduced object transport serialization method when executing said computer program.
A computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of the reduced object delivery serialization method.
Compared with the prior art, the invention has the beneficial effects that: the transmission efficiency of the java object network is improved.
Drawings
Fig. 1 is a schematic flow chart of a simplified object transmission serialization method provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention provides a simple object transmission serialization method and device. Referring to FIG. 1, FIG. 1 is a flow chart of the method of the present invention; the method comprises the following steps:
s1: constructing a reduced object serialization format, wherein the reduced object serialization format comprises the following steps: serializing class numbers, variable length character lengths and class attributes; wherein the class attribute comprises a plurality;
as an example, please refer to table 1 below, where table 1 is a reduced object serialization format.
Table 1 reduced object serialization format
Figure BDA0003456591630000031
In the table, fields 1, 2, and 3 refer to different attributes representing classes;
in the embodiments of the present application, a description will be given by taking "person class" as an example.
The "person class" is defined in the reduced object serialization format. For purposes of illustration, this application provides partial code for illustration only.
“Person
@ SjbClassSerial (class No ═ 1)// identify class number
Class Person{
The execution character string of the 1 st part of the position in the @ SjbFieldSerial (fieldNo 1)// attribute serialization represents a character according to the provisional 3 bytes of utf coding, and the character string corresponds to the protocol variable length
String name;
@ sjbfeldserial (fieldNo ═ 2)// location block 24 byte in attribute serialization
Int age;
@ SjbFieldSeral (fieldNo ═ 3)// 3 rd block 8byte
Long birthday;
@SjbFieldSerial(fieldNo=4)
String address;
@SjbFieldSerial(fieldNo=5)
Long creatTime;
}
In the person class, the first part is the number of the class; the second part is the length of the variable-length character, in the embodiment, the execution character string represents a character by tentatively 3 bytes according to utf coding, and the corresponding protocol of the character string is variable in length;
the other parts correspond to the attribute values of the person class in turn, and as in the present embodiment, the person class includes the following attributes: name, birthday, address, creatTime.
S2: extracting meta-information, namely extracting the meta-information of the serialized classes to a memory in advance according to the annotations of the serialized classes; a mapping table of a serialization class exists in the memory;
as an example, the mapping table of the class is shown in table 2;
table 2 class mapping table
Numbering Class full path
1 Com.sjb.entiry.Person
2 Com.sjb.entiry.Car
In table 2, the class number is 1, which is the person class in this embodiment.
According to the class mapping table, a further class-corresponding attribute lookup table exists in the memory, as shown in table 3:
table 3 type correspondence attribute lookup table
Figure BDA0003456591630000041
In tables 2 and 3, metadata is stored.
S3: generating an object byte sequence, and reflecting the information of the analysis class by a network sender according to a mapping table of the serialization class to generate the object byte sequence;
as an example, the object byte sequence of the person class is as follows:
1|0 6|0 27|-27 -68 -96 -28 -72 -119|0 0 0 25|0 0 1 125 -118 -89 -124 -27|-26 -83 -90 -26 -79 -119 -27 -72 -126 -26 -76 -86 -27 -79 -79 -27 -116 -70 -23 -121 -111 -24 -98 -115 -26 -72 -81|0 0 0 4-99 127 27-124
the result is after extracting the metadata, the byte sequence of the object is regarded as a string of data, send to the network receiver;
s4: and analyzing the object byte sequence, analyzing the received object byte sequence by the network receiver, and inversely encoding the object byte sequence into an object.
In step S4, the specific process of inversely encoding the object byte sequence into the object is as follows: acquiring a serialized class number in a first byte in an object byte sequence, and acquiring metadata of a corresponding class through a memory according to the serialized intra-class number; and analyzing attribute data of the class in sequence according to the class attribute and the metadata, and inversely coding the object byte sequence into the object.
When attribute data of a string class is encountered during analysis, the size of the attribute data is obtained through metadata and byte array header data when the attribute data of the string class is encountered, and attribute data of other basic types are obtained. Reading is performed according to the basic type length specified by the java specification.
According to the above process, the analysis is:
1 denotes the number of classes
06 denotes the length name of the 1 st string attribute
027 denotes the length address of the 2 nd string attribute
-27-68-96-28-72-119 represents the name value
00025 shows age value
001125-118-89-124-27 represents the birthday value
The values of-26-83-90-26-79-119-27-72-126-26-76-86-27-79-27-116-70-23-121-111-24-98-115-26-72-81 represent the address values
0004-.
A reduced object transmission serialization apparatus, the apparatus comprising:
the simplified object serialization format construction module comprises: the reduced object serialization format includes: serializing class numbers, variable length character lengths and class attributes; wherein the class attribute comprises a plurality;
the meta-information extraction module: according to the annotation of the serialization class, extracting the meta information of the serialization class to a memory in advance; a mapping table of a serialization class exists in the memory;
an object byte sequence generation module: the network sender reflects the information of the analysis class according to the mapping table of the serialization class and generates an object byte sequence;
an object byte sequence analysis module: the network receiver analyzes the received object byte sequence and reversely encodes the object byte sequence into an object.
A computer device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, said processor implementing the steps of said reduced object transport serialization method when executing said computer program.
A computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of the reduced object delivery serialization method.
To better illustrate the beneficial effects of the present invention, the present invention compares the two serialization methods jdk and fastjson and tests them.
Comparison of test results with 5 attributes of the Persion object
TABLE 4 local serialization deserialization test results for Single object
Figure BDA0003456591630000061
Figure BDA0003456591630000071
TABLE 5100 local serialization deserialization test results for ten thousand objects
Figure BDA0003456591630000072
Local serialization deserialization test for table 61000 ten thousand objects
Figure BDA0003456591630000073
TABLE 7 network communication 1W test
Figure BDA0003456591630000081
Through the overall performance of the test, the simple object serialization protocol is transmitted in the single object to take absolute advantage.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
The invention has the beneficial effects that: the transmission efficiency of the java object network is improved.
The above-described embodiments of the present invention should not be construed as limiting the scope of the present invention. Any other corresponding changes and modifications made according to the technical idea of the present invention should be included in the protection scope of the claims of the present invention.

Claims (6)

1. A reduced object transmission serialization method, comprising: the method comprises the following steps:
s1: constructing a reduced object serialization format, wherein the reduced object serialization format comprises the following steps: serializing class numbers, variable length character lengths and class attributes; wherein the class attribute comprises a plurality;
s2: extracting meta-information, namely extracting the meta-information of the serialized classes to a memory in advance according to the annotations of the serialized classes; a mapping table of a serialization class exists in the memory;
s3: generating an object byte sequence, and reflecting the information of the analysis class by a network sender according to a mapping table of the serialization class to generate the object byte sequence;
s4: and analyzing the object byte sequence, analyzing the received object byte sequence by the network receiver, and inversely encoding the object byte sequence into an object.
2. A reduced object transmission serialization method as defined in claim 1, wherein: in step S4, the specific process of inversely encoding the object byte sequence into the object is as follows: acquiring a serialized class number in a first byte in an object byte sequence, and acquiring metadata of a corresponding class through a memory according to the serialized intra-class number; and analyzing attribute data of the class in sequence according to the class attribute and the metadata, and inversely coding the object byte sequence into the object.
3. A reduced object transmission serialization method as defined in claim 2, wherein: when attribute data of a string class is encountered during analysis, the size of the attribute data is obtained through metadata and byte array header data when the attribute data of the string class is encountered, and attribute data of other basic types are obtained. Reading is performed according to the basic type length specified by the java specification.
4. A reduced object transmission serialization apparatus, comprising: the device comprises:
the simplified object serialization format construction module comprises: the reduced object serialization format includes: serializing class numbers, variable length character lengths and class attributes; wherein the class attribute comprises a plurality;
the meta-information extraction module: according to the annotation of the serialization class, extracting the meta information of the serialization class to a memory in advance; a mapping table of a serialization class exists in the memory;
an object byte sequence generation module: the network sender reflects the information of the analysis class according to the mapping table of the serialization class and generates an object byte sequence;
an object byte sequence analysis module: the network receiver analyzes the received object byte sequence and reversely encodes the object byte sequence into an object.
5. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of a reduced object transfer serialization method as claimed in any one of claims 1 to 3 when executing the computer program.
6. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, implements the steps of a reduced object delivery serialization method as defined in any one of claims 1 to 3.
CN202210008892.4A 2022-01-05 2022-01-05 Simple object transmission serialization method and device Pending CN114385146A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210008892.4A CN114385146A (en) 2022-01-05 2022-01-05 Simple object transmission serialization method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210008892.4A CN114385146A (en) 2022-01-05 2022-01-05 Simple object transmission serialization method and device

Publications (1)

Publication Number Publication Date
CN114385146A true CN114385146A (en) 2022-04-22

Family

ID=81198943

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210008892.4A Pending CN114385146A (en) 2022-01-05 2022-01-05 Simple object transmission serialization method and device

Country Status (1)

Country Link
CN (1) CN114385146A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116126429A (en) * 2022-12-06 2023-05-16 谷斗科技(上海)有限公司 Method for persistence and recovery of reference of non-data type object
CN116301666A (en) * 2023-05-17 2023-06-23 杭州数云信息技术有限公司 Java object serialization method, java object deserialization device and terminal

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116126429A (en) * 2022-12-06 2023-05-16 谷斗科技(上海)有限公司 Method for persistence and recovery of reference of non-data type object
CN116126429B (en) * 2022-12-06 2023-11-17 谷斗科技(上海)有限公司 Method for persistence and recovery of reference of non-data type object
CN116301666A (en) * 2023-05-17 2023-06-23 杭州数云信息技术有限公司 Java object serialization method, java object deserialization device and terminal
CN116301666B (en) * 2023-05-17 2023-10-10 杭州数云信息技术有限公司 Java object serialization method, java object deserialization device and terminal

Similar Documents

Publication Publication Date Title
CN114385146A (en) Simple object transmission serialization method and device
US9300764B2 (en) High efficiency binary encoding
CN106570018B (en) Serialization and deserialization method, device and system and electronic equipment
US7263654B2 (en) System and method for generating optimized binary representation of an object tree
KR20040007442A (en) Method for compressing/decompressing a structured document
US7924183B2 (en) Method and system for reducing required storage during decompression of a compressed file
CN105450232A (en) Encoding method, decoding method, encoding device and decoding device
Breje et al. Comparative study of data sending methods for XML and JSON models
WO2022148304A1 (en) Sorting network-based dynamic huffman coding method, apparatus and device
CN112650529B (en) System and method for configurable generation of mobile terminal APP codes
US10515092B2 (en) Structured record compression and retrieval
CN116701325B (en) Binary file cache-based XBRL classification standard loading method
Mantoro et al. The performance of text file compression using Shannon-Fano and Huffman on small mobile devices
CN115167869A (en) Method, electronic device and medium for serialization and deserialization of Java object
CN114385139B (en) Message serialization and comparison method and device for flight framework to run ETL (extract transform load) process
CN116089663A (en) Rule expression matching method and device and computer readable storage medium
US7657559B2 (en) Method to exchange objects between object-oriented and non-object-oriented environments
KR20190088112A (en) Method for transforming data for low volume transmission of meta model base protocol which monitors power amount data of new recycle energy, and data transmitting system for low volume transmission of meta model base protocol which monitors power amount data of new recycle energy
CN116126429B (en) Method for persistence and recovery of reference of non-data type object
CN116095184B (en) Structured network data transmission coding method, device and medium
CN105608122A (en) Method and apparatus for storing electronic form data
CN107967368B (en) Cache method containing array structure
CN111506781A (en) Method, system, terminal device and readable storage medium for greatly compressing volume of database
CN114490809A (en) Data mining method and device based on feature transformation function and readable medium
CN117453276A (en) JSON data processing method, JSON data restoring device, JSON data processing equipment and storage medium

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