cascading.tuple.TupleEntry.getString()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中cascading.tuple.TupleEntry.getString()方法的一些代码示例,展示了TupleEntry.getString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TupleEntry.getString()方法的具体详情如下:
包路径:cascading.tuple.TupleEntry
类名称:TupleEntry
方法名:getString

TupleEntry.getString介绍

[英]Method getString returns the element for the given field name or position as a String.
fieldName may optionally be a Fields instance. Only the first field name or position will be considered.
[中]方法getString将给定字段名或位置的元素作为字符串返回。
fieldName也可以是Fields实例。只考虑第一个字段名或位置。

代码示例

代码示例来源:origin: cascading/pattern-core

public boolean applies( TupleEntry tupleEntry )
 {
 return predictor.matches( tupleEntry.getString( index ) );
 }
}

代码示例来源:origin: Big-Data-Manning/big-data-code

public void operate(FlowProcess process, FunctionCall call) {
    String urlStr = call.getArguments().getString(0);
    try {
      URL url = new URL(urlStr);
      call.getOutputCollector().add(
        new Tuple(url.getAuthority()));
    } catch(MalformedURLException e) {
    }
  }
}

代码示例来源:origin: Big-Data-Manning/big-data-code

public void operate(FlowProcess process, FunctionCall call) {
    String str = call.getArguments().getString(0);
    try {
      call.getOutputCollector().add(
        new Tuple(str.getBytes("UTF-8")));
    } catch(UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: cascading/cascading-hadoop2-mr1

@Override
public boolean isRemove( FlowProcess flowProcess, FilterCall filterCall )
 {
 return partitions.contains( filterCall.getArguments().getString( "number" ) );
 }
}

代码示例来源:origin: Big-Data-Manning/big-data-code

public void operate(FlowProcess process, FunctionCall call) {
    String url = call.getArguments().getString(0);
    String gran = call.getArguments().getString(1);
    Integer bucket = call.getArguments().getInteger(2);
    String keyStr = url + "/" + gran + "-" + bucket;
    try {
      call.getOutputCollector().add(
        new Tuple(keyStr.getBytes("UTF-8")));
    } catch(UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: cwensel/cascading

@Override
public boolean isRemove( FlowProcess flowProcess, FilterCall filterCall )
 {
 return partitions.contains( filterCall.getArguments().getString( "number" ) );
 }
}

代码示例来源:origin: cwensel/cascading

@Override
public void operate( FlowProcess flowProcess, FunctionCall<Pair<Matcher, TupleEntry>> functionCall )
 {
 // coerce to string
 String value = functionCall.getArguments().getString( 0 );
 // make safe
 if( value == null )
  value = "";
 TupleEntry output = functionCall.getContext().getRhs();
 Matcher matcher = functionCall.getContext().getLhs().reset( value );
 if( replaceAll )
  output.setString( 0, matcher.replaceAll( replacement ) );
 else
  output.setString( 0, matcher.replaceFirst( replacement ) );
 functionCall.getOutputCollector().add( output );
 }

代码示例来源:origin: cwensel/cascading

@Override
public void operate( FlowProcess flowProcess, FunctionCall<Pair<Matcher, TupleEntry>> functionCall )
 {
 String value = functionCall.getArguments().getString( 0 );
 if( value == null )
  value = "";
 Matcher matcher = functionCall.getContext().getLhs().reset( value );
 while( matcher.find() )
  {
  functionCall.getContext().getRhs().setString( 0, matcher.group() );
  functionCall.getOutputCollector().add( functionCall.getContext().getRhs() );
  }
 }
}

代码示例来源:origin: cwensel/cascading

public void operate( FlowProcess flowProcess, FunctionCall functionCall )
 {
 functionCall.getOutputCollector().add( new Tuple( new BytesWritable( functionCall.getArguments().getString( 0 ).getBytes() ) ) );
 }
}

代码示例来源:origin: cascading/cascading-hadoop2-common

public void operate( FlowProcess flowProcess, FunctionCall functionCall )
 {
 functionCall.getOutputCollector().add( new Tuple( new BytesWritable( functionCall.getArguments().getString( 0 ).getBytes() ) ) );
 }
}

代码示例来源:origin: cwensel/cascading

@Override
public void operate( FlowProcess flowProcess, FunctionCall<Pair<Matcher, TupleEntry>> functionCall )
 {
 String value = functionCall.getArguments().getString( 0 );
 if( value == null )
  value = "";
 Matcher matcher = functionCall.getContext().getLhs().reset( value );
 if( !matcher.find() )
  throw new OperationException( "could not match pattern: [" + getPatternString() + "] with value: [" + value + "]" );
 TupleEntry output = functionCall.getContext().getRhs();
 if( groups != null )
  onGivenGroups( functionCall, matcher, output );
 else
  onFoundGroups( functionCall, matcher, output );
 }

代码示例来源:origin: cwensel/cascading

