Search in sources :

Example 1 with GridH2Row

use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Row in project ignite by apache.

the class IgniteH2Indexing method rebuildIndexesFromHash.

/** {@inheritDoc} */
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
@Override
public void rebuildIndexesFromHash(GridCacheContext cctx, String schemaName, String typeName) throws IgniteCheckedException {
    H2TableDescriptor tbl = tableDescriptor(schemaName, typeName);
    if (tbl == null)
        return;
    assert tbl.table() != null;
    assert tbl.table().rebuildFromHashInProgress();
    H2PkHashIndex hashIdx = tbl.primaryKeyHashIndex();
    Cursor cursor = hashIdx.find((Session) null, null, null);
    while (cursor.next()) {
        CacheDataRow dataRow = (CacheDataRow) cursor.get();
        boolean done = false;
        while (!done) {
            GridCacheEntryEx entry = cctx.cache().entryEx(dataRow.key());
            try {
                synchronized (entry) {
                    // TODO : How to correctly get current value and link here?
                    GridH2Row row = tbl.table().rowDescriptor().createRow(entry.key(), entry.partition(), dataRow.value(), entry.version(), entry.expireTime());
                    row.link(dataRow.link());
                    List<Index> indexes = tbl.table().getAllIndexes();
                    for (int i = 2; i < indexes.size(); i++) {
                        Index idx = indexes.get(i);
                        if (idx instanceof H2TreeIndex)
                            ((H2TreeIndex) idx).put(row);
                    }
                    done = true;
                }
            } catch (GridCacheEntryRemovedException e) {
            // No-op
            }
        }
    }
    tbl.table().markRebuildFromHashInProgress(false);
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.database.CacheDataRow) H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row) Index(org.h2.index.Index) H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex) H2PkHashIndex(org.apache.ignite.internal.processors.query.h2.database.H2PkHashIndex) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) H2PkHashIndex(org.apache.ignite.internal.processors.query.h2.database.H2PkHashIndex) QueryCursor(org.apache.ignite.cache.query.QueryCursor) Cursor(org.h2.index.Cursor) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor)

Example 2 with GridH2Row

use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Row in project ignite by apache.

the class H2ExtrasInnerIO method getLookupRow.

/** {@inheritDoc} */
@Override
public SearchRow getLookupRow(BPlusTree<SearchRow, ?> tree, long pageAddr, int idx) throws IgniteCheckedException {
    long link = getLink(pageAddr, idx);
    assert link != 0;
    GridH2Row r0 = ((H2Tree) tree).getRowFactory().getRow(link);
    return r0;
}
Also used : GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row)

Example 3 with GridH2Row

use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Row in project ignite by apache.

the class GridH2TableSelfTest method checkIndexesConsistent.

/**
     * @param idxs Indexes.
     * @param rowSet Rows.
     * @return Rows.
     */
private Set<Row> checkIndexesConsistent(ArrayList<Index> idxs, @Nullable Set<Row> rowSet) throws IgniteCheckedException {
    for (Index idx : idxs) {
        if (!(idx instanceof GridH2TreeIndex))
            continue;
        Set<Row> set = new HashSet<>();
        GridCursor<GridH2Row> cursor = ((GridH2TreeIndex) idx).rows();
        while (cursor.next()) assertTrue(set.add(cursor.get()));
        if (rowSet == null || rowSet.isEmpty())
            rowSet = set;
        else
            assertEquals(rowSet, set);
    }
    return rowSet;
}
Also used : Index(org.h2.index.Index) H2PkHashIndex(org.apache.ignite.internal.processors.query.h2.database.H2PkHashIndex) Row(org.h2.result.Row) SearchRow(org.h2.result.SearchRow) HashSet(java.util.HashSet)

Example 4 with GridH2Row

use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Row in project ignite by apache.

the class H2Tree method getRow.

/**
 * {@inheritDoc}
 */
@Override
protected GridH2Row getRow(BPlusIO<SearchRow> io, long pageAddr, int idx, Object filter) throws IgniteCheckedException {
    if (filter != null) {
        // Filter out not interesting partitions without deserializing the row.
        IndexingQueryCacheFilter filter0 = (IndexingQueryCacheFilter) filter;
        long link = ((H2RowLinkIO) io).getLink(pageAddr, idx);
        int part = PageIdUtils.partId(PageIdUtils.pageId(link));
        if (!filter0.applyPartition(part))
            return null;
    }
    return (GridH2Row) io.getLookupRow(this, pageAddr, idx);
}
Also used : GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row) H2RowLinkIO(org.apache.ignite.internal.processors.query.h2.database.io.H2RowLinkIO) IndexingQueryCacheFilter(org.apache.ignite.spi.indexing.IndexingQueryCacheFilter)

Example 5 with GridH2Row

use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Row in project ignite by apache.

the class H2ExtrasLeafIO method storeByOffset.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("ForLoopReplaceableByForEach")
@Override
public void storeByOffset(long pageAddr, int off, SearchRow row) {
    GridH2Row row0 = (GridH2Row) row;
    assert row0.link() != 0;
    List<InlineIndexHelper> inlineIdxs = InlineIndexHelper.getCurrentInlineIndexes();
    assert inlineIdxs != null : "no inline index helpers";
    int fieldOff = 0;
    for (int i = 0; i < inlineIdxs.size(); i++) {
        InlineIndexHelper idx = inlineIdxs.get(i);
        int size = idx.put(pageAddr, off + fieldOff, row.getValue(idx.columnIndex()), payloadSize - fieldOff);
        if (size == 0)
            break;
        fieldOff += size;
    }
    PageUtils.putLong(pageAddr, off + payloadSize, row0.link());
}
Also used : GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row) InlineIndexHelper(org.apache.ignite.internal.processors.query.h2.database.InlineIndexHelper)

Aggregations

GridH2Row (org.apache.ignite.internal.processors.query.h2.opt.GridH2Row)11 Index (org.h2.index.Index)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 H2PkHashIndex (org.apache.ignite.internal.processors.query.h2.database.H2PkHashIndex)4 Random (java.util.Random)2 UUID (java.util.UUID)2 IgniteException (org.apache.ignite.IgniteException)2 H2TreeIndex (org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex)2 InlineIndexHelper (org.apache.ignite.internal.processors.query.h2.database.InlineIndexHelper)2 IndexingQueryCacheFilter (org.apache.ignite.spi.indexing.IndexingQueryCacheFilter)2 Cursor (org.h2.index.Cursor)2 SearchRow (org.h2.result.SearchRow)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 Timestamp (java.sql.Timestamp)1 HashSet (java.util.HashSet)1 CacheException (javax.cache.CacheException)1 IgniteSystemProperties.getString (org.apache.ignite.IgniteSystemProperties.getString)1