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();
}
}
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;
}
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;
}
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;
}
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;
}
}
Aggregations