getResults(byte[] eof);
-
- public abstract void clear();
-
-}
diff --git a/src/main/java/com/actiontech/dble/sqlengine/mpp/DataMergeService.java b/src/main/java/com/actiontech/dble/sqlengine/mpp/DataMergeService.java
deleted file mode 100644
index 55cbea29b..000000000
--- a/src/main/java/com/actiontech/dble/sqlengine/mpp/DataMergeService.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2016-2017 ActionTech.
- * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
- */
-
-package com.actiontech.dble.sqlengine.mpp;
-
-import com.actiontech.dble.backend.mysql.BufferUtil;
-import com.actiontech.dble.backend.mysql.nio.handler.MultiNodeQueryHandler;
-import com.actiontech.dble.net.mysql.EOFPacket;
-import com.actiontech.dble.net.mysql.RowDataPacket;
-import com.actiontech.dble.route.RouteResultset;
-import com.actiontech.dble.route.RouteResultsetNode;
-import com.actiontech.dble.server.ServerConnection;
-import org.apache.log4j.Logger;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/*
-* Copyright (C) 2016-2017 ActionTech.
-* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
-* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
-*/
-
-/**
- * Data merge service handle data Min,Max,AVG group . order by . limit
- *
- * @author wuzhih /modify by coder_czp/2015/11/2
- *
- * Fixbug: sql timeout and hang problem.
- * @author Uncle-pan
- * @since 2016-03-23
- */
-public class DataMergeService extends AbstractDataNodeMerge {
-
- private RowDataPacketGrouper grouper;
- private Map> result = new HashMap<>();
- private static final Logger LOGGER = Logger.getLogger(DataMergeService.class);
-
- public DataMergeService(MultiNodeQueryHandler handler, RouteResultset rrs) {
- super(handler, rrs);
-
- for (RouteResultsetNode node : rrs.getNodes()) {
- result.put(node.getName(), new LinkedList());
- }
- }
-
-
- /**
- * @param columnToIndex columnToIndex
- * @param fieldSize fieldSize
- */
- public void onRowMetaData(Map columnToIndex, int fieldSize) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("field metadata keys:" + columnToIndex.keySet());
- LOGGER.debug("field metadata values:" + columnToIndex.values());
- }
-
- int[] groupColumnIndexes = null;
- this.fieldCount = fieldSize;
-
- if (rrs.getGroupByCols() != null) {
-
- groupColumnIndexes = toColumnIndex(rrs.getGroupByCols(), columnToIndex);
- }
- grouper = new RowDataPacketGrouper(groupColumnIndexes);
- }
-
-
- /**
- * release resources
- */
- public void clear() {
- result.clear();
- grouper = null;
- }
-
- @Override
- public void run() {
- // sort-or-group: no need for us to using multi-threads, because
- //both sorter and group are synchronized!!
- // @author Uncle-pan
- // @since 2016-03-23
- if (!running.compareAndSet(false, true)) {
- return;
- }
- // eof handler has been placed to "if (pack == END_FLAG_PACK){}" in for-statement
- // @author Uncle-pan
- // @since 2016-03-23
- boolean nulPack = false;
- try {
- // loop-on-packs
- for (; ; ) {
- final PackWraper pack = packs.poll();
- // async: handling row pack queue, this business thread should exit when no pack
- // @author Uncle-pan
- // @since 2016-03-23
- if (pack == null) {
- nulPack = true;
- break;
- }
- // eof: handling eof pack and exit
- if (pack == endFlagPack) {
-
-
- final int warningCount = 0;
- final EOFPacket eofPacket = new EOFPacket();
- final ByteBuffer eof = ByteBuffer.allocate(9);
- BufferUtil.writeUB3(eof, eofPacket.calcPacketSize());
- eof.put(eofPacket.getPacketId());
- eof.put(eofPacket.getFieldCount());
- BufferUtil.writeUB2(eof, warningCount);
- BufferUtil.writeUB2(eof, eofPacket.getStatus());
- final ServerConnection source = multiQueryHandler.getSession().getSource();
- final byte[] array = eof.array();
- multiQueryHandler.outputMergeResult(source, array, getResults(array));
- break;
- }
-
-
- // merge: sort-or-group, or simple add
- final RowDataPacket row = new RowDataPacket(fieldCount);
- row.read(pack.getRowData());
-
- if (grouper != null) {
- grouper.addRow(row);
- } else {
- result.get(pack.getDataNode()).add(row);
- }
- } // rof
- } catch (final Exception e) {
- multiQueryHandler.handleDataProcessException(e);
- } finally {
- running.set(false);
- }
- // try to check packs, it's possible that adding a pack after polling a null pack
- //and before this time pointer!!
- // @author Uncle-pan
- // @since 2016-03-23
- if (nulPack && !packs.isEmpty()) {
- this.run();
- }
- }
-
-
- /**
- * return merged data (i * (offset + size) rows at most)
- *
- * @return list
- */
- public List getResults(byte[] eof) {
-
- List tmpResult = null;
-
- if (this.grouper != null) {
- tmpResult = grouper.getResult();
- grouper = null;
- }
-
- //no grouper and sorter
- if (tmpResult == null) {
- tmpResult = new LinkedList<>();
- for (RouteResultsetNode node : rrs.getNodes()) {
- tmpResult.addAll(result.get(node.getName()));
- }
- }
-
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("prepare mpp merge result for " + rrs.getStatement());
- }
- return tmpResult;
- }
-}
-
diff --git a/src/main/java/com/actiontech/dble/sqlengine/mpp/DataNodeMergeManager.java b/src/main/java/com/actiontech/dble/sqlengine/mpp/DataNodeMergeManager.java
deleted file mode 100644
index 8e5abb36a..000000000
--- a/src/main/java/com/actiontech/dble/sqlengine/mpp/DataNodeMergeManager.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2016-2017 ActionTech.
- * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
- */
-
-package com.actiontech.dble.sqlengine.mpp;
-
-import com.actiontech.dble.DbleServer;
-import com.actiontech.dble.backend.mysql.BufferUtil;
-import com.actiontech.dble.backend.mysql.MySQLMessage;
-import com.actiontech.dble.backend.mysql.nio.handler.MultiNodeQueryHandler;
-import com.actiontech.dble.memory.SeverMemory;
-import com.actiontech.dble.memory.unsafe.memory.mm.DataNodeMemoryManager;
-import com.actiontech.dble.memory.unsafe.memory.mm.MemoryManager;
-import com.actiontech.dble.memory.unsafe.row.BufferHolder;
-import com.actiontech.dble.memory.unsafe.row.StructType;
-import com.actiontech.dble.memory.unsafe.row.UnsafeRow;
-import com.actiontech.dble.memory.unsafe.row.UnsafeRowWriter;
-import com.actiontech.dble.memory.unsafe.utils.ServerPropertyConf;
-import com.actiontech.dble.memory.unsafe.utils.sort.PrefixComparator;
-import com.actiontech.dble.memory.unsafe.utils.sort.PrefixComparators;
-import com.actiontech.dble.memory.unsafe.utils.sort.RowPrefixComputer;
-import com.actiontech.dble.memory.unsafe.utils.sort.UnsafeExternalRowSorter;
-import com.actiontech.dble.net.mysql.EOFPacket;
-import com.actiontech.dble.net.mysql.RowDataPacket;
-import com.actiontech.dble.route.RouteResultset;
-import com.actiontech.dble.server.ServerConnection;
-import org.apache.log4j.Logger;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * Created by zagnix on 2016/6/21.
- */
-public class DataNodeMergeManager extends AbstractDataNodeMerge {
-
- private static final Logger LOGGER = Logger.getLogger(DataNodeMergeManager.class);
-
- /**
- * UnsafeRowGrouper
- */
- private UnsafeRowGrouper unsafeRowGrouper = null;
-
- /**
- * global merge sorter
- */
- private UnsafeExternalRowSorter globalMergeResult = null;
-
- /**
- * the context of sorter
- */
- private final SeverMemory serverMemory;
- private final MemoryManager memoryManager;
- private final ServerPropertyConf conf;
-
-
- public DataNodeMergeManager(MultiNodeQueryHandler handler, RouteResultset rrs) {
- super(handler, rrs);
- this.serverMemory = DbleServer.getInstance().getServerMemory();
- this.memoryManager = serverMemory.getResultMergeMemoryManager();
- this.conf = serverMemory.getConf();
- }
-
-
- public void onRowMetaData(Map columnToIndex, int fieldSize) throws IOException {
-
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("field metadata keys:" + columnToIndex.keySet());
- LOGGER.debug("field metadata values:" + columnToIndex.values());
- }
- this.fieldCount = fieldSize;
- String[] groupByCols = rrs.getGroupByCols();
- unsafeRowGrouper = new UnsafeRowGrouper(columnToIndex, groupByCols);
- // 1.schema
- StructType schema = new StructType(columnToIndex, fieldSize);
- if (groupByCols != null) {
- OrderCol[] orderCols = new OrderCol[groupByCols.length];
- for (int i = 0; i < groupByCols.length; i++) {
- orderCols[i] = new OrderCol(columnToIndex.get(groupByCols[i].toUpperCase()));
- }
- schema.setOrderCols(orderCols);
- }
- //2 .PrefixComputer
- UnsafeExternalRowSorter.PrefixComputer prefixComputer = new RowPrefixComputer(schema);
-
- //3 .PrefixComparator ,ASC/DESC and the default is ASC
-
- PrefixComparator prefixComparator = PrefixComparators.LONG;
-
-
- DataNodeMemoryManager dataNodeMemoryManager = new DataNodeMemoryManager(memoryManager,
- Thread.currentThread().getId());
-
- globalMergeResult = new UnsafeExternalRowSorter(
- dataNodeMemoryManager,
- serverMemory,
- schema,
- prefixComparator,
- prefixComputer,
- conf.getSizeAsBytes("server.buffer.pageSize", "1m"),
- false,
- true);
- }
-
- @Override
- public List getResults(byte[] eof) {
- return null;
- }
-
- @Override
- public void run() {
-
- if (!running.compareAndSet(false, true)) {
- return;
- }
-
- boolean nulPack = false;
-
- try {
- for (; ; ) {
- final PackWraper pack = packs.poll();
-
- if (pack == null) {
- nulPack = true;
- break;
- }
- if (pack == endFlagPack) {
- /*
- * if last date node send row eof packet
- * means all the data have received
- */
- final int warningCount = 0;
- final EOFPacket eofPacket = new EOFPacket();
- final ByteBuffer eof = ByteBuffer.allocate(9);
- BufferUtil.writeUB3(eof, eofPacket.calcPacketSize());
- eof.put(eofPacket.getPacketId());
- eof.put(eofPacket.getFieldCount());
- BufferUtil.writeUB2(eof, warningCount);
- BufferUtil.writeUB2(eof, eofPacket.getStatus());
- final ServerConnection source = multiQueryHandler.getSession().getSource();
- final byte[] array = eof.array();
-
-
- Iterator iterator;
- if (unsafeRowGrouper != null) {
- iterator = unsafeRowGrouper.getResult(globalMergeResult);
- } else {
- iterator = globalMergeResult.sort();
- }
-
- if (iterator != null) {
- multiQueryHandler.outputMergeResult(source, array, iterator);
- }
-
- if (unsafeRowGrouper != null) {
- unsafeRowGrouper.free();
- unsafeRowGrouper = null;
- }
-
- if (globalMergeResult != null) {
- globalMergeResult.cleanupResources();
- globalMergeResult = null;
- }
-
- break;
- }
-
- UnsafeRow unsafeRow = new UnsafeRow(fieldCount);
- BufferHolder bufferHolder = new BufferHolder(unsafeRow, 0);
- UnsafeRowWriter unsafeRowWriter = new UnsafeRowWriter(bufferHolder, fieldCount);
- bufferHolder.reset();
-
- // make a row to filled col
- MySQLMessage mm = new MySQLMessage(pack.getRowData());
- mm.readUB3();
- mm.read();
-
- for (int i = 0; i < fieldCount; i++) {
- byte[] colValue = mm.readBytesWithLength();
- if (colValue != null)
- unsafeRowWriter.write(i, colValue);
- else
- unsafeRow.setNullAt(i);
- }
-
- unsafeRow.setTotalSize(bufferHolder.totalSize());
-
- if (unsafeRowGrouper != null) {
- unsafeRowGrouper.addRow(unsafeRow);
- } else {
- globalMergeResult.insertRow(unsafeRow);
- }
- }
-
- } catch (final Exception e) {
- multiQueryHandler.handleDataProcessException(e);
- } finally {
- running.set(false);
- if (nulPack && !packs.isEmpty()) {
- this.run();
- }
- }
- }
-
- /**
- * release the resource of DataNodeMergeManager
- */
- public void clear() {
-
- if (unsafeRowGrouper != null) {
- unsafeRowGrouper.free();
- unsafeRowGrouper = null;
- }
-
- if (globalMergeResult != null) {
- globalMergeResult.cleanupResources();
- globalMergeResult = null;
- }
- }
-}
diff --git a/src/main/java/com/actiontech/dble/sqlengine/mpp/RangRowDataPacketSorter.java b/src/main/java/com/actiontech/dble/sqlengine/mpp/RangRowDataPacketSorter.java
deleted file mode 100644
index 7b4722105..000000000
--- a/src/main/java/com/actiontech/dble/sqlengine/mpp/RangRowDataPacketSorter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Copyright (C) 2016-2017 ActionTech.
-* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
-* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
-*/
-package com.actiontech.dble.sqlengine.mpp;
-
-import com.actiontech.dble.net.mysql.RowDataPacket;
-import com.actiontech.dble.sqlengine.mpp.tmp.RowDataSorter;
-
-
-public class RangRowDataPacketSorter extends RowDataSorter {
- public RangRowDataPacketSorter(OrderCol[] orderCols) {
- super(orderCols);
- }
-
- public boolean ascDesc(int byColumnIndex) {
- return this.orderCols[byColumnIndex].orderType == OrderCol.COL_ORDER_TYPE_ASC;
- }
-
- public int compareRowData(RowDataPacket l, RowDataPacket r, int byColumnIndex) {
- byte[] left = l.fieldValues.get(this.orderCols[byColumnIndex].colMeta.getColIndex());
- byte[] right = r.fieldValues.get(this.orderCols[byColumnIndex].colMeta.getColIndex());
-
- return RowDataPacketSorter.compareObject(left, right, this.orderCols[byColumnIndex]);
- }
-}
diff --git a/src/main/java/com/actiontech/dble/sqlengine/mpp/RowDataPacketGrouper.java b/src/main/java/com/actiontech/dble/sqlengine/mpp/RowDataPacketGrouper.java
deleted file mode 100644
index 58f0797d8..000000000
--- a/src/main/java/com/actiontech/dble/sqlengine/mpp/RowDataPacketGrouper.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (C) 2016-2017 ActionTech.
-* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
-* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
-*/
-package com.actiontech.dble.sqlengine.mpp;
-
-import com.actiontech.dble.net.mysql.RowDataPacket;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * implement group function select a,count(*),sum(*) from A group by a
- *
- * @author wuzhih
- */
-public class RowDataPacketGrouper {
-
- private List result = Collections.synchronizedList(new ArrayList());
- private final int[] groupColumnIndexes;
-
- public RowDataPacketGrouper(int[] groupColumnIndexes) {
- super();
- this.groupColumnIndexes = groupColumnIndexes;
- }
-
- public List getResult() {
- return result;
- }
-
- public void addRow(RowDataPacket rowDataPkg) {
- for (RowDataPacket row : result) {
- if (sameGroupColumns(rowDataPkg, row)) {
- return;
- }
- }
-
- // not aggreated ,insert new
- result.add(rowDataPkg);
-
- }
-
-
- // private static final
-
- private boolean sameGroupColumns(RowDataPacket newRow, RowDataPacket existRow) {
- if (groupColumnIndexes == null) { // select count(*) from aaa , or group
- // column
- return true;
- }
- for (int groupColumnIndex : groupColumnIndexes) {
- if (!Arrays.equals(newRow.fieldValues.get(groupColumnIndex),
- existRow.fieldValues.get(groupColumnIndex))) {
- return false;
- }
-
- }
- return true;
-
- }
-}
diff --git a/src/main/java/com/actiontech/dble/sqlengine/mpp/UnsafeRowGrouper.java b/src/main/java/com/actiontech/dble/sqlengine/mpp/UnsafeRowGrouper.java
deleted file mode 100644
index ca84e61e1..000000000
--- a/src/main/java/com/actiontech/dble/sqlengine/mpp/UnsafeRowGrouper.java
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
-* Copyright (C) 2016-2017 ActionTech.
-* based on code by MyCATCopyrightHolder Copyright (c) 2013, OpenCloudDB/MyCAT.
-* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
-*/
-package com.actiontech.dble.sqlengine.mpp;
-
-import com.actiontech.dble.DbleServer;
-import com.actiontech.dble.memory.SeverMemory;
-import com.actiontech.dble.memory.unsafe.KVIterator;
-import com.actiontech.dble.memory.unsafe.map.UnsafeFixedWidthAggregationMap;
-import com.actiontech.dble.memory.unsafe.memory.mm.DataNodeMemoryManager;
-import com.actiontech.dble.memory.unsafe.memory.mm.MemoryManager;
-import com.actiontech.dble.memory.unsafe.row.BufferHolder;
-import com.actiontech.dble.memory.unsafe.row.StructType;
-import com.actiontech.dble.memory.unsafe.row.UnsafeRow;
-import com.actiontech.dble.memory.unsafe.row.UnsafeRowWriter;
-import com.actiontech.dble.memory.unsafe.utils.BytesTools;
-import com.actiontech.dble.memory.unsafe.utils.ServerPropertyConf;
-import com.actiontech.dble.memory.unsafe.utils.sort.UnsafeExternalRowSorter;
-import com.actiontech.dble.util.ByteUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nonnull;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Created by zagnix on 2016/6/26.
- *
- * implement group function select a,count(*),sum(*) from A group by a
- */
-public class UnsafeRowGrouper {
- private static final Logger LOGGER = LoggerFactory.getLogger(UnsafeRowGrouper.class);
-
- private UnsafeFixedWidthAggregationMap aggregationMap = null;
- private final Map columnToIndexes;
- private String[] sortColumnsByIndex = null;
- private UnsafeRow valueKey = null;
- private BufferHolder bufferHolder = null;
- private UnsafeRowWriter unsafeRowWriter = null;
- private final int groupKeyFieldCount;
- private final int valueFieldCount;
- private StructType groupKeySchema;
- private StructType aggBufferSchema;
- private UnsafeRow emptyAggregationBuffer;
-
- public UnsafeRowGrouper(Map columnToIndexes, String[] columns) {
- super();
- assert columns != null;
- assert columnToIndexes != null;
- this.columnToIndexes = columnToIndexes;
- this.sortColumnsByIndex = columns != null ? toSortColumnsByIndex(columns, columnToIndexes) : null;
- this.groupKeyFieldCount = columns != null ? columns.length : 0;
- this.valueFieldCount = columnToIndexes != null ? columnToIndexes.size() : 0;
-
- LOGGER.debug("columnToIndex :" + (columnToIndexes != null ? columnToIndexes.toString() : "null"));
-
- SeverMemory serverMemory = DbleServer.getInstance().getServerMemory();
- MemoryManager memoryManager = serverMemory.getResultMergeMemoryManager();
- ServerPropertyConf conf = serverMemory.getConf();
-
- initGroupKey();
- initEmptyValueKey();
-
- DataNodeMemoryManager dataNodeMemoryManager =
- new DataNodeMemoryManager(memoryManager, Thread.currentThread().getId());
-
- aggregationMap = new UnsafeFixedWidthAggregationMap(
- emptyAggregationBuffer,
- aggBufferSchema,
- groupKeySchema,
- dataNodeMemoryManager,
- 2 * 1024,
- conf.getSizeAsBytes("server.buffer.pageSize", "1m"),
- false);
- }
-
- private String[] toSortColumnsByIndex(String[] columns, Map colMetaMap) {
-
- Map map = new HashMap<>();
-
- ColMeta curColMeta;
- for (String column : columns) {
- curColMeta = colMetaMap.get(column.toUpperCase());
- if (curColMeta == null) {
- throw new IllegalArgumentException(
- "all columns in group by clause should be in the selected column list.!" + column);
- }
- map.put(column, curColMeta.getColIndex());
- }
-
-
- String[] sortColumnsIndexes = new String[map.size()];
-
- List> entryList = new ArrayList<>(
- map.entrySet());
-
- Collections.sort(entryList, new Comparator>() {
- @Override
- public int compare(Map.Entry o1, Map.Entry o2) {
- return o1.getValue().compareTo(o2.getValue());
- }
- });
-
- Iterator> iterator = entryList.iterator();
- Map.Entry tmpEntry = null;
-
- int index = 0;
-
- while (iterator.hasNext()) {
- tmpEntry = iterator.next();
- sortColumnsIndexes[index++] = tmpEntry.getKey();
- }
-
- return sortColumnsIndexes;
- }
-
- private void initGroupKey() {
- Map groupColMetaMap = new HashMap<>(this.groupKeyFieldCount);
-
- UnsafeRow groupKey = new UnsafeRow(this.groupKeyFieldCount);
- bufferHolder = new BufferHolder(groupKey, 0);
- unsafeRowWriter = new UnsafeRowWriter(bufferHolder, this.groupKeyFieldCount);
- bufferHolder.reset();
-
- ColMeta curColMeta = null;
-
- for (int i = 0; i < this.groupKeyFieldCount; i++) {
- curColMeta = this.columnToIndexes.get(sortColumnsByIndex[i].toUpperCase());
- groupColMetaMap.put(sortColumnsByIndex[i], curColMeta);
-
-
- switch (curColMeta.getColType()) {
- case ColMeta.COL_TYPE_BIT:
- groupKey.setByte(i, (byte) 0);
- break;
- case ColMeta.COL_TYPE_INT:
- case ColMeta.COL_TYPE_INT24:
- case ColMeta.COL_TYPE_LONG:
- groupKey.setInt(i, 0);
- break;
- case ColMeta.COL_TYPE_SHORT:
- groupKey.setShort(i, (short) 0);
- break;
- case ColMeta.COL_TYPE_FLOAT:
- groupKey.setFloat(i, 0);
- break;
- case ColMeta.COL_TYPE_DOUBLE:
- groupKey.setDouble(i, 0);
- break;
- case ColMeta.COL_TYPE_NEWDECIMAL:
- //groupKey.setDouble(i, 0);
- unsafeRowWriter.write(i, new BigDecimal(0L));
- break;
- case ColMeta.COL_TYPE_LONGLONG:
- groupKey.setLong(i, 0);
- break;
- default:
- unsafeRowWriter.write(i, "init".getBytes());
- break;
- }
-
- }
- groupKey.setTotalSize(bufferHolder.totalSize());
-
- groupKeySchema = new StructType(groupColMetaMap, this.groupKeyFieldCount);
- }
-
- private void initEmptyValueKey() {
- emptyAggregationBuffer = new UnsafeRow(this.valueFieldCount);
- bufferHolder = new BufferHolder(emptyAggregationBuffer, 0);
- unsafeRowWriter = new UnsafeRowWriter(bufferHolder, this.valueFieldCount);
- bufferHolder.reset();
-
- ColMeta curColMeta = null;
- for (Map.Entry fieldEntry : columnToIndexes.entrySet()) {
- curColMeta = fieldEntry.getValue();
-
- switch (curColMeta.getColType()) {
- case ColMeta.COL_TYPE_BIT:
- emptyAggregationBuffer.setByte(curColMeta.getColIndex(), (byte) 0);
- break;
- case ColMeta.COL_TYPE_INT:
- case ColMeta.COL_TYPE_INT24:
- case ColMeta.COL_TYPE_LONG:
- emptyAggregationBuffer.setInt(curColMeta.getColIndex(), 0);
- break;
- case ColMeta.COL_TYPE_SHORT:
- emptyAggregationBuffer.setShort(curColMeta.getColIndex(), (short) 0);
- break;
- case ColMeta.COL_TYPE_LONGLONG:
- emptyAggregationBuffer.setLong(curColMeta.getColIndex(), 0);
- break;
- case ColMeta.COL_TYPE_FLOAT:
- emptyAggregationBuffer.setFloat(curColMeta.getColIndex(), 0);
- break;
- case ColMeta.COL_TYPE_DOUBLE:
- emptyAggregationBuffer.setDouble(curColMeta.getColIndex(), 0);
- break;
- case ColMeta.COL_TYPE_NEWDECIMAL:
- //emptyAggregationBuffer.setDouble(curColMeta.colIndex, 0);
- unsafeRowWriter.write(curColMeta.getColIndex(), new BigDecimal(0L));
- break;
- default:
- unsafeRowWriter.write(curColMeta.getColIndex(), "init".getBytes());
- break;
- }
-
- }
-
- emptyAggregationBuffer.setTotalSize(bufferHolder.totalSize());
- aggBufferSchema = new StructType(columnToIndexes, this.valueFieldCount);
- }
-
-
- public Iterator getResult(@Nonnull UnsafeExternalRowSorter sorter) throws IOException {
- KVIterator iterator = aggregationMap.iterator();
- /**
- * group having
- */
- insertValue(sorter);
- return sorter.sort();
- }
-
-
- /**
- * is Avg Field
- *
- * @param columnName
- * @return
- */
- private boolean isAvgField(String columnName) {
- Pattern pattern = Pattern.compile("AVG([1-9]\\d*|0)SUM");
- Matcher matcher = pattern.matcher(columnName);
- return matcher.find();
- }
-
-
- public UnsafeRow getAllBinaryRow(UnsafeRow row) throws UnsupportedEncodingException {
-
- UnsafeRow value = new UnsafeRow(this.valueFieldCount);
- bufferHolder = new BufferHolder(value, 0);
- unsafeRowWriter = new UnsafeRowWriter(bufferHolder, this.valueFieldCount);
- bufferHolder.reset();
- ColMeta curColMeta = null;
-
- for (Map.Entry fieldEntry : columnToIndexes.entrySet()) {
- curColMeta = fieldEntry.getValue();
-
- if (!row.isNullAt(curColMeta.getColIndex())) {
- switch (curColMeta.getColType()) {
- case ColMeta.COL_TYPE_BIT:
- unsafeRowWriter.write(curColMeta.getColIndex(), row.getByte(curColMeta.getColIndex()));
- break;
- case ColMeta.COL_TYPE_INT:
- case ColMeta.COL_TYPE_LONG:
- case ColMeta.COL_TYPE_INT24:
- unsafeRowWriter.write(curColMeta.getColIndex(),
- BytesTools.int2Bytes(row.getInt(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_SHORT:
- unsafeRowWriter.write(curColMeta.getColIndex(),
- BytesTools.short2Bytes(row.getShort(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_LONGLONG:
- unsafeRowWriter.write(curColMeta.getColIndex(),
- BytesTools.long2Bytes(row.getLong(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_FLOAT:
- unsafeRowWriter.write(curColMeta.getColIndex(),
- BytesTools.float2Bytes(row.getFloat(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_DOUBLE:
- unsafeRowWriter.write(curColMeta.getColIndex(),
- BytesTools.double2Bytes(row.getDouble(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_NEWDECIMAL:
- int scale = curColMeta.getDecimals();
- BigDecimal decimalVal = row.getDecimal(curColMeta.getColIndex(), scale);
- unsafeRowWriter.write(curColMeta.getColIndex(), decimalVal.toString().getBytes());
- break;
- default:
- unsafeRowWriter.write(curColMeta.getColIndex(),
- row.getBinary(curColMeta.getColIndex()));
- break;
- }
- } else {
- unsafeRowWriter.setNullAt(curColMeta.getColIndex());
- }
- }
-
- value.setTotalSize(bufferHolder.totalSize());
- return value;
- }
-
- private void insertValue(@Nonnull UnsafeExternalRowSorter sorter) {
- KVIterator it = aggregationMap.iterator();
- try {
- while (it.next()) {
- UnsafeRow row = getAllBinaryRow(it.getValue());
- sorter.insertRow(row);
- }
- } catch (IOException e) {
- LOGGER.error(e.getMessage());
- }
- }
-
-
- private boolean lt(byte[] l, byte[] r) {
- return -1 != ByteUtil.compareNumberByte(l, r);
- }
-
- private boolean gt(byte[] l, byte[] r) {
- return 1 != ByteUtil.compareNumberByte(l, r);
- }
-
- private boolean eq(byte[] l, byte[] r) {
- return 0 != ByteUtil.compareNumberByte(l, r);
- }
-
- private boolean neq(byte[] l, byte[] r) {
- return 0 == ByteUtil.compareNumberByte(l, r);
- }
-
- private UnsafeRow getGroupKey(UnsafeRow row) throws UnsupportedEncodingException {
-
- UnsafeRow key = null;
- if (this.sortColumnsByIndex == null) {
- /**
- * no group by key word
- * select count(*) from table;
- */
- key = new UnsafeRow(this.groupKeyFieldCount + 1);
- bufferHolder = new BufferHolder(key, 0);
- unsafeRowWriter = new UnsafeRowWriter(bufferHolder, this.groupKeyFieldCount + 1);
- bufferHolder.reset();
- unsafeRowWriter.write(0, "same".getBytes());
- key.setTotalSize(bufferHolder.totalSize());
- return key;
- }
-
-
- key = new UnsafeRow(this.groupKeyFieldCount);
- bufferHolder = new BufferHolder(key, 0);
- unsafeRowWriter = new UnsafeRowWriter(bufferHolder, this.groupKeyFieldCount);
- bufferHolder.reset();
-
-
- ColMeta curColMeta = null;
- for (int i = 0; i < this.groupKeyFieldCount; i++) {
- curColMeta = this.columnToIndexes.get(sortColumnsByIndex[i].toUpperCase());
- if (!row.isNullAt(curColMeta.getColIndex())) {
- switch (curColMeta.getColType()) {
- case ColMeta.COL_TYPE_BIT:
- key.setByte(i, row.getByte(curColMeta.getColIndex()));
- // fallthrough
- case ColMeta.COL_TYPE_INT:
- case ColMeta.COL_TYPE_LONG:
- case ColMeta.COL_TYPE_INT24:
- key.setInt(i,
- BytesTools.getInt(row.getBinary(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_SHORT:
- key.setShort(i,
- BytesTools.getShort(row.getBinary(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_FLOAT:
- key.setFloat(i,
- BytesTools.getFloat(row.getBinary(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_DOUBLE:
- key.setDouble(i,
- BytesTools.getDouble(row.getBinary(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_NEWDECIMAL:
- //key.setDouble(i, BytesTools.getDouble(row.getBinary(curColMeta.colIndex)));
- unsafeRowWriter.write(i,
- new BigDecimal(new String(row.getBinary(curColMeta.getColIndex()))));
- break;
- case ColMeta.COL_TYPE_LONGLONG:
- key.setLong(i,
- BytesTools.getLong(row.getBinary(curColMeta.getColIndex())));
- break;
- default:
- unsafeRowWriter.write(i,
- row.getBinary(curColMeta.getColIndex()));
- break;
- }
- } else {
- key.setNullAt(i);
- }
- }
-
- key.setTotalSize(bufferHolder.totalSize());
-
- return key;
- }
-
- private UnsafeRow getValue(UnsafeRow row) throws UnsupportedEncodingException {
-
- UnsafeRow value = new UnsafeRow(this.valueFieldCount);
- bufferHolder = new BufferHolder(value, 0);
- unsafeRowWriter = new UnsafeRowWriter(bufferHolder, this.valueFieldCount);
- bufferHolder.reset();
- ColMeta curColMeta = null;
- for (Map.Entry fieldEntry : columnToIndexes.entrySet()) {
- curColMeta = fieldEntry.getValue();
- if (!row.isNullAt(curColMeta.getColIndex())) {
- switch (curColMeta.getColType()) {
- case ColMeta.COL_TYPE_BIT:
- value.setByte(curColMeta.getColIndex(), row.getByte(curColMeta.getColIndex()));
- break;
- case ColMeta.COL_TYPE_INT:
- case ColMeta.COL_TYPE_LONG:
- case ColMeta.COL_TYPE_INT24:
- value.setInt(curColMeta.getColIndex(),
- BytesTools.getInt(row.getBinary(curColMeta.getColIndex())));
-
- break;
- case ColMeta.COL_TYPE_SHORT:
- value.setShort(curColMeta.getColIndex(),
- BytesTools.getShort(row.getBinary(curColMeta.getColIndex())));
- break;
- case ColMeta.COL_TYPE_LONGLONG:
- value.setLong(curColMeta.getColIndex(),
- BytesTools.getLong(row.getBinary(curColMeta.getColIndex())));
-
-
- break;
- case ColMeta.COL_TYPE_FLOAT:
- value.setFloat(curColMeta.getColIndex(),
- BytesTools.getFloat(row.getBinary(curColMeta.getColIndex())));
-
- break;
- case ColMeta.COL_TYPE_DOUBLE:
- value.setDouble(curColMeta.getColIndex(), BytesTools.getDouble(row.getBinary(curColMeta.getColIndex())));
-
- break;
- case ColMeta.COL_TYPE_NEWDECIMAL:
- //value.setDouble(curColMeta.colIndex, BytesTools.getDouble(row.getBinary(curColMeta.colIndex)));
- unsafeRowWriter.write(curColMeta.getColIndex(),
- new BigDecimal(new String(row.getBinary(curColMeta.getColIndex()))));
- break;
- default:
- unsafeRowWriter.write(curColMeta.getColIndex(),
- row.getBinary(curColMeta.getColIndex()));
- break;
- }
- } else {
- switch (curColMeta.getColType()) {
- case ColMeta.COL_TYPE_NEWDECIMAL:
- BigDecimal nullDecimal = null;
- unsafeRowWriter.write(curColMeta.getColIndex(), nullDecimal);
- break;
- default:
- value.setNullAt(curColMeta.getColIndex());
- break;
- }
- }
- }
-
-
- value.setTotalSize(bufferHolder.totalSize());
- return value;
- }
-
- public void addRow(UnsafeRow rowDataPkg) throws UnsupportedEncodingException {
- UnsafeRow key = getGroupKey(rowDataPkg);
- UnsafeRow value = getValue(rowDataPkg);
-
- if (!aggregationMap.find(key)) {
- aggregationMap.put(key, value);
- }
- }
-
- public void free() {
- if (aggregationMap != null)
- aggregationMap.free();
- }
-}
diff --git a/src/test/java/com/actiontech/dble/memory/unsafe/sort/TestSorter.java b/src/test/java/com/actiontech/dble/memory/unsafe/sort/TestSorter.java
deleted file mode 100644
index 60b73d7a0..000000000
--- a/src/test/java/com/actiontech/dble/memory/unsafe/sort/TestSorter.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2016-2017 ActionTech.
- * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
- */
-
-package com.actiontech.dble.memory.unsafe.sort;
-
-import com.actiontech.dble.memory.SeverMemory;
-import com.actiontech.dble.memory.unsafe.memory.mm.DataNodeMemoryManager;
-import com.actiontech.dble.memory.unsafe.memory.mm.MemoryManager;
-import com.actiontech.dble.memory.unsafe.row.BufferHolder;
-import com.actiontech.dble.memory.unsafe.row.StructType;
-import com.actiontech.dble.memory.unsafe.row.UnsafeRow;
-import com.actiontech.dble.memory.unsafe.row.UnsafeRowWriter;
-import com.actiontech.dble.memory.unsafe.utils.ServerPropertyConf;
-import com.actiontech.dble.memory.unsafe.utils.sort.PrefixComparator;
-import com.actiontech.dble.memory.unsafe.utils.sort.PrefixComparators;
-import com.actiontech.dble.memory.unsafe.utils.sort.RowPrefixComputer;
-import com.actiontech.dble.memory.unsafe.utils.sort.UnsafeExternalRowSorter;
-import com.actiontech.dble.sqlengine.mpp.ColMeta;
-import com.actiontech.dble.sqlengine.mpp.OrderCol;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * Created by zagnix on 16-7-9.
- */
-public class TestSorter implements Runnable {
- private static final Logger logger = LoggerFactory.getLogger(TestSorter.class);
-
- private static final int TEST_SIZE = 1000000;
- private static int TASK_SIZE = 100;
- private static CountDownLatch countDownLatch = new CountDownLatch(100);
-
- public void runSorter(SeverMemory severMemory,
- MemoryManager memoryManager,
- ServerPropertyConf conf) throws NoSuchFieldException, IllegalAccessException, IOException {
- DataNodeMemoryManager dataNodeMemoryManager = new DataNodeMemoryManager(memoryManager,
- Thread.currentThread().getId());
- /**
- * 1.schema ,mock a field
- *
- */
- int fieldCount = 3;
- ColMeta colMeta = null;
- Map colMetaMap = new HashMap(fieldCount);
- colMeta = new ColMeta(0, ColMeta.COL_TYPE_STRING);
- colMetaMap.put("id", colMeta);
- colMeta = new ColMeta(1, ColMeta.COL_TYPE_STRING);
- colMetaMap.put("name", colMeta);
- colMeta = new ColMeta(2, ColMeta.COL_TYPE_STRING);
- colMetaMap.put("age", colMeta);
-
-
- OrderCol[] orderCols = new OrderCol[1];
- OrderCol orderCol = new OrderCol(colMetaMap.get("id"),
- OrderCol.COL_ORDER_TYPE_ASC);
- orderCols[0] = orderCol;
- /**
- * 2 .PrefixComputer
- */
- StructType schema = new StructType(colMetaMap, fieldCount);
- schema.setOrderCols(orderCols);
-
- UnsafeExternalRowSorter.PrefixComputer prefixComputer =
- new RowPrefixComputer(schema);
-
- /**
- * 3 .PrefixComparator defalut is ASC, or set DESC
- */
- final PrefixComparator prefixComparator = PrefixComparators.LONG;
-
- UnsafeExternalRowSorter sorter =
- new UnsafeExternalRowSorter(dataNodeMemoryManager,
- severMemory,
- schema,
- prefixComparator,
- prefixComputer,
- conf.getSizeAsBytes("server.buffer.pageSize", "1m"),
- true,
- true);
- UnsafeRow unsafeRow;
- BufferHolder bufferHolder;
- UnsafeRowWriter unsafeRowWriter;
- String line = "testUnsafeRow";
- final Random rand = new Random(42);
- for (int i = 0; i < TEST_SIZE; i++) {
- unsafeRow = new UnsafeRow(3);
- bufferHolder = new BufferHolder(unsafeRow);
- unsafeRowWriter = new UnsafeRowWriter(bufferHolder, 3);
- bufferHolder.reset();
-
- String key = getRandomString(rand.nextInt(300) + 100);
-
- unsafeRowWriter.write(0, key.getBytes());
- unsafeRowWriter.write(1, line.getBytes());
- unsafeRowWriter.write(2, ("35" + 1).getBytes());
-
- unsafeRow.setTotalSize(bufferHolder.totalSize());
- sorter.insertRow(unsafeRow);
- }
- Iterator iter = sorter.sort();
- UnsafeRow row = null;
- int indexprint = 0;
- while (iter.hasNext()) {
- row = iter.next();
- indexprint++;
- }
-
- sorter.cleanupResources();
- countDownLatch.countDown();
-
- System.out.println("Thread ID :" + Thread.currentThread().getId() + "Index : " + indexprint);
- }
-
-
- public static String getRandomString(int length) { //length of string
- String base = "abcdefghijklmnopqrstuvwxyz0123456789";
- Random random = new Random();
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < length; i++) {
- int number = random.nextInt(base.length());
- sb.append(base.charAt(number));
- }
- return sb.toString();
- }
-
- final SeverMemory severMemory;
- final MemoryManager memoryManager;
- final ServerPropertyConf conf;
-
-
- public TestSorter(SeverMemory severMemory, MemoryManager memoryManager, ServerPropertyConf conf) throws NoSuchFieldException, IllegalAccessException {
- this.severMemory = severMemory;
- this.memoryManager = memoryManager;
- this.conf = conf;
- }
-
- @Override
- public void run() {
- try {
- runSorter(severMemory, memoryManager, conf);
- } catch (NoSuchFieldException e) {
- logger.error(e.getMessage());
- } catch (IllegalAccessException e) {
- logger.error(e.getMessage());
- } catch (IOException e) {
- logger.error(e.getMessage());
- }
- }
-
- public static void main(String[] args) throws Exception {
-
- SeverMemory severMemory;
- MemoryManager memoryManager;
- ServerPropertyConf conf;
-
- severMemory = new SeverMemory();
- memoryManager = severMemory.getResultMergeMemoryManager();
- conf = severMemory.getConf();
-
- for (int i = 0; i < TASK_SIZE; i++) {
- Thread thread = new Thread(new TestSorter(severMemory, memoryManager, conf));
- thread.start();
- }
-
- while (countDownLatch.getCount() != 0) {
- System.err.println("count ========================>" + countDownLatch.getCount());
- Thread.sleep(1000);
- }
-
- System.err.println(TASK_SIZE + " tasks sorter finished ok !!!!!!!!!");
-
- System.exit(1);
- }
-
-}
diff --git a/src/test/java/com/actiontech/dble/memory/unsafe/sort/UnsafeExternalRowSorterTest.java b/src/test/java/com/actiontech/dble/memory/unsafe/sort/UnsafeExternalRowSorterTest.java
deleted file mode 100644
index ac0d2210f..000000000
--- a/src/test/java/com/actiontech/dble/memory/unsafe/sort/UnsafeExternalRowSorterTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2016-2017 ActionTech.
- * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
- */
-
-package com.actiontech.dble.memory.unsafe.sort;
-
-import com.actiontech.dble.memory.SeverMemory;
-import com.actiontech.dble.memory.unsafe.memory.mm.DataNodeMemoryManager;
-import com.actiontech.dble.memory.unsafe.memory.mm.MemoryManager;
-import com.actiontech.dble.memory.unsafe.row.BufferHolder;
-import com.actiontech.dble.memory.unsafe.row.StructType;
-import com.actiontech.dble.memory.unsafe.row.UnsafeRow;
-import com.actiontech.dble.memory.unsafe.row.UnsafeRowWriter;
-import com.actiontech.dble.memory.unsafe.utils.ServerPropertyConf;
-import com.actiontech.dble.memory.unsafe.utils.sort.PrefixComparator;
-import com.actiontech.dble.memory.unsafe.utils.sort.PrefixComparators;
-import com.actiontech.dble.memory.unsafe.utils.sort.RowPrefixComputer;
-import com.actiontech.dble.memory.unsafe.utils.sort.UnsafeExternalRowSorter;
-import com.actiontech.dble.sqlengine.mpp.ColMeta;
-import com.actiontech.dble.sqlengine.mpp.OrderCol;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Created by zagnix on 2016/6/19.
- */
-public class UnsafeExternalRowSorterTest {
-
- private static final int TEST_SIZE = 100000;
- public static final Logger LOGGER = LoggerFactory.getLogger(UnsafeExternalRowSorterTest.class);
-
- /**
- * test type LONG,INT,SHORT,Float,Double,String,Binary
- */
- @Test
- public void testUnsafeExternalRowSorter() throws NoSuchFieldException, IllegalAccessException, IOException {
- SeverMemory severMemory = new SeverMemory();
- MemoryManager memoryManager = severMemory.getResultMergeMemoryManager();
- ServerPropertyConf conf = severMemory.getConf();
- DataNodeMemoryManager dataNodeMemoryManager = new DataNodeMemoryManager(memoryManager,
- Thread.currentThread().getId());
-
- int fieldCount = 3;
- ColMeta colMeta = null;
- Map colMetaMap = new HashMap(fieldCount);
- colMeta = new ColMeta(0, ColMeta.COL_TYPE_STRING);
- colMetaMap.put("id", colMeta);
- colMeta = new ColMeta(1, ColMeta.COL_TYPE_STRING);
- colMetaMap.put("name", colMeta);
- colMeta = new ColMeta(2, ColMeta.COL_TYPE_STRING);
- colMetaMap.put("age", colMeta);
-
-
- OrderCol[] orderCols = new OrderCol[1];
- OrderCol orderCol = new OrderCol(colMetaMap.get("id"),
- OrderCol.COL_ORDER_TYPE_ASC);
- orderCols[0] = orderCol;
- /**
- * 2 .PrefixComputer
- */
- StructType schema = new StructType(colMetaMap, fieldCount);
- schema.setOrderCols(orderCols);
-
- UnsafeExternalRowSorter.PrefixComputer prefixComputer =
- new RowPrefixComputer(schema);
-
-
- final PrefixComparator prefixComparator = PrefixComparators.LONG;
-
- UnsafeExternalRowSorter sorter =
- new UnsafeExternalRowSorter(dataNodeMemoryManager,
- severMemory,
- schema,
- prefixComparator,
- prefixComputer,
- conf.getSizeAsBytes("server.buffer.pageSize", "1m"),
- true,
- true);
-
- UnsafeRow unsafeRow;
- BufferHolder bufferHolder;
- UnsafeRowWriter unsafeRowWriter;
- String line = "testUnsafeRow";
- // List floats = new ArrayList();
- List longs = new ArrayList();
- final Random rand = new Random(42);
- for (int i = 0; i < TEST_SIZE; i++) {
- unsafeRow = new UnsafeRow(3);
- bufferHolder = new BufferHolder(unsafeRow);
- unsafeRowWriter = new UnsafeRowWriter(bufferHolder, 3);
- bufferHolder.reset();
-
- String key = getRandomString(rand.nextInt(300) + 100);
-
- //long v = rand.nextLong();
- // longs.add(v);
- unsafeRowWriter.write(0, key.getBytes());
- // unsafeRowWriter.write(0, BytesTools.toBytes(v));
- unsafeRowWriter.write(1, line.getBytes());
- unsafeRowWriter.write(2, ("35" + 1).getBytes());
-
- unsafeRow.setTotalSize(bufferHolder.totalSize());
- sorter.insertRow(unsafeRow);
- }
-
- Iterator iter = sorter.sort();
-/*
- float [] com = new float[floats.size()];
- for (int i = 0; i