Search in sources :

Example 1 with IndexRowImpl

use of org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl in project ignite by apache.

the class InlineIndexImpl method onUpdate.

/**
 * {@inheritDoc}
 */
@Override
public void onUpdate(@Nullable CacheDataRow oldRow, @Nullable CacheDataRow newRow, boolean prevRowAvailable) throws IgniteCheckedException {
    try {
        if (destroyed.get())
            return;
        ThreadLocalRowHandlerHolder.rowHandler(rowHnd);
        boolean replaced = false;
        // Create or Update.
        if (newRow != null) {
            int segment = segmentForRow(newRow);
            IndexRowImpl row0 = new IndexRowImpl(rowHnd, newRow);
            row0.prepareCache();
            // Validate all keys before an actual put. User may specify wrong data types for an insert query.
            for (int i = 0; i < def.indexKeyDefinitions().size(); ++i) row0.key(i);
            replaced = putx(row0, segment, prevRowAvailable && !rebuildInProgress());
        }
        // Delete.
        if (!replaced && oldRow != null)
            remove(oldRow);
    } finally {
        ThreadLocalRowHandlerHolder.clearRowHandler();
    }
}
Also used : IndexRowImpl(org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl)

Example 2 with IndexRowImpl

use of org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl in project ignite by apache.

the class GeoSpatialIndexImpl method put.

/**
 */
private boolean put(CacheDataRow row) {
    checkClosed();
    Object key = def.rowHandler().key(row);
    assert key != null;
    final int seg = segmentForRow(row);
    Long rowId = keyToId.get(key);
    if (rowId != null) {
        Long oldRowId = segments[seg].remove(getEnvelope(idToRow.get(rowId).cacheDataRow(), rowId));
        assert rowId.equals(oldRowId);
    } else {
        rowId = ++rowIds;
        keyToId.put(key, rowId);
    }
    IndexRow old = idToRow.put(rowId, new IndexRowImpl(def.rowHandler(), row));
    segments[seg].put(getEnvelope(row, rowId), rowId);
    if (old == null)
        // No replace.
        rowCnt++;
    return old != null;
}
Also used : IndexRow(org.apache.ignite.internal.cache.query.index.sorted.IndexRow) IndexRowImpl(org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl)

Example 3 with IndexRowImpl

use of org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl in project ignite by apache.

the class InlineIndexTree method createMvccIndexRow.

/**
 * Creates an mvcc index row for this tree.
 */
public IndexRowImpl createMvccIndexRow(long link, long mvccCrdVer, long mvccCntr, int mvccOpCntr) throws IgniteCheckedException {
    IndexRowImpl cachedRow = idxRowCache == null ? null : idxRowCache.get(link);
    if (cachedRow != null)
        return cachedRow;
    int partId = PageIdUtils.partId(PageIdUtils.pageId(link));
    MvccDataRow row = new MvccDataRow(cacheGroupContext(), 0, link, partId, null, mvccCrdVer, mvccCntr, mvccOpCntr, true);
    IndexRowImpl r = new IndexRowImpl(rowHandler(), row);
    if (idxRowCache != null)
        idxRowCache.put(r);
    return r;
}
Also used : IndexRowImpl(org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl) MvccDataRow(org.apache.ignite.internal.processors.cache.tree.mvcc.data.MvccDataRow)

Example 4 with IndexRowImpl

use of org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl in project ignite by apache.

the class InlineIndexTree method createIndexRow.

/**
 * Creates an index row for this tree.
 */
public IndexRowImpl createIndexRow(long link) throws IgniteCheckedException {
    IndexRowImpl cachedRow = idxRowCache == null ? null : idxRowCache.get(link);
    if (cachedRow != null)
        return cachedRow;
    CacheDataRowAdapter row = new CacheDataRowAdapter(link);
    row.initFromLink(cacheGroupContext(), CacheDataRowAdapter.RowData.FULL, true);
    IndexRowImpl r = new IndexRowImpl(rowHandler(), row);
    if (idxRowCache != null)
        idxRowCache.put(r);
    return r;
}
Also used : IndexRowImpl(org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl) CacheDataRowAdapter(org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)

Example 5 with IndexRowImpl

use of org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl in project ignite by apache.

the class InlineIndexImpl method remove.

/**
 */
private void remove(CacheDataRow row) throws IgniteCheckedException {
    try {
        int segment = segmentForRow(row);
        IndexRowImpl idxRow = new IndexRowImpl(rowHnd, row);
        idxRow.prepareCache();
        segments[segment].removex(idxRow);
    } catch (Throwable t) {
        cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, t));
        throw t;
    }
}
Also used : FailureContext(org.apache.ignite.failure.FailureContext) IndexRowImpl(org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl)

Aggregations

IndexRowImpl (org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl)6 Map (java.util.Map)1 SqlQuery (org.apache.ignite.cache.query.SqlQuery)1 FailureContext (org.apache.ignite.failure.FailureContext)1 IndexRow (org.apache.ignite.internal.cache.query.index.sorted.IndexRow)1 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)1 CacheDataRowAdapter (org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter)1 MvccDataRow (org.apache.ignite.internal.processors.cache.tree.mvcc.data.MvccDataRow)1 ConcurrentLinkedHashMap (org.jsr166.ConcurrentLinkedHashMap)1