Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is a SQL-to-SQL translator?

2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "what is the SQL-to-SQL translator". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

This time, starting with a picture, it is the following picture. When I finished drawing him, I felt extremely comfortable. Make the entire execution process controllable and scalable. I still remember that when I was in school, in the math modeling class, the teacher wrote blackboard writing full of four blackboards in order to "verify the probability of a chair with four legs and four legs on a plane," and then said to us with a blindfolded face, "look, how beautiful!" I kind of understand what he was like now.

Sharp-eyed students may have found that, yes, here draw lessons from the process design of Flink.

To put it simply, input-> transform-> output classic syllogism construction.

Here we abstract the input SourceFunction and the output SinkFunction, but unlike Flink, the input and output integrate the same interface and can be converted freely. From a requirement point of view, it is not necessary to Sql-to- Sql-to- Sql.

In the transformation process, we refer to DSL to undertake the previous SQL parsing and subsequent SQL generation, so we naturally divide the transformation into two segments, namely input transformation (SourceMapper) and output transformation (SinkMapper).

To define whether to convert or not, and how to complete the conversion, we can easily achieve it through the Function interface of java.

An input can be docked with N outputs, and the direction of the output is entirely realized by the object that implements the SinkFunction.

If the follow-up, parallelization of the task, Pipline to provide higher-order functions, the United States does not look.

DEMO:

Public static void main (String [] args) throws IOException {/ / input FileSourceFunction fileSourceFunction = new FileSourceFunction (); fileSourceFunction.init (new File ("fff.txt")); / / output PrintlnSinkFunction printSinkFunction = new PrintlnSinkFunction (); ListSinkFunction listSinkFunction = new ListSinkFunction (); ansformPepline tp = new TransformPepline (); / / add input and output .addSource (fileSourceFunction) .addSink (printSinkFunction) .addSink (listSinkFunction) / / customize the conversion action tp.addSourceMapFunction (new Function () {SqlTransExecManager sqlTransExecManager = new SqlTransExecManager (). Build (); @ Override public String apply (String s) {return sqlTransExecManager.doParseAndTransform (s). GetTargetSql ();}}); / / execute tp.execute (); System.out.println (listSinkFunction.getLists ()) This is the end of the introduction of "what is the SQL-to-SQL translator". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report