Search in sources :

Example 1 with ItemResult

use of com.actiontech.dble.plan.common.item.Item.ItemResult in project dble by actiontech.

the class MySQLcom method aggResultType.

public static ItemResult aggResultType(List<Item> items, int startIndex, int size) {
    ItemResult type = ItemResult.STRING_RESULT;
    /* Skip beginning NULL items */
    int index = 0, indexEnd;
    Item item;
    for (index = startIndex, indexEnd = startIndex + size; index < indexEnd; index++) {
        item = items.get(index);
        if (item.type() != ItemType.NULL_ITEM) {
            type = item.resultType();
            index++;
            break;
        }
    }
    /* Combine result types. Note: NULL items don't affect the result */
    for (; index < indexEnd; index++) {
        item = items.get(index);
        if (item.type() != ItemType.NULL_ITEM)
            type = itemStoreType(type, item);
    }
    return type;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) ItemResult(com.actiontech.dble.plan.common.item.Item.ItemResult)

Example 2 with ItemResult

use of com.actiontech.dble.plan.common.item.Item.ItemResult in project dble by actiontech.

the class MySQLcom method collectCmpTypes.

/*
     * Collects different types for comparison of first item with each other
     * items
     *
     * SYNOPSIS collectCmpTypes() items Array of items to collect types from
     * nitems Number of items in the array skip_nulls Don't collect types of
     * NULL items if TRUE
     *
     * DESCRIPTION This function collects different result types for comparison
     * of the first item in the list with each of the remaining items in the
     * 'items' array.
     *
     * RETURN 0 - if row type incompatibility has been detected (see
     * cmp_row_type) Bitmap of collected types - otherwise show how many types there are
     */
public static int collectCmpTypes(List<Item> items, boolean skipnulls) {
    int foundtypes = 0;
    ItemResult leftResult = items.get(0).resultType();
    for (int i = 1; i < items.size(); i++) {
        if (skipnulls && items.get(i).type() == Item.ItemType.NULL_ITEM)
            continue;
        if (leftResult == ItemResult.ROW_RESULT || items.get(i).resultType() == ItemResult.ROW_RESULT && cmpRowType(items.get(0), items.get(i)) != 0)
            return 0;
        foundtypes |= 1 << MySQLcom.itemCmpType(leftResult, items.get(i).resultType()).ordinal();
    }
    /*
         * Even if all right-hand items are NULLs and we are skipping them all,
         * we need at least one type bit in the found_type bitmask.
         */
    if (skipnulls && foundtypes == 0)
        foundtypes |= 1 << leftResult.ordinal();
    return foundtypes;
}
Also used : ItemResult(com.actiontech.dble.plan.common.item.Item.ItemResult)

Aggregations

ItemResult (com.actiontech.dble.plan.common.item.Item.ItemResult)2 Item (com.actiontech.dble.plan.common.item.Item)1