Adaptation device and device of database, computer equipment and storage medium

文档序号:7549 发布日期:2021-09-17 浏览:33次 中文

1. An apparatus for adapting a database, comprising:

the source code modification module is used for modifying the source code of the shardingjdbc framework component;

and the newly-added extension module is used for applying the data elements capable of loading the specific database.

2. The database adaptation device of claim 1, wherein the source code modification module comprises:

the first modification submodule is used for enabling the first modification submodule to be loaded to the data meta-information of the dm and supporting the sub-query statement of a specific database;

the second modification submodule is used for enabling the logic table to be found through the table splitting condition;

the third modification submodule is used for finding a table after routing according to the sql condition;

and the fourth modification submodule is used for supporting the normal merging of non-tabular data.

3. The database adapter device of claim 1, wherein the newly added extension module comprises:

a first extension submodule, configured to extend the databasemetadatadialect handler in an spi manner through the dmdatabasemetadatadialect handler;

the second expansion submodule is used for expanding the BranchDatabasetType in an spi mode through the DMDatabasetType and newly adding a database type;

and the third extension submodule is used for extending the data source data loading of the database supported by the data source metadata in a spi mode through the DMDataSourceMetaData.

4. Computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor realizes the corresponding steps of the adaptation means of the database of any of claims 1 to 5 when executing the computer program.

5. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out corresponding steps of an adaptation means of a database according to any one of claims 1 to 5.

Background

The existing databases are various, and it is necessary for users to select and use a proper database according to their own requirements; in terms of usage, there is a great difference between different databases, such as a difference between grammars, a difference between usage modes, and the like. When a user needs to use multiple databases for system development and performs read-write operation on data, data consistency among different databases needs to be ensured, otherwise, the problems of slow access, queuing and the like are caused, and data synchronization among different databases is slow.

Disclosure of Invention

In view of the above, embodiments of the present invention are proposed in order to provide an adaptation apparatus of a database, a computer device and a storage medium that overcome or at least partially solve the above-mentioned problems.

In order to solve the above problem, an embodiment of the present invention discloses an adaptation apparatus for a database, including:

the source code modification module is used for modifying the source code of the shardingjdbc framework component;

and the newly-added extension module is used for applying the data elements capable of loading the specific database.

Preferably, the source code modification module includes:

the first modification submodule is used for enabling the first modification submodule to be loaded to the data meta-information of the dm and supporting the sub-query statement of a specific database;

the second modification submodule is used for enabling the logic table to be found through the table splitting condition;

the third modification submodule is used for finding a table after routing according to the sql condition;

and the fourth modification submodule is used for supporting the normal merging of non-tabular data.

Preferably, the newly added extension module includes:

a first extension submodule, configured to extend the databasemetadatadialect handler in an spi manner through the dmdatabasemetadatadialect handler;

the second expansion submodule is used for expanding the BranchDatabasetType in an spi mode through the DMDatabasetType and newly adding a database type;

and the third extension submodule is used for extending the data source data loading of the database supported by the data source metadata in a spi mode through the DMDataSourceMetaData.

The embodiment of the invention discloses computer equipment, which comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the corresponding steps of the adapter of the database when executing the computer program.

The embodiment of the invention discloses a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the computer program realizes the corresponding steps of the database adaptation device.

The embodiment of the invention has the following advantages:

in the embodiment of the invention, the web application database is operated, sql reaches the database through java jdbc to be executed, shardingjdbc is integrated, sql passes through shardingjdbc, shardingjdbc rewrites sql to be executed by a sub-library sub-table through a configuration strategy, the sub-library sub-table technical scheme supports a domestic database, the data volume of a single library (table) is reduced, the performance is improved, the stability and the load capacity of a system are improved, the structures of the sub-tables are the same, the program change is less, the split service is clear, the special purpose of a special library is achieved, the separation of hot data and cold data can be realized, the data which are not changed frequently and the data which are changed greatly are dispersed into different libraries/tables, and the maintenance is convenient.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts

FIG. 1 is a block diagram of an embodiment of an adaptation apparatus for a database according to an embodiment of the present invention;

FIG. 2 is an internal block diagram of a computer device of an embodiment.

Detailed Description

In order to make the technical problems, technical solutions and advantageous effects solved by the embodiments of the present invention more clearly apparent, the embodiments of the present invention are described in further detail below with reference to the accompanying drawings and the embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

Referring to fig. 1, a block diagram of a structure of an embodiment of an adaptation apparatus for a database according to an embodiment of the present invention is shown, which may specifically include the following modules:

