yupeng9 commented on a change in pull request #7355: URL: https://github.com/apache/pinot/pull/7355#discussion_r694961883
########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/IdSetAggregationFunction.java ########## @@ -225,63 +324,130 @@ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResult Map<ExpressionContext, BlockValSet> blockValSetMap) { BlockValSet blockValSet = blockValSetMap.get(_expression); DataType storedType = blockValSet.getValueType().getStoredType(); - switch (storedType) { - case INT: - int[] intValues = blockValSet.getIntValuesSV(); - for (int i = 0; i < length; i++) { - int intValue = intValues[i]; - for (int groupKey : groupKeysArray[i]) { - getIdSet(groupByResultHolder, groupKey, DataType.INT).add(intValue); + if (blockValSet.isSingleValue()) { + switch (storedType) { + case INT: + int[] intValuesSV = blockValSet.getIntValuesSV(); + for (int i = 0; i < length; i++) { + int intValue = intValuesSV[i]; + for (int groupKey : groupKeysArray[i]) { + getIdSet(groupByResultHolder, groupKey, DataType.INT).add(intValue); + } } - } - break; - case LONG: - long[] longValues = blockValSet.getLongValuesSV(); - for (int i = 0; i < length; i++) { - long longValue = longValues[i]; - for (int groupKey : groupKeysArray[i]) { - getIdSet(groupByResultHolder, groupKey, DataType.LONG).add(longValue); + break; + case LONG: + long[] longValuesSV = blockValSet.getLongValuesSV(); + for (int i = 0; i < length; i++) { + long longValue = longValuesSV[i]; + for (int groupKey : groupKeysArray[i]) { + getIdSet(groupByResultHolder, groupKey, DataType.LONG).add(longValue); + } } - } - break; - case FLOAT: - float[] floatValues = blockValSet.getFloatValuesSV(); - for (int i = 0; i < length; i++) { - float floatValue = floatValues[i]; - for (int groupKey : groupKeysArray[i]) { - getIdSet(groupByResultHolder, groupKey, DataType.FLOAT).add(floatValue); + break; + case FLOAT: + float[] floatValuesSV = blockValSet.getFloatValuesSV(); + for (int i = 0; i < length; i++) { + float floatValue = floatValuesSV[i]; + for (int groupKey : groupKeysArray[i]) { + getIdSet(groupByResultHolder, groupKey, DataType.FLOAT).add(floatValue); + } } - } - break; - case DOUBLE: - double[] doubleValues = blockValSet.getDoubleValuesSV(); - for (int i = 0; i < length; i++) { - double doubleValue = doubleValues[i]; - for (int groupKey : groupKeysArray[i]) { - getIdSet(groupByResultHolder, groupKey, DataType.DOUBLE).add(doubleValue); + break; + case DOUBLE: + double[] doubleValuesSV = blockValSet.getDoubleValuesSV(); + for (int i = 0; i < length; i++) { + double doubleValue = doubleValuesSV[i]; + for (int groupKey : groupKeysArray[i]) { + getIdSet(groupByResultHolder, groupKey, DataType.DOUBLE).add(doubleValue); + } } - } - break; - case STRING: - String[] stringValues = blockValSet.getStringValuesSV(); - for (int i = 0; i < length; i++) { - String stringValue = stringValues[i]; - for (int groupKey : groupKeysArray[i]) { - getIdSet(groupByResultHolder, groupKey, DataType.STRING).add(stringValue); + break; + case STRING: + String[] stringValuesSV = blockValSet.getStringValuesSV(); + for (int i = 0; i < length; i++) { + String stringValue = stringValuesSV[i]; + for (int groupKey : groupKeysArray[i]) { + getIdSet(groupByResultHolder, groupKey, DataType.STRING).add(stringValue); + } } - } - break; - case BYTES: - byte[][] bytesValues = blockValSet.getBytesValuesSV(); - for (int i = 0; i < length; i++) { - byte[] bytesValue = bytesValues[i]; - for (int groupKey : groupKeysArray[i]) { - getIdSet(groupByResultHolder, groupKey, DataType.BYTES).add(bytesValue); + break; + case BYTES: + byte[][] bytesValuesSV = blockValSet.getBytesValuesSV(); + for (int i = 0; i < length; i++) { + byte[] bytesValue = bytesValuesSV[i]; + for (int groupKey : groupKeysArray[i]) { + getIdSet(groupByResultHolder, groupKey, DataType.BYTES).add(bytesValue); + } } - } - break; - default: - throw new IllegalStateException("Illegal data type for ID_SET aggregation function: " + storedType); + break; + default: + throw new IllegalStateException("Illegal SV data type for ID_SET aggregation function: " + storedType); + } + } else { + switch (storedType) { + case INT: + int[][] intValuesMV = blockValSet.getIntValuesMV(); + for (int i = 0; i < length; i++) { + int[] intValues = intValuesMV[i]; + for (int groupKey : groupKeysArray[i]) { + IdSet idSet = getIdSet(groupByResultHolder, groupKey, DataType.INT); + for (int intValue : intValues) { + idSet.add(intValue); + } + } + } + break; + case LONG: + long[][] longValuesMV = blockValSet.getLongValuesMV(); + for (int i = 0; i < length; i++) { + long[] longValues = longValuesMV[i]; + for (int groupKey : groupKeysArray[i]) { + IdSet idSet = getIdSet(groupByResultHolder, groupKey, DataType.LONG); + for (long longValue : longValues) { + idSet.add(longValue); + } + } + } + break; + case FLOAT: + float[][] floatValuesMV = blockValSet.getFloatValuesMV(); + for (int i = 0; i < length; i++) { + float[] floatValues = floatValuesMV[i]; + for (int groupKey : groupKeysArray[i]) { + IdSet idSet = getIdSet(groupByResultHolder, groupKey, DataType.FLOAT); + for (float floatValue : floatValues) { + idSet.add(floatValue); + } + } + } + break; + case DOUBLE: + double[][] doubleValuesMV = blockValSet.getDoubleValuesMV(); + for (int i = 0; i < length; i++) { + double[] doubleValues = doubleValuesMV[i]; + for (int groupKey : groupKeysArray[i]) { + IdSet idSet = getIdSet(groupByResultHolder, groupKey, DataType.DOUBLE); + for (double doubleValue : doubleValues) { + idSet.add(doubleValue); + } + } + } + break; + case STRING: + String[][] stringValuesMV = blockValSet.getStringValuesMV(); + for (int i = 0; i < length; i++) { + String[] stringValues = stringValuesMV[i]; + for (int groupKey : groupKeysArray[i]) { + IdSet idSet = getIdSet(groupByResultHolder, groupKey, DataType.STRING); + for (String stringValue : stringValues) { + idSet.add(stringValue); + } + } + } + break; Review comment: add the bytes support too? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org