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


Java TupleEntryIterator类代码示例

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


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


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