@Test public void groupRows(){ List<Map<FieldName, Object>> table = new ArrayList<>(); table.add(createRow("1", "Cracker")); table.add(createRow("2", "Cracker")); table.add(createRow("1", "Coke")); table.add(createRow("3", "Cracker")); table.add(createRow("3", "Water")); table.add(createRow("3", "Coke")); table.add(createRow("2", "Water")); table = EvaluatorUtil.groupRows(FieldName.create("transaction"), table); checkGroupedRow(table.get(0), "1", Arrays.asList("Cracker", "Coke")); checkGroupedRow(table.get(1), "2", Arrays.asList("Cracker", "Water")); checkGroupedRow(table.get(2), "3", Arrays.asList("Cracker", "Water", "Coke")); }
static public List<? extends Map<FieldName, ?>> groupRows(HasGroupFields hasGroupFields, List<? extends Map<FieldName, ?>> table){ List<InputField> groupFields = hasGroupFields.getGroupFields(); if(groupFields.size() == 1){ InputField groupField = groupFields.get(0); table = EvaluatorUtil.groupRows(groupField.getName(), table); } else if(groupFields.size() > 1){ ModelEvaluator<?> modelEvaluator = (ModelEvaluator<?>)hasGroupFields; throw modelEvaluator.createMiningSchemaException("Expected 0 or 1 group field(s), got " + groupFields.size() + " group fields"); } return table; }
EvaluatorUtil { static public List<? extends Map<FieldName, ?>> groupRows(HasGroupFields hasGroupFields, List<? extends Map<FieldName, ?>> table){ List<InputField> groupFields = hasGroupFields.getGroupFields(); if(groupFields.size() == 1){ InputField groupField = groupFields.get(0); table = EvaluatorUtil.groupRows(groupField.getName(), table); } else if(groupFields.size() > 1){ ModelEvaluator<?> modelEvaluator = (ModelEvaluator<?>)hasGroupFields; throw modelEvaluator.createMiningSchemaException("Expected 0 or 1 group field(s), got " + groupFields.size() + " group fields"); } return table; } }
EvaluatorUtil { static public List<? extends Map<FieldName, ?>> groupRows(HasGroupFields hasGroupFields, List<? extends Map<FieldName, ?>> table){ List<InputField> groupFields = hasGroupFields.getGroupFields(); if(groupFields.size() == 1){ InputField groupField = groupFields.get(0); table = EvaluatorUtil.groupRows(groupField.getName(), table); } else if(groupFields.size() > 1){ ModelEvaluator<?> modelEvaluator = (ModelEvaluator<?>)hasGroupFields; throw modelEvaluator.createMiningSchemaException("Expected 0 or 1 group field(s), got " + groupFields.size() + " group fields"); } return table; } private  EvaluatorUtil(); }
EvaluatorUtil { static public List<? extends Map<FieldName, ?>> groupRows(HasGroupFields hasGroupFields, List<? extends Map<FieldName, ?>> table){ List<InputField> groupFields = hasGroupFields.getGroupFields(); if(groupFields.size() == 1){ InputField groupField = groupFields.get(0); table = EvaluatorUtil.groupRows(groupField.getName(), table); } else if(groupFields.size() > 1){ ModelEvaluator<?> modelEvaluator = (ModelEvaluator<?>)hasGroupFields; throw modelEvaluator.createMiningSchemaException("Expected 0 or 1 group field(s), got " + groupFields.size() + " group fields"); } return table; } private  EvaluatorUtil(); static Map<FieldName, ?> encodeKeys(Map<String, ?> map); static Object decode(Object object); static Map<String, ?> decodeAll(Map<FieldName, ?> map); static List<? extends Map<FieldName, ?>> groupRows(HasGroupFields hasGroupFields, List<? extends Map<FieldName, ?>> table); static List<Map<K, Object>> groupRows(K groupKey, List<? extends Map<K, ?>> table); }
EvaluatorUtil { static public List<? extends Map<FieldName, ?>> groupRows(HasGroupFields hasGroupFields, List<? extends Map<FieldName, ?>> table){ List<InputField> groupFields = hasGroupFields.getGroupFields(); if(groupFields.size() == 1){ InputField groupField = groupFields.get(0); table = EvaluatorUtil.groupRows(groupField.getName(), table); } else if(groupFields.size() > 1){ ModelEvaluator<?> modelEvaluator = (ModelEvaluator<?>)hasGroupFields; throw modelEvaluator.createMiningSchemaException("Expected 0 or 1 group field(s), got " + groupFields.size() + " group fields"); } return table; } private  EvaluatorUtil(); static Map<FieldName, ?> encodeKeys(Map<String, ?> map); static Object decode(Object object); static Map<String, ?> decodeAll(Map<FieldName, ?> map); static List<? extends Map<FieldName, ?>> groupRows(HasGroupFields hasGroupFields, List<? extends Map<FieldName, ?>> table); static List<Map<K, Object>> groupRows(K groupKey, List<? extends Map<K, ?>> table);  }