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); }
public static Block createTestBlock() { BlockBuilder blockBuilder = DATE.createBlockBuilder(null, 15); DATE.writeLong(blockBuilder, 1111); DATE.writeLong(blockBuilder, 1111); DATE.writeLong(blockBuilder, 1111); DATE.writeLong(blockBuilder, 2222); DATE.writeLong(blockBuilder, 2222); DATE.writeLong(blockBuilder, 2222); DATE.writeLong(blockBuilder, 2222); DATE.writeLong(blockBuilder, 2222); DATE.writeLong(blockBuilder, 3333); DATE.writeLong(blockBuilder, 3333); DATE.writeLong(blockBuilder, 4444); return blockBuilder.build(); }
private static boolean filter(Page page, int position) { Block discountBlock = page.getBlock(0); Block shipDateBlock = page.getBlock(1); Block quantityBlock = page.getBlock(2); return !shipDateBlock.isNull(position) && DATE.getLong(shipDateBlock, position) >= MIN_SHIP_DATE && !shipDateBlock.isNull(position) && DATE.getLong(shipDateBlock, position) < MAX_SHIP_DATE && !discountBlock.isNull(position) && DOUBLE.getDouble(discountBlock, position) >= 0.05 && !discountBlock.isNull(position) && DOUBLE.getDouble(discountBlock, position) <= 0.07 && !quantityBlock.isNull(position) && BIGINT.getLong(quantityBlock, position) < 24; } }
public static Block createDateSequenceBlock(int start, int end) { BlockBuilder builder = DATE.createFixedSizeBlockBuilder(end - start); for (int i = start; i < end; i++) { DATE.writeLong(builder, i); } return builder.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); } }
boolean value = booleanPartitionKey(partitionKey.getValue(), name); for (int i = 0; i < MAX_VECTOR_LENGTH; i++) { BOOLEAN.writeBoolean(blockBuilder, value); long value = bigintPartitionKey(partitionKey.getValue(), name); for (int i = 0; i < MAX_VECTOR_LENGTH; i++) { BIGINT.writeLong(blockBuilder, value); double value = doublePartitionKey(partitionKey.getValue(), name); for (int i = 0; i < MAX_VECTOR_LENGTH; i++) { DOUBLE.writeDouble(blockBuilder, value); long value = timestampPartitionKey(partitionKey.getValue(), hiveStorageTimeZone, name); for (int i = 0; i < MAX_VECTOR_LENGTH; i++) { TIMESTAMP.writeLong(blockBuilder, value); long value = datePartitionKey(partitionKey.getValue(), name); for (int i = 0; i < MAX_VECTOR_LENGTH; i++) { DATE.writeLong(blockBuilder, value);
.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: RealType.REAL.writeLong(builder, floatToRawIntBits(((FloatObjectInspector) inspector).get(object))); 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:
int shipDate = (int) DATE.getLong(shipDateBlock, position); long quantity = BIGINT.getLong(quantityBlock, position); double extendedPrice = DOUBLE.getDouble(extendedPriceBlock, position); double discount = DOUBLE.getDouble(discountBlock, position); double tax = DOUBLE.getDouble(taxBlock, position); BIGINT.writeLong(pageBuilder.getBlockBuilder(2), quantity);
switch (primitiveCategory) { case BOOLEAN: return BOOLEAN.getBoolean(block, position) ? 1 : 0; case BYTE: case SHORT: case INT: return Ints.checkedCast(BIGINT.getLong(block, position)); case LONG: long bigintValue = BIGINT.getLong(block, position); return (int) ((bigintValue >>> 32) ^ bigintValue); case FLOAT: return Float.floatToIntBits((float) DOUBLE.getDouble(block, position)); case DOUBLE: long doubleValue = doubleToLongBits(DOUBLE.getDouble(block, position)); return (int) ((doubleValue >>> 32) ^ doubleValue); case STRING: case DATE: long days = DATE.getLong(block, position); return Ints.checkedCast(days); case TIMESTAMP: long millisSinceEpoch = TIMESTAMP.getLong(block, position);
int shipDate = (int) DATE.getLong(shipDateBlock, position); double quantity = DOUBLE.getDouble(quantityBlock, position); double extendedPrice = DOUBLE.getDouble(extendedPriceBlock, position); double discount = DOUBLE.getDouble(discountBlock, position); double tax = DOUBLE.getDouble(taxBlock, position);
switch (column.getType()) { case BIGINT: BIGINT.writeLong(blockBuilder, column.getLong(lineItem)); break; case DATE: DATE.writeLong(blockBuilder, column.getDate(lineItem)); break; case DOUBLE: DOUBLE.writeDouble(blockBuilder, column.getDouble(lineItem)); break; case VARCHAR:
@Override public Block toBlock(Type desiredType) { checkArgument(DATE.equals(desiredType), "type doesn't match: %s", desiredType); int numberOfRecords = numberOfRecords(); return new IntArrayBlock( numberOfRecords, Optional.ofNullable(nulls), dates == null ? new int[numberOfRecords] : dates); }
private static Page createInputPage(int positions, List<Type> types) { PageBuilder pageBuilder = new PageBuilder(types); LineItemGenerator lineItemGenerator = new LineItemGenerator(1, 1, 1); Iterator<LineItem> iterator = lineItemGenerator.iterator(); for (int i = 0; i < positions; i++) { pageBuilder.declarePosition(); LineItem lineItem = iterator.next(); DOUBLE.writeDouble(pageBuilder.getBlockBuilder(EXTENDED_PRICE), lineItem.getExtendedPrice()); DOUBLE.writeDouble(pageBuilder.getBlockBuilder(DISCOUNT), lineItem.getDiscount()); DATE.writeLong(pageBuilder.getBlockBuilder(SHIP_DATE), lineItem.getShipDate()); DOUBLE.writeDouble(pageBuilder.getBlockBuilder(QUANTITY), lineItem.getQuantity()); } return pageBuilder.build(); } }
@Override Object extractValue(Block block, int position) { return DATE.getLong(block, position); }
public int getDay(Type type, Block block, int position) { if (type.equals(DATE)) { return toIntExact(DATE.getLong(block, position)); } if (type.equals(TIMESTAMP)) { long millis = TIMESTAMP.getLong(block, position); long local = timeZone.convertUTCToLocal(millis); long days = MILLISECONDS.toDays(local); return toIntExact(days); } throw new IllegalArgumentException("Wrong type for temporal column: " + type); }
@Override void writeNextRandomValue(Random random, BlockBuilder builder) { DATE.writeLong(builder, nextDate(random)); } }
return; case FLOAT: DoubleType.DOUBLE.writeDouble(builder, ((FloatObjectInspector) inspector).get(object)); 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:
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: