Search in sources :

Example 1 with SortFactory

use of org.apache.derby.iapi.store.access.conglomerate.SortFactory in project derby by apache.

the class RAMTransaction method openSortCostController.

/**
 * Return an open SortCostController.
 * <p>
 * Return an open SortCostController which can be used to ask about
 * the estimated costs of SortController() operations.
 * <p>
 *
 * @return The open StoreCostController.
 *
 * @exception  StandardException  Standard exception policy.
 *
 * @see StoreCostController
 */
public SortCostController openSortCostController() throws StandardException {
    // Get the implementation type from the parameters.
    // RESOLVE (mikem) need to figure out how to select sort implementation.
    String implementation = null;
    if (implementation == null)
        implementation = AccessFactoryGlobals.SORT_EXTERNAL;
    // Find the appropriate factory for the desired implementation.
    MethodFactory mfactory;
    mfactory = accessmanager.findMethodFactoryByImpl(implementation);
    if (mfactory == null || !(mfactory instanceof SortFactory)) {
        throw (StandardException.newException(SQLState.AM_NO_FACTORY_FOR_IMPLEMENTATION, implementation));
    }
    SortFactory sfactory = (SortFactory) mfactory;
    // open sort cost controller
    return (sfactory.openSortCostController());
}
Also used : MethodFactory(org.apache.derby.iapi.store.access.conglomerate.MethodFactory) SortFactory(org.apache.derby.iapi.store.access.conglomerate.SortFactory)

Example 2 with SortFactory

use of org.apache.derby.iapi.store.access.conglomerate.SortFactory in project derby by apache.

the class RAMTransaction method createSort.

/**
 *	@see TransactionController#createSort
 *	@exception StandardException Standard error policy.
 */
public long createSort(Properties implParameters, DataValueDescriptor[] template, ColumnOrdering[] columnOrdering, SortObserver sortObserver, boolean alreadyInOrder, long estimatedRows, int estimatedRowSize) throws StandardException {
    // Get the implementation type from the parameters.
    // XXX (nat) need to figure out how to select sort implementation.
    String implementation = null;
    if (implParameters != null)
        implementation = implParameters.getProperty(AccessFactoryGlobals.IMPL_TYPE);
    if (implementation == null)
        implementation = AccessFactoryGlobals.SORT_EXTERNAL;
    // Find the appropriate factory for the desired implementation.
    MethodFactory mfactory;
    mfactory = accessmanager.findMethodFactoryByImpl(implementation);
    if (mfactory == null || !(mfactory instanceof SortFactory)) {
        throw (StandardException.newException(SQLState.AM_NO_FACTORY_FOR_IMPLEMENTATION, implementation));
    }
    SortFactory sfactory = (SortFactory) mfactory;
    // Decide what segment the sort should use.
    // XXX (nat) sorts always in segment 0
    int segment = 0;
    // Create the sort.
    Sort sort = sfactory.createSort(this, segment, implParameters, template, columnOrdering, sortObserver, alreadyInOrder, estimatedRows, estimatedRowSize);
    // Add the sort to the sorts vector
    if (sorts == null) {
        sorts = new ArrayList<Sort>();
        freeSortIds = new ArrayList<Integer>();
    }
    int sortid;
    if (freeSortIds.isEmpty()) {
        // no free identifiers, add sort at the end
        sortid = sorts.size();
        sorts.add(sort);
    } else {
        // reuse a sort identifier
        sortid = (freeSortIds.remove(freeSortIds.size() - 1)).intValue();
        sorts.set(sortid, sort);
    }
    return sortid;
}
Also used : MethodFactory(org.apache.derby.iapi.store.access.conglomerate.MethodFactory) Sort(org.apache.derby.iapi.store.access.conglomerate.Sort) SortFactory(org.apache.derby.iapi.store.access.conglomerate.SortFactory)

Aggregations

MethodFactory (org.apache.derby.iapi.store.access.conglomerate.MethodFactory)2 SortFactory (org.apache.derby.iapi.store.access.conglomerate.SortFactory)2 Sort (org.apache.derby.iapi.store.access.conglomerate.Sort)1