cascading.pipe.Each.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(14.4k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中cascading.pipe.Each.<init>()方法的一些代码示例,展示了Each.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Each.<init>()方法的具体详情如下:
包路径:cascading.pipe.Each
类名称:Each
方法名:<init>

Each.<init>介绍

暂无

代码示例

代码示例来源:origin: cwensel/cascading

@Test
public void testBuildMerge()
 {
 Tap sourceLower = getPlatform().getTextFile( "file1" );
 Tap sourceUpper = getPlatform().getTextFile( "file2" );
 Map sources = new HashMap();
 sources.put( "lower", sourceLower );
 sources.put( "upper", sourceUpper );
 Function splitter = new RegexSplitter( new Fields( "num", "char" ), " " );
 Tap sink = getPlatform().getTextFile( "outpath", SinkMode.REPLACE );
 Pipe pipeLower = new Each( new Pipe( "lower" ), new Fields( "line" ), splitter );
 Pipe pipeUpper = new Each( new Pipe( "upper" ), new Fields( "line" ), splitter );
 Pipe splice = new GroupBy( "merge", Pipe.pipes( pipeLower, pipeUpper ), new Fields( "num" ), null, false );
 Flow flow = getPlatform().getFlowConnector().connect( sources, sink, splice );
 }

代码示例来源:origin: cascading/cascading-platform

@Test
public void testBuildMerge()
 {
 Tap sourceLower = getPlatform().getTextFile( "file1" );
 Tap sourceUpper = getPlatform().getTextFile( "file2" );
 Map sources = new HashMap();
 sources.put( "lower", sourceLower );
 sources.put( "upper", sourceUpper );
 Function splitter = new RegexSplitter( new Fields( "num", "char" ), " " );
 Tap sink = getPlatform().getTextFile( "outpath", SinkMode.REPLACE );
 Pipe pipeLower = new Each( new Pipe( "lower" ), new Fields( "line" ), splitter );
 Pipe pipeUpper = new Each( new Pipe( "upper" ), new Fields( "line" ), splitter );
 Pipe splice = new GroupBy( "merge", Pipe.pipes( pipeLower, pipeUpper ), new Fields( "num" ), null, false );
 Flow flow = getPlatform().getFlowConnector().connect( sources, sink, splice );
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testUnGroup() throws Exception
 {
 getPlatform().copyFromLocal( inputFileJoined );
 Tap source = getPlatform().getTextFile( inputFileJoined );
 Tap sink = getPlatform().getTextFile( getOutputPath( "ungrouped" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 pipe = new Each( pipe, new Fields( "line" ), new RegexSplitter( new Fields( "num", "lower", "upper" ) ) );
 pipe = new Each( pipe, new UnGroup( new Fields( "num", "char" ), new Fields( "num" ), Fields.fields( new Fields( "lower" ), new Fields( "upper" ) ) ) );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 10 );
 }

代码示例来源:origin: cascading/cascading-platform

@Test
public void testUnGroup() throws Exception
 {
 getPlatform().copyFromLocal( inputFileJoined );
 Tap source = getPlatform().getTextFile( inputFileJoined );
 Tap sink = getPlatform().getTextFile( getOutputPath( "ungrouped" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 pipe = new Each( pipe, new Fields( "line" ), new RegexSplitter( new Fields( "num", "lower", "upper" ) ) );
 pipe = new Each( pipe, new UnGroup( new Fields( "num", "char" ), new Fields( "num" ), Fields.fields( new Fields( "lower" ), new Fields( "upper" ) ) ) );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 10 );
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testSwap() throws Exception
 {
 Tap source = getPlatform().getTextFile( new Fields( "offset", "line" ), inputFileApache );
 Tap sink = getPlatform().getTextFile( new Fields( "offset", "line" ), new Fields( "count", "ipaddress" ), getOutputPath( "swap" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 Function parser = new RegexParser( new Fields( "ip" ), "^[^ ]*" );
 pipe = new Each( pipe, new Fields( "line" ), parser, Fields.SWAP );
 pipe = new GroupBy( pipe, new Fields( "ip" ) );
 pipe = new Every( pipe, new Fields( "ip" ), new Count( new Fields( "count" ) ) );
 pipe = new Each( pipe, new Fields( "ip" ), new Identity( new Fields( "ipaddress" ) ), Fields.SWAP );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 8, 2, Pattern.compile( "^\\d+\\s\\d+\\s[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}$" ) );
 }

代码示例来源:origin: cascading/cascading-platform

private Flow firstFlow( String path, boolean doFail )
 {
 Tap source = getPlatform().getTextFile( inputFileIps );
 Pipe pipe = new Pipe( "first" );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "ip" ) ), new Fields( "ip" ) );
 if( doFail )
  pipe = new Each( pipe, new Fields( "ip" ), new FailFunction( Fields.ARGS ), Fields.REPLACE );
 Tap sink = getPlatform().getTabDelimitedFile( new Fields( "ip" ), getOutputPath( path ), SinkMode.REPLACE );
 return getPlatform().getFlowConnector().connect( "first", source, sink, pipe );
 }

代码示例来源:origin: cwensel/cascading

private Flow firstFlow( String path, boolean doFail )
 {
 Tap source = getPlatform().getTextFile( inputFileIps );
 Pipe pipe = new Pipe( "first" );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "ip" ) ), new Fields( "ip" ) );
 if( doFail )
  pipe = new Each( pipe, new Fields( "ip" ), new FailFunction( Fields.ARGS ), Fields.REPLACE );
 Tap sink = getPlatform().getTabDelimitedFile( new Fields( "ip" ), getOutputPath( path ), SinkMode.REPLACE );
 return getPlatform().getFlowConnector().connect( "first", source, sink, pipe );
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testReplace() throws Exception
 {
 Tap source = getPlatform().getTextFile( new Fields( "offset", "line" ), inputFileApache );
 Tap sink = getPlatform().getTextFile( new Fields( "offset", "line" ), new Fields( "offset", "line" ), getOutputPath( "replace" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 Function parser = new RegexParser( new Fields( 0 ), "^[^ ]*" );
 pipe = new Each( pipe, new Fields( "line" ), parser, Fields.REPLACE );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( Fields.ARGS ), Fields.REPLACE );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "line" ) ), Fields.REPLACE );
 pipe = new Each( pipe, new Debug( true ) );
 Flow flow = getPlatform().getFlowConnector( disableDebug() ).connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 10, 2, Pattern.compile( "^\\d+\\s\\d+\\s[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}$" ) );
 }

