class Utils {

    public static String buildKeyIndexForEvent(Event event, List<String> groupBy) {
        StringBuffer stringBuffer = new StringBuffer();
        if (groupBy == null || groupBy.size() == 0)
            return stringBuffer.toString();  // default partition when no groupBy fields are specified.

        //groupBy可以定义多个字段.
        for (String groupField : groupBy) {
            //一条事件Event可以有多个Tuples.
            Collection<Tuple> tuples = event.getAll(groupField);
            SortedSet<String> values = new TreeSet<String>();

            if (tuples == null) {
                values.add("");
            } else {
                for (Tuple tuple : tuples)
                    values.add(registry.encode(tuple.getValue()));
            }
            stringBuffer.append(groupField + join(values, "") + "|");
        }
        try {
            return stringBuffer.toString();
        } catch (Exception e) {
            return null;
        }
    }

    private  Utils();

}