2016-03-22 13 views
0

Bazı ortak alan değerlerine göre iki dosyaya katılmaya çalışıyorum ve tüm eşleşen kayıtları al.Cascading - Alan değerini temel alan iki dosyaya katılın

İki dosya okuması için iki tane Tap sahibim. Dosyalara katılmak ve noField kullanarak eşleşen kayıtları almak istiyorum.

Dosyalara ve assemble borularına nasıl bağlanırım Flow oluşturmak için?

Örnek Kod: dokunuşlarınıza bağlı

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"); 

cevap

0

Yapı boruları, onlara katılmak, ardından lavaboya çıktı borusunu bağlayın.

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 Ben Basamaklı başlayanlar için tavsiye ederim iyi bir öğretici olduğunu.

İlgili konular