当前位置: 首页>>代码示例>>Java>>正文


Java Type.equalTo方法代码示例

本文整理汇总了Java中com.facebook.presto.spi.type.Type.equalTo方法的典型用法代码示例。如果您正苦于以下问题:Java Type.equalTo方法的具体用法?Java Type.equalTo怎么用?Java Type.equalTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.presto.spi.type.Type的用法示例。


在下文中一共展示了Type.equalTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapBlocksEqual

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static boolean mapBlocksEqual(Type keyType, Type valueType, Block block1, Block block2)
{
    if (block1.getPositionCount() != block2.getPositionCount()) {
        return false;
    }
    for (int i = 0; i < block1.getPositionCount(); i += 2) {
        if (block1.isNull(i) != block2.isNull(i) || block1.isNull(i + 1) != block2.isNull(i + 1)) {
            return false;
        }
        if (!block1.isNull(i) && !keyType.equalTo(block1, i, block2, i)) {
            return false;
        }
        if (!block1.isNull(i + 1) && !valueType.equalTo(block1, i + 1, block2, i + 1)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:StructuralTestUtil.java

示例2: distinct

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static Block distinct(Type type, Block array)
{
    if (array.getPositionCount() < 2) {
        return array;
    }

    if (array.getPositionCount() == 2) {
        if (type.equalTo(array, 0, array, 1)) {
            return array.getSingleValueBlock(0);
        }
        else {
            return array;
        }
    }

    TypedSet typedSet = new TypedSet(type, array.getPositionCount());
    BlockBuilder distinctElementBlockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), array.getPositionCount());
    for (int i = 0; i < array.getPositionCount(); i++) {
        if (!typedSet.contains(array, i)) {
            typedSet.add(array, i);
            type.appendTo(array, i, distinctElementBlockBuilder);
        }
    }

    return distinctElementBlockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:ArrayDistinctFunction.java

示例3: equalTo

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
    Block leftRow = leftBlock.getObject(leftPosition, Block.class);
    Block rightRow = rightBlock.getObject(rightPosition, Block.class);

    for (int i = 0; i < leftRow.getPositionCount(); i++) {
        checkElementNotNull(leftRow.isNull(i));
        checkElementNotNull(rightRow.isNull(i));
        Type fieldType = fields.get(i).getType();
        if (!fieldType.equalTo(leftRow, i, rightRow, i)) {
            return false;
        }
    }

    return true;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:RowType.java

示例4: arrayBlocksEqual

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static boolean arrayBlocksEqual(Type elementType, Block block1, Block block2)
{
    if (block1.getPositionCount() != block2.getPositionCount()) {
        return false;
    }
    for (int i = 0; i < block1.getPositionCount(); i++) {
        if (block1.isNull(i) != block2.isNull(i)) {
            return false;
        }
        if (!block1.isNull(i) && !elementType.equalTo(block1, i, block2, i)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:16,代码来源:StructuralTestUtil.java

示例5: matches

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private boolean matches(int position, Page page)
{
    for (int i = 0; i < outputTupleChannels.length; i++) {
        Type type = outputTypes.get(outputTupleChannels[i]);
        Block outputBlock = page.getBlock(outputTupleChannels[i]);
        Block singleTupleBlock = tuplePage.getBlock(i);
        if (!type.equalTo(singleTupleBlock, 0, outputBlock, position)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:13,代码来源:TupleFilterProcessor.java

示例6: equals

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static boolean equals(Type rowType, Block leftRow, Block rightRow)
{
    // TODO: Fix this. It feels very inefficient and unnecessary to wrap and unwrap with Block
    BlockBuilder leftBlockBuilder = rowType.createBlockBuilder(new BlockBuilderStatus(), 1);
    BlockBuilder rightBlockBuilder = rowType.createBlockBuilder(new BlockBuilderStatus(), 1);
    rowType.writeObject(leftBlockBuilder, leftRow);
    rowType.writeObject(rightBlockBuilder, rightRow);
    return rowType.equalTo(leftBlockBuilder.build(), 0, rightBlockBuilder.build(), 0);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:RowEqualOperator.java

示例7: positionEqualsPosition

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static boolean positionEqualsPosition(Type type, Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
    boolean leftIsNull = leftBlock.isNull(leftPosition);
    boolean rightIsNull = rightBlock.isNull(rightPosition);
    if (leftIsNull || rightIsNull) {
        return leftIsNull && rightIsNull;
    }
    return type.equalTo(leftBlock, leftPosition, rightBlock, rightPosition);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:TypeUtils.java

示例8: intersect

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static Block intersect(Type type, Block leftArray, Block rightArray)
{
    int leftPositionCount = leftArray.getPositionCount();
    int rightPositionCount = rightArray.getPositionCount();

    if (leftPositionCount == 0) {
        return leftArray;
    }
    if (rightPositionCount == 0) {
        return rightArray;
    }

    int[] leftPositions = new int[leftPositionCount];
    int[] rightPositions = new int[rightPositionCount];

    for (int i = 0; i < leftPositionCount; i++) {
        leftPositions[i] = i;
    }
    for (int i = 0; i < rightPositionCount; i++) {
        rightPositions[i] = i;
    }
    IntArrays.quickSort(leftPositions, IntBlockCompare(type, leftArray));
    IntArrays.quickSort(rightPositions, IntBlockCompare(type, rightArray));

    int entrySize;
    if (leftPositionCount < rightPositionCount) {
        entrySize = (int) Math.ceil(leftArray.getSizeInBytes() / (double) leftPositionCount);
    }
    else {
        entrySize = (int) Math.ceil(rightArray.getSizeInBytes() / (double) rightPositionCount);
    }
    BlockBuilder resultBlockBuilder = type.createBlockBuilder(
            new BlockBuilderStatus(),
            Math.min(leftArray.getPositionCount(), rightArray.getPositionCount()),
            entrySize);

    int leftCurrentPosition = 0;
    int rightCurrentPosition = 0;
    int leftBasePosition;
    int rightBasePosition;

    while (leftCurrentPosition < leftPositionCount && rightCurrentPosition < rightPositionCount) {
        leftBasePosition = leftCurrentPosition;
        rightBasePosition = rightCurrentPosition;
        int compareValue = type.compareTo(leftArray, leftPositions[leftCurrentPosition], rightArray, rightPositions[rightCurrentPosition]);
        if (compareValue > 0) {
            rightCurrentPosition++;
        }
        else if (compareValue < 0) {
            leftCurrentPosition++;
        }
        else {
            type.appendTo(leftArray, leftPositions[leftCurrentPosition], resultBlockBuilder);
            leftCurrentPosition++;
            rightCurrentPosition++;
            while (leftCurrentPosition < leftPositionCount && type.equalTo(leftArray, leftPositions[leftBasePosition], leftArray, leftPositions[leftCurrentPosition])) {
                leftCurrentPosition++;
            }
            while (rightCurrentPosition < rightPositionCount && type.equalTo(rightArray, rightPositions[rightBasePosition], rightArray, rightPositions[rightCurrentPosition])) {
                rightCurrentPosition++;
            }
        }
    }

    return resultBlockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:67,代码来源:ArrayIntersectFunction.java


注:本文中的com.facebook.presto.spi.type.Type.equalTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。