当前位置: 首页>>代码示例>>Java>>正文


Java Flow类代码示例

本文整理汇总了Java中cascading.flow.Flow的典型用法代码示例。如果您正苦于以下问题:Java Flow类的具体用法?Java Flow怎么用?Java Flow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Flow类属于cascading.flow包,在下文中一共展示了Flow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import cascading.flow.Flow; //导入依赖的package包/类
public static void main(String [] args) {

        Properties properties = new Properties();

        properties.put(SplunkConf.SPLUNK_USERNAME, "admin");
        properties.put(SplunkConf.SPLUNK_PASSWORD, "changeIt");
        properties.put(SplunkConf.SPLUNK_HOST, "localhost");
        properties.put(SplunkConf.SPLUNK_PORT, "9050");

        SplunkDataQuery splunkSearch = new SplunkDataQuery();
        SplunkScheme inputScheme = new SplunkScheme(splunkSearch);
        SplunkTap input = new SplunkTap(properties,inputScheme);

        TextLine outputScheme = new TextLine();
        Hfs output = new Hfs( outputScheme, PATH_TO_OUTPUT, SinkMode.REPLACE );

        Pipe pipe = new Pipe( "test" );
        Flow flow = new HadoopFlowConnector().connect( input, output, pipe );

        flow.complete();
    }
 
开发者ID:yolodata,项目名称:tbana,代码行数:22,代码来源:SplunkSchemeExample.java

示例2: runCascadingJob

