WO2017059798A1 - Methods, apparatus, and system for serialization and deserialization, and electronic devices - Google Patents

Methods, apparatus, and system for serialization and deserialization, and electronic devices Download PDF

Info

Publication number
WO2017059798A1
WO2017059798A1 PCT/CN2016/101448 CN2016101448W WO2017059798A1 WO 2017059798 A1 WO2017059798 A1 WO 2017059798A1 CN 2016101448 W CN2016101448 W CN 2016101448W WO 2017059798 A1 WO2017059798 A1 WO 2017059798A1
Authority
WO
WIPO (PCT)
Prior art keywords
attribute
data object
description file
metadata
description
Prior art date
Application number
PCT/CN2016/101448
Other languages
French (fr)
Chinese (zh)
Inventor
董石鸣
Original Assignee
阿里巴巴集团控股有限公司
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 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2017059798A1 publication Critical patent/WO2017059798A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

A method and apparatus, and electronic device for data object serialization; a method, apparatus, and electronic device for data stream deserialization; and a system for serialization and deserialization. The method for data object serialization comprises: obtaining a metadata description file for a data object to be serialized (S101); on the basis of an attribute operating class name provided by each attribute description in the metadata description file, obtaining a corresponding attribute operating class (S103); on the basis of a reading method provided by each attribute operating class, reading each attribute value in the data object to be serialized (S105); according to the order of the sequence numbers of the attribute descriptions, writing each read attribute value into a resulting data stream for the data object (S107). The described method solves compatibility problems arising between systems upon changes to object attributes. In the method, object metadata and object values are separated, thereby economizing on storage space and transmission traffic during storage and transmission operations. The method also allows for a reduction in system processing overhead during deserialization.

Description

