test_class.file: storm/trident-ml/src/test/java/com/github/pmerienne/trident/ml/classification/ClassifyQueryTest.java
test_class.identifier: ClassifyQueryTest
test_case.body: @Test
  	public void should_classify_instance_using_classifier() {
  		// Given
  		Boolean expectedLabel1 = true;
  		Boolean expectedLabel2 = false;
  
  		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);
  
  		List<List<Object>> expectedKeys = asList(asList((Object) classifierName));
  		MapState<Classifier<Boolean>> state = mock(MapState.class);
  		given(state.multiGet(expectedKeys)).willReturn(Arrays.asList(expectedClassifier));
  
  		// When
  		List<Boolean> labels = query.batchRetrieve(state, tuples);
  
  		assertEquals(2, labels.size());
  		assertTrue(labels.get(0));
  		assertFalse(labels.get(1));
  	}
test_case.class_method_signature: ClassifyQueryTest.should_classify_instance_using_classifier()
test_case.full_signature: @Test public void should_classify_instance_using_classifier()
test_case.identifier: should_classify_instance_using_classifier
test_case.invocations: createMockedInstanceTuple createMockedInstanceTuple asList mock willReturn given classify same willReturn given classify same asList asList mock willReturn given multiGet asList batchRetrieve assertEquals size assertTrue get assertFalse get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void should_classify_instance_using_classifier()
focal_class.declarator: serialVersionUID = -9046858936834644113L
focal_class.modifier: private static final
focal_class.original_string: private static final long serialVersionUID = -9046858936834644113L;
focal_class.type: long
focal_class.var_name: serialVersionUID
focal_class.declarator: classifierName
focal_class.modifier: private
focal_class.original_string: private String classifierName;
focal_class.type: String
focal_class.var_name: classifierName
focal_class.file: storm/trident-ml/src/main/java/com/github/pmerienne/trident/ml/classification/ClassifyQuery.java
focal_class.identifier: ClassifyQuery
focal_class.class_method_signature: ClassifyQuery.ClassifyQuery(String classifierName)
focal_class.full_signature: public  ClassifyQuery(String classifierName)
focal_class.identifier: ClassifyQuery
focal_class.modifiers: public
focal_class.parameters: (String classifierName)
focal_class.signature:  ClassifyQuery(String classifierName)
focal_class.class_method_signature: ClassifyQuery.batchRetrieve(MapState<Classifier<L>> state, List<TridentTuple> tuples)
focal_class.full_signature: @SuppressWarnings("unchecked") @Override public List<L> batchRetrieve(MapState<Classifier<L>> state, List<TridentTuple> tuples)
focal_class.identifier: batchRetrieve
focal_class.modifiers: @SuppressWarnings("unchecked") @Override public
focal_class.parameters: (MapState<Classifier<L>> state, List<TridentTuple> tuples)
focal_class.return: List<L>
focal_class.signature: List<L> batchRetrieve(MapState<Classifier<L>> state, List<TridentTuple> tuples)
focal_class.class_method_signature: ClassifyQuery.execute(TridentTuple tuple, L result, TridentCollector collector)
focal_class.full_signature: public void execute(TridentTuple tuple, L result, TridentCollector collector)
focal_class.identifier: execute
focal_class.modifiers: public
focal_class.parameters: (TridentTuple tuple, L result, TridentCollector collector)
focal_class.return: void
focal_class.signature: void execute(TridentTuple tuple, L result, TridentCollector collector)
focal_class.superclass: extends BaseQueryFunction<MapState<Classifier<L>>, L>
focal_method.body: @SuppressWarnings("unchecked")
  	@Override
  	public List<L> batchRetrieve(MapState<Classifier<L>> state, List<TridentTuple> tuples) {
  		List<L> labels = new ArrayList<L>();
  
  		List<Classifier<L>> classifiers = state.multiGet(KeysUtil.toKeys(this.classifierName));
  		if (classifiers != null && !classifiers.isEmpty()) {
  			Classifier<L> classifier = classifiers.get(0);
  			if (classifier == null) {
  				for (int i = 0; i < tuples.size(); i++) {
  					labels.add(null);
  				}
  			} else {
  
  				L label;
  				Instance<L> instance;
  				for (TridentTuple tuple : tuples) {
  					instance = (Instance<L>) tuple.get(0);
  					label = classifier.classify(instance.features);
  					labels.add(label);
  				}
  			}
  		} else {
  			for (int i = 0; i < tuples.size(); i++) {
  				labels.add(null);
  			}
  		}
  
  		return labels;
  	}
focal_method.class_method_signature: ClassifyQuery.batchRetrieve(MapState<Classifier<L>> state, List<TridentTuple> tuples)
focal_method.full_signature: @SuppressWarnings("unchecked") @Override public List<L> batchRetrieve(MapState<Classifier<L>> state, List<TridentTuple> tuples)
focal_method.identifier: batchRetrieve
focal_method.invocations: multiGet toKeys isEmpty get size add get classify add size add
focal_method.modifiers: @SuppressWarnings("unchecked") @Override public
focal_method.parameters: (MapState<Classifier<L>> state, List<TridentTuple> tuples)
focal_method.return: List<L>
focal_method.signature: List<L> batchRetrieve(MapState<Classifier<L>> state, List<TridentTuple> tuples)