a source code modification module 301, configured to modify a shardingjdbc framework component source code;

a add-on extension module 302 for applying data elements that can load a particular database.

Preferably, the source code modification module includes:

the first modification submodule is used for enabling the first modification submodule to be loaded to the data meta-information of the dm and supporting the sub-query statement of a specific database;

the second modification submodule is used for enabling the logic table to be found through the table splitting condition;

the third modification submodule is used for finding a table after routing according to the sql condition;

and the fourth modification submodule is used for supporting the normal merging of non-tabular data.

Preferably, the newly added extension module includes:

a first extension submodule, configured to extend the databasemetadatadialect handler in an spi manner through the dmdatabasemetadatadialect handler;

the second expansion submodule is used for expanding the BranchDatabasetType in an spi mode through the DMDatabasetType and newly adding a database type of the current dream;

and the third extension submodule is used for extending the DataSourceMetaData in a spi mode through the DMDataSourceMetaData to support the data loading of the extended Darmon database data source.

The strategy of database and table division is adopted, one mode of the database and table division is horizontal division, and the horizontal division is to divide data according to a certain rule, such as time or id sequence values and the like. Such as splitting different databases by year. Each database structure is consistent, but the data is split, thereby improving performance. For example, according to the value of the user id, the user id is divided into a plurality of tables according to the rule, and the structure of each table is consistent. The second is vertical partitioning, in which the database is partitioned according to the business, for example, tables related to goods, orders, and users in the shop library are partitioned into one library, and the performance is improved by reducing the size of a single library (table), but this way does not solve the performance loss caused by high data volume. Similarly, in the case of table division, a large table is divided into sub-tables according to service functions, for example, a user table can be divided into a basic information table and a detailed information table according to services. Integrating through a Sharding-JDBC framework, and modifying source code: and modifying shardingjdbc source codes, and modifying a plurality of source codes to support grammar compatibility of a specific database, such as a Dameng database. Branch: and an extension module is newly added, so that the application can load information such as data elements of the dream database.

On the first hand, shardingjdbc source codes can be modified, specifically, an adaptation jdbc module is modified, so that the data metadata of dm can be loaded, and sub-query statements reaching dream are supported; modifying the SQL analysis module to find out the logic table according to the table splitting condition; modifying a routing module to find a table after routing according to the sql condition; and modifying the result merging module to support normal merging of non-tabular data.

On the first hand, an extension module is added, so that an application can load information such as data elements of a specific database, such as a Dameng database;

the method comprises the following steps that (1) a Webink-sharing-dm module is written to expand, so that sharing jdbc supports a dreaming database, and a module which needs to support the dreaming database can support the sharing data by introducing the module; developing a DMDatabaeMetaDataDialect Handler, and expanding the DMDatabaeMetaDataDialect Handler in an spi mode; developing a DMDatabasetType, expanding the BranchDatabasetType in a spi mode, and newly adding a database type of the current dream; developing DMDataSourceMetaData to expand the DataSourceMetaData in a spi mode to support the data loading of the data source of the expanded Dameng database;

in the embodiment of the invention, the web application database is operated, sql reaches the database through java jdbc to be executed, shardingjdbc is integrated, sql passes through shardingjdbc, shardingjdbc rewrites sql to be executed by a sub-library sub-table through a configuration strategy, the sub-library sub-table technical scheme supports a domestic database, the data volume of a single library (table) is reduced, the performance is improved, the stability and the load capacity of a system are improved, the structures of the sub-tables are the same, the program change is less, the split service is clear, the special purpose of a special library is achieved, the separation of hot data and cold data can be realized, the data which are not changed frequently and the data which are changed greatly are dispersed into different libraries/tables, and the maintenance is convenient.

The modules in the adaptation means of the database described above may be implemented wholly or partly in software, hardware or a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.

In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 2. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of adapting a database. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.

Those skilled in the art will appreciate that the architecture shown in fig. 2 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.

In an embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the corresponding steps of the adaptation means of the database described above when executing the computer program.

In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the corresponding steps of the adaptation means of the database described above.

The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.

As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may 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, and the like) having computer-usable program code embodied therein.

Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.

Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.

The foregoing describes in detail a database adaptation method, a database adaptation device, a computer device, and a storage medium, which are provided by the present invention, and specific examples are applied herein to explain the principles and embodiments of the present invention, and the descriptions of the foregoing examples are only used to help understand the method and the core ideas of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:基于ClickHouse字典表的大数据查询方法、系统和介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!