Search in sources :

Example 6 with Session

use of org.h2.engine.Session in project ignite by apache.

the class GridH2Table method commitUserIndex.

/**
 * Promote temporary index to make it usable in queries.
 *
 * @param ses H2 session.
 * @param idxName Index name.
 * @return Temporary index with given name.
 */
private Index commitUserIndex(Session ses, String idxName) {
    lock(true);
    try {
        ensureNotDestroyed();
        Index idx = tmpIdxs.remove(idxName);
        assert idx != null;
        Index cloneIdx = createDuplicateIndexIfNeeded(idx);
        ArrayList<Index> newIdxs = new ArrayList<>(idxs.size() + ((cloneIdx == null) ? 1 : 2));
        newIdxs.addAll(idxs);
        newIdxs.add(idx);
        if (cloneIdx != null)
            newIdxs.add(cloneIdx);
        idxs = newIdxs;
        database.addSchemaObject(ses, idx);
        if (cloneIdx != null)
            database.addSchemaObject(ses, cloneIdx);
        setModified();
        return idx;
    } finally {
        unlock(true);
    }
}
Also used : ArrayList(java.util.ArrayList) Index(org.h2.index.Index) SpatialIndex(org.h2.index.SpatialIndex) H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex)

Example 7 with Session

use of org.h2.engine.Session in project ignite by apache.

the class H2TreeIndex method findFirstOrLast.

/**
 * {@inheritDoc}
 */
@Override
public Cursor findFirstOrLast(Session session, boolean b) {
    try {
        int seg = threadLocalSegment();
        H2Tree tree = treeForRead(seg);
        GridH2Row row = b ? tree.findFirst() : tree.findLast();
        return new SingleRowCursor(row);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row) SingleRowCursor(org.h2.index.SingleRowCursor)

Example 8 with Session

use of org.h2.engine.Session in project ignite by apache.

the class H2Utils method setupConnection.

/**
 * @param conn Connection to use.
 * @param distributedJoins If distributed joins are enabled.
 * @param enforceJoinOrder Enforce join order of tables.
 */
public static void setupConnection(Connection conn, boolean distributedJoins, boolean enforceJoinOrder) {
    Session s = session(conn);
    s.setForceJoinOrder(enforceJoinOrder);
    s.setJoinBatchEnabled(distributedJoins);
}
Also used : Session(org.h2.engine.Session)

Example 9 with Session

use of org.h2.engine.Session in project ignite by apache.

the class GridMergeIndex method getRowCount.

/**
 * {@inheritDoc}
 */
@Override
public long getRowCount(Session ses) {
    Cursor c = find(ses, null, null);
    long cnt = 0;
    while (c.next()) cnt++;
    return cnt;
}
Also used : Cursor(org.h2.index.Cursor)

Example 10 with Session

use of org.h2.engine.Session in project ignite by apache.

the class GridH2TreeIndex method findFirstOrLast.

/** {@inheritDoc} */
@Override
public Cursor findFirstOrLast(Session ses, boolean first) {
    try {
        int seg = threadLocalSegment();
        IgniteTree t = treeForRead(seg);
        GridH2Row row = (GridH2Row) (first ? t.findFirst() : t.findLast());
        return new SingleRowCursor(row);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteTree(org.apache.ignite.internal.util.IgniteTree) SingleRowCursor(org.h2.index.SingleRowCursor)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 SingleRowCursor (org.h2.index.SingleRowCursor)5 ArrayList (java.util.ArrayList)4 H2TreeIndex (org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex)4 Session (org.h2.engine.Session)4 Cursor (org.h2.index.Cursor)4 Index (org.h2.index.Index)4 GridH2Row (org.apache.ignite.internal.processors.query.h2.opt.GridH2Row)3 SpatialIndex (org.h2.index.SpatialIndex)3 SQLException (java.sql.SQLException)2 Node (javax.jcr.Node)2 QueryCancelledException (org.apache.ignite.cache.query.QueryCancelledException)2 H2Cursor (org.apache.ignite.internal.processors.query.h2.H2Cursor)2 GridCursor (org.apache.ignite.internal.util.lang.GridCursor)2 Profiler (org.h2.util.Profiler)2 Test (org.junit.Test)2 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1