序列化与反序列化的方法、装置、系统以及电子设备Method, device, system and electronic device for serialization and deserialization
本申请要求2015年10月10日递交的申请号为201510650688.2发明名称为“序列化与反序列化的方法、装置、系统以及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 201510650, 688, filed on Jan. 10, 2015, entitled Serialization and De-Sequencing, Method, Apparatus, and Electronic Apparatus, the entire contents of In this application.
技术领域Technical field
本申请涉及计算机通信技术领域,具体涉及一种对数据对象序列化的方法、一种对数据对象序列化的装置以及一种电子设备;一种对数据流反序列化的方法、一种对数据流反序列化的装置以及一种电子设备;一种序列化与反序列化系统。The present invention relates to the field of computer communication technologies, and in particular, to a method for serializing data objects, a device for serializing data objects, and an electronic device; a method for deserializing a data stream, and a pair of data A device for stream deserialization and an electronic device; a serialization and deserialization system.
背景技术Background technique
对象序列化(Serialization)技术,是将对象数据转换成另一种持久化数据形式的技术,即将对象的状态信息转换为可以存储或传输的形式的过程。在序列化期间,对象将其当前状态写入到临时或持久性存储区。为了使得存储和传输后的数据能够再次变回内存中的对象,这样的转换必须是可逆的。可以通过从存储区中读取或反序列化对象的状态,重新创建该对象。The object serialization technique is a technique for converting object data into another form of persistent data, that is, a process of converting state information of an object into a form that can be stored or transmitted. During serialization, an object writes its current state to a temporary or persistent store. In order for the stored and transmitted data to be able to change back to objects in memory, such conversions must be reversible. The object can be recreated by reading or deserializing the state of the object from the store.
在网络间数据传输和应用中,通常需要将信息转换成数据流,实现数据传输和应用。但是,在现有的序列化与反序列化方案下,如果对对象中的属性进行增减,执行反序列化的一侧若没有将对象中的属性进行同步,就会引起反序列化失败的问题。增加、减少或修改了对象中的属性,将原来序列化后的文件或数据进行反序列化时,会产生错误或序列化失败。这就是对象序列化的兼容问题。In data transmission and application between networks, it is usually necessary to convert information into data streams for data transmission and application. However, under the existing serialization and deserialization scheme, if the attributes in the object are increased or decreased, the side that performs the deserialization will cause the deserialization to fail if the attributes in the object are not synchronized. problem. When an attribute in an object is added, reduced, or modified, and the original serialized file or data is deserialized, an error or serialization failure occurs. This is the compatibility issue of object serialization.
目前,在现有技术下通常采用google的Protobuf(Protocol Buffers)数据交换格式实现序列化和反序列化。Protobuf是一种数据交换格式,将现有的信息根据不同的类型,按照相应的编码方式序列化为二进制流,用于保存信息或者数据传输。在读取该二进制信息或者接收该二进制信息时,对经序列化的二进制流进行反序列化,获取原始信息或数据。Protobuf在序列化时虽然能减少序列化结果中的元数据内容,但是为了兼容性,还是保留了少量的元数据(属性类型,属性序号),并且在反序列化时,除了获取二进制流外,还需要获知序列化时采用的类型,进而根据类型进行相应的反序列化。At present, serialization and deserialization are usually implemented in the prior art using Google's Protobuf (Protocol Buffers) data exchange format. Protobuf is a data exchange format that serializes existing information into binary streams according to different types according to different types, for saving information or data transmission. Upon reading the binary information or receiving the binary information, the serialized binary stream is deserialized to obtain the original information or data. Although Protobuf can reduce the metadata content in the serialization result during serialization, for compatibility, a small amount of metadata (attribute type, attribute number) is retained, and in the case of deserialization, in addition to obtaining a binary stream, It is also necessary to know the type used in serialization and to perform corresponding deserialization according to the type.
由此可见,在现有技术下,由于序列化时还保留了元数据,使序列化的压缩率低,造 成在保存信息或者数据传输时浪费空间和流量;并且在反序列化时,获取对象序列化时采用的序列化类型的过程复杂,增加处理开销。It can be seen that in the prior art, since the metadata is retained during serialization, the compression ratio of the serialization is low, and It wastes space and traffic when saving information or data transmission; and when deserializing, the process of obtaining the serialization type used when serializing objects is complicated, increasing processing overhead.
发明内容Summary of the invention
本申请提供一种对数据对象序列化的方法、一种对数据对象序列化的装置、一种电子设备、一种对数据流反序列化的方法、一种对数据流反序列化的装置、一种电子设备以及一种序列化与反序列化系统,以解决现有技术中序列化压缩率低的问题。The present application provides a method for serializing a data object, a device for serializing a data object, an electronic device, a method for deserializing a data stream, and a device for deserializing a data stream, An electronic device and a serialization and deserialization system to solve the problem of low serialization compression rate in the prior art.
本申请提供了一种对数据对象序列化的方法,所述对数据对象序列化的方法包括:The application provides a method for serializing data objects, and the method for serializing data objects includes:
获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;Obtaining a metadata description file of the data object to be serialized, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to the attribute in the data object;
根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;Obtaining, according to the attribute operation class name provided by each attribute description in the metadata description file, an attribute operation class corresponding to each attribute;
根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值;Reading the attribute values corresponding to the respective attribute descriptions in the data objects to be serialized according to the reading methods provided by the attribute operation classes corresponding to the respective attributes;
将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。The read attribute values are written to the result data stream of the data object in the order of the attribute description sequence number, and the result data stream is used as a serialization result of the data object.
可选的,所述属性描述,还包括:属性类型。Optionally, the attribute description further includes: an attribute type.
可选的,在所述读取待序列化的数据对象中分别与各个属性描述对应的属性值的步骤之后,包括:Optionally, after the step of reading the attribute value corresponding to each attribute description in the data object to be serialized, the method includes:
获取由于无法获取对应属性的属性操作类而无法读取的属性描述的属性类型;Gets the attribute type of the attribute description that cannot be read because the attribute operation class of the corresponding attribute cannot be obtained;
根据所述属性类型,检索获得对应所述属性类型的缺省属性操作类;Determining, according to the attribute type, a default attribute operation class corresponding to the attribute type;
根据所述缺省属性操作类,为该属性描述对应的属性赋予预先确定的缺省值。According to the default attribute operation class, the corresponding attribute is given a predetermined default value for the attribute description.
可选的,所述获取待序列化的数据对象的元数据描述文件是:Optionally, the metadata description file of the data object to be serialized is:
根据所述待序列化的数据对象的名称,从元数据仓库中查找对应所述待序列化的数据对象且版本号数值最大的所述待序列化的数据对象的元数据描述文件。And searching, according to the name of the data object to be serialized, a metadata description file of the data object to be serialized corresponding to the data object to be serialized and having the largest version number value from the metadata repository.
可选的,在所述将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流的步骤之前,包括:Optionally, before the step of writing the read attribute value into the result data stream of the data object in the order of the attribute description sequence number, the method includes:
读取所述待序列化的数据对象的元数据描述文件的版本号,并将其写入到所述待序列化的数据对象的结果数据流的头部。Reading a version number of the metadata description file of the data object to be serialized and writing it to the head of the result data stream of the data object to be serialized.
可选的,在所述获取待序列化的数据对象的元数据描述文件的步骤之前,还包括: Optionally, before the step of acquiring the metadata description file of the data object to be serialized, the method further includes:
接收对所述待序列化的数据对象的属性的修改操作;所述修改操作包括:对所述待序列化的数据对象的属性进行增加、删除或者变更;Receiving a modification operation on an attribute of the data object to be serialized; the modifying operation includes: adding, deleting, or changing an attribute of the data object to be serialized;
基于对所述待序列化的数据对象的修改操作为所述待序列化的数据对象的新增属性创建属性操作类;Creating an attribute operation class for the newly added attribute of the data object to be serialized based on the modification operation of the data object to be serialized;
根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更。A new version of the metadata description file is created according to the modification operation, and the attribute description in the metadata description file is changed according to the modification operation based on the attribute description in the original version metadata description file.
可选的,在所述根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更的步骤之后,包括:Optionally, the metadata description file is created according to the modifying operation, and the attribute description in the metadata description file is performed according to the attribute description in the original version metadata description file according to the modification operation. After the steps to change, include:
根据所述待序列化的数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述待序列化的数据对象设置的元数据描述文件;And traversing a metadata description file set for the data object to be serialized in a metadata repository storing the metadata description file according to the name of the data object to be serialized;
在遍历过程中,获取在所述元数据仓库中的所述待序列化的数据对象的元数据描述文件的版本号最大的数值;Obtaining, in the traversing process, a value having a maximum version number of the metadata description file of the data object to be serialized in the metadata repository;
将所述数值加一,并将加一后的所述数值作为新版本的元数据描述文件的版本号;Adding the value to one, and adding the added value as the version number of the new version of the metadata description file;
将所述记录有版本号的所述元数据描述文件保存在所述元数据仓库中。The metadata description file in which the version number is recorded is saved in the metadata repository.
可选的,在所述根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值的步骤之后,包括:Optionally, after the step of reading the attribute value corresponding to each attribute description in the data object to be serialized according to the reading method provided by the attribute operation class corresponding to each attribute, the method includes:
将读取到的属性值进行压缩。The read attribute values are compressed.
相应的,本申请还提供了一种对数据对象序列化的装置,所述对数据对象序列化的装置包括:描述文件获取单元、属性操作类获取单元、属性读取单元以及序列化写入单元;Correspondingly, the present application further provides an apparatus for serializing data objects, where the apparatus for serializing data objects includes: a description file acquisition unit, an attribute operation class acquisition unit, an attribute reading unit, and a serialization write unit. ;
所述描述文件获取单元,用于获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;The description file obtaining unit is configured to acquire a metadata description file of the data object to be serialized, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object;
所述属性操作类获取单元,用于根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;The attribute operation class obtaining unit is configured to obtain an attribute operation class name corresponding to each attribute according to the attribute operation class name provided by each attribute description in the metadata description file;
所述属性读取单元,用于根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值;The attribute reading unit is configured to read, according to a reading method provided by the attribute operation class corresponding to each attribute, an attribute value corresponding to each attribute description in the data object to be serialized;
所述序列化写入单元,用于将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。 The serialization writing unit is configured to write the read attribute values into the result data stream of the data object in the order of the attribute description sequence number, and the result data stream is used as a serialization result of the data object.
可选的,所述描述文件获取单元获取的所述待序列化的数据对象的元数据描述文件还包括属性类型。Optionally, the metadata description file of the data object to be serialized acquired by the description file acquiring unit further includes an attribute type.
可选的,所述属性读取单元,还包括:属性类型读取子单元、缺省属性操作类获取子单元以及缺省值读取子单元;Optionally, the attribute reading unit further includes: an attribute type reading subunit, a default attribute operation class obtaining subunit, and a default value reading subunit;
所述属性类型读取子单元,用于读取待序列化的数据对象中分别与各个属性描述对应的属性值之后,获取由于无法获取对应属性的属性操作类而无法读取的属性描述的属性类型;The attribute type reading subunit is configured to read an attribute value corresponding to each attribute description in the data object to be serialized, and obtain an attribute description attribute that cannot be read because the attribute operation class of the corresponding attribute cannot be obtained. Types of;
所述缺省属性操作类获取子单元,用于根据所述属性类型,检索获得对应所述属性类型的缺省属性操作类;The default attribute operation class acquisition sub-unit is configured to retrieve, according to the attribute type, a default attribute operation class corresponding to the attribute type;
所述缺省值读取子单元,用于根据所述缺省属性操作类,为该属性描述对应的属性赋予预先确定的缺省值。The default value reading subunit is configured to assign a predetermined default value to the corresponding attribute of the attribute description according to the default attribute operation class.
可选的,所述描述文件获取单元具体用于根据所述待序列化的数据对象的名称,从元数据仓库中查找对应所述待序列化的数据对象且版本号数值最大的所述待序列化的数据对象的元数据描述文件。Optionally, the description file acquiring unit is configured to: search, according to the name of the data object to be serialized, the to-be-sequence corresponding to the data object to be serialized and having the largest version number value from the metadata repository. Metadata description file for the data object.
可选的,所述序列化写入单元,还包括:版本号写入子单元;Optionally, the serialized writing unit further includes: a version number writing subunit;
所述版本号写入子单元,用于在所述将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流之前,读取所述待序列化的数据对象的元数据描述文件的版本号,并将其写入到所述待序列化的数据对象的结果数据流的头部。The version number is written into the subunit, and is configured to read the data object to be serialized before the attribute value to be read is written into the result data stream of the data object in the order of the attribute description sequence number. The metadata describes the version number of the file and writes it to the head of the resulting data stream of the data object to be serialized.
可选的,所述对数据对象序列化的装置,还包括:修改操作接收单元、操作类创建单元以及描述文件创建单元;Optionally, the device for serializing the data object further includes: a modification operation receiving unit, an operation class creation unit, and a description file creation unit;
所述修改操作接收单元,用于在所述获取待序列化的数据对象的元数据描述文件之前,接收对所述待序列化的数据对象的属性的修改操作;所述修改操作包括:对所述待序列化的数据对象的属性进行增加、删除或者变更;The modifying operation receiving unit is configured to receive, before the acquiring the metadata description file of the data object to be serialized, a modification operation on the attribute of the data object to be serialized; the modifying operation includes: Adding, deleting, or changing the attributes of the serialized data object;
所述操作类创建单元,用于基于对所述待序列化的数据对象的修改操作为所述待序列化的数据对象的新增属性创建属性操作类;The operation class creation unit is configured to create an attribute operation class for the newly added attribute of the data object to be serialized based on the modification operation of the data object to be serialized;
所述描述文件创建单元,用于根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更。a description file creation unit, configured to create a new version of the metadata description file according to the modification operation, where the attribute description in the metadata description file is based on the attribute description in the original version metadata description file, according to the modification operation The change was made.
可选的,所述对数据对象序列化的装置,还包括:遍历单元、数值获取单元、版本号生成单元以及保存单元; Optionally, the device for serializing the data object further includes: a traversal unit, a value obtaining unit, a version number generating unit, and a saving unit;
所述遍历单元,用于在所述根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更之后,根据所述待序列化的数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述待序列化的数据对象设置的元数据描述文件;The traversing unit is configured to create a new version of the metadata description file according to the modification operation, where the attribute description in the metadata description file is based on the attribute description in the original version metadata description file, according to the modification After the operation is changed, the metadata description file set for the data object to be serialized is traversed in the metadata repository storing the metadata description file according to the name of the data object to be serialized;
所述数值获取单元,用于在遍历过程中,获取在所述元数据仓库中的所述待序列化的数据对象的元数据描述文件的版本号最大的数值;The value obtaining unit is configured to acquire, during the traversal process, a maximum value of a version number of the metadata description file of the data object to be serialized in the metadata repository;
所述版本号生成单元,用于将所述数值加一,并将加一后的所述数值作为新版本的元数据描述文件的版本号;The version number generating unit is configured to add the value by one, and use the added value as the version number of the metadata version file of the new version;
所述保存单元,用于将所述记录有版本号的所述元数据描述文件保存在所述元数据仓库中。The saving unit is configured to save the metadata description file with the version number recorded in the metadata repository.
可选的,所述对数据对象序列化的装置,还包括:属性值压缩单元;Optionally, the device for serializing the data object further includes: an attribute value compression unit;
所述属性值压缩单元,用于根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值之后,将读取到的属性值进行压缩。The attribute value compression unit is configured to read the attribute value after the attribute value corresponding to each attribute description in the data object to be serialized according to the reading method provided by the attribute operation class corresponding to each attribute Compress.
此外,本申请实施例还提供了一种电子设备,所述电子设备包括:In addition, an embodiment of the present application further provides an electronic device, where the electronic device includes:
显示器;monitor;
处理器;processor;
存储器,用于存储序列化程序,所述程序在被所述处理器读取执行时,执行如下操作:获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值;将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。a memory for storing a serialization program, the program, when being read and executed by the processor, performing an operation of: acquiring a metadata description file of a data object to be serialized, where the metadata description file includes a serial number identifier The attribute description and the attribute operation class name corresponding to the attribute in the data object; the attribute operation class name provided according to each attribute description in the metadata description file, and the attribute operation class corresponding to each attribute are obtained; according to the corresponding attribute The reading method provided by the attribute operation class reads the attribute value corresponding to each attribute description in the data object to be serialized; and writes the read attribute value into the result data of the data object in the order of the attribute description serial number. Flow, the resulting data stream as a serialization result of the data object.
此外,本申请还提供了一种对数据流反序列化的方法,所述对数据流反序列化的方法包括:In addition, the present application also provides a method for deserializing a data stream, and the method for deserializing the data stream includes:
获取结果数据流;Obtaining a result data stream;
获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;Obtaining a metadata description file of the local data object, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object;
根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个 属性的属性操作类;According to the attribute operation class name provided by each attribute description in the metadata description file, obtain corresponding to each The attribute action class of the attribute;
根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取;According to the reading method provided by the attribute operation class corresponding to each attribute, the attribute values in the result data stream are sequentially read in the order of the attribute description sequence number;
根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。The read attribute values are written into the attributes of the local data object corresponding to the respective attribute descriptions according to the write method provided by the attribute operation class described by each attribute.
可选的,所述属性描述,还包括:属性类型。Optionally, the attribute description further includes: an attribute type.
可选的,在所述根据各个属性描述的所述属性操作类提供的写入方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取的步骤之中,还包括:Optionally, in the step of reading the attribute value in the result data stream in the order of the attribute description sequence number, the method further includes:
对于无法获得属性操作类的属性描述,根据该属性描述的属性类型,获取对应所述属性类型的缺省属性操作类;For the attribute description of the attribute operation class, the default attribute operation class corresponding to the attribute type is obtained according to the attribute type described by the attribute;
获取所述缺省属性操作类提供的读取方法,按照属性描述序号的顺序读取所述结果数据流中的数据;Obtaining the reading method provided by the default attribute operation class, and reading the data in the result data stream according to the sequence of the attribute description sequence number;
将读取的所述结果数据流中的数据丢弃。The data in the result data stream read is discarded.
可选的,所述获取所述本地数据对象的元数据描述文件包括:Optionally, the obtaining the metadata description file of the local data object includes:
获取所述本地数据对象的名称;Obtaining the name of the local data object;
解析所述结果数据流,获取所述结果数据流中的第一个值;Parsing the result data stream to obtain a first value in the result data stream;
根据所述本地数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述本地数据对象设置的元数据描述文件;And traversing a metadata description file set for the local data object in a metadata repository storing the metadata description file according to the name of the local data object;
在遍历过程中,获取与所述本地数据对象的名称相同且版本号与所述结果数据流中的第一个值相同的所述本地数据对象的元数据描述文件。In the traversal process, a metadata description file of the local data object having the same name as the local data object and having the same version number as the first value in the result data stream is obtained.
可选的,在所述根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取的步骤之后,包括:Optionally, after the step of sequentially reading the attribute values in the result data stream according to the sequence of the attribute description sequence according to the reading method provided by the attribute operation class corresponding to each attribute, the method includes:
将从所述结果数据流中读取出的属性值进行解压缩。The attribute values read from the resulting data stream are decompressed.
相应的,本申请还提供了一种对数据流反序列化的装置,所述对数据流反序列化的装置包括:数据流获取单元、描述文件获取单元、属性操作类获取单元、属性值读取单元以及属性值写入单元;Correspondingly, the present application further provides an apparatus for deserializing a data stream, where the apparatus for deserializing the data stream includes: a data stream obtaining unit, a description file acquiring unit, an attribute operation class acquiring unit, and an attribute value reading. The unit and the attribute value are written into the unit;
所述数据流获取单元,用于获取结果数据流;The data stream obtaining unit is configured to obtain a result data stream;
所述描述文件获取单元,用于获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称; The description file obtaining unit is configured to acquire a metadata description file of the local data object, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object;
所述属性操作类获取单元,用于根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;The attribute operation class obtaining unit is configured to obtain an attribute operation class name corresponding to each attribute according to the attribute operation class name provided by each attribute description in the metadata description file;
所述属性值读取单元,用于根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取;The attribute value reading unit is configured to sequentially read the attribute values in the result data stream according to the sequence of the attribute description sequence according to the reading method provided by the attribute operation class corresponding to each attribute;
所述属性值写入单元,用于根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。The attribute value writing unit is configured to write the read attribute value into the attribute of the local data object corresponding to each attribute description according to the writing method provided by the attribute operation class described by each attribute .
可选的,所述描述文件获取单元,获取的所述本地数据对象的元数据描述文件还包括属性类型。Optionally, the description file obtaining unit, the obtained metadata description file of the local data object further includes an attribute type.
可选的,所述属性值读取单元包括:属性类型获取子单元、数据读取子单元以及丢弃子单元;Optionally, the attribute value reading unit includes: an attribute type obtaining subunit, a data reading subunit, and a discarding subunit;
所述属性类型获取子单元,用于在所述根据各个属性描述的所述属性操作类提供的写入方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取之中,对于无法获得属性操作类的属性描述,根据该属性描述的属性类型,获取对应所述属性类型的缺省属性操作类;The attribute type obtaining subunit is configured to sequentially read the attribute values in the result data stream according to the sequence of the attribute description serial number in the writing method provided by the attribute operation class according to each attribute description. For the attribute description of the attribute operation class, the default attribute operation class corresponding to the attribute type is obtained according to the attribute type described by the attribute;
所述数据读取子单元,用于获取所述缺省属性操作类提供的读取方法,按照属性描述序号的顺序读取所述结果数据流中的数据;The data reading subunit is configured to acquire a reading method provided by the default attribute operation class, and read data in the result data stream according to an order of the attribute description sequence number;
所述丢弃单子元,用于将读取的所述结果数据流中的数据丢弃。The discarding a single sub-unit is configured to discard the data in the read result data stream.
可选的,所述描述文件获取单元,包括:本地数据对象名称获取子单元、结果数据流解析子单元、描述文件遍历子单元以及描述文件获取子单元;Optionally, the description file obtaining unit includes: a local data object name obtaining subunit, a result data stream parsing subunit, a description file traversing subunit, and a description file acquiring subunit;
所述本地数据对象名称获取子单元,用于获取所述本地数据对象的名称;The local data object name obtaining subunit is configured to acquire a name of the local data object;
所述结果数据流解析子单元,用于解析所述结果数据流,获取所述结果数据流中的第一个值;The result data stream parsing subunit is configured to parse the result data stream to obtain a first value in the result data stream;
所述描述文件遍历子单元,用于根据所述本地数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述本地数据对象设置的元数据描述文件;The description file traversing subunits for traversing a metadata description file set for the local data object in a metadata repository in which the metadata description file is stored according to the name of the local data object;
所述描述文件获取子单元,用于在遍历过程中,获取与所述本地数据对象的名称相同且版本号与所述结果数据流中的第一个值相同的所述本地数据对象的元数据描述文件。The description file obtaining subunit, configured to acquire metadata of the local data object having the same name as the local data object and having the same version number as the first value in the result data stream during the traversal process Description file.
可选的,所述对数据流反序列化的装置,还包括:属性值解压缩单元;Optionally, the device for deserializing the data stream further includes: an attribute value decompression unit;
所述属性值解压缩单元,用于在所述根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取的之后,将从所述 结果数据流中读取出的属性值进行解压缩。The attribute value decompressing unit is configured to sequentially read the attribute values in the result data stream according to the order of the attribute description sequence in the reading method provided by the attribute operation class corresponding to each attribute, and then From the stated As a result, the attribute values read out in the data stream are decompressed.
此外,本申请实施例还提供了一种电子设备,所述电子设备包括:In addition, an embodiment of the present application further provides an electronic device, where the electronic device includes:
显示器;monitor;
处理器;processor;
存储器,用于存储反序列化程序,所述程序在被所述处理器读取执行时,执行如下操作:获取结果数据流,获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称,根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类,根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取,根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。a memory for storing a deserialization program, the program, when being read and executed by the processor, performing an operation of: acquiring a result data stream, acquiring a metadata description file of the local data object, the metadata description The file includes an attribute description identified by a sequence number and an attribute operation class name corresponding to the attribute in the data object, and an attribute operation class name corresponding to each attribute description in the metadata description file is obtained, and an attribute operation class corresponding to each attribute is obtained, According to the reading method provided by the attribute operation class corresponding to each attribute, the attribute values in the result data stream are sequentially read in the order of the attribute description sequence number, and the writing method provided by the attribute operation class according to each attribute description is The read attribute values are written into the attributes of the local data object corresponding to the respective attribute descriptions.
此外,本申请还提供了一种序列化与反序列化系统,所述序列化与反序列化系统包括:In addition, the present application also provides a serialization and deserialization system, the serialization and deserialization system comprising:
根据上述任一项所述的对数据对象序列化的装置;以及任一项所述的对数据流反序列化的装置。A device for serializing a data object according to any of the preceding claims; and the device for deserializing the data stream according to any of the preceding claims.
与现有技术相比,本申请提供的对数据对象序列化的方法以及装置,通过获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述,各个属性描述中包括所对应的所述数据对象属性的属性操作类名称;根据所述属性操作类名称,能够获取对应属性的属性操作类,根据对应各个属性的属性操作类提供的读取方法,可以读取待序列化的数据对象中分别与各个属性描述对应的属性值,将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。Compared with the prior art, the method and apparatus for serializing a data object provided by the present application obtains a metadata description file of a data object to be serialized, and the metadata description file includes an attribute description identified by a serial number, and each The attribute description includes the attribute operation class name of the corresponding data object attribute; according to the attribute operation class name, the attribute operation class of the corresponding attribute can be obtained, and the reading method provided by the attribute operation class corresponding to each attribute may be Reading the attribute values corresponding to the respective attribute descriptions in the data objects to be serialized, and writing the read attribute values into the result data stream of the data object in the order of the attribute description sequence numbers, where the result data stream is used as the The serialization result of the data object.
本申请提供的对数据流反序列化的方法以及装置,通过获取结果数据流,获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称,根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类,根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取,根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。The method and apparatus for deserializing a data stream provided by the present application obtains a metadata description file of the local data object by acquiring a result data stream, where the metadata description file includes an attribute description identified by a serial number and corresponding to the description The attribute operation class name of the attribute in the data object, according to the attribute operation class name provided by each attribute description in the metadata description file, obtaining the attribute operation class corresponding to each attribute, and reading according to the attribute operation class corresponding to each attribute The method sequentially reads the attribute values in the result data stream according to the sequence of the attribute description sequence numbers, and writes the read attribute values into each attribute according to the writing method provided by the attribute operation class described by each attribute. Describe the properties of the corresponding local data object.
上述技术方案解决了改变对象的属性后系统之间序列化和反序列化的兼容性问题, 还通过将对象的元数据和对象的值进行彻底的拆分,在保存信息和数据传输时节约了存储空间和传输流量,并且在反序列化时降低系统的处理开销。The above technical solution solves the compatibility problem of serialization and deserialization between systems after changing the attributes of the object, It also saves storage space and transmission traffic when saving information and data transmission by completely splitting the metadata of the object and the value of the object, and reduces the processing overhead of the system when deserializing.
附图说明DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings to be used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description are only These are some of the embodiments described in this application, and other figures can be obtained from those of ordinary skill in the art in view of these drawings.
图1示出了根据本申请的实施例提供的对数据对象序列化的方法的流程图;1 shows a flow chart of a method of serializing data objects provided in accordance with an embodiment of the present application;
图2示出了根据本申请的实施例提供的创建元数据描述文件的流程图;2 shows a flowchart of creating a metadata description file provided in accordance with an embodiment of the present application;
图3示出了根据本申请的实施例提供的保存元数据描述文件的流程图;FIG. 3 illustrates a flow chart of saving a metadata description file provided in accordance with an embodiment of the present application; FIG.
图4示出了根据本申请的实施例提供的序列化时缺省值的读取方法的流程图。4 shows a flow chart of a method of reading default values at serialization provided in accordance with an embodiment of the present application.
图5示出了根据本申请的实施例提供的对数据对象序列化的装置的示意图;FIG. 5 shows a schematic diagram of an apparatus for serializing data objects provided in accordance with an embodiment of the present application; FIG.
图6示出了根据本申请的实施例提供的电子设备的示意图;FIG. 6 shows a schematic diagram of an electronic device provided in accordance with an embodiment of the present application; FIG.
图7示出了根据本申请的实施例提供的对数据流反序列化的方法的流程图;7 shows a flow diagram of a method of deserializing a data stream, provided in accordance with an embodiment of the present application;
图8示出了根据本申请的实施例提供的获取所述本地数据对象的元数据描述文件的流程图;FIG. 8 is a flowchart showing a metadata description file for acquiring the local data object according to an embodiment of the present application;
图9示出了根据本申请的实施例提供的反序列化时缺省值的丢弃方法的流程图;FIG. 9 is a flowchart of a method for discarding a default value at the time of deserialization according to an embodiment of the present application; FIG.
图10示出了根据本申请的实施例提供的对数据流反序列化的装置的示意图;10 shows a schematic diagram of an apparatus for deserializing a data stream, provided in accordance with an embodiment of the present application;
图11示出了根据本申请的实施例提供的电子设备的示意图;FIG. 11 shows a schematic diagram of an electronic device provided in accordance with an embodiment of the present application; FIG.
图12示出了根据本申请的实施例提供的序列化与反序列化系统的示意图。FIG. 12 shows a schematic diagram of a serialization and deserialization system provided in accordance with an embodiment of the present application.
具体实施方式detailed description
为了能够更清楚地理解本申请的上述目的、特征和优点,下面结合附图和具体实施方式对本申请进行进一步的详细描述。需要说明的是,在不冲突的情况下,本申请的实施例及实施例中的特征可以相互组合。The above objects, features and advantages of the present application will be more clearly understood from the following description of the appended claims. It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict.
在下面的描述中阐述了很多具体细节以便于充分理解本申请。但是,本申请能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本申请内涵的情况下做类似推广,因此,本申请不受下面公开的具体实施的限制。 Numerous specific details are set forth in the description below in order to provide a thorough understanding of the application. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art can make similar promotion without departing from the scope of the present application. Therefore, the present application is not limited by the specific embodiments disclosed below.
本申请的实施例提供了一种对数据对象序列化的方法、一种对数据对象序列化的装置、一种对数据流反序列化的方法、一种对数据流反序列化的装置以及一种序列化与反序列化系统,本申请的实施例同时提供了一种电子设备。在下面的实施例中逐一进行详细说明。Embodiments of the present application provide a method for serializing a data object, a device for serializing a data object, a method for deserializing a data stream, a device for deserializing a data stream, and a device A serialization and deserialization system, the embodiment of the present application simultaneously provides an electronic device. Detailed description will be made one by one in the following embodiments.
本申请的技术方案是针对分布式系统环境下,系统之间进行数据传递或存储而提出的,但是,其应用领域并不局限于分布式系统中,在现有的系统或应用程序中,只要是可以执行序列化与反序列化方法,都可以采用本申请提供的方法,并获得相应的有益效果。The technical solution of the present application is directed to data transmission or storage between systems in a distributed system environment, but the application field thereof is not limited to a distributed system, and in an existing system or application, It is possible to perform serialization and deserialization methods, and the methods provided by the present application can be used, and corresponding beneficial effects can be obtained.
在详细描述本实施例的具体步骤之前,先对本技术方案涉及的序列化方法和反序列化方法作简要说明。Before describing the specific steps of the embodiment in detail, the serialization method and the deserialization method involved in the technical solution are briefly described.
对象序列化(Serialization)技术,是将对象数据转换成另一种持久化数据形式的技术,即将对象的状态信息转换为可以存储或传输的形式的过程。在序列化期间,对象将其当前状态写入到临时或持久性存储区,可以通过从存储区中读取或反序列化对象的状态,重新创建该对象。为了使得存储和传输后的数据能够再次变回内存中的对象,这样的转换必须是可逆的。序列化方法和反序列化方法被广泛使用在网络间数据传输和应用中,通常需要将信息转换成数据流,实现数据传输和应用。但是在数据传输和存储时,如果对对象中的属性进行增减,执行反序列化的一侧若没有将对象中的属性进行同步,就会引起反序列化失败的问题。增加、减少或修改了对象中的属性,将原来序列化后的文件或数据进行反序列化时,会产生错误或序列化失败。这就是对象序列化的兼容问题。通常对象的所有字段都会被序列化,这意味着数据会被表示为序列化数据。类似地,反序列化从序列化的表示形式中提取数据,并直接设置对象状态。The object serialization technique is a technique for converting object data into another form of persistent data, that is, a process of converting state information of an object into a form that can be stored or transmitted. During serialization, an object writes its current state to a temporary or persistent store, which can be recreated by reading or deserializing the state of the object from the store. In order for the stored and transmitted data to be able to change back to objects in memory, such conversions must be reversible. Serialization methods and deserialization methods are widely used in data transmission and application between networks. It is usually necessary to convert information into data streams for data transmission and application. However, when data is transferred and stored, if the attributes in the object are increased or decreased, the side that performs deserialization will not cause the deserialization to fail if the attributes in the object are not synchronized. When an attribute in an object is added, reduced, or modified, and the original serialized file or data is deserialized, an error or serialization failure occurs. This is the compatibility issue of object serialization. Usually all fields of an object are serialized, which means that the data is represented as serialized data. Similarly, deserialization extracts data from the serialized representation and sets the object state directly.
本申请的实施例提供了一种对数据对象序列化的方法。所述对数据对象序列化的方法实施例如下:Embodiments of the present application provide a method of serializing data objects. The method for serializing data objects is as follows:
请参考图1,其示出了根据本申请的实施例提供的对数据对象序列化的方法的流程图。Please refer to FIG. 1 , which shows a flowchart of a method for serializing data objects according to an embodiment of the present application.
所述对数据对象序列化的方法包括:The method for serializing data objects includes:
步骤S101,获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称。Step S101: Obtain a metadata description file of a data object to be serialized, where the metadata description file includes an attribute description identified by a sequence number and an attribute operation class name corresponding to an attribute in the data object.
在本实施例中,所述获取待序列化的数据对象的元数据描述文件,可以采用如下方式实现:根据所述待序列化的数据对象的名称,从元数据仓库中查找对应所述待序列化 的数据对象且版本号数值最大的所述待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称。In this embodiment, the obtaining a metadata description file of the data object to be serialized may be implemented by searching for a corresponding sequence from the metadata repository according to the name of the data object to be serialized. Chemical And a metadata description file of the data object to be serialized with the largest version number value, the metadata description file includes an attribute description identified by a sequence number and an attribute operation class name corresponding to the attribute in the data object.
需要说明的是,所述元数据仓库是用于存储元数据以及与元数据相关信息(如元数据描述文件)的数据库,所述元数据仓库一般可以采用关系型数据库。It should be noted that the metadata warehouse is a database for storing metadata and metadata related information (such as a metadata description file), and the metadata warehouse may generally adopt a relational database.
在本实施例中,所述对数据对象序列化的方法是根据元数据描述文件的描述语义去理解数据的结构构成。可以理解的,由于在步骤S101中获取待序列化的数据对象的元数据描述文件时,是从元数据仓库中查找对应所述待序列化的数据对象且版本号数值最大的所述待序列化的数据对象的元数据描述文件,即本步骤中获取到的都是最新版本的元数据描述文件。In this embodiment, the method of serializing the data object is to understand the structural composition of the data according to the description semantics of the metadata description file. It can be understood that, when the metadata description file of the data object to be serialized is obtained in step S101, the to-serialization corresponding to the data object to be serialized and having the largest version number value is searched from the metadata repository. The metadata description file of the data object, that is, the metadata version description file obtained in this step is the latest version.
具体的,所述元数据描述文件中包括若干条对应于数据对象中属性的属性描述,每条属性描述以序号标识,并包含对应所述数据对象中属性的属性操作类名称。Specifically, the metadata description file includes a plurality of attribute descriptions corresponding to attributes in the data object, each attribute description is identified by a sequence number, and includes an attribute operation class name corresponding to the attribute in the data object.
为了满足序列化时的元数据描述文件和数据对象中属性的兼容问题,本实施例的技术方案提供了一种优选实施方式,在优选方式下,所述元数据描述文件中的每条属性描述,还包括:对应该条属性描述的属性类型。In order to satisfy the compatibility problem of the attributes in the metadata description file and the data object in the serialization, the technical solution of the embodiment provides a preferred implementation manner. In a preferred mode, each attribute description in the metadata description file is described. Also includes: the attribute type described for the attribute of the strip.
例如,元数据描述文件可以如下:For example, the metadata description file can be as follows:
1:com.taobao.galaxy.io.UserIdFieldDef:VARINT1:com.taobao.galaxy.io.UserIdFieldDef:VARINT
2:com.taobao.galaxy.io.AgeFieldDef:VARINT2: com.taobao.galaxy.io.AgeFieldDef:VARINT
其中,数字“1”和“2”是每条属性描述的序号,UserIdFieldDef是对应所述数据对象中属性UserId的属性操作类名称;AgeFieldDef是对应所述数据对象中属性Age的属性操作类名称;VARINT是本条属性描述的属性类型。The numbers "1" and "2" are the sequence numbers of each attribute description, the UserIdFieldDef is the attribute operation class name corresponding to the attribute UserId in the data object; the AgeFieldDef is the attribute operation class name corresponding to the attribute Age in the data object; VARINT is the attribute type described by this attribute.
需要说明的是,元数据描述文件是描述其它数据的数据,或者说是结构数据。具体说,元数据描述文件是描述信息资源或数据等对象的数据。元数据描述文件一经建立便可共享使用。元数据描述文件的开发与利用环境往往是一个变化的分布式环境。由于元数据描述文件也是数据,因此可以用类似数据的方法在元数据仓库中进行存储和获取,方便在分布式环境下共享与使用。It should be noted that the metadata description file is data describing other data, or structural data. Specifically, the metadata description file is data describing an object such as an information resource or data. Once the metadata description file is created, it can be shared. The development and utilization environment of metadata description files is often a changing distributed environment. Since the metadata description file is also data, it can be stored and retrieved in the metadata repository by a similar data method, which is convenient for sharing and use in a distributed environment.
下面针对所述对数据对象序列化的方法,本申请提供了一个具体例子以便对所述对数据对象序列化的方法进行说明:In the following, for the method for serializing data objects, the present application provides a specific example to explain the method for serializing data objects:
待序列化的数据对象为(未示出其属性值):The data object to be serialized is (the attribute value is not shown):
Class User{ Class User{
int userId;Int userId;
string name;String name;
int age;Int age;
}}
根据所述待序列化的数据对象的名称User,从元数据仓库中查找对应所述待序列化的数据对象User且版本号数值最大的所述待序列化的数据对象的元数据描述文件,例如:获取到的待序列化的数据对象的元数据描述文件为:Defining, according to the name User of the data object to be serialized, a metadata description file of the data object to be serialized corresponding to the data object User to be serialized and having the highest version number value, for example, from the metadata repository, for example : The metadata description file of the data object to be serialized is:
1:com.taobao.test.io.UserIdFieldDef:VARINT1:com.taobao.test.io.UserIdFieldDef:VARINT
2:com.taobao.test.io.NameFieldDef:VARCHAR2: com.taobao.test.io.NameFieldDef:VARCHAR
3:com.taobao.test.io.PhoneFieldDef:VARINT3: com.taobao.test.io.PhoneFieldDef:VARINT
4:com.taobao.test.io.AgeFieldDef:VARINT4: com.taobao.test.io.AgeFieldDef:VARINT
上述元数据描述文件所描述的数据对象与前述数据对象的例子User并不完全相符合,这是由于元数据描述文件是最新版本,是根据升级版本的User确定的。The data object described in the metadata description file described above does not exactly match the example User of the aforementioned data object. This is because the metadata description file is the latest version and is determined according to the upgraded version of User.
需要说明的是,数据对象为客观世界中存在的人、事、物体等实体在计算机逻辑中的映射。例如,当对象为书籍,其具有的属性包括书籍编号、作者、出版社和备注等,将该书籍进行序列化后,生成与该书籍对应的二进制数据流,该二进制数据流具有与书籍的属性相对应的属性值,从而通过计算机语言表示客观世界中存在的人、事、物体等实体。数据对象可以是任意的客观世界中存在的人、事、物体等实体,本例子中的数据对象是用户,即User。对象包括至少一个属性,属性的名称称为属性名称,属性对应的值称为属性值,属性值可以为整型,字符型,浮点型,字符串型等基本类型,例如上述数据对象的例子中,属性userId为整型,属性name为字符串型,属性age为整型。It should be noted that the data object is a mapping of entities such as people, things, objects, etc. existing in the objective world in computer logic. For example, when the object is a book, the attributes thereof include a book number, an author, a publisher, a comment, and the like, and after serializing the book, a binary data stream corresponding to the book is generated, the binary data stream having attributes with the book. Corresponding attribute values, thereby representing entities such as people, things, objects, etc. that exist in the objective world through computer language. The data object can be any entity, thing, object, etc. that exists in the objective world. The data object in this example is the user, that is, User. The object includes at least one attribute. The name of the attribute is called the attribute name. The value corresponding to the attribute is called the attribute value. The attribute value can be an integer type such as an integer type, a character type, a floating point type, or a string type, for example, an example of the above data object. The attribute userId is an integer, the attribute name is a string type, and the attribute age is an integer.
在本步骤S101获取待序列化的数据对象的元数据描述文件之前,还需定义或创建所述元数据描述文件,具体包括步骤S100-1至S100-3,下面结合图2作进一步说明。Before the step S101 obtains the metadata description file of the data object to be serialized, the metadata description file needs to be defined or created, and specifically includes steps S100-1 to S100-3, which will be further described below with reference to FIG. 2 .
请参考图2,其示出了根据本申请的实施例提供的创建元数据描述文件的流程图。Please refer to FIG. 2, which shows a flowchart of creating a metadata description file according to an embodiment of the present application.
步骤S100-1,接收对所述待序列化的数据对象的属性的修改操作;所述修改操作包括:对所述待序列化的数据对象的属性进行增加、删除或者变更。Step S100-1: Receive a modification operation on an attribute of the data object to be serialized; the modifying operation includes: adding, deleting, or changing an attribute of the data object to be serialized.
所述接收对所述待序列化的数据对象的属性的修改操作,包括:接收对所述待序列化的数据对象中的属性的增加、删除或者变更。例如,对数据对象User增加类型为string的属性address、将数据对象User中的age属性删除或是将数据对象中的userId属性的名称修改为id。 The receiving a modification operation on an attribute of the data object to be serialized includes: receiving an addition, deletion, or change of an attribute in the data object to be serialized. For example, add the attribute address of type string to the data object User, delete the age attribute of the data object User, or modify the name of the userId attribute in the data object to id.
步骤S100-2,基于对所述待序列化的数据对象的修改操作为所述待序列化的数据对象的新增属性创建属性操作类。Step S100-2: Create an attribute operation class for the newly added attribute of the data object to be serialized based on the modification operation of the data object to be serialized.
本步骤根据步骤S100-1中接收的对所述待序列化的数据对象的属性的修改操作为新增属性创建属性操作类。例如,在步骤S100-1中增加了类型为string的属性address,则为属性address创建名称为AddressFieldDef的属性操作类。其中,所述AddressFieldDef类中封装了getter与setter方法。This step creates an attribute operation class for the newly added attribute according to the modification operation of the attribute of the data object to be serialized received in step S100-1. For example, if the attribute address of type string is added in step S100-1, an attribute operation class named AddressFieldDef is created for the attribute address. The AddressFieldDef class encapsulates the getter and setter methods.
需要说明的是,若所述修改操作为删除属性,可以不删除对应属性的属性操作类;若所述修改操作为修改属性,即删除原有属性后创建修改后的属性,并为该修改后的属性创建相应的属性操作类。It should be noted that, if the modification operation is to delete an attribute, the attribute operation class of the corresponding attribute may not be deleted; if the modification operation is to modify the attribute, the original attribute is deleted, and the modified attribute is created, and the modified attribute is modified. The properties of the corresponding property action class are created.
步骤S100-3,根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更。Step S100-3: Create a new version of the metadata description file according to the modification operation, and the attribute description in the metadata description file is changed according to the modification operation based on the attribute description in the original version metadata description file.
在本实施例中,所述根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更,可以采用如下方式实现:获取接收修改操作后的所述待序列化的数据对象的属性,按照属性在数据对象中定义的顺序生成属性描述的序号,获取对应所述待序列化的数据对象中属性的属性操作类名称,并获取所述待序列化的数据对象中属性的属性类型,根据属性在数据对象中定义的顺序将属性操作类名称以及属性类型按顺序写入每条属性描述中,将生成的全部属性描述作为新版本的元数据描述文件。In this embodiment, the new version of the metadata description file is created according to the modification operation, and the attribute description in the metadata description file is performed according to the modification operation on the basis of the attribute description in the original version metadata description file. The change may be implemented by acquiring the attribute of the data object to be serialized after receiving the modification operation, generating the sequence number of the attribute description in the order defined by the attribute in the data object, and acquiring the data corresponding to the serialization to be serialized. The attribute of the attribute in the object manipulates the class name, and obtains the attribute type of the attribute in the data object to be serialized, and writes the attribute operation class name and the attribute type into each attribute description in sequence according to the order defined by the attribute in the data object. In the middle, all the generated attribute descriptions are used as the metadata version file of the new version.
在所述根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更之后,为了使新版本的元数据描述文件与旧版本的元数据描述文件区分开,并且在分布式环境下能被共享使用,本实施例的技术方案提供了一种优选实施方式,在优选方式下,具体包括步骤S100-4至S100-7,下面结合图3作进一步说明。Creating a new version of the metadata description file according to the modification operation, and the attribute description in the metadata description file is changed according to the attribute description in the original version metadata description file, according to the modification operation, The new version of the metadata description file is distinguished from the old version of the metadata description file, and can be shared and used in a distributed environment. The technical solution of this embodiment provides a preferred embodiment. In a preferred manner, Steps S100-4 to S100-7 are included, which will be further described below in conjunction with FIG. 3.
请参考图3,其示出了根据本申请的实施例提供的保存元数据描述文件的流程图。Please refer to FIG. 3, which shows a flowchart of saving a metadata description file according to an embodiment of the present application.
步骤S100-4,根据所述待序列化的数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述待序列化的数据对象设置的元数据描述文件。Step S100-4, traversing a metadata description file set for the data object to be serialized in a metadata repository in which the metadata description file is stored according to the name of the data object to be serialized.
例如,所述待序列化的数据对象的名称为User,在存有元数据描述文件的元数据仓库中遍历针对数据对象User设置的元数据描述文件。For example, the name of the data object to be serialized is User, and the metadata description file set for the data object User is traversed in the metadata repository in which the metadata description file is stored.
步骤S100-5,在遍历过程中,获取在所述元数据仓库中的所述待序列化的数据对象 的元数据描述文件的版本号最大的数值。Step S100-5, in the traversal process, acquiring the data object to be serialized in the metadata repository The metadata describes the version number of the file with the largest value.
例如,在遍历过程中,查找出在所述元数据仓库中的针对数据对象User设置的元数据描述文件共有6个,版本号为1-6,则在本步骤S100-5中获取的数值为6。For example, in the traversal process, it is found that there are six metadata description files set for the data object User in the metadata repository, and the version number is 1-6, and the value obtained in this step S100-5 is 6.
步骤S100-6,将所述数值加一,并将加一后的所述数值作为新版本的元数据描述文件的版本号。In step S100-6, the value is incremented by one, and the added value is used as the version number of the metadata version file of the new version.
在本实施例中,将加一后的数值与步骤S100-3中创建的新版本的元数据描述文件建立映射关系。In this embodiment, the added value is mapped to the new version of the metadata description file created in step S100-3.
步骤S100-7,将所述记录有版本号的所述元数据描述文件保存在所述元数据仓库中。Step S100-7, storing the metadata description file with the version number recorded in the metadata repository.
需要说明的是,步骤S100-1至步骤S100-7这七个步骤,可以预先创建完成,也可以在执行对数据对象序列化的方法时候进行现场配置,对此不做限定。It should be noted that the seven steps of step S100-1 to step S100-7 may be created in advance, or may be configured on site when performing the method of serializing data objects, which is not limited.
步骤S103,根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类。Step S103: Obtain an attribute operation class name corresponding to each attribute description in the metadata description file, and obtain an attribute operation class corresponding to each attribute.
在本实施例中,所述根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类,可以采用如下方式实现:根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,检索并获取与各个属性描述提供的属性操作类名称相同的属性操作类。In this embodiment, the attribute operation class name provided by each attribute description in the metadata description file is obtained, and the attribute operation class corresponding to each attribute is obtained, which may be implemented in the following manner: according to the metadata description file Each attribute describes the provided attribute action class name, retrieves and retrieves the same attribute action class as the attribute action class name provided by each attribute description.
下面仍沿用上述对数据对象序列化的方法的具体例子,对本步骤的处理过程作进一步说明。The processing of this step will be further described below using the specific example of the above method for serializing data objects.
待序列化的数据对象为(未示出其属性值):The data object to be serialized is (the attribute value is not shown):
Class User{Class User{
int userId;Int userId;
string name;String name;
int age;Int age;
}}
待序列化的数据对象的元数据描述文件为:The metadata description file of the data object to be serialized is:
1:com.taobao.test.io.UserIdFieldDef:VARINT1:com.taobao.test.io.UserIdFieldDef:VARINT
2:com.taobao.test.io.NameFieldDef:VARINT2: com.taobao.test.io.NameFieldDef:VARINT
3:com.taobao.test.io.PhoneFieldDef:VARINT3: com.taobao.test.io.PhoneFieldDef:VARINT
4:com.taobao.test.io.AgeFieldDef:VARINT4: com.taobao.test.io.AgeFieldDef:VARINT
从所述待序列化的数据对象的元数据描述文件中,获取各个属性描述提供的属性操 作类名称,包括UserIdFieldDef、NameFieldDef、PhoneFieldDef以及AgeFieldDef,检索并获取与各个属性描述提供的属性操作类名称相同的属性操作类,在本例子中,获取到的属性操作类包括:UserIdFieldDef、NameFieldDef以及AgeFieldDef。Obtaining the attribute operation provided by each attribute description from the metadata description file of the data object to be serialized The class name, including UserIdFieldDef, NameFieldDef, PhoneFieldDef, and AgeFieldDef, retrieves and retrieves the same attribute operation class as the attribute operation class name provided by each attribute description. In this example, the obtained attribute operation class includes: UserIdFieldDef, NameFieldDef, and AgeFieldDef. .
步骤S105,根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值。Step S105: Read the attribute values corresponding to the respective attribute descriptions in the data objects to be serialized according to the reading method provided by the attribute operation class corresponding to each attribute.
在本实施例中,根据步骤S103中获取对应各个属性的属性操作类中,各个属性描述的所述属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值。In this embodiment, according to the step S103, the reading operation method provided by the attribute operation class of each attribute description in the attribute operation class corresponding to each attribute is obtained, and the data object to be serialized is respectively corresponding to each attribute description. Property value.
在具体实施时,调用与各个属性描述提供的属性操作类名称相同的属性操作类封装的getter方法,读取待序列化的数据对象相应属性的属性值。In a specific implementation, the getter method encapsulated with the same attribute operation class name provided by each attribute description is called, and the attribute value of the corresponding attribute of the data object to be serialized is read.
为了使读取到的待序列化的数据对象中的属性值,在写入所述数据对象的结果数据流时节省存储空间或传输时减小数据传输量,本实施例的技术方案提供了一种优选实施方式,在优选方式下,在写入所述数据对象的结果数据流前,将读取到的属性值进行压缩。In order to make the attribute value in the read data object to be serialized, the storage space is saved when the result data stream of the data object is written or the data transmission amount is reduced during the transmission, the technical solution of the embodiment provides a In a preferred embodiment, the read attribute values are compressed prior to writing the result data stream of the data object.
在具体实施时,对属性值进行压缩可以采用out.writeVarint()进行压缩,或者采用比如较流行的LZ及系列变种(LZW,LZR,LZX)压缩算法等。In the specific implementation, the attribute value can be compressed by using out.writeVarint(), or by using more popular LZ and series variants (LZW, LZR, LZX) compression algorithms.
需要说明的是,在步骤S103中,所述根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类时,会出现以下2种情况:It should be noted that, in step S103, when the attribute operation class name provided by each attribute description in the metadata description file is obtained, and the attribute operation class corresponding to each attribute is obtained, the following two cases occur:
第一种情况,能在代码库中获取到与所述元数据描述文件中的各个属性描述提供的属性操作类名称且数目相同的属性操作类,说明所述待序列化的数据对象与元数据描述文件的版本匹配,即:所述待序列化的数据对象与所述元数据描述文件版本兼容,所以不会出现兼容性问题。In the first case, the attribute operation class with the same number of the attribute operation class name provided by each attribute description in the metadata description file can be obtained in the code library, and the data object and metadata to be serialized are described. The version of the description file matches, that is, the data object to be serialized is compatible with the metadata description file version, so compatibility problems do not occur.
需要说明的是,在第一种情况中,有可能是代码库中的属性操作类的数目与名称均与所述元数据描述文件中各个属性描述描述的属性操作类相同;还有一种可能是,代码库中的属性操作类的数目大于所述元数据描述文件中各个属性描述描述的属性操作类,但是代码库中包含有所述元数据描述文件中各个属性描述描述的所有属性操作类,在序列化时,是按照所述元数据描述文件加载对应于所述元数据描述文件中的属性操作类名称的属性操作类,代码库中没有用到的属性操作类不会被使用,所以不会出现兼容性问题。It should be noted that, in the first case, it is possible that the number and name of the attribute operation classes in the code base are the same as the attribute operation classes described in the respective attribute descriptions in the metadata description file; The number of attribute operation classes in the code library is greater than the attribute operation class described by each attribute description in the metadata description file, but the code library includes all attribute operation classes described by each attribute description in the metadata description file, At the time of serialization, the attribute operation class corresponding to the attribute operation class name in the metadata description file is loaded according to the metadata description file, and the attribute operation class not used in the code library is not used, so A compatibility issue will occur.
第二种情况,只能在代码库中获取到部分与所述元数据描述文件中的各个属性描述 提供的属性操作类名称相同的属性操作类,说明所述待序列化的数据对象与元数据描述文件版本不匹配,即:数据对象是老版本下生成的数据对象,而元数据描述文件是最新版本,在序列化时会出现兼容性问题。In the second case, only the part of the code base and the description of each attribute in the metadata description file can be obtained in the code base. The attribute operation class with the same attribute operation class name is provided, indicating that the data object to be serialized does not match the version of the metadata description file, that is, the data object is a data object generated under the old version, and the metadata description file is the latest. Version, compatibility issues occur during serialization.
为了解决序列化时的元数据描述文件和数据对象的兼容性问题,本实施例的技术方案提供了一种优选实施方式,在优选方式下,具体包括步骤S106-1至S106-3,下面结合图4作进一步说明。In order to solve the problem of the compatibility of the metadata description file and the data object during the serialization, the technical solution of the present embodiment provides a preferred embodiment. In a preferred manner, the method specifically includes the steps S106-1 to S106-3. Figure 4 is further illustrated.
请参考图4,其示出了根据本申请的实施例提供的序列化时缺省值的读取方法的流程图。Please refer to FIG. 4, which shows a flowchart of a method for reading default values at the time of serialization according to an embodiment of the present application.
步骤S106-1,获取由于无法获取对应属性的属性操作类而无法读取的属性描述的属性类型。Step S106-1: Acquire an attribute type of the attribute description that cannot be read because the attribute operation class of the corresponding attribute cannot be obtained.
所述获取由于无法获取对应属性的属性操作类而无法读取的属性描述的属性类型,可以采用如下方式实现:从元数据描述文件中,确定由于无法获取对应属性操作类而无法读取属性值的属性描述,即:该条属性描述描述的属性操作类不存在,获取该条属性描述的属性类型。The obtaining the attribute type of the attribute description that cannot be read because the attribute operation class of the corresponding attribute cannot be obtained may be implemented as follows: from the metadata description file, determining that the attribute value cannot be read because the corresponding attribute operation class cannot be obtained The attribute description, that is, the attribute operation class described by the attribute description does not exist, and the attribute type described by the attribute is obtained.
需要说明的是,所述由于无法获取对应属性操作类而无法读取属性值,是由于代码库没有更新或者其它原因而没有存储该属性操作类。由于代码库一般存放在各种终端本地,因此很可能没有及时根据最新版本更新;而所使用的元数据描述文件则均为最新更新版本。It should be noted that the attribute value cannot be read because the corresponding attribute operation class cannot be obtained, because the code library is not updated or other reasons, and the attribute operation class is not stored. Since the code base is generally stored locally on various terminals, it is likely that it is not updated in time according to the latest version; the metadata description file used is the latest update version.
步骤S106-2,根据所述属性类型,检索获得对应所述属性类型的缺省属性操作类。Step S106-2, according to the attribute type, retrieve a default attribute operation class corresponding to the attribute type.
在本实施例中,所述属性类型,包括:整型,字符型,浮点型,字符串型等类型。In this embodiment, the attribute type includes: an integer type, a character type, a floating point type, a string type, and the like.
例如,获取的所述属性类型为VARINT,检索类型为DefaultVarintFieldDef的缺省属性操作类。For example, the obtained property type is VARINT, and the default property operation class of the type DefaultVarintFieldDef is retrieved.
步骤S106-3,根据所述缺省属性操作类,为该属性描述对应的属性赋予预先确定的缺省值。Step S106-3, according to the default attribute operation class, assign a predetermined default value to the attribute corresponding to the attribute description.
加载检索出的所述缺省属性操作类,调用所述缺省属性操作类中封装的getter方法,读取预先赋予的缺省值。Loading the retrieved default attribute operation class, calling the getter method encapsulated in the default attribute operation class, and reading the default value given in advance.
所述预先确定的缺省值根据不同的属性类型可以采用不同的缺省值,例如,整型类型的缺省值为0。The predetermined default value may adopt different default values according to different attribute types. For example, the default value of the integer type is 0.
下面仍沿用上述对数据对象序列化的方法的具体例子,对本步骤的处理过程作进一步说明。 The processing of this step will be further described below using the specific example of the above method for serializing data objects.
待序列化的数据对象为:The data objects to be serialized are:
Class User{Class User{
int userId;Int userId;
string name;String name;
int age;Int age;
}}
该数据对象的具体属性值存放在对应的数据库表中,例如一个具体的数据对象User为:The specific attribute value of the data object is stored in the corresponding database table, for example, a specific data object User is:
userIduserId nameName ageAge
11 aaaAaa 2020
需要说明的是,上述给出的User表仅仅是示意性的,在具体的实施中,对象User中的属性数据通常会更多,在本例子中仅给出一组数据说明本步骤的处理过程。It should be noted that the User table given above is only schematic. In a specific implementation, the attribute data in the object User is usually more. In this example, only a set of data is given to illustrate the processing of this step. .
获取到的待序列化的数据对象的元数据描述文件为:The metadata description file of the obtained data object to be serialized is:
1:com.taobao.test.io.UserIdFieldDef:VARINT1:com.taobao.test.io.UserIdFieldDef:VARINT
2:com.taobao.test.io.NameFieldDef:VARCHART2: com.taobao.test.io.NameFieldDef: VARCHART
3:com.taobao.test.io.PhoneFieldDef:VARINT3: com.taobao.test.io.PhoneFieldDef:VARINT
4:com.taobao.test.io.AgeFieldDef:VARINT4: com.taobao.test.io.AgeFieldDef:VARINT
在步骤S103中,获取到的属性操作类包括:UserIdFieldDef、NameFieldDef以及AgeFieldDef,其中由于第三条属性描述未获取到与PhoneFieldDef同名的属性操作类,所以获取第三条属性描述中的属性类型,即:获取VARINT类型,通过获取的VARINT类型,检索对应类型VARINT的缺省属性操作类DefaultVarintFieldDef,获取属性操作类DefaultVarintFieldDef后,按照元数据描述文件中属性描述的序号的顺序,分别执行UserIdFieldDef中的getter方法读取userId的属性值1、执行NameFieldDef中的getter方法读取name的属性值aaa、执行DefaultVarintFieldDef中的getter方法读取缺省值0以及执行AgeFieldDef中的getter方法读取age的属性值20。In step S103, the obtained attribute operation class includes: UserIdFieldDef, NameFieldDef, and AgeFieldDef, wherein the attribute type in the third attribute description is obtained, because the attribute operation class with the same name as PhoneFieldDef is not acquired according to the third attribute description, that is, Get the VARINT type, retrieve the default property operation class DefaultVarintFieldDef of the corresponding type VARINT by obtaining the VARINT type, obtain the property operation class DefaultVarintFieldDef, and execute the getter method in UserIdFieldDef according to the sequence number of the attribute description in the metadata description file. Read the attribute value of userId, execute the getter method in NameFieldDef to read the attribute value aaa of name, execute the getter method in DefaultVarintFieldDef to read the default value of 0, and execute the getter method in AgeFieldDef to read the attribute value 20 of age.
以UserIdFieldDef和DefaultVarintFieldDef为例,详细代码示例如下所示:UserIdFieldDef:Take UserIdFieldDef and DefaultVarintFieldDef as examples. The detailed code example is as follows: UserIdFieldDef:
public class UserIdFieldDef<Item>implements FieldDef<T>{Public class UserIdFieldDef<Item>implements FieldDef<T>{
public void setter(User user,CodedInputStream in){Public void setter(User user,CodedInputStream in){
user.setUserId(in.readVarint()); user.setUserId(in.readVarint());
}}
public void getter(User user,CodedOutputStream out){Public void getter(User user,CodedOutputStream out){
out.writeVarint(user.getUserId());out.writeVarint(user.getUserId());
}}
}}
DefaultVarintFieldDef:DefaultVarintFieldDef:
public class DefaultVarintFieldDef<Object>implements FieldDef<T>{Public class DefaultVarintFieldDef<Object>implements FieldDef<T>{
public void setter(Object o,CodedInputStream in){Public void setter(Object o,CodedInputStream in){
in.readVarint();in.readVarint();
}}
public void getter(Object o,CodedOutputStream out){Public void getter(Object o,CodedOutputStream out){
out.writeVarint(0);out.writeVarint(0);
}}
}}
执行不同的属性操作类时,只需修改对应的参数即可,对此不再赘述。When executing different attribute operation classes, you only need to modify the corresponding parameters, which will not be described here.
步骤S107,将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。Step S107, the read attribute values are written into the result data stream of the data object in the order of the attribute description sequence number, and the result data stream is used as the serialization result of the data object.
为了使结果数据流在之后执行反序列化时获取序列化时使用的元数据描述文件,保证兼容性问题,再将取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流的步骤之前,包括:In order to make the result data stream obtain the metadata description file used in the serialization when the deserialization is performed later, the compatibility problem is ensured, and the obtained attribute value is written into the result data of the data object in the order of the attribute description sequence number. Before the flow steps, include:
读取所述待序列化的数据对象的元数据描述文件的版本号,并将其写入到所述待序列化的数据对象的结果数据流的头部。Reading a version number of the metadata description file of the data object to be serialized and writing it to the head of the result data stream of the data object to be serialized.
在具体实施时,先获取所述待序列化的数据对象的元数据描述文件的版本号,将所述版本号的的数值写入结果数据流的第一个字节的位置,写入后序列化指针相应后移,将步骤S105中读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流。In a specific implementation, the version number of the metadata description file of the data object to be serialized is first obtained, and the value of the version number is written into the position of the first byte of the result data stream, and the sequence is written. The pointers are correspondingly moved backward, and the attribute values read in step S105 are written into the result data stream of the data object in the order of the attribute description sequence numbers.
需要说明的是,所述序列化的结果数据流可以是二进制数据,但不限于二进制数据。It should be noted that the serialized result data stream may be binary data, but is not limited to binary data.
通过本申请实施例提供的一种对数据对象序列化的方法,通过获取元数据描述文件,根据元数据描述文件,对数据对象进行序列化;使得生成的结果数据流中除了数据外不包含附加数据,在保存信息和数据传输时节约了存储空间和传输流量,并且在反序列化时可以降低系统的处理开销。 A method for serializing a data object provided by the embodiment of the present application, by acquiring a metadata description file, serializing the data object according to the metadata description file, so that the generated result data stream does not include an addition except the data. Data saves storage space and transmission traffic when saving information and data transmission, and can reduce system processing overhead when deserializing.
在上述的实施例中,提供了一种对数据对象序列化的方法,与上述对数据对象序列化的方法相对应的,本申请还提供了一种对数据对象序列化的装置。由于装置的实施例基本相似于方法的实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。下述描述的装置实施例仅仅是示意性的。所述对数据对象序列化的装置实施例如下:In the above embodiment, a method for serializing a data object is provided. Corresponding to the above method for serializing a data object, the present application further provides an apparatus for serializing a data object. Since the embodiment of the device is substantially similar to the embodiment of the method, the description is relatively simple, and the relevant portions can be referred to the description of the method embodiment. The device embodiments described below are merely illustrative. The device for serializing the data object is implemented as follows:
请参考图5,其示出了根据本申请的实施例提供的对数据对象序列化的装置的示意图。Please refer to FIG. 5, which shows a schematic diagram of an apparatus for serializing data objects according to an embodiment of the present application.
所述对数据对象序列化的装置,包括:描述文件获取单元501、属性操作类获取单元503、属性读取单元505以及序列化写入单元507;The device for serializing the data object includes: a description file obtaining unit 501, an attribute operation class obtaining unit 503, an attribute reading unit 505, and a serialization writing unit 507;
所述描述文件获取单元501,用于获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;The description file obtaining unit 501 is configured to acquire a metadata description file of a data object to be serialized, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object;
所述属性操作类获取单元503,用于根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;The attribute operation class obtaining unit 503 is configured to obtain an attribute operation class name corresponding to each attribute according to each attribute description in the metadata description file, and obtain an attribute operation class corresponding to each attribute;
所述属性读取单元505,用于根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值;The attribute reading unit 505 is configured to read, according to a reading method provided by the attribute operation class corresponding to each attribute, an attribute value corresponding to each attribute description in the data object to be serialized;
所述序列化写入单元507,用于将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。The serialization writing unit 507 is configured to write the read attribute values into the result data stream of the data object in the order of the attribute description sequence number, and the result data stream is used as a serialization result of the data object.
可选的,所述描述文件获取单元501获取的所述待序列化的数据对象的元数据描述文件还包括属性类型。Optionally, the metadata description file of the data object to be serialized acquired by the description file acquiring unit 501 further includes an attribute type.
可选的,所述属性读取单元505,还包括:属性类型读取子单元、缺省属性操作类获取子单元以及缺省值读取子单元;Optionally, the attribute reading unit 505 further includes: an attribute type reading subunit, a default attribute operation class obtaining subunit, and a default value reading subunit;
所述属性类型读取子单元,用于读取待序列化的数据对象中分别与各个属性描述对应的属性值之后,获取由于无法获取对应属性的属性操作类而无法读取的属性描述的属性类型;The attribute type reading subunit is configured to read an attribute value corresponding to each attribute description in the data object to be serialized, and obtain an attribute description attribute that cannot be read because the attribute operation class of the corresponding attribute cannot be obtained. Types of;
所述缺省属性操作类获取子单元,用于根据所述属性类型,检索获得对应所述属性类型的缺省属性操作类;The default attribute operation class acquisition sub-unit is configured to retrieve, according to the attribute type, a default attribute operation class corresponding to the attribute type;
所述缺省值读取子单元,用于根据所述缺省属性操作类,为该属性描述对应的属性赋予预先确定的缺省值。The default value reading subunit is configured to assign a predetermined default value to the corresponding attribute of the attribute description according to the default attribute operation class.
可选的,所述描述文件获取单元501具体用于根据所述待序列化的数据对象的名称, 从元数据仓库中查找对应所述待序列化的数据对象且版本号数值最大的所述待序列化的数据对象的元数据描述文件。Optionally, the description file obtaining unit 501 is specifically configured to use, according to the name of the data object to be serialized, Finding, from the metadata repository, a metadata description file of the data object to be serialized corresponding to the data object to be serialized and having the highest version number value.
可选的,所述序列化写入单元507,还包括:版本号写入子单元;Optionally, the serialization writing unit 507 further includes: a version number writing subunit;
所述版本号写入子单元,用于在所述将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流之前,读取所述待序列化的数据对象的元数据描述文件的版本号,并将其写入到所述待序列化的数据对象的结果数据流的头部。The version number is written into the subunit, and is configured to read the data object to be serialized before the attribute value to be read is written into the result data stream of the data object in the order of the attribute description sequence number. The metadata describes the version number of the file and writes it to the head of the resulting data stream of the data object to be serialized.
可选的,所述对数据对象序列化的装置,还包括:修改操作接收单元、操作类创建单元以及描述文件创建单元;Optionally, the device for serializing the data object further includes: a modification operation receiving unit, an operation class creation unit, and a description file creation unit;
所述修改操作接收单元,用于在所述获取待序列化的数据对象的元数据描述文件之前,接收对所述待序列化的数据对象的属性的修改操作;所述修改操作包括:对所述待序列化的数据对象的属性进行增加、删除或者变更;The modifying operation receiving unit is configured to receive, before the acquiring the metadata description file of the data object to be serialized, a modification operation on the attribute of the data object to be serialized; the modifying operation includes: Adding, deleting, or changing the attributes of the serialized data object;
所述操作类创建单元,用于基于对所述待序列化的数据对象的修改操作为所述待序列化的数据对象的新增属性创建属性操作类;The operation class creation unit is configured to create an attribute operation class for the newly added attribute of the data object to be serialized based on the modification operation of the data object to be serialized;
所述描述文件创建单元,用于根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更a description file creation unit, configured to create a new version of the metadata description file according to the modification operation, where the attribute description in the metadata description file is based on the attribute description in the original version metadata description file, according to the modification operation Changed
可选的,所述对数据对象序列化的装置,还包括:遍历单元、数值获取单元、版本号生成单元以及保存单元;Optionally, the device for serializing the data object further includes: a traversal unit, a value obtaining unit, a version number generating unit, and a saving unit;
所述遍历单元,用于在所述根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更之后,根据所述待序列化的数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述待序列化的数据对象设置的元数据描述文件;The traversing unit is configured to create a new version of the metadata description file according to the modification operation, where the attribute description in the metadata description file is based on the attribute description in the original version metadata description file, according to the modification After the operation is changed, the metadata description file set for the data object to be serialized is traversed in the metadata repository storing the metadata description file according to the name of the data object to be serialized;
所述数值获取单元,用于在遍历过程中,获取在所述元数据仓库中的所述待序列化的数据对象的元数据描述文件的版本号最大的数值;The value obtaining unit is configured to acquire, during the traversal process, a maximum value of a version number of the metadata description file of the data object to be serialized in the metadata repository;
所述版本号生成单元,用于将所述数值加一,并将加一后的所述数值作为新版本的元数据描述文件的版本号;The version number generating unit is configured to add the value by one, and use the added value as the version number of the metadata version file of the new version;
所述保存单元,用于将所述记录有版本号的所述元数据描述文件保存在所述元数据仓库中。The saving unit is configured to save the metadata description file with the version number recorded in the metadata repository.
可选的,所述对数据对象序列化的装置,还包括:属性值压缩单元;Optionally, the device for serializing the data object further includes: an attribute value compression unit;
所述属性值压缩单元,用于根据对应各个属性的属性操作类提供的读取方法,读取 待序列化的数据对象中分别与各个属性描述对应的属性值之后,将读取到的属性值进行压缩。The attribute value compression unit is configured to read according to a reading method provided by an attribute operation class corresponding to each attribute After the attribute values corresponding to the respective attribute descriptions in the data objects to be serialized are respectively, the read attribute values are compressed.
在上述的实施例中,提供了一种对数据对象序列化的方法以及一种对数据对象序列化的装置,此外,本申请还提供了一种电子设备;所述电子设备实施例如下:In the above embodiments, a method for serializing data objects and a device for serializing data objects are provided. In addition, the present application further provides an electronic device; the electronic device implementation is as follows:
请参考图6,其示出了根据本申请的实施例提供的电子设备的示意图。Please refer to FIG. 6 , which shows a schematic diagram of an electronic device provided in accordance with an embodiment of the present application.
所述电子设备,包括:显示器601;处理器603;存储器605;The electronic device includes: a display 601; a processor 603; a memory 605;
所述存储器605,用于存储序列化程序,所述程序在被所述处理器读取执行时,执行如下操作:获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值;将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。The memory 605 is configured to store a serialization program, where the program, when being read and executed by the processor, performs an operation of: acquiring a metadata description file of a data object to be serialized, where the metadata description file includes The attribute operation class identified by the serial number and the attribute operation class name corresponding to the attribute in the data object; the attribute operation class name provided according to each attribute description in the metadata description file, and the attribute operation class corresponding to each attribute are obtained; The reading method provided by the attribute operation class of each attribute reads the attribute value corresponding to each attribute description in the data object to be serialized; and writes the read attribute value into the data object according to the order of the attribute description serial number The resulting data stream, the resulting data stream being the serialized result of the data object.
在上述的实施例中,提供了一种对数据对象序列化的方法、一种对数据对象序列化的装置以及一种电子设备,此外,本申请还提供了一种对数据流反序列化的方法;所述对数据流反序列化的方法实施例如下:In the above embodiments, a method for serializing a data object, a device for serializing a data object, and an electronic device are provided. Further, the present application further provides a deserialization of the data stream. Method; the method for deserializing the data stream is implemented as follows:
请参考图7,其示出了根据本申请的实施例提供的对数据流反序列化的方法的流程图。Please refer to FIG. 7, which illustrates a flow diagram of a method of deserializing a data stream, in accordance with an embodiment of the present application.
所述对数据流反序列化的方法包括:The method for deserializing a data stream includes:
步骤S701,获取结果数据流。Step S701, obtaining a result data stream.
在本实施例中,所述获取结果数据流,包括:通过网络传输获取所述结果数据流或是从本地获取压缩的所述结果数据流。In this embodiment, the obtaining the result data stream includes: acquiring the result data stream by network transmission or obtaining the compressed result data stream from the local.
需要说明的是,所述结果数据流可以是二进制数据,但不限于二进制数据。It should be noted that the result data stream may be binary data, but is not limited to binary data.
步骤S703,获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称。Step S703: Obtain a metadata description file of the local data object, where the metadata description file includes an attribute description identified by a sequence number and an attribute operation class name corresponding to an attribute in the data object.
在本实施例中,所述获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称,具体包括步骤S703-1至S703-4,下面结合图8作进一步说明。In this embodiment, the acquiring a metadata description file of the local data object, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object, specifically including steps S703-1 to S703-4, which will be further described below in conjunction with FIG.
请参考图8,其示出了根据本申请的实施例提供的获取所述本地数据对象的元数据描述文件的流程图。 Please refer to FIG. 8 , which shows a flowchart of acquiring a metadata description file of the local data object according to an embodiment of the present application.
步骤S703-1,获取所述本地数据对象的名称。Step S703-1, acquiring a name of the local data object.
例如,所述本地数据对象的名称为User,则获取的所述本地数据对象的名称为User。For example, if the name of the local data object is User, the name of the local data object obtained is User.
步骤S703-2,解析所述结果数据流,获取所述结果数据流中的第一个值。Step S703-2, parsing the result data stream to obtain a first value in the result data stream.
解析所述结果数据流,获取所述结果数据流中的第一个字节。Parsing the result data stream to obtain the first byte in the result data stream.
例如,获取的数值为6。For example, the value obtained is 6.
步骤S703-3,根据所述本地数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述本地数据对象设置的元数据描述文件。Step S703-3, traversing the metadata description file set for the local data object in a metadata repository in which the metadata description file is stored according to the name of the local data object.
例如,根据所述本地数据对象User,在存有元数据描述文件的元数据仓库中遍历针对所述本地数据对象User设置的元数据描述文件。For example, according to the local data object User, a metadata description file set for the local data object User is traversed in a metadata repository in which a metadata description file is stored.
步骤S703-4,在遍历过程中,获取与所述本地数据对象的名称相同且版本号与所述结果数据流中的第一个值相同的所述本地数据对象的元数据描述文件。Step S703-4, in the traversal process, acquiring a metadata description file of the local data object having the same name as the local data object and having the same version number as the first value in the result data stream.
例如,在遍历过程中,查找出在所述元数据仓库中的针对数据对象User设置的元数据描述文件共有6个,版本号为1-6,则在本步骤S603-4中获取版本号为6的元数据描述文件。For example, in the traversal process, if there are six metadata description files set for the data object User in the metadata repository, the version number is 1-6, and the version number is obtained in step S603-4. 6 metadata description file.
为了满足反序列化时的元数据描述文件和本地数据对象中属性的兼容问题,本实施例的技术方案提供了一种优选实施方式,在优选方式下,所述元数据描述文件中的每条属性描述,还包括:对应该条属性描述的属性类型。In order to satisfy the compatibility problem between the metadata description file in the deserialization and the attributes in the local data object, the technical solution of the embodiment provides a preferred embodiment. In a preferred manner, each of the metadata description files The attribute description also includes: the attribute type corresponding to the attribute description.
下面针对所述对数据流反序列化的方法,本申请提供了一个具体例子便于对所述对数据流反序列化的方法进行说明:For the method for deserializing the data stream, the present application provides a specific example to facilitate the method for deserializing the data stream:
待写入属性值的本地数据对象为:The local data object to be written to the attribute value is:
Class User{Class User{
int userId;Int userId;
string name;String name;
int phone;Int phone;
}}
根据所述本地数据对象User,在存有元数据描述文件的元数据仓库中遍历针对所述本地数据对象User设置的元数据描述文件,若所述结果数据流中的第一个数值为6,那么获取版本号为6的元数据描述文件。例如:获取到的所述本地数据对象的元数据描述文件为:And traversing, according to the local data object User, a metadata description file set for the local data object User in a metadata repository storing a metadata description file, if the first value in the result data stream is 6, Then get the metadata description file with version number 6. For example, the metadata description file of the obtained local data object is:
1:com.taobao.test.io.UserIdFieldDef:VARINT 1:com.taobao.test.io.UserIdFieldDef:VARINT
2:com.taobao.test.io.NameFieldDef:VARCHART2: com.taobao.test.io.NameFieldDef: VARCHART
3:com.taobao.test.io.PhoneFieldDef:VARINT3: com.taobao.test.io.PhoneFieldDef:VARINT
4:com.taobao.test.io.AgeFieldDef:VARINT4: com.taobao.test.io.AgeFieldDef:VARINT
需要说明的是,由于所述本地数据对象在获取元数据描述文件时,是根据序列化时写入结果数据流头部的数值确定的,所以在序列化时与反序列化时使用的元数据描述文件是相同的,即元数据描述文件是兼容的。It should be noted that, since the local data object is determined according to the value of the header of the write result data stream when the metadata description file is obtained, the metadata used during serialization and deserialization is used. The description files are the same, ie the metadata description files are compatible.
步骤S705,根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类。Step S705: Acquire an attribute operation class name provided by each attribute description in the metadata description file, and obtain an attribute operation class corresponding to each attribute.
在本实施例中,所述根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类,可以采用如下方式实现:根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,检索并获取与各个属性描述提供的属性操作类名称相同的属性操作类。In this embodiment, the attribute operation class name provided by each attribute description in the metadata description file is obtained, and the attribute operation class corresponding to each attribute is obtained, which may be implemented in the following manner: according to the metadata description file Each attribute describes the provided attribute action class name, retrieves and retrieves the same attribute action class as the attribute action class name provided by each attribute description.
下面仍沿用上述对数据流反序列化的方法的具体例子,对本步骤的处理过程作进一步说明。The specific example of the above method for deserializing the data stream is still used below, and the processing of this step is further explained.
待写入属性值的本地数据对象为:The local data object to be written to the attribute value is:
Class User{Class User{
int userId;Int userId;
String name;String name;
int phone;Int phone;
}}
所述本地数据对象的元数据描述文件为:The metadata description file of the local data object is:
1:com.taobao.test.io.UserIdFieldDef:VARINT1:com.taobao.test.io.UserIdFieldDef:VARINT
2:com.taobao.test.io.NameFieldDef:VARINT2: com.taobao.test.io.NameFieldDef:VARINT
3:com.taobao.test.io.PhoneFieldDef:VARINT3: com.taobao.test.io.PhoneFieldDef:VARINT
4:com.taobao.test.io.AgeFieldDef:VARINT4: com.taobao.test.io.AgeFieldDef:VARINT
从所述本地数据对象的元数据描述文件中,获取各个属性描述提供的属性操作类名称,包括UserIdFieldDef、NameFieldDef、PhoneFieldDef以及AgeFieldDef,检索并获取与各个属性描述提供的属性操作类名称相同的属性操作类,在本例子中,获取到的属性操作类包括:UserIdFieldDef、NameFieldDef以及PhoneFieldDef。From the metadata description file of the local data object, obtain the attribute operation class name provided by each attribute description, including UserIdFieldDef, NameFieldDef, PhoneFieldDef, and AgeFieldDef, and retrieve and obtain the same attribute operation as the attribute operation class name provided by each attribute description. Class, in this example, the obtained property action classes include: UserIdFieldDef, NameFieldDef, and PhoneFieldDef.
步骤S707,根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取。 Step S707, according to the reading method provided by the attribute operation class corresponding to each attribute, sequentially reading the attribute values in the result data stream in the order of the attribute description sequence number.
在本实施例中,根据步骤S705中获取对应各个属性的属性操作类中,各个属性描述的所述属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取。In this embodiment, according to the step S705, the reading operation method provided by the attribute operation class of each attribute description in the attribute operation class corresponding to each attribute is obtained, and the attribute value in the result data stream is sequentially described according to the attribute description number. The order is read.
为了保证数据的完整性,本实施例的技术方案提供了一种优选实施方式,在优选方式下,在从所述结果数据流中读取出属性值后,将从所述结果数据流中读取出的属性值进行解压缩。In order to ensure the integrity of the data, the technical solution of the embodiment provides a preferred embodiment. In a preferred manner, after the attribute value is read from the result data stream, the result data stream is read from the result data stream. The extracted attribute values are decompressed.
在具体实施时,调用各个属性描述的所述属性操作类的in.readVarint()方法,读取序列化的数据对象相应属性的属性值,并将读取到的属性值进行解压缩。In a specific implementation, the in.readVarint() method of the attribute operation class described by each attribute is called, the attribute value of the corresponding attribute of the serialized data object is read, and the read attribute value is decompressed.
需要说明的是,在步骤S705中,所述根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类时,会出现以下2种情况:It should be noted that, in step S705, when the attribute operation class name provided by each attribute description in the metadata description file is obtained, and the attribute operation class corresponding to each attribute is obtained, the following two cases occur:
第一种情况,能在代码库中获取到与所述元数据描述文件中的各个属性描述提供的属性操作类名称且数目相同的属性操作类,说明所述本地数据对象与元数据描述文件的版本匹配,即:所述本地数据对象与所述元数据描述文件版本兼容,所以不会出现兼容性问题。In the first case, the attribute operation class with the same number of the attribute operation class name provided by each attribute description in the metadata description file can be obtained in the code library, and the local data object and the metadata description file are described. The version matches, ie the local data object is compatible with the metadata description file version, so no compatibility issues arise.
需要说明的是,在第一种情况中,有可能是代码库中的属性操作类的数目与名称均与所述元数据描述文件中各个属性描述描述的属性操作类相同;还有一种可能是,代码库中的属性操作类的数目大于所述元数据描述文件中各个属性描述描述的属性操作类,但是代码库中的属性操作类均包含所述元数据描述文件中各个属性描述描述的属性操作类,但是由于在序列化时,是按照所述元数据描述文件加载对应于所述元数据描述文件中的属性操作类名称的属性操作类,所以不会出现兼容性问题。It should be noted that, in the first case, it is possible that the number and name of the attribute operation classes in the code base are the same as the attribute operation classes described in the respective attribute descriptions in the metadata description file; The number of attribute operation classes in the code base is greater than the attribute operation class described in each attribute description file in the metadata description file, but the attribute operation class in the code library includes attributes described by each attribute description in the metadata description file. The operation class, but since the attribute operation class corresponding to the attribute operation class name in the metadata description file is loaded according to the metadata description file at the time of serialization, a compatibility problem does not occur.
第二种情况,只能在代码库中获取到部分与所述元数据描述文件中的各个属性描述提供的属性操作类名称相同的属性操作类,说明所述本地数据对象与元数据描述文件版本不匹配,即:元数据描述文件是较新版本,在序列化时会出现兼容性问题。In the second case, only the attribute operation class with the same name as the attribute operation class provided by each attribute description in the metadata description file can be obtained in the code library, indicating the local data object and the metadata description file version. Mismatch, ie the metadata description file is a newer version and compatibility issues occur during serialization.
为了满足反序列化时的元数据描述文件和本地数据对象的兼容性问题,本实施例的技术方案提供了一种优选实施方式,在优选方式下,具体包括步骤S707-1至S707-3,下面结合图9作进一步说明。In order to meet the compatibility problem between the metadata description file and the local data object in the deserialization, the technical solution of the present embodiment provides a preferred implementation manner. In a preferred manner, the method specifically includes steps S707-1 to S707-3. This will be further described below in conjunction with FIG.
请参考图9,其示出了根据本申请的实施例提供的反序列化时缺省值的丢弃方法的流程图。Please refer to FIG. 9 , which shows a flowchart of a method for discarding default values during deserialization according to an embodiment of the present application.
步骤S707-1,对于无法获得属性操作类的属性描述,根据该属性描述的属性类型,获取对应所述属性类型的缺省属性操作类。 In step S707-1, for the attribute description of the attribute operation class, the default attribute operation class corresponding to the attribute type is obtained according to the attribute type described by the attribute.
所述对于无法获得属性操作类的属性描述,根据该属性描述的属性类型,获取对应所述属性类型的缺省属性操作类,可以采用如下方式实现:从元数据描述文件中,确定无法获得属性操作类的属性描述,即:该条属性描述描述的属性操作类不存在,在所述本地数据对象中不存在对应该属性操作类的属性,获取该条属性描述的属性类型,并根据该属性描述的属性类型,获取对应所述属性类型的缺省属性操作类。For the attribute description that cannot obtain the attribute operation class, obtaining the default attribute operation class corresponding to the attribute type according to the attribute type described by the attribute may be implemented as follows: from the metadata description file, determining that the attribute cannot be obtained The attribute description of the operation class, that is, the attribute operation class described by the attribute description does not exist, the attribute corresponding to the attribute operation class does not exist in the local data object, and the attribute type described by the attribute is obtained, and according to the attribute The attribute type described, and obtain the default attribute operation class corresponding to the attribute type.
在本实施例中,所述属性类型,包括:整型,字符型,浮点型,字符串型等类型。In this embodiment, the attribute type includes: an integer type, a character type, a floating point type, a string type, and the like.
例如:获取的所述属性类型为VARINT,获取类型为DefaultVarintFieldDef的缺省属性操作类。For example, the obtained attribute type is VARINT, and the default attribute operation class of type DefaultVarintFieldDef is obtained.
步骤S707-2,获取所述缺省属性操作类提供的读取方法,按照属性描述序号的顺序读取所述结果数据流中的数据。In step S707-2, the reading method provided by the default attribute operation class is obtained, and the data in the result data stream is read in the order of the attribute description sequence number.
加载获取的所述缺省属性操作类,调用所述缺省属性操作类中封装的setter方法,读取出所述结果数据流中的属性值。Loading the obtained default attribute operation class, calling the setter method encapsulated in the default attribute operation class, and reading out the attribute value in the result data stream.
步骤S707-3,将读取的所述结果数据流中的数据丢弃。Step S707-3, discarding the data in the read result data stream.
需要说明的是,所述将读取的所述结果数据流中的数据丢弃,具体是指:将所述结果数据流中的属性值读取出之后,不进行写入,即:不将该属性值写入所述本地数据对象中。It should be noted that, the discarding the data in the read result data stream refers to: after the attribute value in the result data stream is read out, no writing is performed, that is, the data is not to be The attribute value is written to the local data object.
在具体实施时,在本步骤S707中,每从所述结果数据流中读取出一个属性值后,就将反序列化指针相应后移至下一个属性值的位置。In a specific implementation, in this step S707, after reading an attribute value from the result data stream, the deserialization pointer is correspondingly moved to the position of the next attribute value.
下面仍沿用上述对数据流反序列化的方法的具体例子,对本步骤的处理过程作进一步说明。The specific example of the above method for deserializing the data stream is still used below, and the processing of this step is further explained.
待写入属性值的本地数据对象为:The local data object to be written to the attribute value is:
Class User{Class User{
int userId;Int userId;
String name;String name;
int phone;Int phone;
}}
所述本地数据对象的元数据描述文件为:The metadata description file of the local data object is:
1:com.taobao.test.io.UserIdFieldDef:VARINT1:com.taobao.test.io.UserIdFieldDef:VARINT
2:com.taobao.test.io.NameFieldDef:VARINT2: com.taobao.test.io.NameFieldDef:VARINT
3:com.taobao.test.io.PhoneFieldDef:VARINT 3: com.taobao.test.io.PhoneFieldDef:VARINT
4:com.taobao.test.io.AgeFieldDef:VARINT4: com.taobao.test.io.AgeFieldDef:VARINT
在步骤S705中,获取到的属性操作类包括:UserIdFieldDef、NameFieldDef以及PhoneFieldDef,其中由于第四条属性描述未获取到与AgeFieldDef同名的属性操作类,所以获取第四条属性描述中的属性类型,即:获取VARINT类型,通过获取的VARINT类型,检索对应类型VARINT的缺省属性操作类DefaultVarintFieldDef,获取属性操作类DefaultVarintFieldDef后,按照元数据描述文件中属性描述的序号的顺序,分别执行UserIdFieldDef中的in.readVarint()方法读取所述结果数据流相应位置的数据1,并对该数据进行解压缩,将反序列化指针相应后移至下一个属性值的位置、执行NameFieldDef中的in.readVarint()方法读取所述结果数据流相应位置的数据aaa,并对该数据进行解压缩,将反序列化指针相应后移至下一个属性值的位置、执行PhoneFieldDef中的in.readVarint()方法读取所述结果数据流相应位置的数据0,并对该数据进行解压缩,将反序列化指针相应后移至下一个属性值的位置,以及执行DefaultVarintFieldDef中的in.readVarint()方法读取,对该属性值解压缩后丢弃属性值20。In step S705, the obtained attribute operation class includes: UserIdFieldDef, NameFieldDef, and PhoneFieldDef, wherein the attribute type in the fourth attribute description is obtained, because the attribute operation class having the same name as the AgeFieldDef is not acquired according to the fourth attribute description, that is, : Get the VARINT type, retrieve the default property operation class DefaultVarintFieldDef of the corresponding type VARINT by obtaining the VARINT type, obtain the property operation class DefaultVarintFieldDef, and execute the in. in the UserIdFieldDef according to the sequence number of the attribute description in the metadata description file. The readVarint() method reads the data 1 at the corresponding position of the result data stream, and decompresses the data, moves the deserialized pointer accordingly to the position of the next attribute value, and executes in.readVarint() in the NameFieldDef. The method reads the data aaa of the corresponding position of the result data stream, decompresses the data, moves the deserialized pointer to the position of the next attribute value, and executes the in.readVarint() method in the PhoneFieldDef. The result data stream corresponds to the data of the location 0, and the number Decompresses the in.readVarint deserialization pointer position corresponding to the next attribute value, and performing the DefaultVarintFieldDef () method reads, discarding 20 the attribute value attribute value after decompression.
以UserIdFieldDef和DefaultVarintFieldDef为例,详细代码示例如下所示:UserIdFieldDef:Take UserIdFieldDef and DefaultVarintFieldDef as examples. The detailed code example is as follows: UserIdFieldDef:
public class UserIdFieldDef<Item>implements FieldDef<T>{Public class UserIdFieldDef<Item>implements FieldDef<T>{
public void setter(User user,CodedInputStream in){Public void setter(User user,CodedInputStream in){
user.setUserId(in.readVarint());user.setUserId(in.readVarint());
}}
public void getter(User user,CodedOutputStream out){Public void getter(User user,CodedOutputStream out){
out.writeVarint(user.getUserId());out.writeVarint(user.getUserId());
}}
}}
DefaultVarintFieldDef:DefaultVarintFieldDef:
public class DefaultVarintFieldDef<Object>implements FieldDef<T>{Public class DefaultVarintFieldDef<Object>implements FieldDef<T>{
public void setter(Object o,CodedInputStream in){Public void setter(Object o,CodedInputStream in){
in.readVarint();in.readVarint();
}}
public void getter(Object o,CodedOutputStream out){Public void getter(Object o,CodedOutputStream out){
out.writeVarint(0);out.writeVarint(0);
}}
} }
执行不同的属性操作类时,只需修改对应的参数即可,对此不再赘述。When executing different attribute operation classes, you only need to modify the corresponding parameters, which will not be described here.
步骤S709,根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。Step S709: Write the read attribute values into the attributes of the local data objects corresponding to the respective attribute descriptions according to the writing method provided by the attribute operation class described by each attribute.
在具体实施时,将步骤S707中通过in.readVarint()方法读取的所述结果数据流中的属性值,对读取到的属性值进行解压缩后,按照属性描述序号通过setter方法写入对应的所述本地数据对象的属性中。In a specific implementation, the attribute value in the result data stream read by the in.readVarint() method in step S707 is decompressed, and then the attribute value is written according to the attribute description number by a setter method. Corresponding to the properties of the local data object.
例如,执行UserIdFieldDef中的user.setUserId(in.readVarint())将从所述结果数据流中读取到的属性值写入与userId相对应的所述本地数据对象的属性中For example, the user.setUserId(in.readVarint()) in the UserIdFieldDef is executed to write the attribute value read from the result data stream into the attribute of the local data object corresponding to the userId.
在上述的实施例中,提供了一种对数据流反序列化的方法,与上述对数据流反序列化的方法相对应的,本申请还提供了一种对数据流反序列化的装置。由于装置的实施例基本相似于方法的实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。下述描述的装置实施例仅仅是示意性的。所述对数据流反序列化的装置实施例如下:In the above embodiments, a method for deserializing a data stream is provided. Corresponding to the above method for deserializing a data stream, the present application further provides an apparatus for deserializing a data stream. Since the embodiment of the device is substantially similar to the embodiment of the method, the description is relatively simple, and the relevant portions can be referred to the description of the method embodiment. The device embodiments described below are merely illustrative. The apparatus for deserializing the data stream is implemented as follows:
请参考图10,其示出了根据本申请的实施例提供的对数据流反序列化的装置的示意图。Please refer to FIG. 10, which shows a schematic diagram of an apparatus for deserializing a data stream according to an embodiment of the present application.
所述对数据流反序列化的装置,包括:数据流获取单元1001、描述文件获取单元1003、属性操作类获取单元1005、属性值读取单元1007以及属性值写入单元1009;The device for deserializing the data stream includes: a data stream obtaining unit 1001, a description file acquiring unit 1003, an attribute operation class obtaining unit 1005, an attribute value reading unit 1007, and an attribute value writing unit 1009;
所述数据流获取单元1001,用于获取结果数据流;The data stream obtaining unit 1001 is configured to acquire a result data stream;
所述描述文件获取单元1003,用于获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;The description file obtaining unit 1003 is configured to acquire a metadata description file of the local data object, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object;
所述属性操作类获取单元1005,用于根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;The attribute operation class obtaining unit 1005 is configured to obtain, according to the attribute operation class name provided by each attribute description in the metadata description file, an attribute operation class corresponding to each attribute;
所述属性值读取单元1007,用于根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取;The attribute value reading unit 1007 is configured to sequentially read the attribute values in the result data stream according to the sequence of the attribute description sequence according to the reading method provided by the attribute operation class corresponding to each attribute;
所述属性值写入单元1009,用于根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。The attribute value writing unit 1009 is configured to write the read attribute value into the attribute of the local data object corresponding to each attribute description according to the writing method provided by the attribute operation class described by each attribute. in.
可选的,所述描述文件获取单元1003,获取的所述本地数据对象的元数据描述文件还包括属性类型。Optionally, the description file obtaining unit 1003, the obtained metadata description file of the local data object further includes an attribute type.
可选的,所述属性值读取单元1007包括:属性类型获取子单元、数据读取子单元以 及丢弃子单元;Optionally, the attribute value reading unit 1007 includes: an attribute type acquiring subunit, and a data reading subunit. And discarding subunits;
所述属性类型获取子单元,用于在所述根据各个属性描述的所述属性操作类提供的写入方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取之中,对于无法获得属性操作类的属性描述,根据该属性描述的属性类型,获取对应所述属性类型的缺省属性操作类;The attribute type obtaining subunit is configured to sequentially read the attribute values in the result data stream according to the sequence of the attribute description serial number in the writing method provided by the attribute operation class according to each attribute description. For the attribute description of the attribute operation class, the default attribute operation class corresponding to the attribute type is obtained according to the attribute type described by the attribute;
所述数据读取子单元,用于获取所述缺省属性操作类提供的读取方法,按照属性描述序号的顺序读取所述结果数据流中的数据;The data reading subunit is configured to acquire a reading method provided by the default attribute operation class, and read data in the result data stream according to an order of the attribute description sequence number;
所述丢弃单子元,用于将读取的所述结果数据流中的数据丢弃。The discarding a single sub-unit is configured to discard the data in the read result data stream.
可选的,所述描述文件获取单元1003,包括:本地数据对象名称获取子单元、结果数据流解析子单元、描述文件遍历子单元以及描述文件获取子单元;Optionally, the description file obtaining unit 1003 includes: a local data object name obtaining subunit, a result data stream parsing subunit, a description file traversing subunit, and a description file acquiring subunit;
所述本地数据对象名称获取子单元,用于获取所述本地数据对象的名称;The local data object name obtaining subunit is configured to acquire a name of the local data object;
所述结果数据流解析子单元,用于解析所述结果数据流,获取所述结果数据流中的第一个值;The result data stream parsing subunit is configured to parse the result data stream to obtain a first value in the result data stream;
所述描述文件遍历子单元,用于根据所述本地数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述本地数据对象设置的元数据描述文件;The description file traversing subunits for traversing a metadata description file set for the local data object in a metadata repository in which the metadata description file is stored according to the name of the local data object;
所述描述文件获取子单元,用于在遍历过程中,获取与所述本地数据对象的名称相同且版本号与所述结果数据流中的第一个值相同的所述本地数据对象的元数据描述文件。The description file obtaining subunit, configured to acquire metadata of the local data object having the same name as the local data object and having the same version number as the first value in the result data stream during the traversal process Description file.
可选的,所述对数据流反序列化的装置,还包括:属性值解压缩单元;Optionally, the device for deserializing the data stream further includes: an attribute value decompression unit;
所述属性值解压缩单元,用于在所述根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取的之后,将从所述结果数据流中读取出的属性值进行解压缩。The attribute value decompressing unit is configured to sequentially read the attribute values in the result data stream according to the order of the attribute description sequence in the reading method provided by the attribute operation class corresponding to each attribute, and then The attribute values read from the result data stream are decompressed.
在上述的实施例中,提供了一种对数据对象序列化的方法、一种对数据对象序列化的装置、一种电子设备、一种对数据流反序列化的方法以及一种对数据流反序列化的装置,此外,本申请还提供了又一种电子设备;所述电子设备实施例如下:In the above embodiments, a method for serializing a data object, a device for serializing a data object, an electronic device, a method for deserializing a data stream, and a pair of data streams are provided The apparatus for deserialization, in addition, the present application also provides yet another electronic device; the electronic device implementation is as follows:
请参考图11,其示出了根据本申请的实施例提供的电子设备的示意图。Please refer to FIG. 11 , which shows a schematic diagram of an electronic device provided in accordance with an embodiment of the present application.
所述电子设备,包括:显示器1101;处理器1103;存储器1105;The electronic device includes: a display 1101; a processor 1103; a memory 1105;
所述存储器1105,用于存储反序列化程序,所述程序在被所述处理器读取执行时,执行如下操作:获取结果数据流,获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称,根 据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类,根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取,根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。The memory 1105 is configured to store a deserialization program, where the program, when being read and executed by the processor, performs an operation of: acquiring a result data stream, acquiring a metadata description file of the local data object, The metadata description file includes an attribute description identified by a sequence number and an attribute operation class name corresponding to the attribute in the data object, the root According to the attribute operation class name provided by each attribute description in the metadata description file, the attribute operation class corresponding to each attribute is obtained, and the read data provided by the attribute operation class corresponding to each attribute is sequentially used in the result data stream. The attribute values are read in the order of the attribute description sequence numbers, and the read attribute values are written into the local data objects corresponding to the respective attribute descriptions according to the writing method provided by the attribute operation class described by each attribute. In the attribute.
在上述的实施例中,提供了一种对数据对象序列化的方法、一种对数据对象序列化的装置、一种电子设备、一种对数据流反序列化的方法、一种对数据流反序列化的装置以及又一种电子设备,此外,本申请还提供了一种序列化与反序列化系统;所述序列化与反序列化系统实施例如下:In the above embodiments, a method for serializing a data object, a device for serializing a data object, an electronic device, a method for deserializing a data stream, and a pair of data streams are provided. Deserializing device and yet another electronic device, in addition, the present application also provides a serialization and deserialization system; the serialization and deserialization system implementation is as follows:
请参考图12,示出了根据本申请的实施例提供的序列化与反序列化系统的示意图。Referring to Figure 12, a schematic diagram of a serialization and deserialization system provided in accordance with an embodiment of the present application is shown.
所述序列化与反序列化系统包括:对数据对象序列化的装置1201以及对数据流反序列化的装置1203;The serialization and deserialization system includes: a device 1201 for serializing a data object and a device 1203 for deserializing the data stream;
其中,所述对数据对象序列化的装置1201,用于获取元数据描述文件,根据所述元数据描述文件获取对应各个属性的属性操作类,读取待序列化的数据对象中分别与各个属性描述对应的属性值,并将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流;The device 1201 for serializing the data object is configured to obtain a metadata description file, obtain an attribute operation class corresponding to each attribute according to the metadata description file, and read each attribute and each attribute of the data object to be serialized. Describe the corresponding attribute value, and write the read attribute value to the result data stream of the data object in the order of the attribute description sequence number;
所述对数据流反序列化的装置1203,用于获取结果数据流,获取元数据描述文件,根据所述元数据描述文件获取对应各个属性的属性操作类,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取,并将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。The device 1203 for deserializing the data stream is configured to acquire a result data stream, obtain a metadata description file, obtain an attribute operation class corresponding to each attribute according to the metadata description file, and sequentially perform the attribute data stream in the result data stream. The attribute values are read in the order of the attribute description sequence numbers, and the read attribute values are written in the attributes of the local data objects corresponding to the respective attribute descriptions.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。The memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory. Memory is an example of a computer readable medium.
1、计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁 带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括非暂存电脑可读媒体(transitory media),如调制的数据信号和载波。1. Computer readable media including both permanent and non-persistent, removable and non-removable media may be implemented by any method or technology. The information can be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic box magnetic A tape, magnetic tape storage or other magnetic storage device or any other non-transportable medium can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media, such as modulated data signals and carrier waves.
2、本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。2. Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, system, or computer program product. Thus, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment in combination of software and hardware. Moreover, the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本申请虽然以较佳实施例公开如上,但其并不是用来限定本申请,任何本领域技术人员在不脱离本申请的精神和范围内,都可以做出可能的变动和修改,因此本申请的保护范围应当以本申请权利要求所界定的范围为准。 The present application is disclosed in the above preferred embodiments, but it is not intended to limit the present application, and any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. The scope of protection should be based on the scope defined by the claims of the present application.

