CN117251144B - Theme-based data object access and release method and related equipment - Google Patents

Theme-based data object access and release method and related equipment Download PDF

Info

Publication number
CN117251144B
CN117251144B CN202311540191.6A CN202311540191A CN117251144B CN 117251144 B CN117251144 B CN 117251144B CN 202311540191 A CN202311540191 A CN 202311540191A CN 117251144 B CN117251144 B CN 117251144B
Authority
CN
China
Prior art keywords
data
field
data model
annotation
type
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311540191.6A
Other languages
Chinese (zh)
Other versions
CN117251144A (en
Inventor
姚宏志
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
BEIJING YOYO TIANYU SYSTEM TECHNOLOGY CO LTD
Original Assignee
BEIJING YOYO TIANYU SYSTEM TECHNOLOGY CO LTD
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by BEIJING YOYO TIANYU SYSTEM TECHNOLOGY CO LTD filed Critical BEIJING YOYO TIANYU SYSTEM TECHNOLOGY CO LTD
Priority to CN202311540191.6A priority Critical patent/CN117251144B/en
Publication of CN117251144A publication Critical patent/CN117251144A/en
Application granted granted Critical
Publication of CN117251144B publication Critical patent/CN117251144B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/133Protocols for remote procedure calls [RPC]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention provides a data object access and release method based on a theme and related equipment, belonging to the technical field of software development, wherein the method comprises the following steps: defining a data model and a data interface based on a protobuf file according to a preset method; the data model and the data interface include: keyword definition and specification; mapping data types in the protobuf file to data types in the data model based on specification in the data model; and according to the data model, the data interface and the mapping method of the data type, the access and the release of the data object are realized. The invention can effectively expand the information bearing capacity of the protobuf protocol, expand the support of protobuf to the field types of the database, generate the operable engineering codes according to the data structure in the theme and improve the development efficiency of users.

Description

Theme-based data object access and release method and related equipment
Technical Field
The invention relates to the technical field of software development, in particular to a theme-based data object access and release method and related equipment.
Background
With the development of information technology, the situations of quick start project, code generation, quick iteration, database reconstruction, new hand entry, basic CRUD operation, quick prototype development and the like are carried out, so that the workload of developers is required to be reduced, and the development efficiency is improved. As distributed systems become more popular, the use of Remote Procedure Calls (RPCs) is more and more a scenario, requiring frequent data serialization and de-serialization. To meet the above requirements, protobuf is selected for data structure definition, and data is serialized and de-serialized.
Protobuf has the advantages of language neutrality, high efficiency, expandability, performance, code generation, wide support, structured data and the like, but has fewer supported data types and poor compatibility with database field types; the original data format of the Protobuf protocol has less information quantity, and can not effectively restrict a data model and codes.
Disclosure of Invention
The invention provides a data object access and release method based on a theme and related equipment, which can effectively expand the information bearing capacity of a protobuf protocol, expand the support of protobuf on the field types of a database, generate an operable engineering code according to a data structure in the theme and improve the development efficiency of a user.
In a first aspect, an embodiment of the present invention provides a method for accessing and publishing a data object based on a theme, the method including:
defining a data model and a data interface based on a protobuf file according to a preset method;
wherein the data model and the data interface comprise: keyword definition and specification;
mapping the data types in the protobuf file to the data types in the data model based on the specification in the data model;
and accessing and publishing the data object according to the data model, the data interface and the mapping method of the data type.
Optionally, defining a data model and a data interface based on a protobuf file according to a preset method includes:
defining the entity class names in the data model and the relationships among the entities in the data model by using the keywords;
specification in the data model includes: message header notes, message trailer notes, field header notes, and field trailer notes;
the message header notes are used for representing description information of the data model, the message tail notes are used for representing names of the data model, the field header notes are used for representing description information of fields, and the field tail notes are used for representing constraint information of the data model.
Optionally, defining a data model and a data interface based on a protobuf file according to a preset method includes:
defining the name, calling method and returned response of the data interface by using the key words;
specification in the data interface includes: service header, service trailer, rpc header, and rpc trailer;
the service header annotation is used for representing an instance name corresponding to the interface, the service tail annotation is used for representing a data model name corresponding to the interface, the rpc header annotation is used for representing description information of a method, and the rpc tail annotation is used for representing entry information and exit information of the interface.
Optionally, the constraint information of the data model includes: field type, field length/precision, field scale, whether null is allowed, primary key, auto increment, inline information, and field default.
Optionally, the parameter entering information includes: parameter identification, field number, whether filling is necessary, screening conditions and sorting; the parameter information comprises: parameter identification and field numbering.
Optionally, mapping the data type in the protobuf file to the data type in the data model based on the specification in the data model includes:
defining first type data of an unsupported type in a protobuf file in a data model;
defining second type data of any support type in a protobuf file;
and mapping the second type data into the first type data to realize the expansion of the protobuf file data type.
Optionally, the method further comprises:
generating a server development template, a client development template and a sample code by analyzing the protobuf file;
the server development template, the client development template and the sample code are used for being directly called by a developer through a data interface.
In a second aspect, embodiments of the present invention provide a topic-based data object access and release apparatus, the apparatus comprising:
the definition module is used for defining a data model and a data interface based on the protobuf file according to a preset method;
wherein the data model and the data interface comprise: keyword definition and specification;
the mapping module is used for mapping the data types in the protobuf file to the data types in the data model based on the specification in the data model;
and the access and release module is used for realizing the access and release of the data object according to the data model, the data interface and the mapping method of the data type.
In a third aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor, where the memory stores a computer program, and the processor implements the method according to any implementation manner of the first aspect when executing the program.
In a fourth aspect, embodiments of the present invention provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method according to any of the implementations of the first aspect.
The invention provides a data object access and release method based on a theme and related equipment, wherein the method comprises the following steps: defining a data model and a data interface based on a protobuf file according to a preset method; the data model and the data interface include: keyword definition and specification; mapping data types in the protobuf file to data types in the data model based on specification in the data model; and according to the data model, the data interface and the mapping method of the data type, the access and the release of the data object are realized. The invention can effectively expand the information bearing capacity of the protobuf protocol, expand the support of protobuf to the field types of the database, generate the operable engineering codes according to the data structure in the theme and improve the development efficiency of users.
It should be understood that the description in this summary is not intended to limit the critical or essential features of the embodiments of the invention, nor is it intended to limit the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
The above and other features, advantages and aspects of embodiments of the present invention will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. In the drawings, the same or similar reference numerals denote the same or similar elements.
FIG. 1 is a flow chart of a subject-based data object access and publication method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a theme-based data object accessing and publishing device according to an embodiment of the present invention;
fig. 3 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to enable a person skilled in the art to better understand the technical solutions in one or more embodiments of the present specification, the technical solutions in one or more embodiments of the present specification will be clearly and completely described below with reference to the drawings in one or more embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one or more embodiments of the present disclosure without inventive faculty, are intended to be within the scope of the present disclosure.
It should be noted that, the description of the embodiment of the present invention is only for the purpose of more clearly describing the technical solution of the embodiment of the present invention, and does not constitute a limitation on the technical solution provided by the embodiment of the present invention.
FIG. 1 is a flow chart of a subject-based data object access and distribution method according to an embodiment of the present invention. As shown in fig. 1, includes:
s101, defining a data model and a data interface based on a protobuf file according to a preset method.
Wherein the data model and the data interface comprise: keyword definition and specification.
Optionally, defining the entity class name in the data model and the relation between the entities in the data model by using the keywords;
illustratively, a data model is defined using a keyword message, named using entity class names in java. The keyword repeated is used to define a one-to-many relationship description in the data model.
Optionally, the specification in the data model includes: the message header annotation is used for representing description information of the data model, the message tail annotation is used for representing the name of the data model, the field header annotation is used for representing description information of the field, and the field tail annotation is used for representing constraint information of the data model.
Optionally, the different constraint information is separated by a half angle colon, the constraint information comprising: field type, field length/precision, field scale, whether null is allowed (0: no, 1: yes), whether primary key is (0: no, 1: yes), whether auto increment (0: no, 1: yes), external information (external table, field), and field default.
Illustratively, the definition code may be as follows:
record of on-line user
message SysUserOnline {//SYS_USER_ONLINE
User session id
string SESSIONID = 1; // VARCHAR:10::0:0:0::
Account of// login
string LOGIN_NAME = 2; // VARCHAR:50::0:0:0::
V/login IP address
string IPADDR = 3; // VARCHAR:128:0:0:0:0::
Location of/log-in
string LOGIN_LOCATION = 4; // VARCHAR:255::0:0:0::
Type of/(browser)
string BROWSER = 5; // VARCHAR:50::0:0:0::
Operation system
string OS = 6; // VARCHAR:50::0:0:0::
Status of on line
string STATUS = 7; // VARCHAR:10::0:0:0::
Time of creation of/(session)
string START_TIMESTAMP = 8; // DATETIME:::0:0:0::
Time of last access of/(session)
string LAST_ACCESS_TIME = 9; // DATETIME:::0:0:0::
Time-out time in minutes
int32 EXPIRE_TIME = 10; // INT:10::0:0:0::0
User id
int32 USER_ID = 11; // INT:10:0:1:0:0:SYS_USER.ID:
SysUser sysUser=12;
};
Wherein,
record of on-line user
message SysUserOnline {//SYS_USER_ONLINE ;
Header annotation: "on-line user record": annotating information with a data model;
message SysUserOnline: "message" reserves keywords for Protobuf, defining a data structure; "SysUserOnline" is the entity class name corresponding to the data model;
tail annotation: "SYS_USER_ONLINE": data model name.
User session id
string SESSIONID = 1; // VARCHAR:10::0:1:0:: ;
Header annotation: "user session id": annotation information for the field;
string session=1: "string" reserves keywords for Protobuf, defining data types; "SESSIONID" is a data field name; "1" is the first attribute of the data structure;
tail annotation: "VARCHAR 10:0:0:0:0:1" is field type: VARCHAR, field scale: 10, field precision: the field content is not allowed to be null, is a primary key, is not an incremental field, has no external connection information, and has a default value of null.
Account of// login
string LOGIN_NAME = 2; // VARCHAR:50::0:0:0:: ;
Header annotation: "login account": annotation information for the field;
string LOGIN_NAME=1: "string" reserves keywords for Protobuf, defining data types; "LOGIN_NAME" is a data field NAME; "2" is the second attribute of the data structure;
tail annotation: "VARCHAR 50:0:0:0:0:1" is field type: VARCHAR, field scale: 50, field precision: the field content is not allowed to be null, is not a primary key, is not an incremental field, has no externally connected information, and is null by default.
V/login IP address
string IPADDR = 3; // VARCHAR:128:0:0:0:0:: ;
Header annotation: "login IP address": annotation information for the field;
string ipaddr=3: "string" reserves keywords for Protobuf, defining data types; "IPADDR" is a data field name; "3" is the third attribute of the data structure;
tail annotation: "VARCHAR 128:0:0:0:0:" is field type: VARCHAR, field scale: 128, field precision: the field content is not allowed to be null, is not a primary key, is not an incremental field, has no externally connected information, and is null by default.
Location of/log-in
string LOGIN_LOCATION = 4; // VARCHAR:255::0:0:0:: ;
Header annotation: "login location": annotation information for the field;
string LOGIN_LOCATION=4: "string" reserves keywords for Protobuf, defining data types; "LOGIN_LOCATION" is a data field name; "4" is the fourth attribute of the data structure;
tail annotation: "VARCHAR: 255:0:0:0:0:1" is field type: VARCHAR, field scale: 255, field precision: the field content is not allowed to be null, is not a primary key, is not an incremental field, has no externally connected information, and is null by default.
Type of/(browser)
string BROWSER = 5; // VARCHAR:50::0:0:0:: ;
Header annotation: "browser type": annotation information for the field;
string browse = 5: "string" reserves keywords for Protobuf, defining data types; "BROWSER" is a data field name; "5" is the fifth attribute of the data structure;
tail annotation: "VARCHAR 50:0:0:0:0:1" is field type: VARCHAR, field scale: 50, field precision: the field content is not allowed to be null, is not a primary key, is not an incremental field, has no externally connected information, and is null by default.
Operation system
string OS = 6; // VARCHAR:50::0:0:0:: ;
Header annotation: "operating System": annotation information for the field;
string os=6: "string" reserves keywords for Protobuf, defining data types; "OS" is the name of the data field; "6" is the sixth attribute of the data structure;
tail annotation: "VARCHAR 50:0:0:0:0:1" is field type: VARCHAR, field scale: 50, field precision: the field content is not allowed to be null, is not a primary key, is not an incremental field, has no externally connected information, and is null by default.
Status of on line
string STATUS = 7; // VARCHAR:10::0:0:0:: ;
Header annotation: "on-line status": annotation information for the field;
string status=7: "string" reserves keywords for Protobuf, defining data types; "STATUS" is a data field name; "7" is the seventh attribute of the data structure;
tail annotation: "VARCHAR 10:0:0:0:0:1" is field type: VARCHAR, field scale: 10, field precision: the field content is not allowed to be null, is not a primary key, is not an incremental field, has no externally connected information, and is null by default.
Time of creation of/(session)
string START_TIMESTAMP = 8; // DATETIME:::0:0:0:: ;
Header annotation: "session creation time": annotation information for the field;
string start_ TIMESTAMP =8: "string" reserves keywords for Protobuf, defining data types; "START_ TIMESTAMP" is a data field name; "8" is the eighth attribute of the data structure;
tail annotation: "DATETIME:::0:0::" is field type: DATETIME, field scale: null, field precision: the field content is not allowed to be null, is not a primary key, is not an incremental field, has no externally connected information, and is null by default.
Time of last access of/(session)
string LAST_ACCESS_TIME = 9; // DATETIME:::0:0:0:: ;
Header annotation: "session last access time": annotation information for the field;
string last_access_time=9: "string" reserves keywords for Protobuf, defining data types; "LAST_ACCESS_TIME" is a data field name; "9" is the ninth attribute of the data structure;
tail annotation: "DATETIME:::0:0::" is field type: DATETIME, field scale: null, field precision: the field content is not allowed to be null, is not a primary key, is not an incremental field, has no externally connected information, and is null by default.
Time-out time in minutes
int32 EXPIRE_TIME = 10; // INT:10::0:0:0::0 ;
Header annotation: "timeout time in minutes": annotation information for the field;
int32 expire_time=10: "string" reserves keywords for Protobuf, defining data types; "EXPIRE_TIME" is a data field name; "10" is the tenth attribute of the data structure;
tail annotation: "INT: 10:0:0:0:0" is field type: INT, field scale: 10, field precision: null, field content is not allowed to be null, a non-primary key, a non-incremental field, no external connection information and a default value of 0;
user id
int32 USER_ID = 11; // INT:10:0:1:0:0:SYS_USER.ID: ;
Header annotation: "user id": annotation information for the field;
int32 user_id=11: "string" reserves keywords for Protobuf, defining data types; "user_id" is a data field name; "11" is the eleventh attribute of the data structure;
tail annotation: "INT:10:0:1:0:0:SYS_USER.ID:" is field type: INT, field scale: 10, field precision: 0, the field content is allowed to be null, the non-primary key and the non-increment field, the externally connected information is the ID field of the SYS_USER table, and the default value is null.
SysUser sysUser=12;
A custom data structure "syser" is introduced as a twelfth attribute of the data structure.
Optionally, the name of the data interface, the calling method, and the return response are defined using keywords.
Illustratively, the interface name is defined using a key service, the key of the method is defined using rpc, the response is returned using a return definition, and the key is used within the service domain.
Optionally, the specification in the data interface includes: the service header annotation is used for representing an instance name corresponding to the interface, the service tail annotation is used for representing a data model name corresponding to the interface, the rpc header annotation is used for representing description information of a method, and the rpc tail annotation is used for representing the in-parameter information and the out-parameter information of the interface.
Optionally, the plurality of in-parameter information and out-parameter information are separated by a half-angle comma, and the in-parameter information includes: parameter entry identification [ i ], field number, whether filling is necessary (0: no, 1: yes), screening condition (0-9 a-z) and whether sorting is performed (0: no, 1: yes); the parameter information comprises: the parameter identification [ o ] and the field number.
Optionally, the screening conditions include: 0 =, 1: >, 2: <, 3: > =, 4: < =, 5:is NOT NULL, 6:in, 7:not IN, and 8:is NULL.
Illustratively, the definition code may be as follows:
// SysUserOnline
service SysUserOnlineService { // SYS_USER_ONLINE
rpc query (SysUserOnline) returns(WrapsListSysUserOnline);//[i]1:111,2:101,3:101;[o]1,2
rpc insert (SysUserOnline) returns (WrapsInteger);
rpc delete (SysUserOnline) returns (WrapsInteger);
rpc update (SysUserOnline) returns (WrapsInteger);
rpc getQueryTotalCount (SysUserOnline) returns (WrapsInteger);
rpc batchInsert (WrapsListSysUserOnline) returns (WrapsInteger);
rpc batchUpdate (WrapsListSysUserOnline) returns (WrapsInteger);
};
wherein rpc query (sys useronline) returns (WrapsList SysUserOnline); the contents of// [ i ]1:111,2:101,3:101; [ o ]1,2 are as follows: interface name: query, interface action: inquiring data information meeting the conditions; the parameter data entering model is SysUserOnline, the return type is the collection of SysUserOnline, and the parameter entering content is as follows: the first field is used as a screening condition to be filled in, and is equal to a filling value; the second field is used as a screening condition and is not necessarily filled, and is equal to a filling value; the third field is used as a screening condition and is not necessarily filled, and is equal to a filling value; the content of the ginseng: and returning the contents of the first field and the second field.
rpc insert (sys userOnline) returns (WrapsInteger): interface name: insert, interface action: data information is inserted. The input parameter data model is SysUserOnline, and the return type is WrapsInteger. Wrapase inter content means the number of affected rows.
rpc delete (sys useronline) returns (WrapsInteger): interface name: delete, interface action: deleting the data meeting the conditions; the input parameter data model is SysUserOnline, and the return type is Wraps Intger; wrapase inter content means the number of affected rows.
rpc update (sys useronline) returns (WrapsInteger): interface name: update, interface action: updating the data information meeting the conditions; the input parameter data model is SysUserOnline, and the return type is Wraps Intger; wrapase inter content means the number of affected rows.
rpc getQueryTotalCount (SysUserOnline) returns (WrapsInteger): interface name: getQueryTotalCount, interface action: inquiring the number of data strips meeting preset conditions; the input parameter data model is SysUserOnline, and the return type is Wraps Intger; wrapase inter content means the number of affected rows.
rpc batch insert (wrapasslistssys useronline) returns (WrapsInteger): interface name: batch insert, interface action: inserting a plurality of pieces of data information in batches; the input parameter data model is SysUserOnline, and the return type is Wraps Intger; wrapase inter content means the number of affected rows.
rpc batch update (wrapapslistssysuseronline) returns (WrapsInteger): interface name: the batchUpdate, interface action: updating a plurality of data information in batches; the input parameter data model is SysUserOnline, and the return type is Wraps Intger; wrapase inter content means the number of affected rows.
S102, mapping the data types in the protobuf file to the data types in the data model based on the specification in the data model.
Optionally, the data types supported by the native protobuf file include: double, float, int32, uint64, sint32, sint64, fixed32, fixed64, sfixed32, sfixed64, bol, string and bytes; time type data such as date, timestamp and datetime in the database cannot be supported.
Illustratively, string start_time=1:// timestamp:6::0:0:0::, indicating that the string type in the Protobuf file is mapped to a timestamp type in the data model, in which the time type can be stored; in the generated code template, the data is stored, transmitted and sent by directly using the timestamp type, so that multiple types of conversion can be effectively avoided.
S103, accessing and publishing the data object according to the data model, the data interface and the mapping method of the data type.
Optionally, according to the defined data model and the data interface, accessing and publishing the data are realized, if the data type which is not supported by the protobuf protocol is encountered, the data type in the protobuf file is mapped to the data type in the data model by a data type mapping method, so that the accessing and publishing of the data are realized.
Optionally, the method further comprises:
generating a server development template, a client development template and a sample code by analyzing the protobuf file;
the server development template, the client development template and the sample code are used for being directly called by a developer through a data interface.
Optionally, the server development template is a set of server development templates predefined by the system, and a basic theme server development code can be generated according to the template, including Mybatis mapping files, POJO classes, service classes, mapper classes and the like, and a server communication code basic class based on RPC communication; three ways of access are supported restful, RPC, webservcie.
Optionally, the client development template provides a set of development templates for calling the theme service by the client for the system, so that the access code of the theme service can be quickly generated.
Optionally, the sample code is a simple example code provided for providing the sample to the secondary developer.
The embodiment of the invention provides a theme-based data object access and release method, which comprises the following steps: defining a data model and a data interface based on a protobuf file according to a preset method; the data model and the data interface include: keyword definition and specification; mapping data types in the protobuf file to data types in the data model based on specification in the data model; and according to the data model, the data interface and the mapping method of the data type, the access and the release of the data object are realized. The invention can effectively expand the information bearing capacity of the protobuf protocol, expand the support of protobuf to the field types of the database, generate the operable engineering codes according to the data structure in the theme and improve the development efficiency of users.
The apparatus for performing the above-mentioned theme-based data object access and distribution method according to the embodiment of the present invention is described in detail below with reference to fig. 2.
FIG. 2 is a schematic diagram illustrating a structure of a theme-based data object accessing and publishing device according to an embodiment of the present invention; as shown in fig. 2, the access and issue device 20 includes:
a definition module 201, configured to define a data model and a data interface based on a protobuf file according to a preset method;
wherein the data model and the data interface comprise: keyword definition and specification;
a mapping module 202, configured to map the data types in the protobuf file to the data types in the data model based on the specification in the data model;
the access and release module 203 is configured to implement access and release of the data object according to the data model, the data interface, and the mapping method of the data type.
Optionally, the definition module 201 is further configured to define, using the keywords, a relationship between the entity class name in the data model and the entity in the data model;
wherein the specification in the data model includes: message header notes, message trailer notes, field header notes, and field trailer notes; the message header annotation is used for representing description information of the data model, the message trailer annotation is used for representing the name of the data model, the field header annotation is used for representing description information of the field, and the field trailer annotation is used for representing constraint information of the data model.
Optionally, the definition module 201 is further configured to define a name, a calling method, and a return response of the data interface using the key;
wherein, specification in the data interface includes: service header, service trailer, rpc header, and rpc trailer; the service header annotation is used for representing an instance name corresponding to the interface, the service tail annotation is used for representing a data model name corresponding to the interface, the rpc header annotation is used for representing description information of a method, and the rpc tail annotation is used for representing entry information and exit information of the interface.
Optionally, the constraint information of the data model includes: field type, field length/precision, field scale, whether null is allowed, primary key, auto increment, inline information, and field default.
Optionally, the parameter entering information includes: parameter identification, field number, whether filling is necessary, screening conditions and sorting; the parameter information comprises: parameter identification and field numbering.
Optionally, the mapping module 202 is further configured to define, in the data model, first type data of an unsupported type in the protobuf file; defining second type data of any support type in a protobuf file; and mapping the second type data into the first type data to realize the expansion of the protobuf file data type.
Optionally, the device further comprises a generating module, which is used for generating a server development template, a client development template and a sample code by analyzing the protobuf file;
the server development template, the client development template and the sample code are used for being directly called by a developer through a data interface.
The embodiment of the present invention also provides a computer electronic device, fig. 3 shows a schematic diagram of a structure of an electronic device to which the embodiment of the present invention can be applied, and as shown in fig. 3, the computer electronic device includes a central processing module (CPU) 301 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 302 or a program loaded from a storage section 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data required for the system operation are also stored. The CPU 301, ROM 302, and RAM 303 are connected to each other through a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
The following components are connected to the I/O interface 305: an input section 306 including a keyboard, a mouse, and the like; an output portion 307 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 308 including a hard disk or the like; and a communication section 309 including a network interface card such as a LAN card, a modem, or the like. The communication section 309 performs communication processing via a network such as the internet. The drive 310 is also connected to the I/O interface 305 as needed. A removable medium 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed on the drive 310 as needed, so that a computer program read out therefrom is installed into the storage section 308 as needed.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules or modules may also be provided in a processor, for example, as: a processor comprises a definition module 201, a mapping module 202 and an access and release module 203, wherein the names of these modules do not in some cases constitute a limitation of the module itself, e.g. the mapping module 202 may also be described as "mapping module 202 for mapping data types in a protobuf file to data types in a data model based on a specification in the data model".
As another aspect, the present invention also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the subject-based data object accessing and publishing device as described in the above embodiments; or may be a computer-readable storage medium, alone, that is not incorporated into an electronic device. The computer readable storage medium stores one or more programs for use by one or more processors in performing a subject-based data object access and distribution method described herein.
The above description is only illustrative of the preferred embodiments of the present invention and of the principles of the technology employed. It will be appreciated by persons skilled in the art that the scope of the invention referred to in the present invention is not limited to the specific combinations of the technical features described above, but also covers other technical features formed by any combination of the technical features described above or their equivalents without departing from the inventive concept. Such as the above-mentioned features and the technical features disclosed in the present invention (but not limited to) having similar functions are replaced with each other.

Claims (5)

1. A method for topic-based data object access and distribution, the method comprising:
defining a data model and a data interface based on a protobuf file according to a preset method; the data model and the data interface include: keyword definition and specification;
mapping data types in the protobuf file to data types in the data model based on specification in the data model;
according to the data model, the data interface and the mapping method of the data type, the access and the release of the data object are realized;
the mapping the data type in the protobuf file to the data type in the data model based on the specification in the data model comprises:
defining first type data of an unsupported type in the protobuf file in the data model;
defining second type data of any support type in the protobuf file;
mapping the second type data into the first type data to realize expansion of the protobuf file data type;
the defining the data model and the data interface based on the protobuf file according to the preset method comprises the following steps:
defining the entity class names in the data model and the relationships among the entities in the data model by using the keywords;
specification in the data model includes: message header notes, message trailer notes, field header notes, and field trailer notes;
the message header annotation is used for representing description information of the data model, the message tail annotation is used for representing the name of the data model, the field header annotation is used for representing description information of a field, and the field tail annotation is used for representing constraint information of the data model;
the method for defining the data model and the data interface based on the protobuf file according to the preset method further comprises the following steps:
defining the name, calling method and returned response of the data interface by using the key words;
the specification in the data interface includes: service header, service trailer, rpc header, and rpc trailer;
the service head annotation is used for representing an instance name corresponding to the interface, the service tail annotation is used for representing a data model name corresponding to the interface, the rpc head annotation is used for representing description information of a method, and the rpc tail annotation is used for representing entry information and exit information of the interface;
wherein constraint information of the data model includes: field type, field length/precision, field scale, whether null is allowed, primary key, auto increment, inline information, and field default;
the parameter entering information comprises: parameter identification, field number, whether filling is necessary, screening conditions and sorting; the parameter-out information comprises: parameter identification and field numbering.
2. The subject based data object access and publication method of claim 1 further comprising:
generating a server development template, a client development template and a sample code by analyzing the protobuf file;
the server development template, the client development template and the sample code are used for being directly called by a developer through the data interface.
3. A subject-based data object access and distribution apparatus, the apparatus comprising:
the definition module is used for defining a data model and a data interface based on the protobuf file according to a preset method; the data model and the data interface include: keyword definition and specification;
the mapping module is used for mapping the data types in the protobuf file into the data types in the data model based on the specification in the data model;
the access and release module is used for realizing the access and release of the data object according to the data model, the data interface and the mapping method of the data type;
the mapping module is further configured to define, in the data model, first type data of an unsupported type in the protobuf file; defining second type data of any support type in the protobuf file; mapping the second type data into the first type data to realize expansion of the protobuf file data type;
the definition module is also used for defining the entity class names in the data model and the relationships among the entities in the data model by using the keywords; specification in the data model includes: message header notes, message trailer notes, field header notes, and field trailer notes;
the message header annotation is used for representing description information of the data model, the message tail annotation is used for representing the name of the data model, the field header annotation is used for representing description information of a field, and the field tail annotation is used for representing constraint information of the data model;
the definition module is also used for defining the name, calling method and returned response of the data interface by using the keywords; the specification in the data interface includes: service header, service trailer, rpc header, and rpc trailer;
the service head annotation is used for representing an instance name corresponding to the interface, the service tail annotation is used for representing a data model name corresponding to the interface, the rpc head annotation is used for representing description information of a method, and the rpc tail annotation is used for representing entry information and exit information of the interface;
wherein constraint information of the data model includes: field type, field length/precision, field scale, whether null is allowed, primary key, auto increment, inline information, and field default;
the parameter entering information comprises: parameter identification, field number, whether filling is necessary, screening conditions and sorting; the parameter-out information comprises: parameter identification and field numbering.
4. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program, the processor implementing the method of claim 1 or 2 when executing the computer program.
5. A computer-readable storage medium, characterized in that a computer program is stored, which, when being executed by a processor, implements the method according to claim 1 or 2.
CN202311540191.6A 2023-11-20 2023-11-20 Theme-based data object access and release method and related equipment Active CN117251144B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311540191.6A CN117251144B (en) 2023-11-20 2023-11-20 Theme-based data object access and release method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311540191.6A CN117251144B (en) 2023-11-20 2023-11-20 Theme-based data object access and release method and related equipment

Publications (2)

Publication Number Publication Date
CN117251144A CN117251144A (en) 2023-12-19
CN117251144B true CN117251144B (en) 2024-03-29

Family

ID=89131781

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311540191.6A Active CN117251144B (en) 2023-11-20 2023-11-20 Theme-based data object access and release method and related equipment

Country Status (1)

Country Link
CN (1) CN117251144B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110198247A (en) * 2018-02-26 2019-09-03 腾讯科技(深圳)有限公司 Interface test method and system
US10732944B1 (en) * 2019-05-14 2020-08-04 Baidu Usa Llc Generic verification approach for Protobuf based projects
CN113381870A (en) * 2020-03-09 2021-09-10 华为技术有限公司 Message processing method and device
CN114218223A (en) * 2021-12-20 2022-03-22 乐府互娱(上海)网络科技有限公司 Protobuf protocol-based Redis data model construction and access method
CN114625353A (en) * 2020-12-14 2022-06-14 电科云(北京)科技有限公司 Model framework code generation system and method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110198247A (en) * 2018-02-26 2019-09-03 腾讯科技(深圳)有限公司 Interface test method and system
US10732944B1 (en) * 2019-05-14 2020-08-04 Baidu Usa Llc Generic verification approach for Protobuf based projects
CN113381870A (en) * 2020-03-09 2021-09-10 华为技术有限公司 Message processing method and device
CN114625353A (en) * 2020-12-14 2022-06-14 电科云(北京)科技有限公司 Model framework code generation system and method
CN114218223A (en) * 2021-12-20 2022-03-22 乐府互娱(上海)网络科技有限公司 Protobuf protocol-based Redis data model construction and access method

Also Published As

Publication number Publication date
CN117251144A (en) 2023-12-19

Similar Documents

Publication Publication Date Title
US7805713B2 (en) Transaction processing architecture
EP1701261A1 (en) Dynamic service generation for legacy components
US20050114378A1 (en) System and method for providing a standardized adaptor framework
US10078675B2 (en) Method of transferring contents from a database to a mark-up language file
US7320003B2 (en) Method and system for storing and retrieving document data using a markup language string and a serialized string
US20030093403A1 (en) System and method for implementing an event adapter
US7703099B2 (en) Scalable transformation and configuration of EDI interchanges
IL135612A (en) Method of object oriented point-to-point communication and communication apparatus for carrying out such a method
US20080040418A1 (en) Accessing existing data using a service oriented architecture gateway
JP2006500650A (en) Configuration services for autonomous computation
AU2002318987A1 (en) Content transfer
US9189486B2 (en) Autonomic generation of document structure in a content management system
US20080059506A1 (en) Method, system and schema for building a hierarchical model schema definition from a flat model definition
US9135251B2 (en) Generating simulated containment reports of dynamically assembled components in a content management system
CN117251144B (en) Theme-based data object access and release method and related equipment
Liu et al. Engineering information service infrastructure for ubiquitous computing
JP2004046895A (en) Work flow conversion method
CN113672671A (en) Method and device for realizing data processing
US8027960B2 (en) Intelligent deletion of elements to maintain referential integrity of dynamically assembled components in a content management system
US11966719B2 (en) Event consumption for high-level programing language platform
US20240036946A1 (en) Event provisioning for high-level programing language platform
Fraser et al. Service oriented grid architecture for geosciences community
Jun et al. Computer Data Based on Domino Application System Design and Implementation of Interface Analysis Experiment
Sample et al. A comprehensive model for arbitrary result extraction
Lu et al. A ReScUE XML/EDI model

Legal Events

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