Search in sources :

Example 1 with MissingPartitionException

use of com.hazelcast.map.impl.operation.MapFetchIndexOperation.MissingPartitionException in project hazelcast by hazelcast.

the class MapIndexScanP method runSortedIndex.

private boolean runSortedIndex() {
    for (; ; ) {
        if (pendingItem != null && !tryEmit(pendingItem)) {
            return false;
        } else {
            pendingItem = null;
        }
        JetSqlRow extreme = null;
        int extremeIndex = -1;
        for (int i = 0; i < splits.size(); ++i) {
            Split split = splits.get(i);
            try {
                split.peek();
            } catch (MissingPartitionException e) {
                splits.addAll(splitOnMigration(split));
                splits.remove(i--);
                continue;
            }
            if (split.currentRow == null) {
                if (split.done()) {
                    // No more items to read, remove finished split.
                    splits.remove(i--);
                    continue;
                }
                // waiting for more rows from this split
                return false;
            }
            if (extremeIndex < 0 || metadata.getComparator().compare(split.currentRow, splits.get(extremeIndex).currentRow) < 0) {
                extremeIndex = i;
                extreme = split.currentRow;
            }
        }
        if (extremeIndex < 0) {
            assert splits.isEmpty();
            return true;
        }
        pendingItem = extreme;
        splits.get(extremeIndex).remove();
    }
}
Also used : MissingPartitionException(com.hazelcast.map.impl.operation.MapFetchIndexOperation.MissingPartitionException) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow)

Aggregations

MissingPartitionException (com.hazelcast.map.impl.operation.MapFetchIndexOperation.MissingPartitionException)1 JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)1