代码示例来源:origin: cwensel/cascading

private Flow firstFlow( String name )
 {
 Tap source = getPlatform().getTextFile( inputFileIps );
 Pipe pipe = new Pipe( name );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "ip" ) ), new Fields( "ip" ) );
 Tap sink = getPlatform().getTabDelimitedFile( new Fields( "ip" ), getOutputPath( name ), SinkMode.REPLACE );
 return getPlatform().getFlowConnector().connect( source, sink, pipe );
 }

代码示例来源:origin: cwensel/cascading

private Flow firstFlow( String path )
 {
 Tap source = getPlatform().getTextFile( inputFileIps );
 Pipe pipe = new Pipe( "first" );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "ip" ) ), new Fields( "ip" ) );
 Tap sink = getPlatform().getTabDelimitedFile( new Fields( "ip" ), getOutputPath( path + "/first" ), SinkMode.REPLACE );
 return getPlatform().getFlowConnector().connect( source, sink, pipe );
 }

代码示例来源:origin: cascading/cascading-platform

@Test
public void testSwap() throws Exception
 {
 Tap source = getPlatform().getTextFile( new Fields( "offset", "line" ), inputFileApache );
 Tap sink = getPlatform().getTextFile( new Fields( "offset", "line" ), new Fields( "count", "ipaddress" ), getOutputPath( "swap" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 Function parser = new RegexParser( new Fields( "ip" ), "^[^ ]*" );
 pipe = new Each( pipe, new Fields( "line" ), parser, Fields.SWAP );
 pipe = new GroupBy( pipe, new Fields( "ip" ) );
 pipe = new Every( pipe, new Fields( "ip" ), new Count( new Fields( "count" ) ) );
 pipe = new Each( pipe, new Fields( "ip" ), new Identity( new Fields( "ipaddress" ) ), Fields.SWAP );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 8, 2, Pattern.compile( "^\\d+\\s\\d+\\s[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}$" ) );
 }

代码示例来源:origin: cascading/cascading-platform

private Flow firstFlow( String path )
 {
 Tap source = getPlatform().getTextFile( inputFileIps );
 Pipe pipe = new Pipe( "first" );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "ip" ) ), new Fields( "ip" ) );
 Tap sink = getPlatform().getTabDelimitedFile( new Fields( "ip" ), getOutputPath( path + "/first" ), SinkMode.REPLACE );
 return getPlatform().getFlowConnector().connect( source, sink, pipe );
 }

代码示例来源:origin: cascading/cascading-platform

