Package storm.trident.tuple

Examples of storm.trident.tuple.TridentTuple


    String classifierName = "TestLearner";
    ClassifyQuery<Boolean> query = new ClassifyQuery<Boolean>(classifierName);

    double[] features1 = new double[10];
    double[] features2 = new double[10];
    TridentTuple tuple1 = createMockedInstanceTuple(features1);
    TridentTuple tuple2 = createMockedInstanceTuple(features2);
    List<TridentTuple> tuples = Arrays.asList(tuple1, tuple2);

    Classifier<Boolean> expectedClassifier = mock(Classifier.class);
    given(expectedClassifier.classify(same(features1))).willReturn(expectedLabel1);
    given(expectedClassifier.classify(same(features2))).willReturn(expectedLabel2);
View Full Code Here


    String classifierName = "TestLearner";
    ClassifyQuery<Boolean> query = new ClassifyQuery<Boolean>(classifierName);

    double[] features1 = new double[10];
    double[] features2 = new double[10];
    TridentTuple tuple1 = createMockedInstanceTuple(features1);
    TridentTuple tuple2 = createMockedInstanceTuple(features2);
    List<TridentTuple> tuples = Arrays.asList(tuple1, tuple2);

    MapState<Classifier<Boolean>> state = mock(MapState.class);
    given(state.multiGet(asList(asList((Object) classifierName)))).willReturn(EMPTY_LIST);
View Full Code Here

  }

  private TridentTuple createMockedInstanceTuple(double[] features) {
    Instance<Boolean> instance = new Instance<Boolean>(features);

    TridentTuple tuple = mock(TridentTuple.class);
    given(tuple.get(0)).willReturn(instance);

    return tuple;
  }
View Full Code Here

    Boolean prediction = false;

    Instance<Boolean> instance = mock(Instance.class);
    when(instance.getLabel()).thenReturn(label);

    TridentTuple tuple = mock(TridentTuple.class);
    when(tuple.getValue(0)).thenReturn(instance);
    when(tuple.getValue(1)).thenReturn(prediction);

    // When
    AccuracyState<Boolean> actualState = agrgegator.init(tuple);

    // Then
View Full Code Here

    Boolean prediction = true;

    Instance<Boolean> instance = mock(Instance.class);
    when(instance.getLabel()).thenReturn(label);

    TridentTuple tuple = mock(TridentTuple.class);
    when(tuple.getValue(0)).thenReturn(instance);
    when(tuple.getValue(1)).thenReturn(prediction);

    // When
    AccuracyState<Boolean> actualState = agrgegator.init(tuple);

    // Then
View Full Code Here

    // Given
    TextInstanceCreator<Integer> instanceCreator = new TextInstanceCreator<Integer>(true);

    Integer expectedLabel = 1;
    String expectedText = "I can't argue with some arguments on argus with argues";
    TridentTuple tuple = mock(TridentTuple.class);
    when(tuple.get(0)).thenReturn(expectedLabel);
    when(tuple.getString(1)).thenReturn(expectedText);

    // When
    TextInstance<Integer> actualInstance = instanceCreator.createInstance(tuple);

    // Then
View Full Code Here

    }
   
    public void aggregate(ChainedResult val, TridentTuple tuple, TridentCollector collector) {
        val.setFollowThroughCollector(collector);
        for(int i=0; i<_aggs.length; i++) {
            TridentTuple projected = _inputFactories[i].create((TridentTupleView) tuple);
            _aggs[i].aggregate(val.objs[i], projected, val.collectors[i]);
        }
    }
View Full Code Here

    @Override
    public void aggregate(Object[] arr, TridentTuple tuple, TridentCollector collector) {
        GroupCollector groupColl = (GroupCollector) arr[0];
        Map<List, Object> val = (Map) arr[1];
        TridentTuple group = _groupFactory.create((TridentTupleView) tuple);
        TridentTuple input = _inputFactory.create((TridentTupleView) tuple);
        Object curr;
        if(!val.containsKey(group)) {
            curr = _agg.init(arr[2], groupColl);
            val.put((List) group, curr);
        } else {
View Full Code Here

            List<Object> results = _function.batchRetrieve(_state, state.args);
            if(results.size()!=state.tuples.size()) {
                throw new RuntimeException("Results size is different than argument size: " + results.size() + " vs " + state.tuples.size());
            }
            for(int i=0; i<state.tuples.size(); i++) {
                TridentTuple tuple = state.tuples.get(i);
                Object result = results.get(i);
                _collector.setContext(processorContext, tuple);
                _function.execute(_projection.create(tuple), result, _collector);           
            }
        }
View Full Code Here

        @Override
        public void complete(PriorityQueue val, TridentCollector collector) {
            int total = val.size();
            for(int i=0; i<_n && i < total; i++) {
                TridentTuple t = (TridentTuple) val.remove();
                collector.emit(t);
            }
        }
View Full Code Here

TOP

Related Classes of storm.trident.tuple.TridentTuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.