• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TupleEntryIterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Override
public TupleEntryIterator openForRead(FlowProcess<Properties> flowProcess, ScrollQuery input) throws IOException {
    if (input == null) {
        // get original copy
        Settings settings = CascadingUtils.addDefaultsToSettings(CascadingUtils.extractOriginalProperties(flowProcess.getConfigCopy()), tapProperties, log);

        // will be closed by the query is finished
        RestRepository client = new RestRepository(settings);
        Field mapping = client.getMapping();
        Collection<String> fields = CascadingUtils.fieldToAlias(settings, getSourceFields());

        // validate if possible
        FieldPresenceValidation validation = settings.getReadFieldExistanceValidation();
        if (validation.isRequired()) {
            MappingUtils.validateMapping(fields, mapping, validation, log);
        }

        input = QueryBuilder.query(settings).fields(StringUtils.concatenateAndUriEncode(fields,  ",")).
                build(client, new ScrollReader(new ScrollReaderConfig(new JdkValueReader(), mapping, settings)));
    }
    return new TupleEntrySchemeIterator<Properties, ScrollQuery>(flowProcess, getScheme(), input, getIdentifier());
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:23,代码来源:EsLocalTap.java


示例2: testPaths

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
/**
 * Tests the content of an output path against the given expected path.
 */
@SuppressWarnings("unchecked")
private void testPaths(String actual, String expected) throws Exception {

  Tap outputTest = new Hfs(new TextLine(), actual);
  Tap expectedTest = new Hfs(new TextLine(), expected);

  FlowProcess outputProcess = new HadoopFlowProcess(new JobConf(new Configuration()));
  FlowProcess expectedProcess = new HadoopFlowProcess(new JobConf(new Configuration()));

  TupleEntryIterator outputIterator = outputTest.openForRead(outputProcess);
  TupleEntryIterator expectedIterator = expectedTest.openForRead(expectedProcess);

  List<String> outputList = new ArrayList<>();
  while (outputIterator.hasNext()) {
    outputList.add(outputIterator.next().getTuple().getString(1));
  }

  List<String> expectedList = new ArrayList<>();
  while (expectedIterator.hasNext()) {
    expectedList.add(expectedIterator.next().getTuple().getString(1));
  }

  assertTrue(outputList.equals(expectedList));

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


示例3: compareTaps

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
public static boolean compareTaps(final Tap source1, final Tap source2, final Configuration conf) throws IOException {
    final FlowProcess flowProcess1 = new HadoopFlowProcess(new JobConf(conf));
    source1.getScheme().retrieveSourceFields(flowProcess1, source1);
    final TupleEntryIterator iter1 = source1.openForRead(new HadoopFlowProcess(new JobConf(conf)));
    final FlowProcess flowProcess2 = new HadoopFlowProcess(new JobConf(conf));
    source2.getScheme().retrieveSourceFields(flowProcess2, source2);
    final TupleEntryIterator iter2 = source2.openForRead(new HadoopFlowProcess(new JobConf(conf)));
    if (!iter1.getFields().equals(iter2.getFields()))
        return false;
    List<Tuple> list1 = new ArrayList<Tuple>();
    while (iter1.hasNext())
        list1.add(new Tuple(iter1.next().getTuple()));
    iter1.close();
    Collections.sort(list1);
    List<Tuple> list2 = new ArrayList<Tuple>();
    while (iter2.hasNext())
        list2.add(new Tuple(iter2.next().getTuple()));
    iter2.close();
    Collections.sort(list2);
    return list1.equals(list2);
}
 
开发者ID:tresata,项目名称:cascading-opencsv,代码行数:22,代码来源:OpenCsvSchemeTest.java


示例4: read

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
/**
 * Reads the {@link Tuple Tuples} from the {@link Tap} and returns them wrapped in a {@link Data} instance whose
 * {@link Fields} confirm to those supplied by {@link Tap#getSourceFields()}.
 */
Data read() throws IOException {
  TupleEntryIterator tuples = null;
  try {
    Class<?> tapConfigClass = TapTypeUtil.getTapConfigClass(source);

    if (Configuration.class.equals(tapConfigClass)) {
      tuples = getHadoopTupleEntryIterator();
    } else if (Properties.class.equals(tapConfigClass)) {
      tuples = getLocalTupleEntryIterator();
    } else {
      throw new IllegalArgumentException("Unsupported tap type: " + source.getClass());
    }
    List<Tuple> resultTuples = new ArrayList<Tuple>();
    while (tuples.hasNext()) {
      resultTuples.add(new Tuple(tuples.next().getTuple()));
    }
    return new Data(source.getSourceFields(), Collections.unmodifiableList(resultTuples));
  } finally {
    if (tuples != null) {
      tuples.close();
    }
  }
}
 
开发者ID:HotelsDotCom,项目名称:plunger,代码行数:28,代码来源:TapDataReader.java


示例5: runSplunkScheme

import cascading.tuple.TupleEntryIterator; //导入依赖的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


示例6: exerciseScheme

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Test
public void exerciseScheme() throws IOException {
  TupleEntryIterator iterator = tap.openForRead(flowProcess);
  while (iterator.hasNext()) {
    iterator.next();
  }
  iterator.close();
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:9,代码来源:OrcFileSourcePerformanceTest.java


示例7: getHadoopTupleEntryIterator

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
private TupleEntryIterator getHadoopTupleEntryIterator() throws IOException {
  @SuppressWarnings("unchecked")
  Tap<JobConf, ?, ?> hadoopTap = (Tap<JobConf, ?, ?>) source;
  JobConf conf = new JobConf();
  FlowProcess<JobConf> flowProcess = new HadoopFlowProcess(conf);
  hadoopTap.sourceConfInit(flowProcess, conf);
  return hadoopTap.openForRead(flowProcess);
}
 
开发者ID:HotelsDotCom,项目名称:plunger,代码行数:9,代码来源:TapDataReader.java


示例8: getLocalTupleEntryIterator

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
private TupleEntryIterator getLocalTupleEntryIterator() throws IOException {
  @SuppressWarnings("unchecked")
  Tap<Properties, ?, ?> localTap = (Tap<Properties, ?, ?>) source;
  Properties properties = new Properties();
  FlowProcess<Properties> flowProcess = new LocalFlowProcess(properties);
  localTap.sourceConfInit(flowProcess, properties);
  return localTap.openForRead(flowProcess);
}
 
开发者ID:HotelsDotCom,项目名称:plunger,代码行数:9,代码来源:TapDataReader.java


示例9: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Test
public void openForRead() throws IOException {
  TupleEntryIterator iterator = tap.openForRead(null, null);
  assertThat(iterator.hasNext(), is(true));
  assertThat(iterator.next(), is(new TupleEntry(FIELDS, TUPLE_1)));
  assertThat(iterator.hasNext(), is(true));
  assertThat(iterator.next(), is(new TupleEntry(FIELDS, TUPLE_2)));
  assertThat(iterator.hasNext(), is(false));
}
 
开发者ID:HotelsDotCom,项目名称:plunger,代码行数:10,代码来源:TupleListTapTest.java


示例10: verifyContent

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
private void verifyContent(TupleEntryIterator iterator) throws IOException {

        String [] expectedRows = new String[] {
                "1,count=4",
                "2,count=3",
                "3,count=2",
                "4,count=1",
                "5,count=0"
        };
        for(String expectedRow : expectedRows)
            checkResults(iterator.next().getTuple(), expectedRow);
    }
 
开发者ID:yolodata,项目名称:tbana,代码行数:13,代码来源:SplunkSchemeTest.java


示例11: runCSVLine

import cascading.tuple.TupleEntryIterator; //导入依赖的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


示例12: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Override
public TupleEntryIterator openForRead(FlowProcess<JobConf> flowProcess, RecordReader input) throws IOException {
    return new HadoopTupleEntrySchemeIterator(flowProcess, this, input);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:5,代码来源:EsHadoopTap.java


示例13: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Override
public TupleEntryIterator openForRead(FlowProcess<Object> flowProcess, Object input) throws IOException {
    initInnerTapIfNotSetFromFlowProcess(flowProcess);
    return actualTap.openForRead(flowProcess, input);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:6,代码来源:EsTap.java


示例14: openTapForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Override
public TupleEntryIterator openTapForRead(Tap tap) throws IOException {
	return tap.openForRead( this );
}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:5,代码来源:FlinkFlowProcess.java


示例15: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p/>
 * Returned type is a {@link ListTupleEntryIterator}.
 */
@Override
public TupleEntryIterator openForRead(FlowProcess<? extends Properties> flowProcess, Iterator<Tuple> input)
  throws IOException {
  return new ListTupleEntryIterator(getSourceFields(), this.input);
}
 
开发者ID:HotelsDotCom,项目名称:plunger,代码行数:11,代码来源:TupleListTap.java


示例16: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
/**
 * Always throws {@link UnsupportedOperationException} - this is a sink not a tap.
 *
 * @throws UnsupportedOperationException always.
 */
@Override
public TupleEntryIterator openForRead(FlowProcess<? extends Properties> flowProcess, Iterator<Tuple> input)
    throws IOException {
  throw new UnsupportedOperationException("cannot read from a " + getClass().getSimpleName());
}
 
开发者ID:HotelsDotCom,项目名称:plunger,代码行数:11,代码来源:Bucket.java


示例17: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Override
public TupleEntryIterator openForRead(FlowProcess<? extends String> flowProcess, Long input) throws IOException {
  return null;
}
 
开发者ID:HotelsDotCom,项目名称:plunger,代码行数:5,代码来源:UnsupportedTap.java


示例18: launchFlow

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
List<Tuple> launchFlow() throws IOException {
    File tmpDir = Files.createTempDir();
    try {
        FlowDef flowDef = FlowDef.flowDef().setName("testFlow");
        for(int sourceId=0; sourceId<sources.length; sourceId++) {
            Source source = sources[sourceId];
            File input = new File(tmpDir, "input"+sourceId+".csv");
            FileWriter writer = new FileWriter(input);
            try {
                for(Tuple tuple : source.tuples) {
                    if(source.fields.size() != tuple.size()) {
                        throw new IllegalArgumentException("Number of input fields is not the same of value of input tuple");
                    }
                    writer.write((tuple.getString(0) == null)? "" : tuple.getString(0));
                    for(int i=1; i<tuple.size(); i++) {
                        writer.write("\t");
                        writer.write((tuple.getString(i) == null)? "" : tuple.getString(i));
                    }
                    writer.write("\n");
                }
            } finally {
                writer.flush();
                writer.close();
            }
            FileTap inputTap = new FileTap(new TextDelimited(source.fields), input.getAbsolutePath());
            flowDef.addSource(source.pipe, inputTap);
        }
        File output = new File(tmpDir, "output.csv");
        FileTap outputTap = new FileTap(new TextDelimited(true, "\t"), output.getAbsolutePath());
        flowDef.addTailSink(tail, outputTap);
        Flow<?> flow = new LocalFlowConnector(new Properties()).connect(flowDef);
        flow.complete();
        
        List<Tuple> result = new ArrayList<Tuple>();
        TupleEntryIterator iterator = flow.openSink();
        while(iterator.hasNext()) {
            result.add(iterator.next().getTupleCopy());
        }
        iterator.close();
        return result;
    } finally {
        FileUtils.deleteDirectory(tmpDir);
    }
}
 
开发者ID:vbehar,项目名称:cascading-flapi,代码行数:45,代码来源:TestHelper.java


示例19: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Override
public TupleEntryIterator openForRead(FlowProcess<JobConf> flowProcess, RecordReader recordReader) throws IOException {
    return new HadoopTupleEntrySchemeIterator( flowProcess, this, recordReader );
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:5,代码来源:SplunkTap.java


示例20: openForRead

import cascading.tuple.TupleEntryIterator; //导入依赖的package包/类
@Override
public TupleEntryIterator openForRead(FlowProcess<Properties> flowProcess, ScrollQuery input) throws IOException {
    if (input == null) {
        // get original copy
        Settings settings = CascadingUtils.addDefaultsToSettings(CascadingUtils.extractOriginalProperties(flowProcess.getConfigCopy()), tapProperties, log);

        // will be closed by the query is finished
        RestRepository client = new RestRepository(settings);
        MappingSet mappings = client.getMappings();
        Mapping mapping = mappings.isEmpty() ? null : mappings.getResolvedView();
        Collection<String> fields = CascadingUtils.fieldToAlias(settings, getSourceFields());

        String userFilter = settings.getReadSourceFilter();
        if (StringUtils.hasText(userFilter)){
            if (fields.isEmpty()) {
                fields = StringUtils.tokenize(userFilter, ",");
            } else {
                throw new EsHadoopIllegalStateException("User specified source filters were found [" + userFilter + "], " +
                        "but the connector is executing in a state where it has provided its own source filtering " +
                        "[" + StringUtils.concatenate(fields, ",") + "]. Please clear the user specified source fields under the " +
                        "[" + ConfigurationOptions.ES_READ_SOURCE_FILTER + "] property to continue.");
            }
        }

        // validate if possible
        FieldPresenceValidation validation = settings.getReadFieldExistanceValidation();
        if (validation.isRequired()) {
            MappingUtils.validateMapping(fields, mapping, validation, log);
        }
        
        EsMajorVersion esVersion = settings.getInternalVersionOrThrow();
        Resource read = new Resource(settings, true);
        SearchRequestBuilder queryBuilder =
                new SearchRequestBuilder(esVersion, settings.getReadMetadata() && settings.getReadMetadataVersion())
                        .types(read.type())
                        .indices(read.index())
                        .query(QueryUtils.parseQuery(settings))
                        .scroll(settings.getScrollKeepAlive())
                        .size(settings.getScrollSize())
                        .limit(settings.getScrollLimit())
                        .filters(QueryUtils.parseFilters(settings))
                        .fields(StringUtils.concatenate(fields, ","));
        input = queryBuilder.build(client, new ScrollReader(new ScrollReaderConfig(new JdkValueReader(), mapping, settings)));
    }
    return new TupleEntrySchemeIterator<Properties, ScrollQuery>(flowProcess, getScheme(), input, getIdentifier());
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:47,代码来源:EsLocalTap.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Macro类代码示例发布时间:2022-05-22
下一篇:
Java GetBlockLocalPathInfoRequestProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap