Examples of TridentTuple


Examples of storm.trident.tuple.TridentTuple

        try {
            Result[] results = hBaseClient.batchGet(gets);
            for(int i = 0; i < results.length; i++) {
                Result result = results[i];
                TridentTuple tuple = tridentTuples.get(i);
                List<Values> values = options.rowToStormValueMapper.toValues(tuple, result);
                batchRetrieveResult.add(values);
            }
        } catch (Exception e) {
            LOG.warn("Batch get operation failed. Triggering replay.", e);
View Full Code Here

Examples of storm.trident.tuple.TridentTuple

        clientConfig.put(StormCassandraConstants.CASSANDRA_KEYSPACE, Arrays.asList(new String [] {KEYSPACE}));
        client.start(clientConfig);
       
        Fields fields = new Fields("key1", "key2", "foo", "bar");
        Values values = new Values("key1val", "key2val", "fooval", "barval");
        TridentTuple tuple = newTridentTuple(fields, values);
       
        SimpleTridentTupleMapper tupleMapper = new SimpleTridentTupleMapper(KEYSPACE, fields);
       
        client.writeTuple(tuple, tupleMapper);
       
View Full Code Here

Examples of storm.trident.tuple.TridentTuple

        clientConfig.put(StormCassandraConstants.CASSANDRA_KEYSPACE, Arrays.asList(new String [] {KEYSPACE}));
        client.start(clientConfig);
       
        Fields fields = new Fields("rowkey", "a", "b", "value");
        Values values = new Values("my_row", "a", "a", "aa");
        TridentTuple tuple = newTridentTuple(fields, values);
       
        CompositeColumnTridentTupleMapper tupleMapper = new CompositeColumnTridentTupleMapper(KEYSPACE);
       
        client.writeTuple(tuple, tupleMapper);
       
View Full Code Here

Examples of storm.trident.tuple.TridentTuple

        int i = 1;
        List<Double> tempList = new LinkedList<Double>();
        for (String key : classifier.model.schema.keySet())
          tempList.add(Double.parseDouble(test_vector[i++]));

        TridentTuple values = new MockTridentTuple(new LinkedList(
            classifier.model.schema.keySet()), tempList);

        // compare classifier label vs. predicted

        classifier.prepare();

        String label = classifier.classifyTuple(values);
        LOG.debug(values.toString() + " predicted: " + predicted
            + " score: " + label);

        if (!predicted.equals(label)) {
          StringBuilder sb = new StringBuilder();
View Full Code Here

Examples of storm.trident.tuple.TridentTuple

    String regressorName = "TestLearner";
    RegressionQuery query = new RegressionQuery(regressorName);

    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);

    Regressor expectedRegressor = mock(Regressor.class);
    given(expectedRegressor.predict(same(features1))).willReturn(expectedPrediction1);
    given(expectedRegressor.predict(same(features2))).willReturn(expectedPrediction2);
View Full Code Here

Examples of storm.trident.tuple.TridentTuple

  public void should_classify_instance_without_classifier() {
    // Given
    String regressorName = "TestLearner";
    RegressionQuery query = new RegressionQuery(regressorName);

    TridentTuple tuple1 = mock(TridentTuple.class);
    TridentTuple tuple2 = mock(TridentTuple.class);
    List<TridentTuple> tuples = Arrays.asList(tuple1, tuple2);

    List<List<Object>> expectedKeys = asList(asList((Object) regressorName));
    MapState<Regressor> state = mock(MapState.class);
    given(state.multiGet(expectedKeys)).willReturn(EMPTY_LIST);
View Full Code Here

Examples of storm.trident.tuple.TridentTuple

  }

  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

Examples of storm.trident.tuple.TridentTuple

  public void testCreateInstanceWithoutLabel() {
    // Given
    TextInstanceCreator<Integer> instanceCreator = new TextInstanceCreator<Integer>(false);

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

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

    // Then
View Full Code Here

Examples of storm.trident.tuple.TridentTuple

  @Test
  public void testCreateInstanceWithLabel() {
    // Given
    InstanceCreator<Boolean> instanceCreator = new InstanceCreator<Boolean>();

    TridentTuple tuple = mock(TridentTuple.class);
    Boolean expectedLabel = true;
    double f1 = 0.53;
    double f2 = 0.65;
    when(tuple.size()).thenReturn(3);
    when(tuple.get(0)).thenReturn(expectedLabel);
    when(tuple.getDouble(1)).thenReturn(f1);
    when(tuple.getDouble(2)).thenReturn(f2);

    // When
    Instance<Boolean> actualInstance = instanceCreator.createInstance(tuple);

    // Then
View Full Code Here

Examples of storm.trident.tuple.TridentTuple

  @Test
  public void testCreateInstanceWithoutLabel() {
    // Given
    InstanceCreator<Boolean> instanceCreator = new InstanceCreator<Boolean>(false);

    TridentTuple tuple = mock(TridentTuple.class);
    double f1 = 0.53;
    double f2 = 0.65;
    when(tuple.size()).thenReturn(2);
    when(tuple.getDouble(0)).thenReturn(f1);
    when(tuple.getDouble(1)).thenReturn(f2);

    // When
    Instance<Boolean> actualInstance = instanceCreator.createInstance(tuple);

    // Then
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.