eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject [05/55] [abbrv] [partial] incubator-eagle git commit: [EAGLE-46] Rename package name as "org.apache.eagle"
Date Thu, 19 Nov 2015 10:47:12 GMT
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestHierarchicalAggregator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestHierarchicalAggregator.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestHierarchicalAggregator.java
deleted file mode 100755
index 973f6d8..0000000
--- a/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestHierarchicalAggregator.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package eagle.query.aggregate.test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import eagle.query.aggregate.timeseries.PostHierarchicalAggregateSort;
-import eagle.query.aggregate.timeseries.HierarchicalAggregateEntity;
-import eagle.query.aggregate.timeseries.HierarchicalAggregator;
-import eagle.query.aggregate.AggregateFunctionType;
-import junit.framework.Assert;
-
-import org.codehaus.jackson.JsonFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import eagle.log.entity.test.TestEntity;
-import eagle.query.aggregate.timeseries.SortOption;
-
-
-public class TestHierarchicalAggregator {
-private final static Logger LOG = LoggerFactory.getLogger(TestHierarchicalAggregator.class);
-
-	@SuppressWarnings("serial")
-	private TestEntity createEntity(final String cluster, final String datacenter, final String rack, int numHosts, long numClusters){
-		TestEntity entity = new TestEntity();
-		Map<String, String> tags = new HashMap<String, String>(){{
-			put("cluster", cluster);
-			put("datacenter", datacenter);
-			put("rack", rack);
-		}}; 
-		entity.setTags(tags);
-		entity.setNumHosts(numHosts);
-		entity.setNumClusters(numClusters);
-		return entity;
-	}
-	
-	@SuppressWarnings("serial")
-	private TestEntity createEntityWithoutDatacenter(final String cluster, final String rack, int numHosts, long numClusters){
-		TestEntity entity = new TestEntity();
-		Map<String, String> tags = new HashMap<String, String>(){{
-			put("cluster", cluster);
-			put("rack", rack);
-		}}; 
-		entity.setTags(tags);
-		entity.setNumHosts(numHosts);
-		entity.setNumClusters(numClusters);
-		return entity;
-	}
-
-	private void writeToJson(String message, Object obj){
-		JsonFactory factory = new JsonFactory();
-		ObjectMapper mapper = new ObjectMapper(factory);
-		try{
-			String result = mapper.writeValueAsString(obj);
-			LOG.info(message + ":\n" + result);
-		}catch(Exception ex){
-			LOG.error("Can not write json", ex);
-			Assert.fail("Can not write json");
-		}
-	}
-	
-	@Test
-	public void testZeroGropubyFieldHierarchicalAggregator(){ 
-		TestEntity[] entities = new TestEntity[5];
-		entities[0] = createEntity("cluster1", "dc1", "rack123", 12, 2);
-		entities[1] = createEntity("cluster1", "dc1", "rack123", 20, 1);
-		entities[2] = createEntity("cluster1", "dc1", "rack128", 10, 0);
-		entities[3] = createEntity("cluster2", "dc1", "rack125", 9, 2);
-		entities[4] = createEntity("cluster2", "dc1", "rack126", 15, 2);
-		HierarchicalAggregator agg = new HierarchicalAggregator(new ArrayList<String>(), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"));
-		try{
-			for(TestEntity e : entities){
-				agg.accumulate(e);
-			}
-			HierarchicalAggregateEntity result = agg.result();
-			writeToJson("After aggregate", result);
-			Assert.assertEquals(result.getChildren().size(), 0);
-			Assert.assertEquals(result.getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()+entities[3].getNumHosts()+entities[4].getNumHosts()));
-
-			// test sort by function1
-			SortOption so = new SortOption();
-			so.setIndex(0);
-			so.setAscendant(true);
-			List<SortOption> sortOptions = Arrays.asList(so);
-			PostHierarchicalAggregateSort.sort(result, sortOptions);
-			writeToJson("After sort" ,result);
-			Assert.assertEquals(null, result.getChildren());
-			Assert.assertEquals(0, result.getSortedList().size());
-			Assert.assertEquals(result.getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()+entities[3].getNumHosts()+entities[4].getNumHosts()));
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-	}
-	
-	@Test
-	public void testSingleGropubyFieldHierarchicalAggregator(){ 
-		TestEntity[] entities = new TestEntity[5];
-		entities[0] = createEntity("cluster1", "dc1", "rack123", 12, 2);
-		entities[1] = createEntity("cluster1", "dc1", "rack123", 20, 1);
-		entities[2] = createEntity("cluster1", "dc2", "rack128", 10, 0);
-		entities[3] = createEntity("cluster2", "dc1", "rack125", 9, 2);
-		entities[4] = createEntity("cluster2", "dc1", "rack126", 15, 2);
-		HierarchicalAggregator agg = new HierarchicalAggregator(Arrays.asList("cluster"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"));
-		try{
-			for(TestEntity e : entities){
-				agg.accumulate(e);
-			}
-			HierarchicalAggregateEntity result = agg.result();
-			writeToJson("After aggregate" ,result);
-			Assert.assertEquals(result.getChildren().size(), 2);
-			Assert.assertEquals(result.getChildren().get("cluster1").getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("cluster2").getValues().get(0), (double)(entities[3].getNumHosts()+entities[4].getNumHosts()));
-			
-			// test sort by function 1
-			SortOption so = new SortOption();
-			so.setIndex(0);
-			so.setAscendant(true);
-			List<SortOption> sortOptions = Arrays.asList(so);
-			PostHierarchicalAggregateSort.sort(result, sortOptions);
-			writeToJson("After sort" ,result);
-			Assert.assertEquals(null, result.getChildren());
-			Assert.assertEquals(2, result.getSortedList().size(), 2);
-			Iterator<Map.Entry<String, HierarchicalAggregateEntity>> it = result.getSortedList().iterator();
-			Assert.assertEquals(true, it.hasNext());
-			Map.Entry<String, HierarchicalAggregateEntity> entry = it.next();
-			Assert.assertEquals("cluster2", entry.getKey());
-			Assert.assertEquals(entry.getValue().getValues().get(0), (double)(entities[3].getNumHosts()+entities[4].getNumHosts()));
-			
-			Assert.assertEquals(true, it.hasNext());
-			entry = it.next();
-			Assert.assertEquals("cluster1", entry.getKey());
-			Assert.assertEquals(entry.getValue().getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()));
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-		
-		agg = new HierarchicalAggregator(Arrays.asList("datacenter"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"));
-		try{
-			for(TestEntity e : entities){
-				agg.accumulate(e);
-			}
-			HierarchicalAggregateEntity result = agg.result();
-			writeToJson("After aggregate" , result);
-			Assert.assertEquals(result.getChildren().size(), 2);
-			Assert.assertEquals(result.getChildren().get("dc1").getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[3].getNumHosts()+entities[4].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("dc2").getValues().get(0), (double)(entities[2].getNumHosts()));
-			
-			// test sort by function 1
-			SortOption so = new SortOption();
-			so.setIndex(0);
-			so.setAscendant(true);
-			List<SortOption> sortOptions = Arrays.asList(so);
-			PostHierarchicalAggregateSort.sort(result, sortOptions);
-			writeToJson("After sort" ,result);
-			Assert.assertEquals(null, result.getChildren());
-			Assert.assertEquals(2, result.getSortedList().size(), 2);
-			Iterator<Map.Entry<String, HierarchicalAggregateEntity>> it = result.getSortedList().iterator();
-			Assert.assertEquals(true, it.hasNext());
-			Map.Entry<String, HierarchicalAggregateEntity> entry = it.next();
-			Assert.assertEquals("dc2", entry.getKey());
-			Assert.assertEquals(entry.getValue().getValues().get(0), (double)(entities[2].getNumHosts()));
-			
-			Assert.assertEquals(true, it.hasNext());
-			entry = it.next();
-			Assert.assertEquals("dc1", entry.getKey());
-			Assert.assertEquals(entry.getValue().getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[3].getNumHosts()+entities[4].getNumHosts()));			
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-		
-		agg = new HierarchicalAggregator(Arrays.asList("cluster"), Arrays.asList(AggregateFunctionType.sum, AggregateFunctionType.sum), Arrays.asList("numHosts", "numClusters"));
-		try{
-			for(TestEntity e : entities){
-				agg.accumulate(e);
-			}
-			HierarchicalAggregateEntity result = agg.result();
-			writeToJson("After aggregate" , result);
-			Assert.assertEquals(result.getChildren().size(), 2);
-			Assert.assertEquals(2, result.getChildren().get("cluster1").getValues().size());
-			Assert.assertEquals(result.getChildren().get("cluster1").getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("cluster1").getValues().get(1), (double)(entities[0].getNumClusters()+entities[1].getNumClusters()+entities[2].getNumClusters()));
-			Assert.assertEquals(2, result.getChildren().get("cluster2").getValues().size());
-			Assert.assertEquals(result.getChildren().get("cluster2").getValues().get(0), (double)(entities[3].getNumHosts()+entities[4].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("cluster2").getValues().get(1), (double)(entities[3].getNumClusters()+entities[4].getNumClusters()));
-			
-			// test sort by function 2
-			SortOption so = new SortOption();
-			so.setIndex(1);
-			so.setAscendant(true);
-			List<SortOption> sortOptions = Arrays.asList(so);
-			PostHierarchicalAggregateSort.sort(result, sortOptions);
-			writeToJson("After sort" ,result);
-			Assert.assertEquals(null, result.getChildren());
-			Assert.assertEquals(2, result.getSortedList().size(), 2);
-			Iterator<Map.Entry<String, HierarchicalAggregateEntity>> it = result.getSortedList().iterator();
-			Assert.assertEquals(true, it.hasNext());
-			Map.Entry<String, HierarchicalAggregateEntity> entry = it.next();
-			Assert.assertEquals("cluster1", entry.getKey());
-			Assert.assertEquals(entry.getValue().getValues().get(1), (double)(entities[0].getNumClusters()+entities[1].getNumClusters()+entities[2].getNumClusters()));
-			
-			Assert.assertEquals(true, it.hasNext());
-			entry = it.next();
-			Assert.assertEquals("cluster2", entry.getKey());
-			Assert.assertEquals(entry.getValue().getValues().get(1), (double)(entities[3].getNumClusters()+entities[4].getNumClusters()));
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-	}
-	
-	
-	@Test
-	public void testMultipleGropubyFieldsHierarchicalAggregator(){ 
-		TestEntity[] entities = new TestEntity[5];
-		entities[0] = createEntity("cluster1", "dc1", "rack123", 12, 2);
-		entities[1] = createEntity("cluster1", "dc1", "rack123", 20, 1);
-		entities[2] = createEntity("cluster1", "dc2", "rack128", 10, 0);
-		entities[3] = createEntity("cluster2", "dc1", "rack125", 9, 2);
-		entities[4] = createEntity("cluster2", "dc1", "rack126", 15, 2);
-		HierarchicalAggregator agg = new HierarchicalAggregator(Arrays.asList("cluster", "datacenter"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"));
-		try{
-			for(TestEntity e : entities){
-				agg.accumulate(e);
-			}
-			HierarchicalAggregateEntity result = agg.result();
-			writeToJson("After aggregate", result);
-			Assert.assertEquals(2, result.getChildren().size());
-			Assert.assertEquals(66.0, (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()+entities[3].getNumHosts()+entities[4].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("cluster1").getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(2, result.getChildren().get("cluster1").getChildren().size());
-			Assert.assertEquals(result.getChildren().get("cluster1").getChildren().get("dc1").getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("cluster1").getChildren().get("dc2").getValues().get(0), (double)(entities[2].getNumHosts()));
-			
-			Assert.assertEquals(result.getChildren().get("cluster2").getValues().get(0), (double)(entities[3].getNumHosts()+entities[4].getNumHosts()));
-			Assert.assertEquals(1, result.getChildren().get("cluster2").getChildren().size());
-			Assert.assertEquals(result.getChildren().get("cluster2").getChildren().get("dc1").getValues().get(0), (double)(entities[3].getNumHosts()+entities[4].getNumHosts()));
-			
-			// test sort by function 2
-			SortOption so = new SortOption();
-			so.setIndex(0);
-			so.setAscendant(true);
-			List<SortOption> sortOptions = Arrays.asList(so);
-			PostHierarchicalAggregateSort.sort(result, sortOptions);
-			writeToJson("After sort" ,result);
-			Assert.assertEquals(null, result.getChildren());
-			Assert.assertEquals(2, result.getSortedList().size());
-			Iterator<Map.Entry<String, HierarchicalAggregateEntity>> it = result.getSortedList().iterator();
-			Assert.assertEquals(true, it.hasNext());
-			Map.Entry<String, HierarchicalAggregateEntity> entry = it.next();
-			Assert.assertEquals("cluster2", entry.getKey());
-			Assert.assertEquals(entry.getValue().getValues().get(0), (double)(entities[3].getNumHosts()+entities[4].getNumHosts()));
-			
-			Assert.assertEquals(true, it.hasNext());
-			entry = it.next();
-			Assert.assertEquals("cluster1", entry.getKey());
-			Assert.assertEquals(entry.getValue().getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()));			
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-	}
-	
-	@Test
-	public void testUnassigned(){ 
-		TestEntity[] entities = new TestEntity[5];
-		entities[0] = createEntityWithoutDatacenter("cluster1", "rack123", 12, 2);
-		entities[1] = createEntity("cluster1", "dc1", "rack123", 20, 1);
-		entities[2] = createEntity("cluster1", "dc1", "rack128", 10, 0);
-		entities[3] = createEntityWithoutDatacenter("cluster2", "rack125", 9, 2);
-		entities[4] = createEntity("cluster2", "dc1", "rack126", 15, 2);
-		HierarchicalAggregator agg = new HierarchicalAggregator(Arrays.asList("datacenter"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"));
-		try{
-			for(TestEntity e : entities){
-				agg.accumulate(e);
-			}
-			HierarchicalAggregateEntity result = agg.result();
-			writeToJson("After aggregate", result);
-			Assert.assertEquals(result.getChildren().size(), 2);
-			Assert.assertEquals(result.getChildren().get("dc1").getValues().get(0), (double)(entities[1].getNumHosts()+entities[2].getNumHosts())+entities[4].getNumHosts());
-			Assert.assertEquals(result.getChildren().get("unassigned").getValues().get(0), (double)(entities[0].getNumHosts()+entities[3].getNumHosts()));
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-		
-		agg = new HierarchicalAggregator(Arrays.asList("cluster", "datacenter"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"));
-		try{
-			for(TestEntity e : entities){
-				agg.accumulate(e);
-			}
-			HierarchicalAggregateEntity result = agg.result();
-			writeToJson("After aggregate", result);
-			Assert.assertEquals(result.getChildren().size(), 2);
-			Assert.assertEquals(result.getChildren().get("cluster1").getValues().get(0), (double)(entities[0].getNumHosts()+entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(2, result.getChildren().get("cluster1").getChildren().size());
-			Assert.assertEquals(result.getChildren().get("cluster1").getChildren().get("dc1").getValues().get(0), (double)(entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("cluster1").getChildren().get("unassigned").getValues().get(0), (double)(entities[0].getNumHosts()));
-			
-			Assert.assertEquals(result.getChildren().get("cluster2").getValues().get(0), (double)(entities[3].getNumHosts()+entities[4].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("cluster2").getChildren().get("dc1").getValues().get(0), (double)(entities[4].getNumHosts()));
-			Assert.assertEquals(result.getChildren().get("cluster2").getChildren().get("unassigned").getValues().get(0), (double)(entities[3].getNumHosts()));
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestPostFlatAggregateSort.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestPostFlatAggregateSort.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestPostFlatAggregateSort.java
deleted file mode 100644
index d1bb10e..0000000
--- a/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestPostFlatAggregateSort.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package eagle.query.aggregate.test;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import eagle.query.aggregate.timeseries.PostFlatAggregateSort;
-import junit.framework.Assert;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.junit.Test;
-
-import eagle.query.aggregate.timeseries.SortOption;
-
-public class TestPostFlatAggregateSort {
-	private static final Logger logger = Logger.getLogger(TestPostFlatAggregateSort.class);
-	@Test
-	public void testSort(){
-		final String aggField1Value1 = "field1value1";
-		final String aggField1Value2 = "field1value2";
-		final String aggField2Value1 = "field2value1";
-		final String aggField2Value2 = "field2value2";
-		final Double d1 = new Double(1);
-		final Double d2 = new Double(2);
-		final Double d3 = new Double(3);
-		final Double d4 = new Double(4);
-		@SuppressWarnings("serial")
-		Map<List<String>, List<Double>> result = new HashMap<List<String>, List<Double>>(){{
-			put(Arrays.asList(aggField1Value1, aggField2Value1), Arrays.asList(d2, d3));
-			put(Arrays.asList(aggField1Value2, aggField2Value2), Arrays.asList(d1, d4));
-		}};
-		
-		// sort by function1
-		SortOption so = new SortOption();
-		so.setIndex(0);
-		so.setAscendant(true);
-		List<SortOption> sortOptions = Arrays.asList(so);
-		List<Map.Entry<List<String>, List<Double>>> set = 
-				PostFlatAggregateSort.sort(result, sortOptions, 0);
-		JsonFactory factory = new JsonFactory();
-		ObjectMapper mapper = new ObjectMapper(factory);
-		Assert.assertEquals(2, set.size());
-		Iterator<Map.Entry<List<String>, List<Double>>> it = set.iterator();
-		Map.Entry<List<String>, List<Double>> e = it.next();
-		Assert.assertTrue(e.getKey().get(0).equals(aggField1Value2));
-		Assert.assertTrue(e.getValue().get(0).equals(d1));
-		e = it.next();
-		Assert.assertTrue(e.getKey().get(0).equals(aggField1Value1));
-		Assert.assertTrue(e.getValue().get(0).equals(d2));
-		try{
-			String value = mapper.writeValueAsString(set);
-			logger.info(value);
-		}catch(Exception ex){
-			logger.error("fail with mapping", ex);
-			Assert.fail("fail with mapping");
-		}
-		
-		
-		// sort by function2
-		so = new SortOption();
-		so.setIndex(1);
-		so.setAscendant(true);
-		sortOptions = Arrays.asList(so);
-		set = PostFlatAggregateSort.sort(result, sortOptions, 0);
-		factory = new JsonFactory();
-		mapper = new ObjectMapper(factory);
-		Assert.assertEquals(2, set.size());
-		it = set.iterator();
-		e = it.next();
-		Assert.assertTrue(e.getKey().get(0).equals(aggField1Value1));
-		Assert.assertTrue(e.getValue().get(0).equals(d2));
-		e = it.next();
-		Assert.assertTrue(e.getKey().get(0).equals(aggField1Value2));
-		Assert.assertTrue(e.getValue().get(0).equals(d1));
-		try{
-			String value = mapper.writeValueAsString(set);
-			logger.info(value);
-		}catch(Exception ex){
-			logger.error("fail with mapping", ex);
-			Assert.fail("fail with mapping");
-		}
-	}
-	
-	@Test
-	public void testDefaultSort(){
-		final String aggField1Value1 = "xyz";
-		final String aggField1Value2 = "xyz";
-		final String aggField2Value1 = "abd";
-		final String aggField2Value2 = "abc";
-		final Double d1 = new Double(1);
-		final Double d2 = new Double(1);
-		@SuppressWarnings("serial")
-		Map<List<String>, List<Double>> result = new HashMap<List<String>, List<Double>>(){{
-			put(Arrays.asList(aggField1Value1, aggField2Value1), Arrays.asList(d2));
-			put(Arrays.asList(aggField1Value2, aggField2Value2), Arrays.asList(d1));
-		}};
-		
-		// sort by function1
-		SortOption so = new SortOption();
-		so.setIndex(0);
-		so.setAscendant(true);
-		List<SortOption> sortOptions = Arrays.asList(so);
-		List<Map.Entry<List<String>, List<Double>>> set = 
-				PostFlatAggregateSort.sort(result, sortOptions, 0);
-		JsonFactory factory = new JsonFactory();
-		ObjectMapper mapper = new ObjectMapper(factory);
-		Assert.assertEquals(2, set.size());
-		Iterator<Map.Entry<List<String>, List<Double>>> it = set.iterator();
-		Map.Entry<List<String>, List<Double>> e = it.next();
-		Assert.assertTrue(e.getKey().get(0).equals(aggField1Value2));
-		Assert.assertTrue(e.getValue().get(0).equals(d1));
-		e = it.next();
-		Assert.assertTrue(e.getKey().get(0).equals(aggField1Value1));
-		Assert.assertTrue(e.getValue().get(0).equals(d2));
-		try{
-			String value = mapper.writeValueAsString(set);
-			logger.info(value);
-		}catch(Exception ex){
-			logger.error("fail with mapping", ex);
-			Assert.fail("fail with mapping");
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestTimeSeriesAggregator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestTimeSeriesAggregator.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestTimeSeriesAggregator.java
deleted file mode 100755
index 844a517..0000000
--- a/eagle-core/eagle-query/eagle-query-base/src/test/java/eagle/query/aggregate/test/TestTimeSeriesAggregator.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package eagle.query.aggregate.test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import eagle.query.aggregate.timeseries.TimeSeriesAggregator;
-import junit.framework.Assert;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import eagle.log.entity.test.TestEntity;
-import eagle.query.aggregate.AggregateFunctionType;
-
-public class TestTimeSeriesAggregator {
-	private static final Logger LOG = LoggerFactory.getLogger(TestFlatAggregator.class);
-	@SuppressWarnings("serial")
-	private TestEntity createEntity(final String cluster, final String datacenter, final String rack, int numHosts, long numClusters, long timestamp){
-		TestEntity entity = new TestEntity();
-		Map<String, String> tags = new HashMap<String, String>(){{
-			put("cluster", cluster);
-			put("datacenter", datacenter);
-			put("rack", rack);
-		}}; 
-		entity.setTags(tags);
-		entity.setNumHosts(numHosts);
-		entity.setNumClusters(numClusters);
-		entity.setTimestamp(timestamp);
-		return entity;
-	}
-	
-	@Test
-	public void testTimeSeriesAggregator(){
-		TestEntity[] entities = new TestEntity[8];
-		entities[0] = createEntity("cluster1", "dc1", "rack123", 12, 2, 1386120000*1000); // bucket 0
-		entities[1] = createEntity("cluster1", "dc1", "rack123", 20, 1, 1386121060*1000); // bucket 17
-		entities[2] = createEntity("cluster1", "dc1", "rack128", 10, 0, 1386121070*1000); // bucket 17
-		entities[3] = createEntity("cluster2", "dc1", "rack125", 9,   2, 1386122122*1000); // bucket 35
-		entities[4] = createEntity("cluster2", "dc1", "rack126", 15,  5, 1386123210*1000); // bucket 53
-		entities[5] = createEntity("cluster2", "dc1", "rack234", 25,  1, 1386123480*1000); // bucket 58
-		entities[6] = createEntity("cluster2", "dc1", "rack234", 12,  0, 1386123481*1000); // bucket 58
-		entities[7] = createEntity("cluster1", "dc1", "rack123", 3,    2, 1386123482*1000); // bucket 58
-		
-		TimeSeriesAggregator tsAgg = new TimeSeriesAggregator(Arrays.asList("cluster"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"),
-				1386120000*1000, 1386123600*1000, 60*1000);
-		try{
-			for(TestEntity e : entities){
-				tsAgg.accumulate(e);
-			}
-			Map<List<String>, List<Double>> result = tsAgg.result();
-			Assert.assertEquals(result.size(), 6);
-			Assert.assertEquals(result.get(Arrays.asList("cluster1", "0")).get(0), (double)(entities[0].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("cluster1", "17")).get(0), (double)(entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("cluster2", "35")).get(0), (double)(entities[3].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("cluster2", "53")).get(0), (double)(entities[4].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("cluster2", "58")).get(0), (double)(entities[5].getNumHosts()+entities[6].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("cluster1", "58")).get(0), (double)(entities[7].getNumHosts()));
-			
-			Map<List<String>, List<double[]>> tsResult = tsAgg.getMetric();
-			Assert.assertEquals(tsResult.size(), 2);
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster1")).get(0).length, 60);
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster1")).get(0)[0], (double)(entities[0].getNumHosts()));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster1")).get(0)[17], (double)(entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster2")).get(0)[35], (double)(entities[3].getNumHosts()));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster2")).get(0)[53], (double)(entities[4].getNumHosts()));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster2")).get(0)[58], (double)(entities[5].getNumHosts()+entities[6].getNumHosts()));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster1")).get(0)[58], (double)(entities[7].getNumHosts()));
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-		
-		tsAgg = new TimeSeriesAggregator(new ArrayList<String>(), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"), 
-				1386120000*1000, 1386123600*1000, 60*1000);
-		try{
-			for(TestEntity e : entities){
-				tsAgg.accumulate(e);
-			}
-			Map<List<String>, List<Double>> result = tsAgg.result();
-			Assert.assertEquals(result.size(), 5);
-			Assert.assertEquals(result.get(Arrays.asList("0")).get(0), (double)(entities[0].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("17")).get(0), (double)(entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("35")).get(0), (double)(entities[3].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("53")).get(0), (double)(entities[4].getNumHosts()));
-			Assert.assertEquals(result.get(Arrays.asList("58")).get(0), (double)(entities[5].getNumHosts()+entities[6].getNumHosts()+entities[7].getNumHosts()));
-			
-			Map<List<String>, List<double[]>> tsResult = tsAgg.getMetric();
-			Assert.assertEquals(tsResult.size(), 1);
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0).length, 60);
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[0], (double)(entities[0].getNumHosts()));
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[17], (double)(entities[1].getNumHosts()+entities[2].getNumHosts()));
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[35], (double)(entities[3].getNumHosts()));
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[53], (double)(entities[4].getNumHosts()));
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[58], (double)(entities[5].getNumHosts()+entities[6].getNumHosts()+entities[7].getNumHosts()));		
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-		
-		tsAgg = new TimeSeriesAggregator(Arrays.asList("cluster"), Arrays.asList(AggregateFunctionType.count), Arrays.asList("*"), 
-				1386120000*1000, 1386123600*1000, 60*1000);
-		try{
-			for(TestEntity e : entities){
-				tsAgg.accumulate(e);
-			}
-			Map<List<String>, List<Double>> result = tsAgg.result();
-			Assert.assertEquals(result.size(), 6);
-			Assert.assertEquals(result.get(Arrays.asList("cluster1", "0")).get(0), (double)(1));
-			Assert.assertEquals(result.get(Arrays.asList("cluster1", "17")).get(0), (double)(2));
-			Assert.assertEquals(result.get(Arrays.asList("cluster2", "35")).get(0), (double)(1));
-			Assert.assertEquals(result.get(Arrays.asList("cluster2", "53")).get(0), (double)(1));
-			Assert.assertEquals(result.get(Arrays.asList("cluster2", "58")).get(0), (double)(2));
-			Assert.assertEquals(result.get(Arrays.asList("cluster1", "58")).get(0), (double)(1));
-			
-			Map<List<String>, List<double[]>> tsResult = tsAgg.getMetric();
-			Assert.assertEquals(tsResult.size(), 2);
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster1")).get(0).length, 60);
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster1")).get(0)[0], (double)(1));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster1")).get(0)[17], (double)(2));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster2")).get(0)[35], (double)(1));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster2")).get(0)[53], (double)(1));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster2")).get(0)[58], (double)(2));
-			Assert.assertEquals(tsResult.get(Arrays.asList("cluster1")).get(0)[58], (double)(1));
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-		
-		tsAgg = new TimeSeriesAggregator(new ArrayList<String>(), Arrays.asList(AggregateFunctionType.count), Arrays.asList("*"), 
-				1386120000*1000, 1386123600*1000, 60*1000);
-		try{
-			for(TestEntity e : entities){
-				tsAgg.accumulate(e);
-			}
-			Map<List<String>, List<Double>> result = tsAgg.result();
-			Assert.assertEquals(result.size(), 5);
-			Assert.assertEquals(result.get(Arrays.asList("0")).get(0), (double)(1));
-			Assert.assertEquals(result.get(Arrays.asList("17")).get(0), (double)(2));
-			Assert.assertEquals(result.get(Arrays.asList("35")).get(0), (double)(1));
-			Assert.assertEquals(result.get(Arrays.asList("53")).get(0), (double)(1));
-			Assert.assertEquals(result.get(Arrays.asList("58")).get(0), (double)(3));
-			
-			Map<List<String>, List<double[]>> tsResult = tsAgg.getMetric();
-			Assert.assertEquals(tsResult.size(), 1);
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0).length, 60);
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[0], (double)(1));
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[17], (double)(2));
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[35], (double)(1));
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[53], (double)(1));
-			Assert.assertEquals(tsResult.get(new ArrayList<String>()).get(0)[58], (double)(3));		
-		}catch(Exception ex){
-			LOG.error("Can not aggregate", ex);
-			Assert.fail("Can not aggregate");
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestGroupbyKey.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestGroupbyKey.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestGroupbyKey.java
new file mode 100755
index 0000000..b07229b
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestGroupbyKey.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.aggregate.raw;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TestGroupbyKey {
+	@Test
+	public void testGroupbyKey(){
+		GroupbyKey key1 = new GroupbyKey();
+		Assert.assertEquals(0, key1.getValue().size());
+		
+		key1.addValue(new byte[]{1, 3, 5});
+		Assert.assertEquals(1, key1.getValue().size());
+		
+		key1.clear();
+		Assert.assertEquals(0, key1.getValue().size());
+		
+		key1.addValue(new byte[]{1, 3, 5});
+		GroupbyKey key2 = new GroupbyKey();
+		key2.addValue(new byte[]{1, 3, 5});
+		Assert.assertEquals(key1, key2);
+		
+		GroupbyKey key3 = new GroupbyKey(key1);
+		Assert.assertEquals(key1, key3);
+		Assert.assertEquals(key2, key3);
+	}
+	
+	@Test
+	public void testGroupbyKeyComparator(){
+		GroupbyKeyComparator comparator = new GroupbyKeyComparator();
+		GroupbyKey key1 = new GroupbyKey();
+		key1.addValue("hello".getBytes());
+		GroupbyKey key2 = new GroupbyKey();
+		key2.addValue("world".getBytes());
+		int r = comparator.compare(key1, key2);
+		Assert.assertTrue(r < 0);
+		
+		key2.clear();
+		key2.addValue("friend".getBytes());
+		r = comparator.compare(key1, key2);
+		Assert.assertTrue(r > 0);
+		
+		key2.clear();
+		key2.addValue("hello".getBytes());
+		r = comparator.compare(key1, key2);
+		Assert.assertTrue(r == 0);
+		
+		key1.clear();
+		key2.clear();
+		key1.addValue("hello".getBytes());
+		key1.addValue("tom".getBytes());
+		key2.addValue("hello".getBytes());
+		key2.addValue("jackie".getBytes());
+		r = comparator.compare(key1, key2);
+		Assert.assertTrue(r > 0);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestRawAggregator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestRawAggregator.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestRawAggregator.java
new file mode 100644
index 0000000..41bc18a
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestRawAggregator.java
@@ -0,0 +1,517 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.aggregate.raw;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.eagle.query.aggregate.AggregateFunctionType;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.eagle.log.entity.meta.EntityDefinition;
+import org.apache.eagle.log.entity.meta.EntitySerDeser;
+import org.apache.eagle.log.entity.meta.IntSerDeser;
+import org.apache.eagle.log.entity.meta.LongSerDeser;
+import org.apache.eagle.log.entity.meta.Qualifier;
+import org.apache.eagle.common.ByteUtil;
+
+public class TestRawAggregator {
+	private static final Logger LOG = LoggerFactory.getLogger(TestRawAggregator.class);
+	
+	private EntityDefinition ed;
+	@SuppressWarnings("unchecked")
+	@Before
+	public void setup(){
+		ed = new EntityDefinition();
+		Qualifier q = new Qualifier();
+		q.setDisplayName("numHosts");
+		q.setQualifierName("a");
+		EntitySerDeser<?> serDeser = new IntSerDeser();
+		q.setSerDeser((EntitySerDeser<Object>)(serDeser));
+		ed.getDisplayNameMap().put("numHosts", q);
+		q = new Qualifier();
+		q.setDisplayName("numClusters");
+		q.setQualifierName("b");
+		serDeser = new LongSerDeser();
+		q.setSerDeser((EntitySerDeser<Object>)(serDeser));
+		ed.getDisplayNameMap().put("numClusters", q);
+	}
+	
+	private Map<String, byte[]> createQualifiers(final String cluster, final String datacenter, final String rack, int numHosts, long numClusters){
+		Map<String, byte[]> qualifiers = new HashMap<String, byte[]>();
+		qualifiers.put("cluster", cluster == null ? null : cluster.getBytes());
+		qualifiers.put("datacenter", datacenter == null ? null : datacenter.getBytes());
+		qualifiers.put("rack", rack == null ? null : rack.getBytes());
+		qualifiers.put("numHosts", ByteUtil.intToBytes(numHosts));
+		qualifiers.put("numClusters", ByteUtil.longToBytes(numClusters));
+		return qualifiers;
+	}
+
+	@Test
+	public void testZeroGroupbyFieldSingleFunctionForSummary(){
+		List<Map<String, byte[]>> entities = new ArrayList<Map<String, byte[]>>();
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 12, 2));
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 20, 1));
+		entities.add(createQualifiers("cluster1", "dc1", "rack128", 10, 0));
+		entities.add(createQualifiers("cluster2", "dc1", "rack125", 9, 2));
+		entities.add(createQualifiers("cluster2", "dc1", "rack126", 15, 2));
+		
+		RawAggregator agg = new RawAggregator(new ArrayList<String>(), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 1);
+			
+			double total = 0.0;
+			for(Map<String, byte[]> e : entities){
+				int a = ByteUtil.bytesToInt(e.get("numHosts"));
+				total += a;
+			}
+			
+			Assert.assertEquals(result.get(new ArrayList<String>()).get(0).doubleValue(), total, 0.00000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(new ArrayList<String>(), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numClusters"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 1);
+			double total = 0.0;
+			for(Map<String, byte[]> e : entities){
+				long a = ByteUtil.bytesToLong(e.get("numClusters"));
+				total += a;
+			}
+			Assert.assertEquals(result.get(new ArrayList<String>()).get(0).doubleValue(), total, 0.00000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(new ArrayList<String>(), Arrays.asList(AggregateFunctionType.count), Arrays.asList("*"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 1);
+			Assert.assertEquals(result.get(new ArrayList<String>()).get(0).doubleValue(), 5, 0.0000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+	}
+	
+	@Test
+	public void testSingleGroupbyFieldSingleFunctionForSummary(){
+		List<Map<String, byte[]>> entities = new ArrayList<Map<String, byte[]>>();
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 12, 2));
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 20, 1));
+		entities.add(createQualifiers("cluster1", "dc2", "rack128", 10, 0));
+		entities.add(createQualifiers("cluster2", "dc1", "rack125", 9, 2));
+		entities.add(createQualifiers("cluster2", "dc1", "rack126", 15, 2));
+		
+		RawAggregator agg = new RawAggregator(Arrays.asList("cluster"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			double total1 = 0.0;
+			total1 += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total1 += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			total1 += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			
+			double total2 = 0.0;
+			total2 += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			total2 += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster1")).get(0).doubleValue(), total1, 0.0000000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2")).get(0), total2, 0.00000000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(Arrays.asList("datacenter"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			double total1 = 0.0;
+			total1 += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total1 += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			total1 += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			total1 += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			
+			double total2 = 0.0;
+			total2 += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(0), total1, 0.000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("dc2")).get(0), total2, 0.000000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(Arrays.asList("cluster"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numClusters"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			double total1 = 0.0;
+			total1 += ByteUtil.bytesToLong(entities.get(0).get("numClusters"));
+			total1 += ByteUtil.bytesToLong(entities.get(1).get("numClusters"));
+			total1 += ByteUtil.bytesToLong(entities.get(2).get("numClusters"));
+			
+			double total2 = 0.0;
+			total2 += ByteUtil.bytesToLong(entities.get(3).get("numClusters"));
+			total2 += ByteUtil.bytesToLong(entities.get(4).get("numClusters"));
+			
+			Assert.assertEquals(result.get(Arrays.asList("cluster1")).get(0), total1, 0.0000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2")).get(0), total2, 0.0000000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(Arrays.asList("datacenter"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numClusters"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			double total1 = 0.0;
+			total1 += ByteUtil.bytesToLong(entities.get(0).get("numClusters"));
+			total1 += ByteUtil.bytesToLong(entities.get(1).get("numClusters"));
+			total1 += ByteUtil.bytesToLong(entities.get(3).get("numClusters"));
+			total1 += ByteUtil.bytesToLong(entities.get(4).get("numClusters"));
+			
+			double total2 = 0.0;
+			total2 += ByteUtil.bytesToLong(entities.get(2).get("numClusters"));
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(0), total1, 0.00000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("dc2")).get(0), total2, 0.00000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+	}
+	
+	
+	@Test
+	public void testSingleGroupbyFieldSingleFunctionForCount(){
+		List<Map<String, byte[]>> entities = new ArrayList<Map<String, byte[]>>();
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 12, 2));
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 20, 1));
+		entities.add(createQualifiers("cluster1", "dc1", "rack128", 10, 0));
+		entities.add(createQualifiers("cluster2", "dc1", "rack125", 9, 2));
+		entities.add(createQualifiers("cluster2", "dc2", "rack126", 15, 2));
+		
+		RawAggregator agg = new RawAggregator(Arrays.asList("cluster"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			double total1 = 0.0;
+			total1 += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total1 += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			total1 += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			
+			double total2 = 0.0;
+			total2 += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			total2 += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			
+			Assert.assertEquals(result.get(Arrays.asList("cluster1")).get(0), total1, 0.0000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2")).get(0), total2, 0.0000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(Arrays.asList("datacenter"), Arrays.asList(AggregateFunctionType.count), Arrays.asList("*"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(0), (double)(4), 0.00000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("dc2")).get(0), (double)(1), 0.00000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("can not aggregate", ex);
+			Assert.fail("can not aggregate");
+		}
+	}
+	
+	@Test
+	public void testMultipleFieldsSingleFunctionForSummary(){
+		List<Map<String, byte[]>> entities = new ArrayList<Map<String, byte[]>>();
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 12, 2));
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 20, 1));
+		entities.add(createQualifiers("cluster1", "dc1", "rack128", 10, 0));
+		entities.add(createQualifiers("cluster2", "dc1", "rack125", 9, 2));
+		entities.add(createQualifiers("cluster2", "dc1", "rack126", 15, 2));
+		entities.add(createQualifiers("cluster2", null, "rack126", 1, 3));
+		
+		RawAggregator agg = new RawAggregator(Arrays.asList("cluster", "datacenter"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(3, result.size());
+			double total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "dc1")).get(0), total, 0.00000000000000000000000001);
+			
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "dc1")).get(0), total, 0.0000000000000000000000001);
+			
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "dc1")).get(0), total, 0.0000000000000000000000001);
+			
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(5).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "unassigned")).get(0), total, 0.0000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(Arrays.asList("cluster", "datacenter", "rack"), Arrays.asList(AggregateFunctionType.sum), Arrays.asList("numHosts"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(5, result.size());
+			double total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "dc1", "rack123")).get(0), total, 0.0000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "dc1", "rack128")).get(0), total, 0.0000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "dc1", "rack125")).get(0), total, 0.0000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "dc1", "rack126")).get(0), total, 0.0000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(5).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "unassigned", "rack126")).get(0), total, 0.0000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+	}
+	
+	@Test
+	public void testMultipleFieldsSingleFunctionForCount(){
+		List<Map<String, byte[]>> entities = new ArrayList<Map<String, byte[]>>();
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 12, 2));
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 20, 1));
+		entities.add(createQualifiers("cluster1", "dc1", "rack128", 10, 0));
+		entities.add(createQualifiers("cluster2", "dc1", "rack125", 9, 2));
+		entities.add(createQualifiers("cluster2", "dc1", "rack126", 15, 2));
+		entities.add(createQualifiers("cluster2", null, "rack126", 1, 3));
+		
+		RawAggregator agg = new RawAggregator(Arrays.asList("cluster", "datacenter"), Arrays.asList(AggregateFunctionType.count), Arrays.asList("*"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(3, result.size());
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "dc1")).get(0), (double)(3), 0.00000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "dc1")).get(0), (double)(2), 0.0000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "unassigned")).get(0), (double)(1), 0.000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(Arrays.asList("cluster", "datacenter", "rack"), Arrays.asList(AggregateFunctionType.count), Arrays.asList("*"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(5, result.size());
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "dc1", "rack123")).get(0), (double)(2), 0.0000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "dc1", "rack128")).get(0), (double)(1), 0.0000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "dc1", "rack125")).get(0), (double)(1), 0.0000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "dc1", "rack126")).get(0), (double)(1), 0.0000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "unassigned", "rack126")).get(0), (double)(1), 0.0000000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+	}
+	
+	@Test
+	public void testSingleGroupbyFieldMultipleFunctions(){
+		List<Map<String, byte[]>> entities = new ArrayList<Map<String, byte[]>>();
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 12, 2));
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 20, 1));
+		entities.add(createQualifiers("cluster1", "dc1", "rack128", 10, 0));
+		entities.add(createQualifiers("cluster2", "dc1", "rack125", 9, 2));
+		entities.add(createQualifiers("cluster2", "dc2", "rack126", 15, 2));
+		
+		RawAggregator agg = new RawAggregator(Arrays.asList("cluster"), Arrays.asList(AggregateFunctionType.sum, AggregateFunctionType.count), 
+				Arrays.asList("numHosts", "*"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			double total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster1")).get(0), total, 0.0000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster1")).get(1), (double)(3), 0.00000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2")).get(0), total, 0.0000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2")).get(1), (double)(2), 0.0000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(Arrays.asList("datacenter"), Arrays.asList(AggregateFunctionType.count, AggregateFunctionType.sum), Arrays.asList("*", "numHosts"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			double total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(0), (double)(4), 0.00000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(1), total, 0.00000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+		
+		agg = new RawAggregator(Arrays.asList("datacenter"), Arrays.asList(AggregateFunctionType.count, AggregateFunctionType.sum, AggregateFunctionType.sum), 
+				Arrays.asList("*", "numHosts", "numClusters"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 2);
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(0), (double)(4), 0.000000000000000000000000001);
+			double total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(1), total, 0.0000000000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToLong(entities.get(0).get("numClusters"));
+			total += ByteUtil.bytesToLong(entities.get(1).get("numClusters"));
+			total += ByteUtil.bytesToLong(entities.get(2).get("numClusters"));
+			total += ByteUtil.bytesToLong(entities.get(3).get("numClusters"));
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(2), total, 0.00000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("dc1")).get(0), (double)(4), 0.000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("dc2")).get(1), total, 0.00000000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToLong(entities.get(4).get("numClusters"));
+			Assert.assertEquals(result.get(Arrays.asList("dc2")).get(2), total, 0.000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+	}
+	
+	@Test
+	public void testMultipleGroupbyFieldsMultipleFunctions(){
+		List<Map<String, byte[]>> entities = new ArrayList<Map<String, byte[]>>();
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 12, 2));
+		entities.add(createQualifiers("cluster1", "dc1", "rack123", 20, 1));
+		entities.add(createQualifiers("cluster1", "dc1", "rack128", 10, 0));
+		entities.add(createQualifiers("cluster2", "dc1", "rack125", 9, 2));
+		entities.add(createQualifiers("cluster2", "dc1", "rack126", 15, 2));
+		
+		RawAggregator agg = new RawAggregator(Arrays.asList("cluster", "rack"), Arrays.asList(AggregateFunctionType.sum, AggregateFunctionType.count), 
+				Arrays.asList("numHosts", "*"), ed);
+		try{
+			for(Map<String, byte[]> e : entities){
+				agg.qualifierCreated(e);
+			}
+			Map<List<String>, List<Double>> result = agg.result();
+			Assert.assertEquals(result.size(), 4);
+			double total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(0).get("numHosts"));
+			total += ByteUtil.bytesToInt(entities.get(1).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "rack123")).get(0), total, 0.000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "rack123")).get(1), (double)(2), 0.00000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(2).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "rack128")).get(0), total, 0.00000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster1", "rack128")).get(1), (double)(1), 0.00000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(3).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "rack125")).get(0), total, 0.000000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "rack125")).get(1), (double)(1), 0.0000000000000000000000001);
+			total = 0.0;
+			total += ByteUtil.bytesToInt(entities.get(4).get("numHosts"));
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "rack126")).get(0), total, 0.00000000000000000000000001);
+			Assert.assertEquals(result.get(Arrays.asList("cluster2", "rack126")).get(1), (double)(1), 0.000000000000000000000000001);
+		}catch(Exception ex){
+			LOG.error("Can not aggregate", ex);
+			Assert.fail("Can not aggregate");
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestRawHBaseLogReaderAndAgg.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestRawHBaseLogReaderAndAgg.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestRawHBaseLogReaderAndAgg.java
new file mode 100644
index 0000000..a304ea9
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/raw/TestRawHBaseLogReaderAndAgg.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.aggregate.raw;
+
+import org.junit.Test;
+
+public class TestRawHBaseLogReaderAndAgg {
+	@Test
+	public void testRawReaderAndAgg(){
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestAggregator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestAggregator.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestAggregator.java
new file mode 100644
index 0000000..135e6d0
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestAggregator.java
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.aggregate.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.eagle.query.aggregate.*;
+import org.codehaus.jackson.JsonFactory;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.query.aggregate.Aggregator;
+
+public class TestAggregator {
+	private final static Logger LOG = LoggerFactory.getLogger(TestAggregator.class);
+	
+	public static class AggregatedSampleAPIEntityFactory implements AggregateAPIEntityFactory {
+		@Override
+		public AggregateAPIEntity create(){
+			return new AggregatedSampleAPIEntity();
+		}
+	}
+	
+	
+	public static class TestAPIEntity extends TaggedLogAPIEntity{
+		private String numTotalAlerts;
+		private String usedCapacity;
+		private String status;
+
+		public String getStatus() {
+			return status;
+		}
+
+		public void setStatus(String status) {
+			this.status = status;
+		}
+
+		public String getNumTotalAlerts() {
+			return numTotalAlerts;
+		}
+
+		public void setNumTotalAlerts(String numTotalAlerts) {
+			this.numTotalAlerts = numTotalAlerts;
+		}
+
+		public String getUsedCapacity() {
+			return usedCapacity;
+		}
+
+		public void setUsedCapacity(String usedCapacity) {
+			this.usedCapacity = usedCapacity;
+		}
+	}
+	
+
+
+	public static class AggregatedSampleAPIEntity extends AggregateAPIEntity{
+		private long numTotalAlerts;
+	
+		@JsonProperty("nTA")
+		public long getNumTotalAlerts() {
+			return numTotalAlerts;
+		}
+	
+		public void setNumTotalAlerts(long numTotalAlerts) {
+			this.numTotalAlerts = numTotalAlerts;
+		}
+	}
+	
+	@Test
+	public void testAggregate(){ 
+		try{
+			final AggregatedSampleAPIEntity root = new AggregatedSampleAPIEntity();
+			List<String> sumFunctionFields = Arrays.asList("numTotalAlerts");
+			boolean counting = true;
+			List<String> groupbys = Arrays.asList(Aggregator.GROUPBY_ROOT_FIELD_NAME, "cluster");
+			List<AggregateParams.SortFieldOrder> sortFieldOrders = new ArrayList<AggregateParams.SortFieldOrder>();
+			sortFieldOrders.add(new AggregateParams.SortFieldOrder("numTotalAlerts", false));
+			Aggregator agg = new Aggregator(new AggregatedSampleAPIEntityFactory(), root, groupbys, counting, sumFunctionFields);
+			List<TestAPIEntity> list = new ArrayList<TestAPIEntity>();
+			TestAPIEntity entity = new TestAPIEntity();
+			entity.setTags(new HashMap<String, String>());
+			entity.getTags().put("category", "checkHadoopFS");
+			entity.getTags().put("rack", "rack123");
+			entity.getTags().put("cluster", "cluster1");
+			entity.setNumTotalAlerts("123");
+			entity.setUsedCapacity("12.5");
+			entity.setStatus("live");
+			list.add(entity);
+	
+			TestAPIEntity entity2 = new TestAPIEntity();
+			entity2.setTags(new HashMap<String, String>());
+			entity2.getTags().put("category", "checkHadoopFS");
+			entity2.getTags().put("rack", "rack124");
+			entity2.getTags().put("cluster", "cluster2");
+			entity2.setNumTotalAlerts("35");
+			entity2.setUsedCapacity("32.1");
+			entity2.setStatus("dead");
+			list.add(entity2);
+			
+			TestAPIEntity entity3 = new TestAPIEntity();
+			entity3.setTags(new HashMap<String, String>());
+			entity3.getTags().put("category", "checkHadoopFS");
+	//		entity3.getTags().put("rack", "rack124");
+			entity3.getTags().put("cluster", "cluster2");
+			entity3.setNumTotalAlerts("11");
+			entity3.setUsedCapacity("82.11");
+			entity3.setStatus("live");
+			list.add(entity3);
+						
+			TestAPIEntity entity4 = new TestAPIEntity();
+			entity4.setTags(new HashMap<String, String>());
+			entity4.getTags().put("category", "diskfailure");
+			entity4.getTags().put("rack", "rack124");
+			entity4.getTags().put("cluster", "cluster2");
+			entity4.setNumTotalAlerts("61");
+			entity4.setUsedCapacity("253.2");
+			entity4.setStatus("dead");
+			list.add(entity4);
+			
+			long numTotalAlerts = 0;
+			for(TestAPIEntity e : list){
+				agg.accumulate(e);
+				numTotalAlerts += Long.valueOf(e.getNumTotalAlerts());
+			}
+
+			JsonFactory factory = new JsonFactory(); 
+			ObjectMapper mapper = new ObjectMapper(factory);
+			String result = null;
+			AggregatedSampleAPIEntity toBeVerified = (AggregatedSampleAPIEntity)root.getEntityList().get(Aggregator.GROUPBY_ROOT_FIELD_VALUE);
+			result = mapper.writeValueAsString(toBeVerified);
+			
+			Assert.assertEquals(2, toBeVerified.getNumDirectDescendants());
+			Assert.assertEquals(4, toBeVerified.getNumTotalDescendants());
+			Assert.assertEquals(numTotalAlerts, toBeVerified.getNumTotalAlerts());
+			
+	    	LOG.info(result);
+	    	
+	    	PostAggregateSorting.sort(root, sortFieldOrders);
+	    	toBeVerified = (AggregatedSampleAPIEntity)root.getSortedList().get(0);
+			result = mapper.writeValueAsString(toBeVerified);
+	    	LOG.info(result);
+	    }catch(Exception ex){
+	    	LOG.error("Test aggregator fails", ex);
+	    	Assert.fail("Test aggregator fails");
+	    }
+	}
+	
+	@Test
+	public void testUnassigned(){ 
+		// rack is unassigned
+		try{
+			final AggregatedSampleAPIEntity root = new AggregatedSampleAPIEntity();
+			boolean counting = true;
+			List<String> groupbys = Arrays.asList(Aggregator.GROUPBY_ROOT_FIELD_NAME, "rack");
+			List<AggregateParams.SortFieldOrder> sortFieldOrders = new ArrayList<AggregateParams.SortFieldOrder>();
+			sortFieldOrders.add(new AggregateParams.SortFieldOrder("count", false));
+			sortFieldOrders.add(new AggregateParams.SortFieldOrder("key", false));
+			Aggregator agg = new Aggregator(new AggregatedSampleAPIEntityFactory(), root, groupbys, counting, new ArrayList<String>());
+			List<TestAPIEntity> list = new ArrayList<TestAPIEntity>();
+			TestAPIEntity entity = new TestAPIEntity();
+			entity.setTags(new HashMap<String, String>());
+			entity.getTags().put("category", "checkHadoopFS");
+			entity.getTags().put("rack", "rack123");
+			entity.getTags().put("cluster", "cluster1");
+			entity.setNumTotalAlerts("123");
+			entity.setUsedCapacity("12.5");
+			entity.setStatus("live");
+			list.add(entity);
+	
+			TestAPIEntity entity2 = new TestAPIEntity();
+			entity2.setTags(new HashMap<String, String>());
+			entity2.getTags().put("category", "checkHadoopFS");
+			entity2.getTags().put("rack", "rack124");
+			entity2.getTags().put("cluster", "cluster2");
+			entity2.setNumTotalAlerts("35");
+			entity2.setUsedCapacity("32.1");
+			entity2.setStatus("dead");
+			list.add(entity2);
+			
+			TestAPIEntity entity3 = new TestAPIEntity();
+			entity3.setTags(new HashMap<String, String>());
+			entity3.getTags().put("category", "checkHadoopFS");
+	//		entity3.getTags().put("rack", "rack124");
+			entity3.getTags().put("cluster", "cluster2");
+			entity3.setNumTotalAlerts("11");
+			entity3.setUsedCapacity("82.11");
+			entity3.setStatus("live");
+			list.add(entity3);
+						
+			TestAPIEntity entity4 = new TestAPIEntity();
+			entity4.setTags(new HashMap<String, String>());
+			entity4.getTags().put("category", "diskfailure");
+			entity4.getTags().put("rack", "rack124");
+			entity4.getTags().put("cluster", "cluster2");
+			entity4.setNumTotalAlerts("61");
+			entity4.setUsedCapacity("253.2");
+			entity4.setStatus("dead");
+			list.add(entity4);
+			
+//			long numTotalAlerts = 0;
+			for(TestAPIEntity e : list){
+				agg.accumulate(e);
+//				numTotalAlerts += Long.valueOf(e.getNumTotalAlerts());
+			}
+
+			JsonFactory factory = new JsonFactory(); 
+			ObjectMapper mapper = new ObjectMapper(factory);
+			String result = null;
+			AggregatedSampleAPIEntity toBeVerified = (AggregatedSampleAPIEntity)root.getEntityList().get(Aggregator.GROUPBY_ROOT_FIELD_VALUE);
+			result = mapper.writeValueAsString(toBeVerified);
+			
+			Assert.assertEquals(3, toBeVerified.getNumDirectDescendants());
+			Assert.assertEquals(4, toBeVerified.getNumTotalDescendants());
+//			Assert.assertEquals(numTotalAlerts, toBeVerified.getNumTotalAlerts());
+			
+	    	LOG.info(result);
+	    	
+	    	PostAggregateSorting.sort(root, sortFieldOrders);			
+	    	toBeVerified = (AggregatedSampleAPIEntity)root.getSortedList().get(0);
+			result = mapper.writeValueAsString(toBeVerified);
+	    	LOG.info(result);
+	    }catch(Exception ex){
+	    	LOG.error("Test aggregator fails", ex);
+	    	Assert.fail("Test aggregator fails");
+	    }
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestAlertAggService.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestAlertAggService.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestAlertAggService.java
new file mode 100644
index 0000000..c2d0a26
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestAlertAggService.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.aggregate.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+import org.junit.Test;
+
+public class TestAlertAggService {
+	@Test
+	public void testCompileAndSplitCondition(){
+		List<String> alertTagNameValues = new ArrayList<String>();
+		String tagNameValue1 = "cluster=cluster1";
+		String tagNameValue2 = "category=checkHadoopFS";
+		String tagNameValue3 = "category=highloadDisk";
+		String tagNameValue4 = "cluster=dc124";
+		String tagNameValue5 = "category=lowloadDisk";
+		alertTagNameValues.add(tagNameValue1);
+		alertTagNameValues.add(tagNameValue2);
+		alertTagNameValues.add(tagNameValue3);
+		alertTagNameValues.add(tagNameValue4);
+		alertTagNameValues.add(tagNameValue5);
+//		AlertAggResource r = new AlertAggResource();
+//		List<List<String>> result = r.compileAndSplitConditions(alertTagNameValues);
+//		Assert.assertEquals(result.size(), 3);
+//		Assert.assertEquals(result.get(0).size(), 3);
+//		Assert.assertTrue(result.get(0).contains(tagNameValue2));
+//		Assert.assertTrue(result.get(0).contains(tagNameValue1));
+//		Assert.assertTrue(result.get(0).contains(tagNameValue4));
+//		Assert.assertEquals(result.get(1).size(), 3);
+//		Assert.assertTrue(result.get(1).contains(tagNameValue3));
+//		Assert.assertTrue(result.get(1).contains(tagNameValue1));
+//		Assert.assertTrue(result.get(1).contains(tagNameValue4));
+//		Assert.assertEquals(result.get(2).size(), 3);
+//		Assert.assertTrue(result.get(2).contains(tagNameValue5));
+//		Assert.assertTrue(result.get(2).contains(tagNameValue1));
+//		Assert.assertTrue(result.get(2).contains(tagNameValue4));
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestBucketQuery.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestBucketQuery.java b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestBucketQuery.java
new file mode 100755
index 0000000..e879bdf
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-query-base/src/test/java/org/apache/eagle/query/aggregate/test/TestBucketQuery.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.aggregate.test;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.query.aggregate.BucketQuery;
+import junit.framework.Assert;
+import org.codehaus.jackson.JsonFactory;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TestBucketQuery {
+	private static class SampleTaggedLogAPIEntity extends TaggedLogAPIEntity{
+		private String description;
+
+		@SuppressWarnings("unused")
+		public String getDescription() {
+			return description;
+		}
+
+		public void setDescription(String description) {
+			this.description = description;
+		}
+	}
+
+	@SuppressWarnings("unchecked")
+	@Test
+	public void testBucketQuery(){
+		SampleTaggedLogAPIEntity e1 = new SampleTaggedLogAPIEntity();
+		e1.setTags(new HashMap<String, String>());
+		e1.getTags().put("cluster", "cluster1");
+		e1.getTags().put("rack", "rack123");
+		e1.setDescription("this is description 1");
+		
+		SampleTaggedLogAPIEntity e2 = new SampleTaggedLogAPIEntity();
+		e2.setTags(new HashMap<String, String>());
+		e2.getTags().put("cluster", "cluster1");
+		e2.getTags().put("rack", "rack123");
+		e2.setDescription("this is description 2");
+		
+		List<String> bucketFields = new ArrayList<String>();
+		bucketFields.add("cluster");
+		int limit = 1;
+		
+		BucketQuery query1 = new BucketQuery(bucketFields, limit);
+		query1.put(e1);
+		query1.put(e2);
+		
+		Map<String, Object> map = query1.get();
+		
+		List<TaggedLogAPIEntity> o = (List<TaggedLogAPIEntity>)map.get("cluster1");
+		Assert.assertEquals(limit, o.size());
+		
+		JsonFactory factory = new JsonFactory();
+		ObjectMapper mapper = new ObjectMapper(factory);
+		mapper.setFilters(TaggedLogAPIEntity.getFilterProvider());
+		try{
+			String result = mapper.writeValueAsString(map);
+			System.out.println(result);
+		}catch(Exception ex){
+			ex.printStackTrace();
+			Assert.fail("can not serialize bucket query result");
+		}
+		
+		limit = 2;
+		BucketQuery query2 = new BucketQuery(bucketFields, limit);
+		query2.put(e1);
+		query2.put(e2);
+		Map<String, Object> map2 = query2.get();
+		o = (List<TaggedLogAPIEntity>)map2.get("cluster1");
+		try{
+			String result = mapper.writeValueAsString(map2);
+			System.out.println(result);
+		}catch(Exception ex){
+			ex.printStackTrace();
+			Assert.fail("can not serialize bucket query result");
+		}
+		Assert.assertEquals(limit, o.size());
+		
+		
+		SampleTaggedLogAPIEntity e3 = new SampleTaggedLogAPIEntity();
+		e3.setTags(new HashMap<String, String>());
+		e3.getTags().put("cluster", "cluster1");
+		e3.getTags().put("rack", "rack124");
+		e3.setDescription("this is description 3");
+		bucketFields.add("rack");
+		limit = 2;
+		BucketQuery query3 = new BucketQuery(bucketFields, limit);
+		query3.put(e1);
+		query3.put(e2);
+		query3.put(e3);
+		Map<String, Object> map3 = query3.get();
+		Map<String, Object> o3 = (Map<String, Object>)map3.get("cluster1");
+		List<TaggedLogAPIEntity> o4 = (List<TaggedLogAPIEntity>)o3.get("rack124");
+		Assert.assertEquals(1, o4.size());
+		List<TaggedLogAPIEntity> o5 = (List<TaggedLogAPIEntity>)o3.get("rack123");
+		Assert.assertEquals(o5.size(), 2);
+		
+		try{
+			String result = mapper.writeValueAsString(map3);
+			System.out.println(result);
+		}catch(Exception ex){
+			ex.printStackTrace();
+			Assert.fail("can not serialize bucket query result");
+		}
+		
+		
+		SampleTaggedLogAPIEntity e4 = new SampleTaggedLogAPIEntity();
+		e4.setTags(new HashMap<String, String>());
+		e4.getTags().put("cluster", "cluster1");
+		// rack is set to null
+//		e4.getTags().put("rack", "rack124");
+		e4.setDescription("this is description 3");
+		limit = 2;
+		BucketQuery query4 = new BucketQuery(bucketFields, limit);
+		query4.put(e1);
+		query4.put(e2);
+		query4.put(e3);
+		query4.put(e4);
+		Map<String, Object> map4 = query4.get();
+		Map<String, Object> o6 = (Map<String, Object>)map4.get("cluster1");
+		List<TaggedLogAPIEntity> o7 = (List<TaggedLogAPIEntity>)o6.get("rack124");
+		Assert.assertEquals(1, o7.size());
+		List<TaggedLogAPIEntity> o8 = (List<TaggedLogAPIEntity>)o6.get("rack123");
+		Assert.assertEquals(o8.size(), 2);
+		List<TaggedLogAPIEntity> o9 = (List<TaggedLogAPIEntity>)o6.get("unassigned");
+		Assert.assertEquals(o9.size(), 1);
+		
+		try{
+			String result = mapper.writeValueAsString(map4);
+			System.out.println(result);
+		}catch(Exception ex){
+			ex.printStackTrace();
+			Assert.fail("can not serialize bucket query result");
+		}
+	}
+}


Mime
View raw message