@Override
public void operate( FlowProcess flowProcess, FunctionCall<Pair<Pattern, TupleEntry>> functionCall )
 {
 String value = functionCall.getArguments().getString( 0 );
 if( value == null )
  value = "";
 String[] split = functionCall.getContext().getLhs().split( value );
 for( String string : split )
  {
  TupleEntry tupleEntry = functionCall.getContext().getRhs();
  tupleEntry.setString( 0, string );
  functionCall.getOutputCollector().add( tupleEntry );
  }
 }
}

代码示例来源:origin: sujitpal/hia-examples

@Override
public void operate(FlowProcess flowProcess, FunctionCall funCall) {
 TupleEntry args = funCall.getArguments();
 String keyword = args.getString(0);
 List<String> urls = parseSearchResult(keyword);
 for (String url : urls) {
  Tuple t = new Tuple();
  t.add(url);
  funCall.getOutputCollector().add(t);
 }
}

代码示例来源:origin: BertrandDechoux/cascading.learn

@Override
public void operate(@SuppressWarnings("rawtypes") FlowProcess flowProcess,
    FunctionCall<Context> functionCall) {
  String line = functionCall.getArguments().getString(0);
  String word = line; // or not ?
  functionCall.getOutputCollector().add(new Tuple(word));
  functionCall.getOutputCollector().add(new Tuple(word));
}

代码示例来源:origin: sujitpal/hia-examples

@Override
public void operate(FlowProcess flowProcess, FunctionCall funCall) {
 TupleEntry args = funCall.getArguments();
 String url = args.getString(1);
 String rawText = download(url);
 String plainText = parse(rawText);
 List<String> keywords = extractKeywords(plainText);
 for (String keyword : keywords) {
  Tuple t = new Tuple();
  t.add(keyword);
  funCall.getOutputCollector().add(t);
 }
}

代码示例来源:origin: cwensel/cascading

@Override
public void operate( FlowProcess flowProcess, FunctionCall functionCall )
 {
 TupleEntry argument = functionCall.getArguments();
 int num = argument.getInteger( 0 );
 String chr = argument.getString( 1 );
 Tuple result;
 if( num == number )
  result = new Tuple( null, chr );
 else
  result = new Tuple( num, chr );
 functionCall.getOutputCollector().add( result );
 }
}

代码示例来源:origin: cascading/cascading-platform

@Override
public void operate( FlowProcess flowProcess, FunctionCall functionCall )
 {
 TupleEntry argument = functionCall.getArguments();
 int num = argument.getInteger( 0 );
 String chr = argument.getString( 1 );
 Tuple result;
 if( num == number )
  result = new Tuple( null, chr );
 else
  result = new Tuple( num, chr );
 functionCall.getOutputCollector().add( result );
 }
}

代码示例来源:origin: cwensel/cascading

@Test
public void testCoerceCanonicalUnknown()
 {
 Tuple tuple = new Tuple( 1 );
 TupleEntry results = new TupleEntry( Fields.UNKNOWN, tuple );
 assertEquals( 1, results.getObject( 0 ) );
 assertEquals( 1, results.getInteger( 0 ) );
 assertEquals( 1, results.getShort( 0 ) );
 assertEquals( 1L, results.getLong( 0 ) );
 assertEquals( 1.0F, results.getFloat( 0 ) );
 assertEquals( 1.0D, results.getDouble( 0 ) );
 assertEquals( "1", results.getString( 0 ) );
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testSinkDeclaredFields() throws IOException
 {
 getPlatform().copyFromLocal( inputFileCross );
 Tap source = getPlatform().getTextFile( new Fields( "line" ), inputFileCross );
 Pipe pipe = new Pipe( "test" );
 pipe = new Each( pipe, new RegexSplitter( new Fields( "first", "second", "third" ), "\\s" ), Fields.ALL );
 Tap sink = getPlatform().getTextFile( new Fields( "line" ), new Fields( "second", "first", "third" ), getOutputPath( "declaredsinks" ), SinkMode.REPLACE );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 37, null );
 TupleEntryIterator iterator = flow.openSink();
 String line = iterator.next().getString( 0 );
 assertTrue( "not equal: wrong values", line.matches( "[a-z]\t[0-9]\t[A-Z]" ) );
 iterator.close();
 }

代码示例来源:origin: cascading/cascading-platform

@Test
public void testSinkDeclaredFields() throws IOException
 {
 getPlatform().copyFromLocal( inputFileCross );
 Tap source = getPlatform().getTextFile( new Fields( "line" ), inputFileCross );
 Pipe pipe = new Pipe( "test" );
 pipe = new Each( pipe, new RegexSplitter( new Fields( "first", "second", "third" ), "\\s" ), Fields.ALL );
 Tap sink = getPlatform().getTextFile( new Fields( "line" ), new Fields( "second", "first", "third" ), getOutputPath( "declaredsinks" ), SinkMode.REPLACE );
 Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
 flow.complete();
 validateLength( flow, 37, null );
 TupleEntryIterator iterator = flow.openSink();
 String line = iterator.next().getString( 0 );
 assertTrue( "not equal: wrong values", line.matches( "[a-z]\t[0-9]\t[A-Z]" ) );
 iterator.close();
 }

相关文章