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


Java SourceCall.getContext方法代码示例

本文整理汇总了Java中cascading.scheme.SourceCall.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java SourceCall.getContext方法的具体用法?Java SourceCall.getContext怎么用?Java SourceCall.getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cascading.scheme.SourceCall的用法示例。


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

示例1: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
/**
 * Populates the {@link Corc} with the next value from the {@link RecordReader}. Then copies the values into the
 * incoming {@link TupleEntry}.
 */
@Override
public boolean source(FlowProcess<? extends Configuration> flowProcess, SourceCall<Corc, RecordReader> sourceCall)
    throws IOException {
  Corc corc = sourceCall.getContext();
  @SuppressWarnings("unchecked")
  boolean next = sourceCall.getInput().next(NullWritable.get(), corc);
  if (!next) {
    return false;
  }
  TupleEntry tupleEntry = sourceCall.getIncomingEntry();
  for (Comparable<?> fieldName : tupleEntry.getFields()) {
    if (ROW_ID_NAME.equals(fieldName)) {
      tupleEntry.setObject(ROW_ID_NAME, corc.getRecordIdentifier());
    } else {
      tupleEntry.setObject(fieldName, corc.get(fieldName.toString()));
    }
  }
  return true;
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:24,代码来源:OrcFile.java

示例2: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
    Tuple result = new Tuple();

    Object key = sourceCall.getContext()[0];
    Object value = sourceCall.getContext()[1];

    boolean hasNext = sourceCall.getInput().next(key, value);
    if (!hasNext) { return false; }

    // Skip nulls
    if (key == null || value == null) { return true; }

    LongWritable keyWritable = (LongWritable) key;
    ArrayListTextWritable values = (ArrayListTextWritable) value;
    result.add(keyWritable);

    for(Text textValue : values)
        result.add(textValue);

    sourceCall.getIncomingEntry().setTuple(result);

    return true;
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:25,代码来源:ShuttlCsv.java

示例3: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public boolean source(FlowProcess<JobConf> prcs, SourceCall<Object[], RecordReader> sourceCall)
    throws IOException {

  Object key = sourceCall.getContext()[0];
  Object value = sourceCall.getContext()[1];

  boolean result = sourceCall.getInput().next(key, value);

  if (!result) {
    return false;
  }

  sourceCall.getIncomingEntry().setTuple(new Tuple(key, value));
  return true;
}
 
开发者ID:indix,项目名称:dfs-datastores,代码行数:17,代码来源:RawSequenceFile.java

示例4: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public boolean source(FlowProcess<JobConf> flowProcess,
    SourceCall<Object[], RecordReader> sourceCall) throws IOException {
  BytesWritable key = (BytesWritable) sourceCall.getContext()[0];
  BytesWritable value = (BytesWritable) sourceCall.getContext()[1];
  boolean result = sourceCall.getInput().next(key, value);

  if (!result) { return false; }

  Tuple tuple = sourceCall.getIncomingEntry().getTuple();
  tuple.clear();

  tuple.add(getBytes(key));
  tuple.add(getBytes(value));

  return true;
}
 
开发者ID:indix,项目名称:dfs-datastores,代码行数:18,代码来源:KeyValueByteScheme.java

示例5: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall)
		throws IOException {
	Tuple result = new Tuple();

	Object key = sourceCall.getContext()[0];
	Object value = sourceCall.getContext()[1];
	boolean hasNext = sourceCall.getInput().next(key, value);
	if (!hasNext) {
		return false;
	}

	// Skip nulls
	if (key == null || value == null) {
		return true;
	}

	ImmutableBytesWritable keyWritable = (ImmutableBytesWritable) key;
	Result row = (Result) value;
	result.add(keyWritable);
	result.add(row);
	sourceCall.getIncomingEntry().setTuple(result);
	return true;
}
 
开发者ID:ParallelAI,项目名称:SpyGlass,代码行数:26,代码来源:HBaseRawScheme.java

