Java Code Examples for org.apache.spark.unsafe.types.UTF8String#getBaseObject()

The following examples show how to use org.apache.spark.unsafe.types.UTF8String#getBaseObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RSIndex_CMap.java    From indexr with Apache License 2.0 6 votes vote down vote up
public static byte _isLike(long packAddr, LikePattern pattern) {
    // We can exclude cases like "ala%" and "a_l_a%"

    UTF8String original = pattern.original;
    int bytes = original.numBytes();
    Object valueBase = original.getBaseObject();
    long valueOffset = original.getBaseOffset();
    int indexSize = bytes < POSISTIONS ? bytes : POSISTIONS;

    for (int pos = 0; pos < indexSize; pos++) {
        byte c = Platform.getByte(valueBase, valueOffset + pos);
        // The ESCAPE_CHARACTOR case can be optimized. But I'm too lazy...
        if (c == '%' || c == ESCAPE_CHARACTOR) {
            break;
        }
        if (c != '_' && !isSet(packAddr, c, pos)) {
            return RSValue.None;
        }
    }
    return RSValue.Some;
}
 
Example 2
Source File: RSIndex_CMap_V2.java    From indexr with Apache License 2.0 6 votes vote down vote up
static void _putValue(long packAddr, UTF8String value) {
    int valueSize = value.numBytes();
    Object valueBase = value.getBaseObject();
    long valueOffset = value.getBaseOffset();

    long offset = packAddr + indexOffsetBySize(valueSize);
    int checkSize = valueSize < MAX_POSISTIONS ? valueSize : MAX_POSISTIONS;

    if (checkSize == 0) {
        // mark empty string exists.
        set(offset, (byte) 1, 0);
    } else {
        for (int pos = 0; pos < checkSize; pos++) {
            set(offset, Platform.getByte(valueBase, valueOffset + pos), pos);
        }
    }
}
 
Example 3
Source File: RSIndex_CMap_V2.java    From indexr with Apache License 2.0 6 votes vote down vote up
static byte _isValue(long packAddr, UTF8String value) {
    int valueSize = value.numBytes();
    Object valueBase = value.getBaseObject();
    long valueOffset = value.getBaseOffset();

    long offset = packAddr + indexOffsetBySize(valueSize);
    int checkSize = valueSize < MAX_POSISTIONS ? valueSize : MAX_POSISTIONS;

    if (checkSize == 0) {
        if (!isSet(offset, (byte) 1, 0)) {
            return RSValue.None;
        }
    } else {
        for (int pos = 0; pos < checkSize; pos++) {
            if (!isSet(offset, Platform.getByte(valueBase, valueOffset + pos), pos)) {
                return RSValue.None;
            }
        }
    }
    return RSValue.Some;
}
 
Example 4
Source File: DPValues.java    From indexr with Apache License 2.0 5 votes vote down vote up
/**
 * The memory <code>bytes</code> pointed to should considered being freed or changed at any time.
 */
default void rawValueAt(int index, BytePiece bytes) {
    UTF8String string = stringValueAt(index);
    bytes.base = string.getBaseObject();
    bytes.addr = string.getBaseOffset();
    bytes.len = string.numBytes();
}
 
Example 5
Source File: RSIndex_CMap.java    From indexr with Apache License 2.0 5 votes vote down vote up
private static void _putValue(long packAddr, UTF8String value) {
    int bytes = value.numBytes();
    Object valueBase = value.getBaseObject();
    long valueOffset = value.getBaseOffset();
    int indexSize = bytes < POSISTIONS ? bytes : POSISTIONS;

    for (int pos = 0; pos < indexSize; pos++) {
        set(packAddr, Platform.getByte(valueBase, valueOffset + pos), pos);
    }
}
 
Example 6
Source File: RSIndex_CMap.java    From indexr with Apache License 2.0 5 votes vote down vote up
private static byte _isValue(long packAddr, UTF8String value) {
    int bytes = value.numBytes();
    Object valueBase = value.getBaseObject();
    long valueOffset = value.getBaseOffset();
    int indexSize = bytes < POSISTIONS ? bytes : POSISTIONS;

    for (int pos = 0; pos < indexSize; pos++) {
        if (!isSet(packAddr, Platform.getByte(valueBase, valueOffset + pos), pos)) {
            return RSValue.None;
        }
    }
    return RSValue.Some;
}