Claims (29)

  1. 一种对数据对象序列化的方法,其特征在于,包括:A method for serializing data objects, comprising:
    获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;Obtaining a metadata description file of the data object to be serialized, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to the attribute in the data object;
    根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;Obtaining, according to the attribute operation class name provided by each attribute description in the metadata description file, an attribute operation class corresponding to each attribute;
    根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值;Reading the attribute values corresponding to the respective attribute descriptions in the data objects to be serialized according to the reading methods provided by the attribute operation classes corresponding to the respective attributes;
    将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。The read attribute values are written to the result data stream of the data object in the order of the attribute description sequence number, and the result data stream is used as a serialization result of the data object.
  2. 根据权利要求1所述的对数据对象序列化的方法,其特征在于,所述属性描述,还包括:属性类型。The method for serializing data objects according to claim 1, wherein the attribute description further comprises: an attribute type.
  3. 根据权利要求2所述的对数据对象序列化的方法,其特征在于,在所述读取待序列化的数据对象中分别与各个属性描述对应的属性值的步骤之后,包括:The method for serializing a data object according to claim 2, wherein after the step of reading the attribute value corresponding to each attribute description in the data object to be serialized, the method includes:
    获取由于无法获取对应属性的属性操作类而无法读取的属性描述的属性类型;Gets the attribute type of the attribute description that cannot be read because the attribute operation class of the corresponding attribute cannot be obtained;
    根据所述属性类型,检索获得对应所述属性类型的缺省属性操作类;Determining, according to the attribute type, a default attribute operation class corresponding to the attribute type;
    根据所述缺省属性操作类,为该属性描述对应的属性赋予预先确定的缺省值。According to the default attribute operation class, the corresponding attribute is given a predetermined default value for the attribute description.
  4. 根据权利要求1所述的对数据对象序列化的方法,其特征在于,所述获取待序列化的数据对象的元数据描述文件是:The method for serializing a data object according to claim 1, wherein the metadata description file of the data object to be serialized is:
    根据所述待序列化的数据对象的名称,从元数据仓库中查找对应所述待序列化的数据对象且版本号数值最大的所述待序列化的数据对象的元数据描述文件。And searching, according to the name of the data object to be serialized, a metadata description file of the data object to be serialized corresponding to the data object to be serialized and having the largest version number value from the metadata repository.
  5. 根据权利要求4所述的对数据对象序列化的方法,其特征在于,在所述将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流的步骤之前,包括:The method for serializing data objects according to claim 4, wherein before said step of writing the read attribute values into the result data stream of said data object in the order of attribute description numbers, :
    读取所述待序列化的数据对象的元数据描述文件的版本号,并将其写入到所述待序列化的数据对象的结果数据流的头部。Reading a version number of the metadata description file of the data object to be serialized and writing it to the head of the result data stream of the data object to be serialized.
  6. 根据权利要求1所述的对数据对象序列化的方法,其特征在于,在所述获取待序列化的数据对象的元数据描述文件的步骤之前,还包括:The method for serializing data objects according to claim 1, wherein before the step of acquiring the metadata description file of the data object to be serialized, the method further comprises:
    接收对所述待序列化的数据对象的属性的修改操作;所述修改操作包括:对所述待序列化的数据对象的属性进行增加、删除或者变更; Receiving a modification operation on an attribute of the data object to be serialized; the modifying operation includes: adding, deleting, or changing an attribute of the data object to be serialized;
    基于对所述待序列化的数据对象的修改操作为所述待序列化的数据对象的新增属性创建属性操作类;Creating an attribute operation class for the newly added attribute of the data object to be serialized based on the modification operation of the data object to be serialized;
    根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更。A new version of the metadata description file is created according to the modification operation, and the attribute description in the metadata description file is changed according to the modification operation based on the attribute description in the original version metadata description file.
  7. 根据权利要求6所述的对数据对象序列化的方法,其特征在于,在所述根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更的步骤之后,包括:The method for serializing data objects according to claim 6, wherein in the modifying operation, a new version of the metadata description file is created, and the attribute description in the metadata description file is described in the original version metadata. After the steps of the attribute description in the file are changed according to the modification operation, including:
    根据所述待序列化的数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述待序列化的数据对象设置的元数据描述文件;And traversing a metadata description file set for the data object to be serialized in a metadata repository storing the metadata description file according to the name of the data object to be serialized;
    在遍历过程中,获取在所述元数据仓库中的所述待序列化的数据对象的元数据描述文件的版本号最大的数值;Obtaining, in the traversing process, a value having a maximum version number of the metadata description file of the data object to be serialized in the metadata repository;
    将所述数值加一,并将加一后的所述数值作为新版本的元数据描述文件的版本号;Adding the value to one, and adding the added value as the version number of the new version of the metadata description file;
    将所述记录有版本号的所述元数据描述文件保存在所述元数据仓库中。The metadata description file in which the version number is recorded is saved in the metadata repository.
  8. 根据权利要求1所述的对数据对象序列化的方法,其特征在于,在所述根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值的步骤之后,包括:The method for serializing a data object according to claim 1, wherein in the reading method provided by the attribute operation class corresponding to each attribute, reading the data object to be serialized and each attribute description After the steps corresponding to the attribute values, include:
    将读取到的属性值进行压缩。The read attribute values are compressed.
  9. 一种对数据对象序列化的装置,其特征在于,包括:描述文件获取单元、属性操作类获取单元、属性读取单元以及序列化写入单元;An apparatus for serializing a data object, comprising: a description file acquisition unit, an attribute operation class acquisition unit, an attribute reading unit, and a serialization writing unit;
    所述描述文件获取单元,用于获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;The description file obtaining unit is configured to acquire a metadata description file of the data object to be serialized, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object;
    所述属性操作类获取单元,用于根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;The attribute operation class obtaining unit is configured to obtain an attribute operation class name corresponding to each attribute according to the attribute operation class name provided by each attribute description in the metadata description file;
    所述属性读取单元,用于根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值;The attribute reading unit is configured to read, according to a reading method provided by the attribute operation class corresponding to each attribute, an attribute value corresponding to each attribute description in the data object to be serialized;
    所述序列化写入单元,用于将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。The serialization writing unit is configured to write the read attribute values into the result data stream of the data object in the order of the attribute description sequence number, and the result data stream is used as a serialization result of the data object.
  10. 根据权利要求9所述的对数据对象序列化的装置,其特征在于,所述描述文件获取单元获取的所述待序列化的数据对象的元数据描述文件还包括属性类型。 The apparatus for serializing a data object according to claim 9, wherein the metadata description file of the data object to be serialized acquired by the description file obtaining unit further includes an attribute type.
  11. 根据权利要求10所述的对数据对象序列化的装置,其特征在于,所述属性读取单元,还包括:属性类型读取子单元、缺省属性操作类获取子单元以及缺省值读取子单元;The apparatus for serializing data objects according to claim 10, wherein the attribute reading unit further comprises: an attribute type reading subunit, a default attribute operation class obtaining subunit, and a default value reading. Subunit
    所述属性类型读取子单元,用于读取待序列化的数据对象中分别与各个属性描述对应的属性值之后,获取由于无法获取对应属性的属性操作类而无法读取的属性描述的属性类型;The attribute type reading subunit is configured to read an attribute value corresponding to each attribute description in the data object to be serialized, and obtain an attribute description attribute that cannot be read because the attribute operation class of the corresponding attribute cannot be obtained. Types of;
    所述缺省属性操作类获取子单元,用于根据所述属性类型,检索获得对应所述属性类型的缺省属性操作类;The default attribute operation class acquisition sub-unit is configured to retrieve, according to the attribute type, a default attribute operation class corresponding to the attribute type;
    所述缺省值读取子单元,用于根据所述缺省属性操作类,为该属性描述对应的属性赋予预先确定的缺省值。The default value reading subunit is configured to assign a predetermined default value to the corresponding attribute of the attribute description according to the default attribute operation class.
  12. 根据权利要求9所述的对数据对象序列化的装置,其特征在于,所述描述文件获取单元具体用于根据所述待序列化的数据对象的名称,从元数据仓库中查找对应所述待序列化的数据对象且版本号数值最大的所述待序列化的数据对象的元数据描述文件。The apparatus for serializing a data object according to claim 9, wherein the description file obtaining unit is specifically configured to: search for a corresponding to the waiting from the metadata repository according to the name of the data object to be serialized A metadata description file of the serialized data object and the serial number value of the data object to be serialized.
  13. 根据权利要求12所述的对数据对象序列化的装置,其特征在于,所述序列化写入单元,还包括:版本号写入子单元;The apparatus for serializing a data object according to claim 12, wherein the serialization writing unit further comprises: a version number writing subunit;
    所述版本号写入子单元,用于在所述将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流之前,读取所述待序列化的数据对象的元数据描述文件的版本号,并将其写入到所述待序列化的数据对象的结果数据流的头部。The version number is written into the subunit, and is configured to read the data object to be serialized before the attribute value to be read is written into the result data stream of the data object in the order of the attribute description sequence number. The metadata describes the version number of the file and writes it to the head of the resulting data stream of the data object to be serialized.
  14. 根据权利要求9所述的对数据对象序列化的装置,其特征在于,还包括:修改操作接收单元、操作类创建单元以及描述文件创建单元;The apparatus for serializing a data object according to claim 9, further comprising: a modification operation receiving unit, an operation class creation unit, and a description file creation unit;
    所述修改操作接收单元,用于在所述获取待序列化的数据对象的元数据描述文件之前,接收对所述待序列化的数据对象的属性的修改操作;所述修改操作包括:对所述待序列化的数据对象的属性进行增加、删除或者变更;The modifying operation receiving unit is configured to receive, before the acquiring the metadata description file of the data object to be serialized, a modification operation on the attribute of the data object to be serialized; the modifying operation includes: Adding, deleting, or changing the attributes of the serialized data object;
    所述操作类创建单元,用于基于对所述待序列化的数据对象的修改操作为所述待序列化的数据对象的新增属性创建属性操作类;The operation class creation unit is configured to create an attribute operation class for the newly added attribute of the data object to be serialized based on the modification operation of the data object to be serialized;
    所述描述文件创建单元,用于根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更。a description file creation unit, configured to create a new version of the metadata description file according to the modification operation, where the attribute description in the metadata description file is based on the attribute description in the original version metadata description file, according to the modification operation The change was made.
  15. 根据权利要求14所述的对数据对象序列化的装置,其特征在于,还包括:遍 历单元、数值获取单元、版本号生成单元以及保存单元;The apparatus for serializing data objects according to claim 14, further comprising: Calendar unit, value acquisition unit, version number generation unit, and save unit;
    所述遍历单元,用于在所述根据所述修改操作创建新版本的元数据描述文件,该元数据描述文件中的属性描述在原版本元数据描述文件中的属性描述的基础上根据所述修改操作进行了变更之后,根据所述待序列化的数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述待序列化的数据对象设置的元数据描述文件;The traversing unit is configured to create a new version of the metadata description file according to the modification operation, where the attribute description in the metadata description file is based on the attribute description in the original version metadata description file, according to the modification After the operation is changed, the metadata description file set for the data object to be serialized is traversed in the metadata repository storing the metadata description file according to the name of the data object to be serialized;
    所述数值获取单元,用于在遍历过程中,获取在所述元数据仓库中的所述待序列化的数据对象的元数据描述文件的版本号最大的数值;The value obtaining unit is configured to acquire, during the traversal process, a maximum value of a version number of the metadata description file of the data object to be serialized in the metadata repository;
    所述版本号生成单元,用于将所述数值加一,并将加一后的所述数值作为新版本的元数据描述文件的版本号;The version number generating unit is configured to add the value by one, and use the added value as the version number of the metadata version file of the new version;
    所述保存单元,用于将所述记录有版本号的所述元数据描述文件保存在所述元数据仓库中。The saving unit is configured to save the metadata description file with the version number recorded in the metadata repository.
  16. 根据权利要求9所述的对数据对象序列化的装置,其特征在于,还包括:属性值压缩单元;The apparatus for serializing data objects according to claim 9, further comprising: an attribute value compression unit;
    所述属性值压缩单元,用于根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值之后,将读取到的属性值进行压缩。The attribute value compression unit is configured to read the attribute value after the attribute value corresponding to each attribute description in the data object to be serialized according to the reading method provided by the attribute operation class corresponding to each attribute Compress.
  17. 一种电子设备,其特征在于,所述电子设备包括:An electronic device, comprising:
    显示器;monitor;
    处理器;processor;
    存储器,用于存储序列化程序,所述程序在被所述处理器读取执行时,执行如下操作:获取待序列化的数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;根据对应各个属性的属性操作类提供的读取方法,读取待序列化的数据对象中分别与各个属性描述对应的属性值;将读取到的属性值按照属性描述序号的顺序写入所述数据对象的结果数据流,所述结果数据流作为所述数据对象的序列化结果。a memory for storing a serialization program, the program, when being read and executed by the processor, performing an operation of: acquiring a metadata description file of a data object to be serialized, where the metadata description file includes a serial number identifier The attribute description and the attribute operation class name corresponding to the attribute in the data object; the attribute operation class name provided according to each attribute description in the metadata description file, and the attribute operation class corresponding to each attribute are obtained; according to the corresponding attribute The reading method provided by the attribute operation class reads the attribute value corresponding to each attribute description in the data object to be serialized; and writes the read attribute value into the result data of the data object in the order of the attribute description serial number. Flow, the resulting data stream as a serialization result of the data object.
  18. 一种对数据流反序列化的方法,其特征在于,包括:A method for deserializing a data stream, comprising:
    获取结果数据流;Obtaining a result data stream;
    获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称; Obtaining a metadata description file of the local data object, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object;
    根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;Obtaining, according to the attribute operation class name provided by each attribute description in the metadata description file, an attribute operation class corresponding to each attribute;
    根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取;According to the reading method provided by the attribute operation class corresponding to each attribute, the attribute values in the result data stream are sequentially read in the order of the attribute description sequence number;
    根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。The read attribute values are written into the attributes of the local data object corresponding to the respective attribute descriptions according to the write method provided by the attribute operation class described by each attribute.
  19. 根据权利要求18所述的对数据流反序列化的方法,其特征在于,所述属性描述,还包括:属性类型。The method for deserializing a data stream according to claim 18, wherein the attribute description further comprises: an attribute type.
  20. 根据权利要求19所述的对数据流反序列化的方法,其特征在于,在所述根据各个属性描述的所述属性操作类提供的写入方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取的步骤之中,还包括:The method for deserializing a data stream according to claim 19, wherein the attribute value in the result data stream is sequentially sequentially performed in the writing method provided by the attribute operation class described according to each attribute Among the steps of reading in the order of the attribute description serial number, it also includes:
    对于无法获得属性操作类的属性描述,根据该属性描述的属性类型,获取对应所述属性类型的缺省属性操作类;For the attribute description of the attribute operation class, the default attribute operation class corresponding to the attribute type is obtained according to the attribute type described by the attribute;
    获取所述缺省属性操作类提供的读取方法,按照属性描述序号的顺序读取所述结果数据流中的数据;Obtaining the reading method provided by the default attribute operation class, and reading the data in the result data stream according to the sequence of the attribute description sequence number;
    将读取的所述结果数据流中的数据丢弃。The data in the result data stream read is discarded.
  21. 根据权利要求18所述的对数据流反序列化的方法,其特征在于,所述获取所述本地数据对象的元数据描述文件包括:The method for deserializing a data stream according to claim 18, wherein the obtaining the metadata description file of the local data object comprises:
    获取所述本地数据对象的名称;Obtaining the name of the local data object;
    解析所述结果数据流,获取所述结果数据流中的第一个值;Parsing the result data stream to obtain a first value in the result data stream;
    根据所述本地数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述本地数据对象设置的元数据描述文件;And traversing a metadata description file set for the local data object in a metadata repository storing the metadata description file according to the name of the local data object;
    在遍历过程中,获取与所述本地数据对象的名称相同且版本号与所述结果数据流中的第一个值相同的所述本地数据对象的元数据描述文件。In the traversal process, a metadata description file of the local data object having the same name as the local data object and having the same version number as the first value in the result data stream is obtained.
  22. 根据权利要求18所述的对数据流反序列化的方法,其特征在于,在所述根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取的步骤之后,包括:The method for deserializing a data stream according to claim 18, wherein, in the reading method provided by the attribute operation class corresponding to each attribute, the attribute values in the result data stream are sequentially attributed according to the attribute After the step of describing the sequential reading of the serial numbers, includes:
    将从所述结果数据流中读取出的属性值进行解压缩。The attribute values read from the resulting data stream are decompressed.
  23. 一种对数据流反序列化的装置,其特征在于,包括:数据流获取单元、描述文件获取单元、属性操作类获取单元、属性值读取单元以及属性值写入单元; An apparatus for deserializing a data stream, comprising: a data stream obtaining unit, a description file acquiring unit, an attribute operation class acquiring unit, an attribute value reading unit, and an attribute value writing unit;
    所述数据流获取单元,用于获取结果数据流;The data stream obtaining unit is configured to obtain a result data stream;
    所述描述文件获取单元,用于获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称;The description file obtaining unit is configured to acquire a metadata description file of the local data object, where the metadata description file includes an attribute description identified by a serial number and an attribute operation class name corresponding to an attribute in the data object;
    所述属性操作类获取单元,用于根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类;The attribute operation class obtaining unit is configured to obtain an attribute operation class name corresponding to each attribute according to the attribute operation class name provided by each attribute description in the metadata description file;
    所述属性值读取单元,用于根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取;The attribute value reading unit is configured to sequentially read the attribute values in the result data stream according to the sequence of the attribute description sequence according to the reading method provided by the attribute operation class corresponding to each attribute;
    所述属性值写入单元,用于根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。The attribute value writing unit is configured to write the read attribute value into the attribute of the local data object corresponding to each attribute description according to the writing method provided by the attribute operation class described by each attribute .
  24. 根据权利要求23所述的对数据流反序列化的装置,其特征在于,所述描述文件获取单元,获取的所述本地数据对象的元数据描述文件还包括属性类型。The apparatus for deserializing a data stream according to claim 23, wherein the description file obtaining unit acquires the metadata description file of the local data object further includes an attribute type.
  25. 根据权利要求24所述的对数据流反序列化的装置,其特征在于,所述属性值读取单元包括:属性类型获取子单元、数据读取子单元以及丢弃子单元;The device for deserializing a data stream according to claim 24, wherein the attribute value reading unit comprises: an attribute type obtaining subunit, a data reading subunit, and a discarding subunit;
    所述属性类型获取子单元,用于在所述根据各个属性描述的所述属性操作类提供的写入方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取之中,对于无法获得属性操作类的属性描述,根据该属性描述的属性类型,获取对应所述属性类型的缺省属性操作类;The attribute type obtaining subunit is configured to sequentially read the attribute values in the result data stream according to the sequence of the attribute description serial number in the writing method provided by the attribute operation class according to each attribute description. For the attribute description of the attribute operation class, the default attribute operation class corresponding to the attribute type is obtained according to the attribute type described by the attribute;
    所述数据读取子单元,用于获取所述缺省属性操作类提供的读取方法,按照属性描述序号的顺序读取所述结果数据流中的数据;The data reading subunit is configured to acquire a reading method provided by the default attribute operation class, and read data in the result data stream according to an order of the attribute description sequence number;
    所述丢弃单子元,用于将读取的所述结果数据流中的数据丢弃。The discarding a single sub-unit is configured to discard the data in the read result data stream.
  26. 根据权利要求23所述的对数据流反序列化的装置,其特征在于,所述描述文件获取单元,包括:本地数据对象名称获取子单元、结果数据流解析子单元、描述文件遍历子单元以及描述文件获取子单元;The apparatus for deserializing a data stream according to claim 23, wherein the description file obtaining unit comprises: a local data object name obtaining subunit, a result data stream parsing subunit, a description file traversing subunit, and Descriptive file acquisition subunit;
    所述本地数据对象名称获取子单元,用于获取所述本地数据对象的名称;The local data object name obtaining subunit is configured to acquire a name of the local data object;
    所述结果数据流解析子单元,用于解析所述结果数据流,获取所述结果数据流中的第一个值;The result data stream parsing subunit is configured to parse the result data stream to obtain a first value in the result data stream;
    所述描述文件遍历子单元,用于根据所述本地数据对象的名称,在存有元数据描述文件的元数据仓库中遍历针对所述本地数据对象设置的元数据描述文件;The description file traversing subunits for traversing a metadata description file set for the local data object in a metadata repository in which the metadata description file is stored according to the name of the local data object;
    所述描述文件获取子单元,用于在遍历过程中,获取与所述本地数据对象的名称相 同且版本号与所述结果数据流中的第一个值相同的所述本地数据对象的元数据描述文件。The description file obtaining subunit is configured to acquire a name of the local data object during the traversal process And a metadata description file of the local data object having the same version number as the first value in the result data stream.
  27. 根据权利要求23所述的对数据流反序列化的装置,其特征在于,还包括:属性值解压缩单元;The apparatus for deserializing a data stream according to claim 23, further comprising: an attribute value decompression unit;
    所述属性值解压缩单元,用于在所述根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取的之后,将从所述结果数据流中读取出的属性值进行解压缩。The attribute value decompressing unit is configured to sequentially read the attribute values in the result data stream according to the order of the attribute description sequence in the reading method provided by the attribute operation class corresponding to each attribute, and then The attribute values read from the result data stream are decompressed.
  28. 一种电子设备,其特征在于,所述电子设备包括:An electronic device, comprising:
    显示器;monitor;
    处理器;processor;
    存储器,用于存储反序列化程序,所述程序在被所述处理器读取执行时,执行如下操作:获取结果数据流,获取所述本地数据对象的元数据描述文件,所述元数据描述文件包含以序号标识的属性描述以及对应所述数据对象中属性的属性操作类名称,根据所述元数据描述文件中的各个属性描述提供的属性操作类名称,获取对应各个属性的属性操作类,根据对应各个属性的属性操作类提供的读取方法,依次将所述结果数据流中的属性值按照属性描述序号的顺序读取,根据各个属性描述的所述属性操作类提供的写入方法,将读取到的属性值写入与各个属性描述相对应的所述本地数据对象的属性中。a memory for storing a deserialization program, the program, when being read and executed by the processor, performing an operation of: acquiring a result data stream, acquiring a metadata description file of the local data object, the metadata description The file includes an attribute description identified by a sequence number and an attribute operation class name corresponding to the attribute in the data object, and an attribute operation class name corresponding to each attribute description in the metadata description file is obtained, and an attribute operation class corresponding to each attribute is obtained, According to the reading method provided by the attribute operation class corresponding to each attribute, the attribute values in the result data stream are sequentially read in the order of the attribute description sequence number, and the writing method provided by the attribute operation class according to each attribute description is The read attribute values are written into the attributes of the local data object corresponding to the respective attribute descriptions.
  29. 一种序列化与反序列化系统,其特征在于,所述系统包括:A serialization and deserialization system, characterized in that the system comprises:
    根据上述权利要求9至16中任一项所述的对数据对象序列化的装置;以及根据权利要求23至27中任一项所述的对数据流反序列化的装置。 Apparatus for serializing data objects according to any one of claims 9 to 16; and apparatus for deserializing a data stream according to any one of claims 23 to 27.
