use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.
the class BplusTree method findOne.
/**
* Returns found result or {@code null}.
*
* @param row Lookup row for exact match.
* @param x Implementation specific argument, {@code null} always means that we need to return full detached data row.
* @throws IgniteInternalCheckedException If failed.
*/
@Nullable
public final <R> R findOne(L row, @Nullable TreeRowClosure<L, T> c, Object x) throws IgniteInternalCheckedException {
checkDestroyed();
GetOne g = new GetOne(row, c, x, false);
try {
doFind(g);
return (R) g.row;
} catch (CorruptedDataStructureException e) {
throw e;
} catch (IgniteInternalCheckedException e) {
throw new IgniteInternalCheckedException("Runtime failure on lookup row: " + row, e);
} catch (RuntimeException | AssertionError e) {
throw corruptedTreeException("Runtime failure on lookup row: " + row, e, grpId, g.pageId);
} finally {
checkDestroyed();
}
}
use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.
the class BplusTree method find.
/**
* Getting the cursor through the rows of the tree.
*
* @param lower Lower bound or {@code null} if unbounded.
* @param upper Upper bound or {@code null} if unbounded.
* @param lowIncl {@code true} if lower bound is inclusive.
* @param upIncl {@code true} if upper bound is inclusive.
* @param c Filter closure.
* @param x Implementation specific argument, {@code null} always means that we need to return full detached data row.
* @return Cursor.
* @throws IgniteInternalCheckedException If failed.
*/
public IgniteCursor<T> find(@Nullable L lower, @Nullable L upper, boolean lowIncl, boolean upIncl, TreeRowClosure<L, T> c, @Nullable Object x) throws IgniteInternalCheckedException {
checkDestroyed();
ForwardCursor cursor = new ForwardCursor(lower, upper, lowIncl, upIncl, c, x);
try {
if (lower == null) {
return findLowerUnbounded(upper, upIncl, c, x);
}
cursor.find();
return cursor;
} catch (CorruptedDataStructureException e) {
throw e;
} catch (IgniteInternalCheckedException e) {
throw new IgniteInternalCheckedException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e);
} catch (RuntimeException | AssertionError e) {
long[] pageIds = pages(lower == null || cursor == null || cursor.getCursor == null, () -> new long[] { cursor.getCursor.pageId });
throw corruptedTreeException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e, grpId, pageIds);
} finally {
checkDestroyed();
}
}
use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.
the class RandomLruPageReplacementPolicy method isStoreMetadataPage.
/**
* Return {@code true} if page is related to metadata.
*
* @param absPageAddr Absolute page address
*/
private boolean isStoreMetadataPage(long absPageAddr) {
try {
long dataAddr = absPageAddr + PAGE_OVERHEAD;
PageIo io = seg.ioRegistry().resolve(dataAddr);
return io instanceof PagesListMetaIo;
} catch (IgniteInternalCheckedException ignored) {
return false;
}
}
use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.
the class PageIo method printPage.
/**
* Returns a string representation of pages content.
*
* @param pageIoRegistry Page IO Registry.
* @param pageAddr Page address.
* @param pageSize Page size.
*/
public static String printPage(PageIoRegistry pageIoRegistry, long pageAddr, int pageSize) {
IgniteStringBuilder sb = new IgniteStringBuilder("Header [\n\ttype=");
try {
PageIo io = pageIoRegistry.resolve(pageAddr);
sb.app(getType(pageAddr)).app(" (").app(io.getClass().getSimpleName()).app("),\n\tver=").app(getVersion(pageAddr)).app(",\n\tcrc=").app(getCrc(pageAddr)).app(",\n\t").app(PageIdUtils.toDetailString(getPageId(pageAddr))).app("\n],\n");
if (getCompressionType(pageAddr) != 0) {
sb.app("CompressedPage[\n\tcompressionType=").app(getCompressionType(pageAddr)).app(",\n\tcompressedSize=").app(getCompressedSize(pageAddr)).app(",\n\tcompactedSize=").app(getCompactedSize(pageAddr)).app("\n]");
} else {
io.printPage(pageAddr, pageSize, sb);
}
} catch (IgniteInternalCheckedException e) {
sb.app("Failed to print page: ").app(e.getMessage());
}
return sb.toString();
}
use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.
the class BplusTree method doPut.
/**
* Does a put.
*
* @param row New value.
* @param needOld {@code True} If need return old value.
* @return Old row.
* @throws IgniteInternalCheckedException If failed.
*/
private T doPut(T row, boolean needOld) throws IgniteInternalCheckedException {
checkDestroyed();
Put p = new Put(row, needOld);
try {
for (; ; ) {
// Go down with retries.
p.init();
Result res = putDown(p, p.rootId, 0L, p.rootLvl);
switch(res) {
case RETRY:
case RETRY_ROOT:
continue;
case FOUND:
// We may need to perform an inner replace on the upper level.
if (!p.isFinished()) {
res = p.finishTail();
// If not found, then the root split has happened and operation should be retried from the actual root.
if (res == RETRY || res == NOT_FOUND) {
p.releaseTail();
assert p.checkTailLevel(getRootLevel()) : "tail=" + p.tail + ", res=" + res;
continue;
}
}
return p.oldRow;
default:
throw new IllegalStateException("Result: " + res);
}
}
} catch (CorruptedDataStructureException e) {
throw e;
} catch (IgniteInternalCheckedException e) {
throw new IgniteInternalCheckedException("Runtime failure on row: " + row, e);
} catch (RuntimeException | AssertionError e) {
throw corruptedTreeException("Runtime failure on row: " + row, e, grpId, p.pageId);
} finally {
checkDestroyed();
}
}
Aggregations