import cascading.flow.Flow; //导入依赖的package包/类
public Flow runCascadingJob( Path inputPath, Path outputPath) throws IOException
{
    Properties properties = new Properties();

    ShuttlCsv inputScheme = new ShuttlCsv(new SplunkDataQuery());
    TextLine outputScheme = new TextLine();

    Hfs input = new Hfs(inputScheme,inputPath.toString());
    Hfs output = new Hfs(outputScheme,outputPath.toString(),SinkMode.REPLACE);

    Pipe pipe = new Pipe( "test" );
    Flow flow = new HadoopFlowConnector( properties ).connect( input, output, pipe );

    flow.complete();

    return flow;
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:18,代码来源:ShuttlCsvTest.java

示例3: runSplunkScheme

import cascading.flow.Flow; //导入依赖的package包/类
public void runSplunkScheme(String path, String inputData) throws IOException
{
    Properties properties = TestConfigurations.getSplunkLoginAsProperties();
    SplunkScheme inputScheme = new SplunkScheme(TestConfigurations.getSplunkSearch());
    TextLine outputScheme = new TextLine();

    SplunkTap input = new SplunkTap(properties,inputScheme);
    Hfs output = new Hfs( outputScheme, outputPath + "/quoted/" + path, SinkMode.REPLACE );

    Pipe pipe = new Pipe( "test" );
    Flow flow = new HadoopFlowConnector().connect( input, output, pipe );

    flow.complete();

    validateLength( flow, 10, 2 );

    TupleEntryIterator iterator = flow.openSource();

    // TODO: Header information not used in SplunkScheme yet
    // verifyHeader(iterator.getFields());

    verifyContent(iterator);
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:24,代码来源:SplunkSchemeTest.java

示例4: printStats

import cascading.flow.Flow; //导入依赖的package包/类
private static void printStats(Flow flow) {
    CascadingStats stats = flow.getStats();
    System.out.println("Cascading stats for " + Counter.class.getName());
    for (String counter : stats.getCountersFor(Counter.class)) {
        System.out.println(String.format("%s\t%s", counter, stats.getCounterValue(Counter.class.getName(), counter)));
    }
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:8,代码来源:StatsUtils.java

示例5: printStats

import cascading.flow.Flow; //导入依赖的package包/类
private void printStats(Flow flow) {
    CascadingStats stats = flow.getStats();
    System.out.println("Cascading stats for " + Counter.class.getName());
    for (String counter : stats.getCountersFor(Counter.class)) {
        System.out.println(String.format("%s\t%s", counter, stats.getCounterValue(Counter.class.getName(), counter)));
    }
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:8,代码来源:ExtendedLocalFlowConnector.java

示例6: testCascadeConnector

import cascading.flow.Flow; //导入依赖的package包/类
@Test
public void testCascadeConnector() {
    Pipe copy = new Pipe("copy");
    Properties cfg = new TestSettings().getProperties();

    FlowDef flow = new FlowDef().addSource(copy, sourceTap()).addTailSink(copy,
            new EsTap("cascading-local/cascade-connector"));

    FlowConnector connector = new LocalFlowConnector(cfg);
    Flow[] flows = new Flow[] { connector.connect(flow) };

    CascadeConnector cascadeConnector = new CascadeConnector(cfg);
    cascadeConnector.connect(flows).complete();
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:15,代码来源:AbstractCascadingLocalSaveTest.java

示例7: testCascadeConnector

import cascading.flow.Flow; //导入依赖的package包/类
@Test
public void testCascadeConnector() {
    Pipe copy = new Pipe("copy");
    Properties cfg = HdpBootstrap.asProperties(CascadingHadoopSuite.configuration);

    FlowDef flow = new FlowDef().addSource(copy, sourceTap())
            .addTailSink(copy, new EsTap("cascading-hadoop/cascade-connector"));

    FlowConnector connector = new HadoopFlowConnector(cfg);
    Flow[] flows = new Flow[] { connector.connect(flow) };

    CascadeConnector cascadeConnector = new CascadeConnector(cfg);
    cascadeConnector.connect(flows).complete();
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:15,代码来源:AbstractCascadingHadoopSaveTest.java

示例8: countFacts

import cascading.flow.Flow; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public static void countFacts() throws Exception {
	// Erzeuge Tap aus Master Pail
	Tap masterDataset = dataTap(FileUtils.prepareMasterFactsPath(false,false));

	// Die Query erzeugt nur einen Zählerwert
	query = new Subquery("?count")
			// Master PailTap generiert Tupel nur mit Data Element
			.predicate(masterDataset, "_", "?raw")
			// Aggregation aller Tupel als Zählerwert
			.predicate(new Count(), "?count");

	// Query ausführen; Ergebnis wird an Stdout gesendet
	Api.execute(new StdoutTap(), query);

	///////////////////////////////////////////////////////////////
	// Optional:
	// Die Querry kann auch als Cascading Flow kompiliert werden
	Flow flow = Api.compileFlow(new StdoutTap(), query);

	// Eine Grafik des Cascading Flows erzeugen (ähnlich Pipe Diagramm)
	flow.writeDOT("/tmp/count_fact_flow.dot");

	// Alternative Möglichkeit, die Query auszuführen
	// flow.complete();
	///////////////////////////////////////////////////////////////
}
 
开发者ID:zirpins,项目名称:bdelab,代码行数:28,代码来源:CountFacts2.java

示例9: main

import cascading.flow.Flow; //导入依赖的package包/类
public static void main(String[] args) {

		if (args.length < 2) {
			throw new IllegalArgumentException("Please specify input and ouput paths as arguments.");
		}

		Fields token = new Fields( "token", String.class );
		Fields text = new Fields( "text" );
		RegexSplitGenerator splitter = new RegexSplitGenerator( token, "\\s+" );
		// only returns "token"
		Pipe docPipe = new Each( "token", text, splitter, Fields.RESULTS );

		Pipe wcPipe = new Pipe( "wc", docPipe );
		wcPipe = new AggregateBy( wcPipe, token, new CountBy(new Fields("count")));

		Tap inTap = new Hfs(new TextDelimited(text, "\n" ), args[0]);
		Tap outTap = new Hfs(new TextDelimited(false, "\n"), args[1], SinkMode.REPLACE);

		FlowDef flowDef = FlowDef.flowDef().setName( "wc" )
				.addSource( docPipe, inTap )
				.addTailSink( wcPipe, outTap );

		FlowConnector flowConnector = new FlinkConnector();

		Flow wcFlow = flowConnector.connect( flowDef );

		wcFlow.complete();
	}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:29,代码来源:WordCount.java

示例10: readWriteInFlowMR1

import cascading.flow.Flow; //导入依赖的package包/类
@Test
public void readWriteInFlowMR1() throws IOException {
  try (OrcWriter writer = new OrcWriter.Builder(conf, new Path(path, "part-00000"))
      .addField("a", TypeInfoFactory.stringTypeInfo)
      .addField("b", TypeInfoFactory.stringTypeInfo)
      .build()) {
    writer.addRow("A1", "B1");
    writer.addRow("A2", "B2");
  }

  String output = new File(temporaryFolder.getRoot(), "output").getCanonicalPath();

  Pipe pipe = new Pipe(UUID.randomUUID().toString());
  FlowDef flowDef = FlowDef
      .flowDef()
      .setName(UUID.randomUUID().toString())
      .addSource(pipe, new Hfs(OrcFile.source().declaredFields(FIELDS_AB).schemaFromFile().build(), path))
      .addTailSink(pipe, new Hfs(OrcFile.sink().schema(FIELDS_AB).build(), output));

  Flow<?> flow = new Hadoop2MR1FlowConnector(HadoopUtil.createProperties(conf)).connect(flowDef);
  flow.complete();
  flow.cleanup();

  try (OrcReader reader = new OrcReader(conf, new Path(output, "part-00000"))) {
    assertThat(reader.hasNext(), is(true));
    List<Object> list = reader.next();
    assertThat(list.size(), is(2));
    assertThat(list.get(0), is((Object) "A1"));
    assertThat(list.get(1), is((Object) "B1"));

    assertThat(reader.hasNext(), is(true));
    list = reader.next();
    assertThat(list.size(), is(2));
    assertThat(list.get(0), is((Object) "A2"));
    assertThat(list.get(1), is((Object) "B2"));

    assertThat(reader.hasNext(), is(false));
  }
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:40,代码来源:OrcFileTest.java

示例11: readWriteInFlowTez

import cascading.flow.Flow; //导入依赖的package包/类
@Test
public void readWriteInFlowTez() throws IOException {
  try (OrcWriter writer = new OrcWriter.Builder(conf, new Path(path, "part-00000"))
      .addField("a", TypeInfoFactory.stringTypeInfo)
      .addField("b", TypeInfoFactory.stringTypeInfo)
      .build()) {
    writer.addRow("A1", "B1");
    writer.addRow("A2", "B2");
  }

  String output = new File(temporaryFolder.getRoot(), "output").getCanonicalPath();

  Pipe pipe = new Pipe(UUID.randomUUID().toString());
  FlowDef flowDef = FlowDef
      .flowDef()
      .setName(UUID.randomUUID().toString())
      .addSource(pipe, new Hfs(OrcFile.source().declaredFields(FIELDS_AB).schemaFromFile().build(), path))
      .addTailSink(pipe, new Hfs(OrcFile.sink().schema(FIELDS_AB).build(), output));

  Flow<?> flow = new Hadoop2TezFlowConnector(HadoopUtil.createProperties(conf)).connect(flowDef);
  flow.complete();
  flow.cleanup();

  try (OrcReader reader = new OrcReader(conf, new Path(output, "part-v000-o000-00000"))) {
    assertThat(reader.hasNext(), is(true));
    List<Object> list = reader.next();
    assertThat(list.size(), is(2));
    assertThat(list.get(0), is((Object) "A1"));
    assertThat(list.get(1), is((Object) "B1"));

    assertThat(reader.hasNext(), is(true));
    list = reader.next();
    assertThat(list.size(), is(2));
    assertThat(list.get(0), is((Object) "A2"));
    assertThat(list.get(1), is((Object) "B2"));

    assertThat(reader.hasNext(), is(false));
  }
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:40,代码来源:OrcFileTest.java

示例12: main

import cascading.flow.Flow; //导入依赖的package包/类
public static void main(String[] args) {
  String salesPath = args[0];
  String storePath = args[1];
  String outPath = args[2];
  String date = "2452229";

  Properties properties = new Properties();
  AppProps.setApplicationJarClass(properties, Main.class);
  HadoopFlowConnector flowConnector = new HadoopFlowConnector(properties);

  Tap salesTap = new Hfs(new ORCFile(null, "0,7"), salesPath);
  Tap storeTap = new Hfs(new AvroScheme(), storePath);
  Tap outTap = new Hfs(new TextDelimited(true, "\t"), outPath);

  Pipe salesPipe = new Each("sales", new Fields("solddatesk"), new DateFilter(Integer.valueOf(date)));
  Pipe storePipe = new Pipe("store");
  Pipe joinPipe = new HashJoin(salesPipe, new Fields("storesk"), storePipe, new Fields("storeSk"));

  // _col24 is state_name
  Pipe countPipe = new CountBy(joinPipe, new Fields("state"),
      new Fields("item_count"));

  FlowDef flowDef = FlowDef.flowDef().setName("count")
      .addSource(salesPipe, salesTap)
      .addSource(storePipe, storeTap)
      .addTailSink(countPipe, outTap);
      //.addTailSink(joinPipe, outTap);

  Flow countFlow = flowConnector.connect(flowDef);
  countFlow.complete();
}
 
开发者ID:cartershanklin,项目名称:orcfile-demos,代码行数:32,代码来源:Main.java

示例13: main

import cascading.flow.Flow; //导入依赖的package包/类
public static void main(String [] args) {

        ShuttlCsv csv = new ShuttlCsv();
        Hfs input = new Hfs(csv,PATH_TO_SHUTTL_ARCHIVE);

        TextLine outputScheme = new TextLine();
        Hfs output = new Hfs(outputScheme, PATH_TO_OUTPUT);
        Pipe pipe = new Pipe( "test" );

        Properties properties = new Properties();
        Flow flow = new HadoopFlowConnector( properties ).connect( input, output, pipe );

        flow.complete();
    }
 
开发者ID:yolodata,项目名称:tbana,代码行数:15,代码来源:ShuttlCsvExample.java

示例14: runCSVLine

import cascading.flow.Flow; //导入依赖的package包/类
public void runCSVLine( String path, String inputData) throws IOException
{
    Properties properties = new Properties();

    CSVLine inputScheme = new CSVLine();
    TextLine outputScheme = new TextLine();

    Hfs input = new Hfs( inputScheme, inputData );
    Hfs output = new Hfs( outputScheme, outputPath + "/quoted/" + path, SinkMode.REPLACE );

    Pipe pipe = new Pipe( "test" );
    Flow flow = new HadoopFlowConnector( properties ).connect( input, output, pipe );

    flow.complete();

    validateLength( flow, 4, 2 ); // The file contains 4 rows, however there are only 3 CSV rows (inc the header row)


    TupleEntryIterator iterator = flow.openSource();

    ArrayListTextWritable expected = new ArrayListTextWritable();

    expected.add(new Text("header1"));
    expected.add(new Text("header2"));
    assertEquals(expected, iterator.next().getTuple().getObject(1));

    expected.clear();
    expected.add(new Text("Column1"));
    expected.add(new Text("Column 2 using\ntwo rows"));
    assertEquals(expected, iterator.next().getTuple().getObject(1));

    expected.clear();
    expected.add(new Text("c1"));
    expected.add(new Text("c2"));
    assertEquals(expected, iterator.next().getTuple().getObject(1));
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:37,代码来源:CSVLineTest.java

示例15: testCascadeConnector

import cascading.flow.Flow; //导入依赖的package包/类
@Test
public void testCascadeConnector() {
    Pipe copy = new Pipe("copy");
    Properties cfg = new TestSettings().getProperties();

    FlowDef flow = new FlowDef().addSource(copy, sourceTap()).addTailSink(copy,
            new EsTap("cascading-local-cascade-connector/data"));

    FlowConnector connector = new LocalFlowConnector(cfg);
    Flow[] flows = new Flow[] { connector.connect(flow) };

    CascadeConnector cascadeConnector = new CascadeConnector(cfg);
    cascadeConnector.connect(flows).complete();
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:15,代码来源:AbstractCascadingLocalSaveTest.java


注:本文中的cascading.flow.Flow类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。