Search in sources :

Example 1 with IgniteStringBuilder

use of org.apache.ignite.lang.IgniteStringBuilder in project ignite-3 by apache.

the class AbstractDataPageIo method printPageLayout.

/**
 * Returns string representation of page.
 *
 * @param pageAddr Page address.
 * @param pageSize Page size.
 */
private String printPageLayout(long pageAddr, int pageSize) {
    IgniteStringBuilder b = new IgniteStringBuilder();
    printPageLayout(pageAddr, pageSize, b);
    return b.toString();
}
Also used : IgniteStringBuilder(org.apache.ignite.lang.IgniteStringBuilder)

Example 2 with IgniteStringBuilder

use of org.apache.ignite.lang.IgniteStringBuilder in project ignite-3 by apache.

the class CorruptedTreeException method getMsg.

/**
 * Creates {@link CorruptedTreeException} error message.
 *
 * @param msg Message.
 * @param indexName Index name.
 * @param grpName Group name.
 * @param grpId Group id.
 * @param pageIds PageId's that can be corrupted.
 * @return Error message.
 */
private static String getMsg(String msg, @Nullable String indexName, @Nullable String grpName, int grpId, long... pageIds) {
    IgniteStringBuilder sb = new IgniteStringBuilder("B+Tree is corrupted [groupId=");
    sb.app(grpId).app(", pageIds=").app(Arrays.toString(pageIds));
    if (indexName != null) {
        sb.app(", indexName=").app(indexName);
    }
    if (grpName != null) {
        sb.app(", groupName=").app(grpName);
    }
    sb.app(", msg=").app(msg).app(']');
    return sb.toString();
}
Also used : IgniteStringBuilder(org.apache.ignite.lang.IgniteStringBuilder)

Example 3 with IgniteStringBuilder

use of org.apache.ignite.lang.IgniteStringBuilder 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();
}
Also used : IgniteInternalCheckedException(org.apache.ignite.lang.IgniteInternalCheckedException) IgniteStringBuilder(org.apache.ignite.lang.IgniteStringBuilder)

Example 4 with IgniteStringBuilder

use of org.apache.ignite.lang.IgniteStringBuilder in project ignite-3 by apache.

the class IgniteToStringBuilder method compact.

/**
 * Returns sorted and compacted string representation of given {@code col}. Two nearby numbers are compacted to one continuous segment.
 * E.g. collection of [1, 2, 3, 5, 6, 7, 10] with {@code nextValFun = i -> i + 1} will be compacted to [1-3, 5-7, 10].
 *
 * @param col        Collection of numbers.
 * @param nextValFun Function to get nearby number.
 * @param <T>        Comparable number type.
 * @return Compacted string representation of given collections.
 */
public static <T extends Number & Comparable<? super T>> String compact(Collection<T> col, Function<T, T> nextValFun) {
    assert nonNull(col);
    assert nonNull(nextValFun);
    if (col.isEmpty()) {
        return "[]";
    }
    IgniteStringBuilder sb = new IgniteStringBuilder();
    sb.app('[');
    List<T> l = new ArrayList<>(col);
    Collections.sort(l);
    T left = l.get(0);
    T right = left;
    for (int i = 1; i < l.size(); i++) {
        T val = l.get(i);
        if (right.compareTo(val) == 0 || nextValFun.apply(right).compareTo(val) == 0) {
            right = val;
            continue;
        }
        if (left.compareTo(right) == 0) {
            sb.app(left);
        } else {
            sb.app(left).app('-').app(right);
        }
        sb.app(',').app(' ');
        left = right = val;
    }
    if (left.compareTo(right) == 0) {
        sb.app(left);
    } else {
        sb.app(left).app('-').app(right);
    }
    sb.app(']');
    return sb.toString();
}
Also used : IgniteStringBuilder(org.apache.ignite.lang.IgniteStringBuilder) IGNITE_TO_STRING_COLLECTION_LIMIT(org.apache.ignite.lang.IgniteSystemProperties.IGNITE_TO_STRING_COLLECTION_LIMIT) ArrayList(java.util.ArrayList)

Aggregations

IgniteStringBuilder (org.apache.ignite.lang.IgniteStringBuilder)4 ArrayList (java.util.ArrayList)1 IgniteInternalCheckedException (org.apache.ignite.lang.IgniteInternalCheckedException)1 IGNITE_TO_STRING_COLLECTION_LIMIT (org.apache.ignite.lang.IgniteSystemProperties.IGNITE_TO_STRING_COLLECTION_LIMIT)1