本文整理了Java中com.facebook.presto.spi.block.Block.getObject()
方法的一些代码示例,展示了Block.getObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getObject()
方法的具体详情如下:
包路径:com.facebook.presto.spi.block.Block
类名称:Block
方法名:getObject
[英]Gets an object in the value at position.
[中]获取位置处的值中的对象。
代码示例来源:origin: prestodb/presto
@Override
public <T> T getObject(int position, Class<T> clazz)
{
return block.getObject(position, clazz);
}
代码示例来源:origin: prestodb/presto
@Override
public Block getObject(Block block, int position)
{
return block.getObject(position, Block.class);
}
代码示例来源:origin: prestodb/presto
@Override
public Block getObject(Block block, int position)
{
return block.getObject(position, Block.class);
}
代码示例来源:origin: prestodb/presto
@Override
public Block getObject(Block block, int position)
{
return block.getObject(position, Block.class);
}
代码示例来源:origin: prestodb/presto
@Override
public <T> T getObject(int position, Class<T> clazz)
{
return dictionary.getObject(getId(position), clazz);
}
代码示例来源:origin: prestodb/presto
@Override
public <T> T getObject(int position, Class<T> clazz)
{
checkReadablePosition(position);
return value.getObject(0, clazz);
}
代码示例来源:origin: prestodb/presto
@Override
public <T> T getObject(int position, Class<T> clazz)
{
assureLoaded();
return block.getObject(position, clazz);
}
代码示例来源:origin: prestodb/presto
@Override
public <T> T getObject(int position, Class<T> clazz)
{
position = getAbsolutePosition(position);
if (position % 2 == 0) {
return getRawKeyBlock().getObject(position / 2, clazz);
}
else {
return getRawValueBlock().getObject(position / 2, clazz);
}
}
代码示例来源:origin: prestodb/presto
@Override
public void setField(Block block, int position)
{
Block rowBlock = block.getObject(position, Block.class);
// TODO reuse row object and use FieldSetters, like we do at the top level
// Ideally, we'd use the same recursive structure starting from the top, but
// this requires modeling row types in the same way we model table rows
// (multiple blocks vs all fields packed in a single block)
List<Object> value = new ArrayList<>(fieldTypes.size());
for (int i = 0; i < fieldTypes.size(); i++) {
Object element = getField(fieldTypes.get(i), rowBlock, i);
value.add(element);
}
rowInspector.setStructFieldData(row, field, value);
}
}
代码示例来源:origin: prestodb/presto
@Override
public <T> T getObject(int position, Class<T> clazz)
{
checkFieldIndex(position);
return getRawFieldBlock(position).getObject(rowIndex, clazz);
}
代码示例来源:origin: prestodb/presto
@Override
public <T> T getObject(int position, Class<T> clazz)
{
checkReadablePosition(position);
return getBlock().getObject(position + start, clazz);
}
代码示例来源:origin: prestodb/presto
@Override
public long hash(Block block, int position)
{
Block arrayBlock = block.getObject(position, Block.class);
long result = 1;
for (int i = 0; i < arrayBlock.getPositionCount(); i++) {
Type elementType = fields.get(i).getType();
result = 31 * result + TypeUtils.hashPosition(elementType, arrayBlock, i);
}
return result;
}
代码示例来源:origin: prestodb/presto
@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
if (block.isNull(position)) {
return null;
}
Block singleMapBlock = block.getObject(position, Block.class);
if (!(singleMapBlock instanceof SingleMapBlock)) {
throw new UnsupportedOperationException("Map is encoded with legacy block representation");
}
Map<Object, Object> map = new HashMap<>();
for (int i = 0; i < singleMapBlock.getPositionCount(); i += 2) {
map.put(keyType.getObjectValue(session, singleMapBlock, i), valueType.getObjectValue(session, singleMapBlock, i + 1));
}
return Collections.unmodifiableMap(map);
}
代码示例来源:origin: prestodb/presto
@Override
public void setField(Block block, int position)
{
Block arrayBlock = block.getObject(position, Block.class);
List<Object> list = new ArrayList<>(arrayBlock.getPositionCount());
for (int i = 0; i < arrayBlock.getPositionCount(); i++) {
Object element = getField(elementType, arrayBlock, i);
list.add(element);
}
rowInspector.setStructFieldData(row, field, list);
}
}
代码示例来源:origin: prestodb/presto
@Override
public void setField(Block block, int position)
{
Block mapBlock = block.getObject(position, Block.class);
Map<Object, Object> map = new HashMap<>(mapBlock.getPositionCount() * 2);
for (int i = 0; i < mapBlock.getPositionCount(); i += 2) {
Object key = getField(keyType, mapBlock, i);
Object value = getField(valueType, mapBlock, i + 1);
map.put(key, value);
}
rowInspector.setStructFieldData(row, field, map);
}
}
代码示例来源:origin: prestodb/presto
@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;
}
代码示例来源:origin: prestodb/presto
private static boolean equals(Block block1, Block block2)
{
boolean retval = block1.getPositionCount() == block2.getPositionCount();
for (int i = 0; i < block1.getPositionCount() && retval; ++i) {
if (block1 instanceof ArrayBlock && block2 instanceof ArrayBlock) {
retval = equals(block1.getObject(i, Block.class), block2.getObject(i, Block.class));
}
else {
retval = block1.compareTo(i, 0, block1.getSliceLength(i), block2, i, 0, block2.getSliceLength(i)) == 0;
}
}
return retval;
}
代码示例来源:origin: prestodb/presto
@Override
public boolean equalTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
Block leftArray = leftBlock.getObject(leftPosition, Block.class);
Block rightArray = rightBlock.getObject(rightPosition, Block.class);
if (leftArray.getPositionCount() != rightArray.getPositionCount()) {
return false;
}
for (int i = 0; i < leftArray.getPositionCount(); i++) {
checkElementNotNull(leftArray.isNull(i), ARRAY_NULL_ELEMENT_MSG);
checkElementNotNull(rightArray.isNull(i), ARRAY_NULL_ELEMENT_MSG);
if (!elementType.equalTo(leftArray, i, rightArray, i)) {
return false;
}
}
return true;
}
代码示例来源:origin: prestodb/presto
@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
if (block.isNull(position)) {
return null;
}
if (block instanceof AbstractArrayBlock) {
return ((AbstractArrayBlock) block).apply((valuesBlock, start, length) -> arrayBlockToObjectValues(session, valuesBlock, start, length), position);
}
else {
Block arrayBlock = block.getObject(position, Block.class);
return arrayBlockToObjectValues(session, arrayBlock, 0, arrayBlock.getPositionCount());
}
}
代码示例来源:origin: prestodb/presto
private static Block copyBlockViaWriteStructure(Block block, Supplier<BlockBuilder> newBlockBuilder)
{
BlockBuilder blockBuilder = newBlockBuilder.get();
for (int i = 0; i < block.getPositionCount(); i++) {
if (block.isNull(i)) {
blockBuilder.appendNull();
}
else {
blockBuilder.appendStructure(block.getObject(i, Block.class));
}
}
return blockBuilder.build();
}
内容来源于网络,如有侵权,请联系作者删除!