PCT/CN2016/101448 2015-10-10 2016-10-08 Methods, apparatus, and system for serialization and deserialization, and electronic devices WO2017059798A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510650688.2 2015-10-10
CN201510650688.2A CN106570018B (en) 2015-10-10 2015-10-10 Serialization and deserialization method, device and system and electronic equipment

Publications (1)

Publication Number Publication Date
WO2017059798A1 true WO2017059798A1 (en) 2017-04-13

Family

ID=58487676

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/101448 WO2017059798A1 (en) 2015-10-10 2016-10-08 Methods, apparatus, and system for serialization and deserialization, and electronic devices

Country Status (2)

Country Link
CN (1) CN106570018B (en)
WO (1) WO2017059798A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108733744A (en) * 2018-04-02 2018-11-02 东方视界科技(北京)有限公司 Data storage, read method and device
CN109359144A (en) * 2018-08-24 2019-02-19 中国建设银行股份有限公司 Date storage method and system, device and storage medium
CN116301666A (en) * 2023-05-17 2023-06-23 杭州数云信息技术有限公司 Java object serialization method, java object deserialization device and terminal

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107273654B (en) * 2017-04-27 2021-04-09 广州慧扬健康科技有限公司 Storage optimization system for electronic medical record forms
CN107341262B (en) * 2017-07-14 2020-01-21 上海达梦数据库有限公司 Serialization and deserialization method and device for object type column in database
CN107451237B (en) * 2017-07-26 2020-09-15 阿里巴巴集团控股有限公司 Serialization and deserialization method, device and equipment
CN107463668B (en) * 2017-08-02 2019-03-26 湖南新航动力信息科技有限公司 Method and device, computer equipment and the storage medium of serializing and unserializing
CN109460304B (en) * 2017-09-06 2022-06-03 阿里巴巴集团控股有限公司 Cross-application notification display and notification content packaging method and device
CN109558251B (en) * 2017-09-26 2021-04-30 北京京东尚科信息技术有限公司 Method and terminal for modifying page structure information
CN108153896B (en) * 2018-01-08 2020-07-10 第四范式(北京)技术有限公司 Processing method and device for input data and output data
CN109947739B (en) * 2018-05-31 2021-10-15 新华三大数据技术有限公司 Data source management method and device
CN110895530A (en) * 2018-09-11 2020-03-20 北京奇虎科技有限公司 Data storage method, partition server and electronic equipment
CN109636884A (en) * 2018-10-25 2019-04-16 阿里巴巴集团控股有限公司 Animation processing method, device and equipment
CN110515893B (en) * 2019-07-26 2022-12-09 济南浪潮数据技术有限公司 Data storage method, device, equipment and computer readable storage medium
CN111563123B (en) * 2020-05-07 2023-08-22 北京首汽智行科技有限公司 Real-time synchronization method for hive warehouse metadata
CN113553033B (en) * 2021-06-24 2022-04-19 厦门正航软件科技有限公司 Object serialization and deserialization method, device and computer readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040064825A1 (en) * 2002-09-30 2004-04-01 Timothy Lim Method and system for object system interoperability
CN101477532A (en) * 2008-12-23 2009-07-08 北京畅游天下网络技术有限公司 Method, apparatus and system for implementing data storage and access
CN104360865A (en) * 2014-11-28 2015-02-18 中国建设银行股份有限公司 Serialization method, deserialization method and related equipment
CN104850565A (en) * 2014-02-19 2015-08-19 北京京东尚科信息技术有限公司 Metadata management method based on K-V storage system
CN104899316A (en) * 2015-06-17 2015-09-09 北京奇虎科技有限公司 Game data serialization and deserialization processing method and device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7191196B2 (en) * 2001-06-28 2007-03-13 International Business Machines Corporation Method and system for maintaining forward and backward compatibility in flattened object streams
CN102004633B (en) * 2009-09-03 2013-04-24 阿里巴巴集团控股有限公司 Method and device for processing control property
CN101661391B (en) * 2009-09-24 2013-08-28 金蝶软件(中国)有限公司 Object serializing method, object deserializing method, device and system
CN101794225A (en) * 2010-02-26 2010-08-04 南京师范大学 GML analytic method based on GDOM and persistence thereof
CN102495757A (en) * 2011-11-15 2012-06-13 深圳市融创天下科技股份有限公司 Optimization method applicable to JAVA remote invocation object transfer and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040064825A1 (en) * 2002-09-30 2004-04-01 Timothy Lim Method and system for object system interoperability
CN101477532A (en) * 2008-12-23 2009-07-08 北京畅游天下网络技术有限公司 Method, apparatus and system for implementing data storage and access
CN104850565A (en) * 2014-02-19 2015-08-19 北京京东尚科信息技术有限公司 Metadata management method based on K-V storage system
CN104360865A (en) * 2014-11-28 2015-02-18 中国建设银行股份有限公司 Serialization method, deserialization method and related equipment
CN104899316A (en) * 2015-06-17 2015-09-09 北京奇虎科技有限公司 Game data serialization and deserialization processing method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108733744A (en) * 2018-04-02 2018-11-02 东方视界科技(北京)有限公司 Data storage, read method and device
CN109359144A (en) * 2018-08-24 2019-02-19 中国建设银行股份有限公司 Date storage method and system, device and storage medium
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