示例6: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<Properties> flowProcess, SourceCall<Object[], ScrollQuery> sourceCall) throws IOException {
    ScrollQuery query = sourceCall.getInput();

    if (!query.hasNext()) {
        return false;
    }

    TupleEntry entry = sourceCall.getIncomingEntry();
    Map<String, ?> data = (Map<String, ?>) query.next()[1];
    FieldAlias alias = (FieldAlias) sourceCall.getContext()[0];

    if (entry.getFields().isDefined()) {
        // lookup using writables
        for (Comparable<?> field : entry.getFields()) {
            Object result = data;
            // check for multi-level alias
            for (String level : StringUtils.tokenize(alias.toES(field.toString()), ".")) {
                result = ((Map) result).get(level);
                if (result == null) {
                    break;
                }
            }
            entry.setObject(field, result);
        }
    }
    else {
        // no definition means no coercion
        List<Object> elements = Tuple.elements(entry.getTuple());
        elements.clear();
        elements.addAll(data.values());
    }
    return true;
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:36,代码来源:EsLocalScheme.java

示例7: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
    Object[] context = sourceCall.getContext();

    if (!sourceCall.getInput().next(context[0], context[1])) {
        return false;
    }

    TupleEntry entry = sourceCall.getIncomingEntry();
    Map data = (Map) context[1];
    FieldAlias alias = (FieldAlias) context[2];

    if (entry.getFields().isDefined()) {
        // lookup using writables
        Text lookupKey = new Text();
        for (Comparable<?> field : entry.getFields()) {
            // check for multi-level alias (since ES 1.0)
            Object result = data;
            for (String level : StringUtils.tokenize(alias.toES(field.toString()), ".")) {
                lookupKey.set(level);
                result = ((Map) result).get(lookupKey);
                if (result == null) {
                    break;
                }
            }
            CascadingUtils.setObject(entry, field, result);
        }
    }
    else {
        // no definition means no coercion
        List<Object> elements = Tuple.elements(entry.getTuple());
        elements.clear();
        elements.addAll(data.values());
    }

    return true;
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:39,代码来源:EsHadoopScheme.java

示例8: sourcePrepare

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public void sourcePrepare(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException {
  initIndices();
  if (sourceCall.getContext() == null) {
    sourceCall.setContext(new Object[2]);
  }
  sourceCall.getContext()[0] = sourceCall.getInput().createKey();
  sourceCall.getContext()[1] = sourceCall.getInput().createValue();
}
 
开发者ID:datascienceinc,项目名称:cascading.csv,代码行数:10,代码来源:CsvScheme.java

示例9: sourcePrepare

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public void sourcePrepare(final FlowProcess<JobConf> flowProcess, final SourceCall<Object[], RecordReader> sourceCall) {
    sourceCall.setContext(new Object[4]);
    sourceCall.getContext()[0] = sourceCall.getInput().createKey();
    sourceCall.getContext()[1] = sourceCall.getInput().createValue();
    sourceCall.getContext()[2] = Charset.forName(charsetName);
    sourceCall.getContext()[3] = createCsvParser();
}
 
开发者ID:tresata,项目名称:cascading-opencsv,代码行数:9,代码来源:OpenCsvScheme.java

示例10: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean source(final FlowProcess<JobConf> flowProcess, final SourceCall<Object[], RecordReader> sourceCall) throws IOException {
    final Object[] context = sourceCall.getContext();

    while (sourceCall.getInput().next(context[0], context[1])) {
        if (hasHeader && ((LongWritable) context[0]).get() == 0)
            continue;
        final String[] split;
        try {
            split = ((CSVParser) sourceCall.getContext()[3]).parseLine(makeEncodedString(context));
        } catch (IOException exc) {
            if (strict)
                throw exc;
            LOGGER.warn("exception", exc);
            flowProcess.increment("com.tresata.cascading.scheme.OpenCsvScheme", "Invalid Records", 1);
            continue;
        }
        for (int i = 0; i < split.length; i++)
            if (split[i].equals(""))
                split[i] = null;
        final Tuple tuple = sourceCall.getIncomingEntry().getTuple();
        tuple.clear();
        tuple.addAll(split);
        if (tuple.size() != getSourceFields().size()) {
            if (strict)
                throw new TapException(String.format("expected %s items but got %s", getSourceFields().size(), tuple.size()), tuple);
            LOGGER.warn("expected {} items but got {}, tuple: {}", new Object[]{getSourceFields().size(), tuple.size() , tuple});
            flowProcess.increment("com.tresata.cascading.scheme.OpenCsvScheme", "Invalid Records", 1);
            tuple.clear(); // probably not necessary
            continue;
        }
        return true;
    }
    return false;
}
 
开发者ID:tresata,项目名称:cascading-opencsv,代码行数:37,代码来源:OpenCsvScheme.java

示例11: sourcePrepare

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public void sourcePrepare(FlowProcess<JobConf> flowProcess,
    SourceCall<Object[], RecordReader> sourceCall) {
  sourceCall.setContext(new Object[2]);

  sourceCall.getContext()[0] = sourceCall.getInput().createKey();
  sourceCall.getContext()[1] = sourceCall.getInput().createValue();
}
 
开发者ID:indix,项目名称:dfs-datastores,代码行数:9,代码来源:RawSequenceFile.java

示例12: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public boolean source(FlowProcess<JobConf> process,
    SourceCall<Object[], RecordReader> sourceCall) throws IOException {
  Object k = sourceCall.getContext()[0];
  Object v = sourceCall.getContext()[1];
  boolean result = sourceCall.getInput().next(k, v);
  if (!result) { return false; }
  PailRecordInfo recordInfo = ((PailRecordInfo) k);
  Object value = deserialize((BytesWritable) v);
  sourceCall.getIncomingEntry().setTuple(new Tuple(recordInfo.getPailRelativePath(), value, recordInfo.getFullPath(), recordInfo.getSplitStartOffset(), recordInfo.getRecordNumber()));
  return true;
}
 
开发者ID:indix,项目名称:dfs-datastores,代码行数:13,代码来源:PailTap.java

示例13: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public boolean source( FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall ) throws IOException
{
    Object key = sourceCall.getContext()[ 0 ];
    Object value = sourceCall.getContext()[ 1 ];
    boolean result = sourceCall.getInput().next( key, value );

    if( !result )
        return false;

    Tuple newTuple = ( (TupleRecord) value ).getTuple();
    sourceCall.getIncomingEntry().setTuple( newTuple );

    return true;
}
 
开发者ID:ParallelAI,项目名称:SpyGlass,代码行数:16,代码来源:JDBCScheme.java

示例14: source

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
@Override
public boolean source(FlowProcess<JobConf> flowProcess,
    SourceCall<Object[], RecordReader> sourceCall) throws IOException {
  Tuple result = new Tuple();

  Object key = sourceCall.getContext()[0];
  Object value = sourceCall.getContext()[1];
  boolean hasNext = sourceCall.getInput().next(key, value);
  if (!hasNext) { return false; }

  // Skip nulls
  if (key == null || value == null) { return true; }

  ImmutableBytesWritable keyWritable = (ImmutableBytesWritable) key;
  Result row = (Result) value;
  result.add(keyWritable);

  for (int i = 0; i < this.familyNames.length; i++) {
    String familyName = this.familyNames[i];
    byte[] familyNameBytes = Bytes.toBytes(familyName);
    Fields fields = this.valueFields[i];
    for (int k = 0; k < fields.size(); k++) {
      String fieldName = (String) fields.get(k);
      byte[] fieldNameBytes = Bytes.toBytes(fieldName);
      byte[] cellValue = row.getValue(familyNameBytes, fieldNameBytes);
      result.add(cellValue != null ? new ImmutableBytesWritable(cellValue) : null);
    }
  }

  sourceCall.getIncomingEntry().setTuple(result);

  return true;
}
 
开发者ID:ParallelAI,项目名称:SpyGlass,代码行数:34,代码来源:HBaseScheme.java

示例15: sourceReadInput

import cascading.scheme.SourceCall; //导入方法依赖的package包/类
private boolean sourceReadInput( SourceCall<Object[], RecordReader> sourceCall ) throws IOException
{
    Object[] context = sourceCall.getContext();
    return sourceCall.getInput().next( context[ 0 ], context[ 1 ] );
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:6,代码来源:CSVLine.java


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