@Test
public void testReplace() throws Exception
 {
 Tap source = getPlatform().getTextFile( new Fields( "offset", "line" ), inputFileApache );
 Tap sink = getPlatform().getTextFile( new Fields( "offset", "line" ), new Fields( "offset", "line" ), getOutputPath( "replace" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 Function parser = new RegexParser( new Fields( 0 ), "^[^ ]*" );
 pipe = new Each( pipe, new Fields( "line" ), parser, Fields.REPLACE );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( Fields.ARGS ), Fields.REPLACE );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "line" ) ), Fields.REPLACE );
 pipe = new Each( pipe, new Debug( true ) );
 Flow flow = getPlatform().getFlowConnector( disableDebug() ).connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 10, 2, Pattern.compile( "^\\d+\\s\\d+\\s[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}$" ) );
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testUnGroupAnon() throws Exception
 {
 getPlatform().copyFromLocal( inputFileJoined );
 Tap source = getPlatform().getTextFile( inputFileJoined );
 Tap sink = getPlatform().getTextFile( getOutputPath( "ungroupedanon" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 pipe = new Each( pipe, new Fields( "line" ), new RegexSplitter( new Fields( "num", "lower", "upper" ) ) );
 pipe = new Each( pipe, new UnGroup( new Fields( "num" ), Fields.fields( new Fields( "lower" ), new Fields( "upper" ) ) ) );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 10 );
 }

代码示例来源:origin: cascading/cascading-platform

private Flow previousMultiTapFlow( String path, String ordinal )
 {
 Tap source = getPlatform().getTextFile( inputFileIps );
 Pipe pipe = new Pipe( ordinal );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "ip" ) ), new Fields( "ip" ) );
 Tap sink = getPlatform().getTabDelimitedFile( new Fields( "ip" ), getOutputPath( path + "/" + ordinal ), SinkMode.REPLACE );
 return getPlatform().getFlowConnector().connect( "previous-multi-tap-" + ordinal, source, sink, pipe );
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testNone() throws Exception
 {
 Tap source = getPlatform().getTextFile( new Fields( "offset", "line" ), inputFileApache );
 Tap sink = getPlatform().getTextFile( new Fields( "offset", "line" ), new Fields( "count", "ip" ), getOutputPath( "none" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 Function parser = new RegexParser( new Fields( "ip" ), "^[^ ]*" );
 pipe = new Each( pipe, new Fields( "line" ), parser, Fields.ALL );
 pipe = new Each( pipe, new Fields( "line" ), new NoOp(), Fields.SWAP ); // declares Fields.NONE
 pipe = new GroupBy( pipe, new Fields( "ip" ) );
 pipe = new Every( pipe, new Fields( "ip" ), new Count( new Fields( "count" ) ) );
 pipe = new Each( pipe, Fields.NONE, new Insert( new Fields( "ipaddress" ), "1.2.3.4" ), Fields.ALL );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 8, 2, Pattern.compile( "^\\d+\\s\\d+\\s[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}\\.[\\d]{1,3}$" ) );
 }

代码示例来源:origin: cwensel/cascading

private Flow previousMultiTapFlow( String path, String ordinal )
 {
 Tap source = getPlatform().getTextFile( inputFileIps );
 Pipe pipe = new Pipe( ordinal );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "ip" ) ), new Fields( "ip" ) );
 Tap sink = getPlatform().getTabDelimitedFile( new Fields( "ip" ), getOutputPath( path + "/" + ordinal ), SinkMode.REPLACE );
 return getPlatform().getFlowConnector().connect( "previous-multi-tap-" + ordinal, source, sink, pipe );
 }

代码示例来源:origin: cascading/cascading-platform

@Test
public void testUnGroupAnon() throws Exception
 {
 getPlatform().copyFromLocal( inputFileJoined );
 Tap source = getPlatform().getTextFile( inputFileJoined );
 Tap sink = getPlatform().getTextFile( getOutputPath( "ungroupedanon" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "test" );
 pipe = new Each( pipe, new Fields( "line" ), new RegexSplitter( new Fields( "num", "lower", "upper" ) ) );
 pipe = new Each( pipe, new UnGroup( new Fields( "num" ), Fields.fields( new Fields( "lower" ), new Fields( "upper" ) ) ) );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 10 );
 }

代码示例来源:origin: cascading/cascading-platform

private Flow firstFlow( String name )
 {
 Tap source = getPlatform().getTextFile( inputFileIps );
 Pipe pipe = new Pipe( name );
 pipe = new Each( pipe, new Fields( "line" ), new Identity( new Fields( "ip" ) ), new Fields( "ip" ) );
 Tap sink = getPlatform().getTabDelimitedFile( new Fields( "ip" ), getOutputPath( name ), SinkMode.REPLACE );
 return getPlatform().getFlowConnector().connect( source, sink, pipe );
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testRenameNamed() throws IOException
 {
 getPlatform().copyFromLocal( inputFileLower );
 Tap source = getPlatform().getTextFile( inputFileLower );
 Tap sink = getPlatform().getTextFile( new Fields( "line" ), new Fields( "item", "element" ), getOutputPath( "rename" ), SinkMode.REPLACE );
 Pipe pipe = new Pipe( "shape" );
 Function splitter = new RegexSplitter( new Fields( "num", "char" ), " " );
 pipe = new Each( pipe, new Fields( "line" ), splitter );
 pipe = new Rename( pipe, new Fields( "num", "char" ), new Fields( "item", "element" ) );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 5, 1, Pattern.compile( "^\\d+\\s\\w+$" ) );
 }

相关文章