Also Published As

Publication number Publication date
CN106570018A (en) 2017-04-19
CN106570018B (en) 2021-01-15

Similar Documents

Publication Publication Date Title
WO2017059798A1 (en) Methods, apparatus, and system for serialization and deserialization, and electronic devices
EP3113043B1 (en) Method, device and host for updating metadata stored in columns in distributed file system
JP5376696B2 (en) Document synchronization via stateless protocol
JP6248182B2 (en) File management using placeholders
KR102128138B1 (en) Hydration and dehydration with placeholders
US11074225B2 (en) Synchronization of index copies in an LSM tree file system
CN109710185B (en) Data processing method and device
CN103595797B (en) Caching method for distributed storage system
US9940353B2 (en) Relationship serialization and reconstruction for entities
US20130067237A1 (en) Providing random access to archives with block maps
US20070124302A1 (en) Mapping a Source File From a Source System To a Target System
US20070156778A1 (en) File indexer
CN108388613B (en) Cache data updating method
US9292549B2 (en) Method and system for index serialization
US20110246451A1 (en) Storage device having full-text search function
Zhai et al. Hadoop perfect file: A fast and memory-efficient metadata access archive file to face small files problem in hdfs
WO2017084520A1 (en) Method and apparatus for synchronizing data files in a cloud environment
CN105404653B (en) A kind of implementation method of full distributed file index and collaborative editing mechanism
CN114117992A (en) Serialization and deserialization method and device and electronic equipment
CN113177095A (en) Enterprise knowledge management method, system, electronic equipment and storage medium
US9201937B2 (en) Rapid provisioning of information for business analytics
US10146791B2 (en) Open file rebalance
CN114816247A (en) Logic data acquisition method and device
CN111444194A (en) Method, device and equipment for clearing indexes in block chain type account book
WO2019119336A1 (en) Multi-thread compression and decompression methods in generic data gz format, and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16853102

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16853102

Country of ref document: EP

Kind code of ref document: A1