本文整理汇总了Java中cascading.tap.SinkMode类的典型用法代码示例。如果您正苦于以下问题:Java SinkMode类的具体用法?Java SinkMode怎么用?Java SinkMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SinkMode类属于cascading.tap包,在下文中一共展示了SinkMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWhenExtraColumnsStrict
import cascading.tap.SinkMode; //导入依赖的package包/类
@Test(expected = FlowException.class)
public void testWhenExtraColumnsStrict() throws Exception {
String sourcePath = "src/test/resources/input/with-extra-columns.txt";
String sinkPath = "src/test/resources/input/sink-with-headers";
FlowConnector connector = new Hadoop2MR1FlowConnector();
CSVFormat sourceFormat = CSVFormat.newFormat('\t')
.withHeader("id", "first name", "last name", "city", "zip")
.withQuote('"')
.withEscape('\\')
.withRecordSeparator('\n');
CSVFormat sinkFormat = CSVFormat.newFormat('\t')
.withEscape('\\')
.withRecordSeparator('\n');
Tap source = new Hfs(new CsvScheme(sourceFormat, true), sourcePath);
Tap sink = new Hfs(new CsvScheme(sinkFormat), sinkPath, SinkMode.REPLACE);
Pipe pipe = new Pipe("pipe");
connector.connect(source, sink, pipe).complete();
}
示例2: testWhenExtraColumnsStrictNoHeaders
import cascading.tap.SinkMode; //导入依赖的package包/类
@Test(expected = FlowException.class)
public void testWhenExtraColumnsStrictNoHeaders() throws Exception {
String sourcePath = "src/test/resources/input/with-extra-columns-no-header.txt";
String sinkPath = "src/test/resources/input/sink-no-headers";
FlowConnector connector = new Hadoop2MR1FlowConnector();
CSVFormat sourceFormat = CSVFormat.newFormat('\t')
.withQuote('"')
.withEscape('\\')
.withRecordSeparator('\n');
CSVFormat sinkFormat = CSVFormat.newFormat('\t')
.withEscape('\\')
.withRecordSeparator('\n');
Tap source = new Hfs(new CsvScheme(sourceFormat, true), sourcePath);
Tap sink = new Hfs(new CsvScheme(sinkFormat), sinkPath, SinkMode.REPLACE);
Pipe pipe = new Pipe("pipe");
connector.connect(source, sink, pipe).complete();
}
示例3: testWithHeader
import cascading.tap.SinkMode; //导入依赖的package包/类
@Test
public void testWithHeader() throws Exception {
final String inputFile = "quoted_header.csv";
final String outputDir = "quoted_header";
final String compareFile = "quoted_header.csv";
final Properties props = new Properties();
final Configuration conf = new Configuration();
final Tap source = new Hfs(new OpenCsvScheme(), DATA_DIR + "/" + inputFile, SinkMode.KEEP);
final Tap sink = new Hfs(new OpenCsvScheme(), TMP_DIR + "/" + outputDir, SinkMode.REPLACE);
final Pipe pipe = new Each(new Pipe("test"), new Debug());
new HadoopFlowConnector(props).connect(source, sink, pipe).complete();
final Tap compare = new Hfs(new OpenCsvScheme(), COMPARE_DIR + "/" + compareFile, SinkMode.KEEP);
assertTrue(compareTaps(sink, compare, conf) == true);
}
示例4: testHeaderless
import cascading.tap.SinkMode; //导入依赖的package包/类
@Test
public void testHeaderless() throws Exception {
final String inputFile = "quoted_headerless.csv";
final String outputDir = "quoted_headerless";
final String compareFile = "quoted_headerless.csv";
final Properties props = new Properties();
final Configuration conf = new Configuration();
final Tap source = new Hfs(new OpenCsvScheme(new Fields("id", "product", "descr")), DATA_DIR + "/" + inputFile, SinkMode.KEEP);
final Tap sink = new Hfs(new OpenCsvScheme(new Fields("id", "product", "descr")), TMP_DIR + "/" + outputDir, SinkMode.REPLACE);
final Pipe pipe = new Each(new Pipe("test"), new Debug());
new HadoopFlowConnector(props).connect(source, sink, pipe).complete();
final Tap compare = new Hfs(new OpenCsvScheme(new Fields("id", "product", "descr")), COMPARE_DIR + "/" + compareFile, SinkMode.KEEP);
assertTrue(compareTaps(sink, compare, conf) == true);
}
示例5: main
import cascading.tap.SinkMode; //导入依赖的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();
}
示例6: runCascadingJob
import cascading.tap.SinkMode; //导入依赖的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;
}
示例7: runSplunkScheme
import cascading.tap.SinkMode; //导入依赖的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);
}
示例8: createTap
import cascading.tap.SinkMode; //导入依赖的package包/类
public Tap createTap(Scheme scheme, String path, SinkMode sinkMode, Properties properties) {
if (!(scheme instanceof EsScheme)) {
throw new EsHadoopIllegalArgumentException("Unknown scheme; expected " + EsScheme.class.getName());
}
String host = properties.getProperty("host");
String portString = properties.getProperty("port");
int port = (StringUtils.hasText(portString) ? Integer.parseInt(portString) : -1);
String query = properties.getProperty("query");
return CascadingUtils.hadoopTap(host, port, path, query, ((EsScheme) scheme).fields, properties);
}
示例9: EsTap
import cascading.tap.SinkMode; //导入依赖的package包/类
public EsTap(String host, int port, String resource, String query, Fields fields, Properties tapSettings) {
super(null, SinkMode.UPDATE);
this.resource = resource;
this.query = query;
this.host = host;
this.port = port;
this.fields = fields;
this.props = tapSettings;
}
示例10: testCreateTap
import cascading.tap.SinkMode; //导入依赖的package包/类
@Test
public void testCreateTap() {
Fields fl = new Fields();
Properties props = new Properties();
Scheme scheme = factory.createScheme(fl, props);
Tap tap = factory.createTap(scheme, "somePath", SinkMode.KEEP, props);
assertThat(tap, notNullValue());
assertThat(tap.getClass().getName(), containsString("HadoopTap"));
}
示例11: fieldsIncludedButNotMatchLengthTest
import cascading.tap.SinkMode; //导入依赖的package包/类
/**
* Tests if subset of input fields are provided, properly outputs only that subset.
*/
@Test
public void fieldsIncludedButNotMatchLengthTest() throws Exception {
String sourcePath = "src/test/resources/input/with-headers.txt";
String sinkPath = "src/test/resources/output/sink-with-headers";
String expectedPath = "src/test/resources/expected/sink-with-headers-id-only.txt";
FlowConnector connector = new Hadoop2MR1FlowConnector();
CSVFormat sourceFormat = CSVFormat.newFormat(',')
.withHeader("id", "first name", "last name")
.withQuote('"')
.withEscape('\\')
.withRecordSeparator('\n');
CSVFormat sinkFormat = CSVFormat.newFormat('\t')
.withSkipHeaderRecord()
.withEscape('\\')
.withRecordSeparator('\n');
Fields sourceFields = new Fields("id");
Tap source = new Hfs(new CsvScheme(sourceFields, sourceFormat), sourcePath);
Tap sink = new Hfs(new CsvScheme(sinkFormat), sinkPath, SinkMode.REPLACE);
Pipe pipe = new Pipe("pipe");
connector.connect(source, sink, pipe).complete();
testPaths(sinkPath, expectedPath);
}
示例12: testWhenExtraColumnsNotStrict
import cascading.tap.SinkMode; //导入依赖的package包/类
@Test
public void testWhenExtraColumnsNotStrict() throws Exception {
String sourcePath = "src/test/resources/input/with-extra-columns.txt";
String sinkPath = "src/test/resources/input/sink-with-headers";
String expectedPath = "src/test/resources/expected/with-extra-columns-no-strict.txt";
String trapPath = "src/test/resources/input/trap-sink-with-headers";
String expectedTrapPath = "src/test/resources/expected/trap-with-extra-columns-no-strict.txt";
FlowConnector connector = new Hadoop2MR1FlowConnector();
CSVFormat sourceFormat = CSVFormat.newFormat('\t')
.withQuote('"')
.withHeader("id", "first name", "last name", "city", "zip")
.withEscape('\\')
.withRecordSeparator('\n');
CSVFormat sinkFormat = CSVFormat.newFormat('\t')
.withSkipHeaderRecord()
.withEscape('\\')
.withRecordSeparator('\n');
Tap source = new Hfs(new CsvScheme(sourceFormat, false), sourcePath);
Tap sink = new Hfs(new CsvScheme(sinkFormat), sinkPath, SinkMode.REPLACE);
Tap trap = new Hfs(new TextDelimited(true, "\t"), trapPath, SinkMode.REPLACE);
Pipe pipe = new Pipe("pipe");
connector.connect("extra-columns-not-strict", source, sink, trap, pipe).complete();
testPaths(sinkPath, expectedPath);
testPaths(trapPath, expectedTrapPath);
}
示例13: testWhenExtraColumnsNotStrictNoHeaders
import cascading.tap.SinkMode; //导入依赖的package包/类
@Test
public void testWhenExtraColumnsNotStrictNoHeaders() throws Exception {
String sourcePath = "src/test/resources/input/with-extra-columns-no-header.txt";
String sinkPath = "src/test/resources/input/sink-no-headers";
String trapPath = "src/test/resources/input/trap-no-headers";
String expectedPath = "src/test/resources/expected/with-extra-columns-no-strict-no-header.txt";
String expectedTrapPath = "src/test/resources/expected/trap-with-extra-columns-no-strict-no-header.txt";
FlowConnector connector = new Hadoop2MR1FlowConnector();
CSVFormat sourceFormat = CSVFormat.newFormat('\t')
.withQuote('"')
.withEscape('\\')
.withRecordSeparator('\n');
CSVFormat sinkFormat = CSVFormat.newFormat('\t')
.withEscape('\\')
.withRecordSeparator('\n');
Tap source = new Hfs(new CsvScheme(sourceFormat, false), sourcePath);
Tap sink = new Hfs(new CsvScheme(sinkFormat), sinkPath, SinkMode.REPLACE);
Tap trap = new Hfs(new TextDelimited(false, "\t"), trapPath, SinkMode.REPLACE);
Pipe pipe = new Pipe("pipe");
connector.connect("test-extra-columns-no-header", source, sink, trap, pipe).complete();
testPaths(sinkPath, expectedPath);
testPaths(trapPath, expectedTrapPath);
}
示例14: main
import cascading.tap.SinkMode; //导入依赖的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();
}
示例15: getTextFile
import cascading.tap.SinkMode; //导入依赖的package包/类
@Override
public Tap getTextFile(Fields sourceFields, Fields sinkFields, String filename, SinkMode mode) {
if( sourceFields == null ) {
return new Hfs(new TextLine(), filename, mode);
}
return new Hfs( new TextLine( sourceFields, sinkFields ), filename, mode );
}