Refine search
private static boolean convertibleToDoubleWithCast(Type type) { return type instanceof DecimalType || DoubleType.DOUBLE.equals(type) || RealType.REAL.equals(type) || BigintType.BIGINT.equals(type) || IntegerType.INTEGER.equals(type) || SmallintType.SMALLINT.equals(type) || TinyintType.TINYINT.equals(type) || BooleanType.BOOLEAN.equals(type); } }
@Override void writeNextRandomValue(Random random, BlockBuilder builder) { INTEGER.writeLong(builder, random.nextInt()); } }
double radius = radiusChannel.map(channel -> DOUBLE.getDouble(channels.get(channel).get(blockIndex), blockPosition)).orElse(0.0); if (radius < 0) { continue; if (partitionChannel.isPresent()) { Block partitionBlock = channels.get(partitionChannel.get()).get(blockIndex); partition = toIntExact(INTEGER.getLong(partitionBlock, blockPosition));
public static Block createTestBlock() { BlockBuilder blockBuilder = INTEGER.createBlockBuilder(null, 15); INTEGER.writeLong(blockBuilder, 1111); INTEGER.writeLong(blockBuilder, 1111); INTEGER.writeLong(blockBuilder, 1111); INTEGER.writeLong(blockBuilder, 2222); INTEGER.writeLong(blockBuilder, 2222); INTEGER.writeLong(blockBuilder, 2222); INTEGER.writeLong(blockBuilder, 2222); INTEGER.writeLong(blockBuilder, 2222); INTEGER.writeLong(blockBuilder, 3333); INTEGER.writeLong(blockBuilder, 3333); INTEGER.writeLong(blockBuilder, 4444); return blockBuilder.build(); }
@Override protected Object getGreaterValue(Object value) { Block block = (Block) value; BlockBuilder blockBuilder = INTEGER.createBlockBuilder(null, block.getPositionCount() + 1); for (int i = 0; i < block.getPositionCount(); i++) { INTEGER.appendTo(block, i, blockBuilder); } INTEGER.writeLong(blockBuilder, 1L); return blockBuilder.build(); } }
private static void serializePrimitive(Type type, BlockBuilder builder, Object object) { requireNonNull(builder, "parent builder is null"); if (object == null) { builder.appendNull(); return; } if (BOOLEAN.equals(type)) { BOOLEAN.writeBoolean(builder, (Boolean) object); } else if (BIGINT.equals(type) || INTEGER.equals(type) || SMALLINT.equals(type) || TINYINT.equals(type) || REAL.equals(type) || DATE.equals(type) || TIMESTAMP.equals(type)) { type.writeLong(builder, getLongExpressedValue(object)); } else if (DOUBLE.equals(type)) { DOUBLE.writeDouble(builder, ((Number) object).doubleValue()); } else if (isVarcharType(type) || VARBINARY.equals(type) || isCharType(type)) { type.writeSlice(builder, getSliceExpressedValue(object, type)); } else { throw new UnsupportedOperationException("Unsupported primitive type: " + type); } }
.map(type -> format.supportsDate() || !DATE.equals(type) ? type : createUnboundedVarcharType()) .collect(toList()); switch (column.getType().getBase()) { case IDENTIFIER: BIGINT.writeLong(blockBuilder, column.getIdentifier(row)); break; case INTEGER: INTEGER.writeLong(blockBuilder, column.getInteger(row)); break; case DATE: if (format.supportsDate()) { DATE.writeLong(blockBuilder, column.getDate(row)); DOUBLE.writeDouble(blockBuilder, column.getDouble(row)); break; case VARCHAR:
BooleanType.BOOLEAN.writeBoolean(builder, ((BooleanObjectInspector) inspector).get(object)); return; case BYTE: return; case INT: IntegerType.INTEGER.writeLong(builder, ((IntObjectInspector) inspector).get(object)); return; case LONG: BigintType.BIGINT.writeLong(builder, ((LongObjectInspector) inspector).get(object)); return; case FLOAT: return; case DOUBLE: DoubleType.DOUBLE.writeDouble(builder, ((DoubleObjectInspector) inspector).get(object)); return; case STRING: return; case DATE: DateType.DATE.writeLong(builder, formatDateAsLong(object, (DateObjectInspector) inspector)); return; case TIMESTAMP: TimestampType.TIMESTAMP.writeLong(builder, formatTimestampAsLong(object, (TimestampObjectInspector) inspector)); return; case BINARY:
@Override public Block toBlock(Type desiredType) { checkArgument(INTEGER.equals(desiredType), "type doesn't match: %s", desiredType); int numberOfRecords = numberOfRecords(); return new IntArrayBlock( numberOfRecords, Optional.ofNullable(nulls), ints == null ? new int[numberOfRecords] : ints); }
@Override Object extractValue(Block block, int position) { return INTEGER.getLong(block, position); }
switch (column.getType().getBase()) { case IDENTIFIER: BIGINT.writeLong(blockBuilder, column.getIdentifier(lineItem)); break; case INTEGER: INTEGER.writeLong(blockBuilder, column.getInteger(lineItem)); break; case DATE: DATE.writeLong(blockBuilder, column.getDate(lineItem)); break; case DOUBLE: DOUBLE.writeDouble(blockBuilder, column.getDouble(lineItem)); break; case VARCHAR:
private StateField(String name, Class<?> type, Object initialValue, String getterName, Optional<Type> sqlType) { this.name = requireNonNull(name, "name is null"); checkArgument(!name.isEmpty(), "name is empty"); this.type = requireNonNull(type, "type is null"); this.getterName = requireNonNull(getterName, "getterName is null"); this.initialValue = initialValue; checkArgument(sqlType != null, "sqlType is null"); if (sqlType.isPresent()) { checkArgument( (sqlType.get().getJavaType() == type) || ((type == byte.class) && TINYINT.equals(sqlType.get())) || ((type == int.class) && INTEGER.equals(sqlType.get())), "Stack type (%s) and provided sql type (%s) are incompatible", type.getName(), sqlType.get().getDisplayName()); } else { sqlType = sqlTypeFromStackType(type); } this.sqlType = sqlType; }
@Override public void setField(Block block, int position) { value.set(toIntExact(IntegerType.INTEGER.getLong(block, position))); rowInspector.setStructFieldData(row, field, value); } }
public static Block createIntsBlock(Iterable<Integer> values) { BlockBuilder builder = INTEGER.createBlockBuilder(null, 100); for (Integer value : values) { if (value == null) { builder.appendNull(); } else { INTEGER.writeLong(builder, value); } } return builder.build(); }
private static Class<?> getMapKeyType(Type type) { if (VarcharType.VARCHAR.equals(type)) { return String.class; } if (BooleanType.BOOLEAN.equals(type)) { return Boolean.class; } if (BigintType.BIGINT.equals(type)) { return Long.class; } if (IntegerType.INTEGER.equals(type)) { return Integer.class; } if (DoubleType.DOUBLE.equals(type)) { return Double.class; } throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property map key type %s is not supported", type)); }
.map(type -> format.supportsDate() || !DATE.equals(type) ? type : createUnboundedVarcharType()) .collect(toList()); switch (column.getType().getBase()) { case IDENTIFIER: BIGINT.writeLong(blockBuilder, column.getIdentifier(row)); break; case INTEGER: INTEGER.writeLong(blockBuilder, column.getInteger(row)); break; case DATE: if (format.supportsDate()) { DATE.writeLong(blockBuilder, column.getDate(row)); DOUBLE.writeDouble(blockBuilder, column.getDouble(row)); break; case VARCHAR:
@Override public void append(JsonParser parser, BlockBuilder blockBuilder) throws IOException { Long result = currentTokenAsInteger(parser); if (result == null) { blockBuilder.appendNull(); } else { INTEGER.writeLong(blockBuilder, result); } } }
@SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = StandardTypes.INTEGER, nativeContainerType = long.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = StandardTypes.INTEGER, nativeContainerType = long.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } return notEqual(INTEGER.getLong(left, leftPosition), INTEGER.getLong(right, rightPosition)); } }
private static boolean isValidPartitionType(Type type) { return type instanceof DecimalType || BOOLEAN.equals(type) || TINYINT.equals(type) || SMALLINT.equals(type) || INTEGER.equals(type) || BIGINT.equals(type) || REAL.equals(type) || DOUBLE.equals(type) || DATE.equals(type) || TIMESTAMP.equals(type) || isVarcharType(type) || isCharType(type); }
switch (column.getType().getBase()) { case IDENTIFIER: BIGINT.writeLong(blockBuilder, column.getIdentifier(lineItem)); break; case INTEGER: INTEGER.writeLong(blockBuilder, column.getInteger(lineItem)); break; case DATE: DATE.writeLong(blockBuilder, column.getDate(lineItem)); break; case DOUBLE: DOUBLE.writeDouble(blockBuilder, column.getDouble(lineItem)); break; case VARCHAR: