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