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


Java Fields类代码示例

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


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

示例1: coerceToString

import cascading.tuple.Fields; //导入依赖的package包/类
static Tuple coerceToString(SinkCall<?, ?> sinkCall) {
    TupleEntry entry = sinkCall.getOutgoingEntry();
    Fields fields = entry.getFields();
    Tuple tuple = entry.getTuple();

    if (fields.hasTypes()) {
        Type types[] = new Type[fields.size()];
        for (int index = 0; index < fields.size(); index++) {
            Type type = fields.getType(index);
            if (type instanceof CoercibleType<?>) {
                types[index] = String.class;
            }
            else {
                types[index] = type;
            }
        }

        tuple = entry.getCoercedTuple(types);
    }
    return tuple;
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:22,代码来源:CascadingUtils.java

示例2: testUpdateOnlyScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpdateOnlyScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "update");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "number");
    properties.put(ConfigurationOptions.ES_INDEX_AUTO_CREATE, "yes");
    properties.put(ConfigurationOptions.ES_UPDATE_RETRY_ON_CONFLICT, "3");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "counter = 3");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_INPUT_JSON, "yes");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("json-cascading-local/createwithid", new Fields("line"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:19,代码来源:AbstractCascadingLocalJsonSaveTest.java

示例3: testUpdateOnlyParamScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpdateOnlyParamScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "update");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "number");
    properties.put(ConfigurationOptions.ES_INDEX_AUTO_CREATE, "yes");
    properties.put(ConfigurationOptions.ES_UPDATE_RETRY_ON_CONFLICT, "3");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "counter = param1; anothercounter = param2");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_PARAMS, " param1:<1>,   param2:number ");
    properties.put(ConfigurationOptions.ES_INPUT_JSON, "yes");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("json-cascading-local/createwithid", new Fields("line"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:20,代码来源:AbstractCascadingLocalJsonSaveTest.java

示例4: testUpdateOnlyParamJsonScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpdateOnlyParamJsonScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "update");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "number");
    properties.put(ConfigurationOptions.ES_UPDATE_RETRY_ON_CONFLICT, "3");

    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "counter = param1; anothercounter = param2");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_PARAMS_JSON, "{ \"param1\":1, \"param2\":2}");
    properties.put(ConfigurationOptions.ES_INPUT_JSON, "yes");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("json-cascading-local/createwithid", new Fields("line"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:20,代码来源:AbstractCascadingLocalJsonSaveTest.java

示例5: testUpsertParamScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpsertParamScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "upsert");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "number");
    properties.put(ConfigurationOptions.ES_INPUT_JSON, "yes");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "counter += param1; anothercounter += param2");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_PARAMS, " param1:<1>,   param2:number ");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("json-cascading-local/upsert-param-script", new Fields("line"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:18,代码来源:AbstractCascadingLocalJsonSaveTest.java

示例6: testUpsertParamJsonScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpsertParamJsonScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "upsert");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "number");
    properties.put(ConfigurationOptions.ES_INPUT_JSON, "yes");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "ctx._source.counter += param1; ctx._source.anothercounter += param2");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_PARAMS_JSON, "{ \"param1\":1, \"param2\":2}");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("json-cascading-local/upsert-script-json-script", new Fields("line"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:18,代码来源:AbstractCascadingLocalJsonSaveTest.java

示例7: testUpdateOnlyParamScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpdateOnlyParamScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "update");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "id");
    properties.put(ConfigurationOptions.ES_INDEX_AUTO_CREATE, "yes");
    properties.put(ConfigurationOptions.ES_UPDATE_RETRY_ON_CONFLICT, "3");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "counter = param1; anothercounter = param2");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_PARAMS, " param1:<1>,   param2:id ");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("cascading-local/createwithid", new Fields("id", "name", "url", "picture"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:19,代码来源:AbstractCascadingLocalSaveTest.java

示例8: testUpdateOnlyParamJsonScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpdateOnlyParamJsonScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "update");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "id");
    properties.put(ConfigurationOptions.ES_UPDATE_RETRY_ON_CONFLICT, "3");

    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "counter = param1; anothercounter = param2");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_PARAMS_JSON, "{ \"param1\":1, \"param2\":2}");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("cascading-local/createwithid", new Fields("id", "name", "url", "picture"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:19,代码来源:AbstractCascadingLocalSaveTest.java

示例9: testUpsertParamScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpsertParamScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "upsert");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "id");

    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "counter += param1; anothercounter += param2");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_PARAMS, " param1:<1>,   param2:id ");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("cascading-local/upsert-param-script", new Fields("id", "name", "url", "picture"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:18,代码来源:AbstractCascadingLocalSaveTest.java

示例10: testUpsertParamJsonScript

import cascading.tuple.Fields; //导入依赖的package包/类
@Test
public void testUpsertParamJsonScript() throws Exception {
    Properties properties = new TestSettings().getProperties();
    properties.put(ConfigurationOptions.ES_WRITE_OPERATION, "upsert");
    properties.put(ConfigurationOptions.ES_MAPPING_ID, "id");

    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT, "counter += param1; anothercounter += param2");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_LANG, "groovy");
    properties.put(ConfigurationOptions.ES_UPDATE_SCRIPT_PARAMS_JSON, "{ \"param1\":1, \"param2\":2}");

    Tap in = sourceTap();
    // use an existing id to allow the update to succeed
    Tap out = new EsTap("cascading-local/upsert-script-json-script", new Fields("id", "name", "url", "picture"));

    Pipe pipe = new Pipe("copy");
    build(properties, in, out, pipe);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:18,代码来源:AbstractCascadingLocalSaveTest.java

示例11: fieldsCountGreaterThanColumnsTest

import cascading.tuple.Fields; //导入依赖的package包/类
/**
 * Tests if correct number of input fields are provided.
 */
@Test(expected = RuntimeException.class)
public void fieldsCountGreaterThanColumnsTest() {

  String sourcePath = "src/test/resources/input/with-headers.txt";
  String sinkPath = "src/test/resources/output/sink-with-headers";

  FlowConnector connector = new Hadoop2MR1FlowConnector();
  CSVFormat sourceFormat = CSVFormat.newFormat(',')
    .withQuote('"')
    .withEscape('\\')
    .withRecordSeparator('\n');

  CSVFormat sinkFormat = CSVFormat.newFormat('\t')
    .withSkipHeaderRecord()
    .withEscape('\\')
    .withRecordSeparator('\n');

  Fields sourceFields = new Fields("id", "last name", "first name", "phone");
  Tap source = new Hfs(new CsvScheme(sourceFields, sourceFormat), sourcePath);
  Tap sink = new Hfs(new CsvScheme(sinkFormat), sinkPath);
  Pipe pipe = new Pipe("pipe");

  connector.connect(source, sink, pipe).complete();

}
 
开发者ID:datascienceinc,项目名称:cascading.csv,代码行数:29,代码来源:CsvSchemeTest.java

示例12: testSchemeFields

import cascading.tuple.Fields; //导入依赖的package包/类
/**
 * Helper method used for assertion of fields generated by CsvScheme.
 */
@SuppressWarnings("unchecked")
private void testSchemeFields(String sourcePath, CsvScheme sourceSchema, String sinkPath, CsvScheme sinkScheme, Set<String> expected) {

  Tap source = new Hfs(sourceSchema, sourcePath);
  Tap sink = new Hfs(sinkScheme, sinkPath);
  Pipe pipe = new Pipe("pipe");

  FlowConnector connector = new Hadoop2MR1FlowConnector();
  connector.connect(source, sink, pipe).complete();

  Fields sinkFields = sink.getSinkFields();
  for (int i = 0; i < sinkFields.size(); i++) {
    assertTrue("Unexpected column " + sinkFields.get(i), expected.contains(sinkFields.get(i)));
    expected.remove(sinkFields.get(i));
  }

  assertTrue("Not all expected values are found", expected.isEmpty());

}
 
开发者ID:datascienceinc,项目名称:cascading.csv,代码行数:23,代码来源:CsvSchemeTest.java

示例13: translateSource

import cascading.tuple.Fields; //导入依赖的package包/类
private DataSet<Tuple> translateSource(FlowProcess flowProcess, ExecutionEnvironment env, FlowNode node, int dop) {

		Tap tap = this.getSingle(node.getSourceTaps());
		JobConf tapConfig = new JobConf(this.getNodeConfig(node));
		tap.sourceConfInit(flowProcess, tapConfig);
		tapConfig.set( "cascading.step.source", Tap.id( tap ) );

		Fields outFields = tap.getSourceFields();
		registerKryoTypes(outFields);

		JobConf sourceConfig = new JobConf(this.getNodeConfig(node));
		MultiInputFormat.addInputFormat(sourceConfig, tapConfig);

		DataSet<Tuple> src = env
				.createInput(new TapInputFormat(node), new TupleTypeInfo(outFields))
						.name(tap.getIdentifier())
						.setParallelism(dop)
						.withParameters(FlinkConfigConverter.toFlinkConfig(new Configuration(sourceConfig)));

		return src;

	}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:23,代码来源:FlinkFlowStep.java

示例14: registerKryoTypes

import cascading.tuple.Fields; //导入依赖的package包/类
private void registerKryoTypes(Fields fields) {

		if(fields.hasTypes()) {
			Class[] fieldTypeClasses = fields.getTypesClasses();
			for(Class fieldTypeClass : fieldTypeClasses) {
				if(!fieldTypeClass.isPrimitive() &&
						!fieldTypeClass.equals(String.class) &&
						!Writable.class.isAssignableFrom(fieldTypeClass)) {
					// register type if it is neither a primitive, String, or Writable

					env.getConfig().registerKryoType(fieldTypeClass);
				}
			}
		}

	}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:17,代码来源:FlinkFlowStep.java

示例15: makeJoinedBuilder

import cascading.tuple.Fields; //导入依赖的package包/类
private TupleBuilder makeJoinedBuilder( final Fields[] joinFields )
{
	final Fields[] fields = isSelfJoin() ? new Fields[ size() ] : joinFields;

	if( isSelfJoin() ) {
		Arrays.fill(fields, 0, fields.length, joinFields[0]);
	}

	return new TupleBuilder()
	{
		Tuple result = TupleViews.createComposite(fields);

		@Override
		public Tuple makeResult( Tuple[] tuples )
		{
			return TupleViews.reset( result, tuples );
		}
	};
}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:20,代码来源:JoinClosure.java


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