public void add(int fieldIndex, Binary value) { switch (this.getType().getType(fieldIndex).asPrimitiveType().getPrimitiveTypeName()) { case BINARY: this.add(fieldIndex, new BinaryValue(value)); break; case INT96: this.add(fieldIndex, new Int96Value(value)); break; default: throw new UnsupportedOperationException( this.getType().asPrimitiveType().getName() + " not supported for Binary"); } }
/** * {@inheritDoc} */ @Override public void writeToStringBuilder(StringBuilder sb, String indent) { sb.append(indent) .append(getRepetition().name().toLowerCase()) .append(" ") .append(primitive.name().toLowerCase()) .append(" ") .append(getName()); if (getOriginalType() != null) { sb.append(" (").append(getOriginalType()).append(")"); } }
/** * {@inheritDoc} */ @Override protected int typeHashCode() { int hash = 17; hash += 31 * getRepetition().hashCode(); hash += 31 * getPrimitiveTypeName().hashCode(); hash += 31 * getName().hashCode(); return hash; }
private void writePrimitive(TupleEntry record, PrimitiveType field) { switch (field.getPrimitiveTypeName()) { case BINARY: recordConsumer.addBinary(Binary.fromString(record.getString(field.getName()))); break; case BOOLEAN: recordConsumer.addBoolean(record.getBoolean(field.getName())); break; case INT32: recordConsumer.addInteger(record.getInteger(field.getName())); break; case INT64: recordConsumer.addLong(record.getLong(field.getName())); break; case DOUBLE: recordConsumer.addDouble(record.getDouble(field.getName())); break; case FLOAT: recordConsumer.addFloat(record.getFloat(field.getName())); break; case FIXED_LEN_BYTE_ARRAY: throw new UnsupportedOperationException("Fixed len byte array type not implemented"); case INT96: throw new UnsupportedOperationException("Int96 type not implemented"); default: throw new UnsupportedOperationException(field.getName() + " type not implemented"); } } }
/** * {@inheritDoc} */ @Override public void writeToStringBuilder(StringBuilder sb, String indent) { sb.append(indent) .append(getRepetition().name().toLowerCase()) .append(" ") .append(primitive.name().toLowerCase()); if (primitive == PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY) { sb.append("(" + length + ")"); } sb.append(" ").append(getName()); if (getOriginalType() != null) { sb.append(" (").append(getOriginalType()); DecimalMetadata meta = getDecimalMetadata(); if (meta != null) { sb.append("(") .append(meta.getPrecision()) .append(",") .append(meta.getScale()) .append(")"); } sb.append(")"); } if (getId() != null) { sb.append(" = ").append(getId()); } }
/** * {@inheritDoc} */ @Override protected boolean typeEquals(Type other) { if (other.isPrimitive()) { PrimitiveType primitiveType = other.asPrimitiveType(); return getRepetition() == primitiveType.getRepetition() && getPrimitiveTypeName().equals(primitiveType.getPrimitiveTypeName()) && getName().equals(primitiveType.getName()); } else { return false; } }
private static void showDetails(PrettyPrintWriter out, PrimitiveType type, int depth, MessageType container, List<String> cpath) { String name = Strings.repeat(".", depth) + type.getName(); OriginalType otype = type.getOriginalType(); Repetition rep = type.getRepetition(); PrimitiveTypeName ptype = type.getPrimitiveTypeName(); out.format("%s: %s %s", name, rep, ptype); if (otype != null) out.format(" O:%s", otype); if (container != null) { cpath.add(type.getName()); String[] paths = cpath.toArray(new String[cpath.size()]); cpath.remove(cpath.size() - 1); ColumnDescriptor desc = container.getColumnDescription(paths); int defl = desc.getMaxDefinitionLevel(); int repl = desc.getMaxRepetitionLevel(); out.format(" R:%d D:%d", repl, defl); } out.println(); }
/** * @param id the field id * @return a new PrimitiveType with the same fields and a new id */ @Override public PrimitiveType withId(int id) { return new PrimitiveType(getRepetition(), primitive, length, getName(), getOriginalType(), decimalMeta, new ID(id)); }
public void add(int fieldIndex, Binary value) { switch (this.getType().getType(fieldIndex).asPrimitiveType().getPrimitiveTypeName()) { case BINARY: this.add(fieldIndex, new BinaryValue(value)); break; case INT96: this.add(fieldIndex, new Int96Value(value)); break; default: throw new UnsupportedOperationException( this.getType().asPrimitiveType().getName() + " not supported for Binary"); } }
@Override public void add(int fieldIndex, Binary value) { switch (getType().getType(fieldIndex).asPrimitiveType().getPrimitiveTypeName()) { case BINARY: case FIXED_LEN_BYTE_ARRAY: add(fieldIndex, new BinaryValue(value)); break; case INT96: add(fieldIndex, new Int96Value(value)); break; default: throw new UnsupportedOperationException( getType().asPrimitiveType().getName() + " not supported for Binary"); } }
@Override protected Type union(Type toMerge, boolean strict) { if (!toMerge.isPrimitive() || (strict && !primitive.equals(toMerge.asPrimitiveType().getPrimitiveTypeName()))) { throw new IncompatibleSchemaModificationException("can not merge type " + toMerge + " into " + this); } Types.PrimitiveBuilder<PrimitiveType> builder = Types.primitive( primitive, toMerge.getRepetition()); if (PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY == primitive) { builder.length(length); } return builder.named(getName()); } }
@Override public void visit(PrimitiveType primitiveType) { SchemaElement element = new SchemaElement(primitiveType.getName()); element.setRepetition_type(toParquetRepetition(primitiveType.getRepetition())); element.setType(getType(primitiveType.getPrimitiveTypeName())); if (primitiveType.getOriginalType() != null) { element.setConverted_type(getConvertedType(primitiveType.getOriginalType())); } if (primitiveType.getDecimalMetadata() != null) { element.setPrecision(primitiveType.getDecimalMetadata().getPrecision()); element.setScale(primitiveType.getDecimalMetadata().getScale()); } if (primitiveType.getTypeLength() > 0) { element.setType_length(primitiveType.getTypeLength()); } result.add(element); }