Java Code Examples for org.apache.arrow.vector.types.pojo.ArrowType#Utf8

The following examples show how to use org.apache.arrow.vector.types.pojo.ArrowType#Utf8 . 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: ArrowUtils.java    From konduit-serving with Apache License 2.0 6 votes vote down vote up
public static ColumnMetaData metaDataFromField(Field field) {
    ArrowType arrowType = field.getFieldType().getType();
    if (arrowType instanceof ArrowType.Int) {
        ArrowType.Int intType = (ArrowType.Int) arrowType;
        return intType.getBitWidth() == 32 ? new IntegerMetaData(field.getName()) : new LongMetaData(field.getName());
    } else if (arrowType instanceof ArrowType.Bool) {
        return new BooleanMetaData(field.getName());
    } else if (arrowType instanceof ArrowType.FloatingPoint) {
        ArrowType.FloatingPoint floatingPointType = (ArrowType.FloatingPoint) arrowType;
        return floatingPointType.getPrecision() == FloatingPointPrecision.DOUBLE ? new DoubleMetaData(field.getName()) : new FloatMetaData(field.getName());
    } else if (arrowType instanceof ArrowType.Binary) {
        return new BinaryMetaData(field.getName());
    } else if (arrowType instanceof ArrowType.Utf8) {
        return new StringMetaData(field.getName());
    } else if (arrowType instanceof ArrowType.Date) {
        return new TimeMetaData(field.getName());
    } else {
        throw new IllegalStateException("Illegal type " + field.getFieldType().getType());
    }
}
 
Example 2
Source File: ArrowConverter.java    From DataVec with Apache License 2.0 5 votes vote down vote up
private static ColumnMetaData metaDataFromField(Field field) {
    ArrowType arrowType = field.getFieldType().getType();
    if(arrowType instanceof ArrowType.Int) {
        val intType = (ArrowType.Int) arrowType;
        if(intType.getBitWidth() == 32)
            return new IntegerMetaData(field.getName());
        else {
            return new LongMetaData(field.getName());
        }
    }
    else if(arrowType instanceof ArrowType.Bool) {
        return new BooleanMetaData(field.getName());
    }
    else if(arrowType  instanceof ArrowType.FloatingPoint) {
        val floatingPointType = (ArrowType.FloatingPoint) arrowType;
        if(floatingPointType.getPrecision() == FloatingPointPrecision.DOUBLE)
            return new DoubleMetaData(field.getName());
        else {
            return new FloatMetaData(field.getName());
        }
    }
    else if(arrowType instanceof  ArrowType.Binary) {
        return new BinaryMetaData(field.getName());
    }
    else if(arrowType instanceof ArrowType.Utf8) {
        return new StringMetaData(field.getName());

    }
    else if(arrowType instanceof ArrowType.Date) {
        return new TimeMetaData(field.getName());
    }
    else {
        throw new IllegalStateException("Illegal type " + field.getFieldType().getType());
    }

}
 
Example 3
Source File: ArrowConverter.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private static ColumnMetaData metaDataFromField(Field field) {
    ArrowType arrowType = field.getFieldType().getType();
    if(arrowType instanceof ArrowType.Int) {
        val intType = (ArrowType.Int) arrowType;
        if(intType.getBitWidth() == 32)
            return new IntegerMetaData(field.getName());
        else {
            return new LongMetaData(field.getName());
        }
    }
    else if(arrowType instanceof ArrowType.Bool) {
        return new BooleanMetaData(field.getName());
    }
    else if(arrowType  instanceof ArrowType.FloatingPoint) {
        val floatingPointType = (ArrowType.FloatingPoint) arrowType;
        if(floatingPointType.getPrecision() == FloatingPointPrecision.DOUBLE)
            return new DoubleMetaData(field.getName());
        else {
            return new FloatMetaData(field.getName());
        }
    }
    else if(arrowType instanceof  ArrowType.Binary) {
        return new BinaryMetaData(field.getName());
    }
    else if(arrowType instanceof ArrowType.Utf8) {
        return new StringMetaData(field.getName());

    }
    else if(arrowType instanceof ArrowType.Date) {
        return new TimeMetaData(field.getName());
    }
    else {
        throw new IllegalStateException("Illegal type " + field.getFieldType().getType());
    }

}
 
