org.apache.arrow.vector.types.UnionMode Java Examples

The following examples show how to use org.apache.arrow.vector.types.UnionMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArrowTypeSerDe.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
@Override
protected ArrowType doTypedDeserialize(JsonParser jparser, DeserializationContext ctxt)
        throws IOException
{
    UnionMode mode = UnionMode.valueOf(getNextStringField(jparser, MODE_FIELD));
    assertFieldName(jparser, TYPE_IDS_FIELD);
    ImmutableList.Builder<Integer> typeIds = ImmutableList.builder();
    while (jparser.nextToken() != JsonToken.END_ARRAY) {
        typeIds.add(jparser.getValueAsInt());
    }
    return new ArrowType.Union(mode, Ints.toArray(typeIds.build()));
}
 
Example #2
Source File: CompleteType.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public static CompleteType union(Iterable<Field> fields){
  ImmutableList<Field> listOfFields = ImmutableList.copyOf(fields);
  int[] typeIds = new int[listOfFields.size()];
  for (int i =0; i < typeIds.length; i++) {
    typeIds[i] = MajorTypeHelper.getArrowMinorType(CompleteType.fromField(listOfFields.get(i)).toMinorType()).ordinal();
  }
  return new CompleteType(new ArrowType.Union(UnionMode.Sparse, typeIds), listOfFields);
}
 
Example #3
Source File: CompleteType.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public static <T extends ValueHolder> CompleteType fromHolderClass(Class<T> holderClass){
    if (holderClass.equals(IntHolder.class)) {
      return CompleteType.INT;
    } else if (holderClass.equals(NullableIntHolder.class)) {
      return CompleteType.INT;
    } else if (holderClass.equals(Float4Holder.class)) {
      return CompleteType.FLOAT;
    } else if (holderClass.equals(NullableFloat4Holder.class)) {
      return CompleteType.FLOAT;
    } else if (holderClass.equals(IntervalYearHolder.class)) {
      return CompleteType.INTERVAL_YEAR_MONTHS;
    } else if (holderClass.equals(NullableIntervalYearHolder.class)) {
      return CompleteType.INTERVAL_YEAR_MONTHS;
    } else if (holderClass.equals(TimeMilliHolder.class)) {
      return CompleteType.TIME;
    } else if (holderClass.equals(NullableTimeMilliHolder.class)) {
      return CompleteType.TIME;
    } else if (holderClass.equals(BigIntHolder.class)) {
      return CompleteType.BIGINT;
    } else if (holderClass.equals(NullableBigIntHolder.class)) {
      return CompleteType.BIGINT;
    } else if (holderClass.equals(Float8Holder.class)) {
      return CompleteType.DOUBLE;
    } else if (holderClass.equals(NullableFloat8Holder.class)) {
      return CompleteType.DOUBLE;
    } else if (holderClass.equals(DateMilliHolder.class)) {
      return CompleteType.DATE;
    } else if (holderClass.equals(NullableDateMilliHolder.class)) {
      return CompleteType.DATE;
    } else if (holderClass.equals(TimeStampMilliHolder.class)) {
      return CompleteType.TIMESTAMP;
    } else if (holderClass.equals(NullableTimeStampMilliHolder.class)) {
      return CompleteType.TIMESTAMP;
    } else if (holderClass.equals(IntervalDayHolder.class)) {
      return CompleteType.INTERVAL_DAY_SECONDS;
    } else if (holderClass.equals(NullableIntervalDayHolder.class)) {
      return CompleteType.INTERVAL_DAY_SECONDS;
    } else if (holderClass.equals(DecimalHolder.class)) {
      return CompleteType.fromDecimalPrecisionScale(0, 0);
    } else if (holderClass.equals(NullableDecimalHolder.class)) {
      return CompleteType.fromDecimalPrecisionScale(0, 0);
    } else if (holderClass.equals(VarBinaryHolder.class)) {
      return CompleteType.VARBINARY;
    } else if (holderClass.equals(NullableVarBinaryHolder.class)) {
      return CompleteType.VARBINARY;
    } else if (holderClass.equals(VarCharHolder.class)) {
      return CompleteType.VARCHAR;
    } else if (holderClass.equals(NullableVarCharHolder.class)) {
      return CompleteType.VARCHAR;
    } else if (holderClass.equals(BitHolder.class)) {
      return CompleteType.BIT;
    } else if (holderClass.equals(NullableBitHolder.class)) {
      return CompleteType.BIT;
    } else if (holderClass.equals(ObjectHolder.class)) {
      return CompleteType.OBJECT;
    } else if (holderClass.equals(UnionHolder.class)) {
      return new CompleteType(new Union(UnionMode.Sparse, new int[0]));
    } else if (holderClass.equals(NullableFixedSizeBinaryHolder.class)) {
      return CompleteType.FIXEDSIZEBINARY;
    }

    throw new UnsupportedOperationException(String.format("%s is not supported for 'getValueHolderType' method.", holderClass.getName()));

}