2016-03-22 1 views
0

に基づいて2つのファイルを結合。カスケード - 私はいくつかの一般的なフィールドの値に基づいて2つのファイルを結合し、すべての一致したレコードを取得しようとしていますフィールド値

は、私が読んだ2 Tapのための2つのファイルを持っています。私は、ファイルを結合し、noFieldを使用して一致したレコードを取得したいです。

にはどうすればFlowを作成するためのファイルとassembleパイプに参加していますか?

サンプルコード:

Properties properties = new Properties(); 
AppProps.setApplicationJarClass(properties, Test.class); 
FlowConnector flowConnector = new LocalFlowConnector(); 

Fields custFields = new Fields("no", "name", "city"); 
FileTap custFileTap = new FileTap(new TextDelimited(custFields,true, ","), "C://Users//Test//cust.txt"); 

Fields tsctnFields = new Fields("no", "tdate", "tamt"); 
FileTap tsctnFileTap = new FileTap(new TextDelimited(tsctnFields,true, ","), "C://Users//Test//tsctn.txt"); 

答えて

0

その後、シンクに出力パイプを接続し、それらを結合、あなたのタップに接続されているパイプを構築します。

Tap outTap = new MultiSinkTap(); // just saying, create your own tap 
Pipe custFilePipe = new Pipe("custFilePipe"); 
Pipe tsctnFilePipe = new Pipe("tsctnFilePipe"); 

Fields groupFields = new Fields("no"); // fields used as joining keys 
Pipe outPipe = new CoGroup(custFilePipe, groupFields, tsctnFilePipe, groupFields, new InnerJoin()); 

// build flow definition 
FlowDef flowDef = FlowDef.flowDef().setName("myFlow") 
.addSource(custFilePipe, custFileTap) 
.addSource(tsctnFilePipe, tsctnFileTap) 
.addTailSink(outPipe, outTap); 

Flow flow = flowConnector.connect(flowDef); // now you build the flow 
flow.complete(); // run flow 

Cascading for the Impatient私はカスケード初心者にお勧めする良いチュートリアルです。

関連する問題