Example 4
Source File: ArrowTypeSerDe.java    From aws-athena-query-federation with Apache License 2.0 4 votes vote down vote up
private Serializer()
{
    super(ArrowType.class, ArrowType.Utf8.class);
}
 
Example 5
Source File: ArrowTypeSerDe.java    From aws-athena-query-federation with Apache License 2.0 4 votes vote down vote up
private Deserializer()
{
    super(ArrowType.class, ArrowType.Utf8.class);
}
 
Example 6
Source File: ArrowTypeSerDe.java    From aws-athena-query-federation with Apache License 2.0 4 votes vote down vote up
@Override
protected ArrowType doTypedDeserialize(JsonParser jparser, DeserializationContext ctxt)
        throws IOException
{
    return new ArrowType.Utf8();
}
 
Example 7
Source File: TestNativeFunctions.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Test
public void testFlippedCodeGenerator() throws Exception {
  ArrowType strType = new ArrowType.Utf8();
  ArrowType bigIntType = new ArrowType.Int(64, true);
  FunctionSignature substrFn = new FunctionSignature("substr", strType, Lists.newArrayList(strType, bigIntType, bigIntType));
  GandivaPushdownSieveHelper helper = new GandivaPushdownSieveHelper();
  try {
    // hide substr function if implemented in Gandiva
    helper.addFunctionToHide(substrFn);
    // enable decimal
    testContext.getOptions().setOption(OptionValue.createBoolean(
      OptionValue.OptionType.SYSTEM,
      PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY,
      true));
    // enable decimal v2
    testContext.getOptions().setOption(OptionValue.createBoolean(
      OptionValue.OptionType.SYSTEM,
      PlannerSettings.ENABLE_DECIMAL_V2_KEY,
      true));
    // enabled mixed mode execution
    testContext.getOptions().setOption(OptionValue.createString(
    OptionValue.OptionType.SYSTEM,
      ExecConstants.QUERY_EXEC_OPTION_KEY,
      execPreferenceMixed
    ));
    // increase the threshold for flipping the code generator
    testContext.getOptions().setOption(OptionValue.createDouble(
      OptionValue.OptionType.SYSTEM,
    ExecConstants.WORK_THRESHOLD_FOR_SPLIT_KEY,
      10.0));
    testFunctionsCompiledOnly(new Object[][]{
      {"c1 = 'CA' or c1 = 'WA' or c1 = 'GA' or c2 > 500 or substr(c0,1,4) = '8566' or substr(c0, 1, 4) = '8619' or substr(c0, 1, 4) = '8827' or substr(c0, 1, 4) = '8340' or substr(c0, 1, 4) = '1111' or substr(c0, 1, 4) = '1234' or substr(c0, 1, 4) = 2222",
        "3031", "TN", BigDecimal.valueOf(100, 2), false}
    });
  } finally {
    testContext.getOptions().setOption(OptionValue.createBoolean(
      OptionValue.OptionType.SYSTEM,
      PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY,
      PlannerSettings.ENABLE_DECIMAL_DATA_TYPE.getDefault().getBoolVal()));
    testContext.getOptions().setOption(OptionValue.createBoolean(
      OptionValue.OptionType.SYSTEM,
      PlannerSettings.ENABLE_DECIMAL_V2_KEY,
      PlannerSettings.ENABLE_DECIMAL_V2.getDefault().getBoolVal()));
    testContext.getOptions().setOption(OptionValue.createDouble(
      OptionValue.OptionType.SYSTEM,
      ExecConstants.WORK_THRESHOLD_FOR_SPLIT_KEY,
      ExecConstants.WORK_THRESHOLD_FOR_SPLIT.getDefault().getFloatVal()));
    testContext.getOptions().setOption(OptionValue.createString(
      OptionValue.OptionType.SYSTEM,
      ExecConstants.QUERY_EXEC_OPTION_KEY,
      execPreferenceGandivaOnly
    ));
    helper.removeFunctionToHide(substrFn);
  }
}
 
Example 8
Source File: APIFieldDescriber.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public Void visit(ArrowType.Utf8 utf8) {
  return writeString("VARCHAR");
}