当前位置: 首页>>代码示例>>Java>>正文


Java BooleanObjectInspector类代码示例

本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector的典型用法代码示例。如果您正苦于以下问题:Java BooleanObjectInspector类的具体用法?Java BooleanObjectInspector怎么用?Java BooleanObjectInspector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BooleanObjectInspector类属于org.apache.hadoop.hive.serde2.objectinspector.primitive包,在下文中一共展示了BooleanObjectInspector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
public static IHivePrimitiveConverter get( final ObjectInspector objectInspector ){

    switch( objectInspector.getCategory() ){
      case PRIMITIVE:
        PrimitiveObjectInspector primitiveInspector = (PrimitiveObjectInspector)objectInspector;
        switch( primitiveInspector.getPrimitiveCategory() ){
          case BINARY:
            return new HiveBytesPrimitiveConverter( (BinaryObjectInspector)objectInspector );
          case BOOLEAN:
            return new HiveBooleanPrimitiveConverter( (BooleanObjectInspector)objectInspector );
          case BYTE:
            return new HiveBytePrimitiveConverter( (ByteObjectInspector)objectInspector );
          case DOUBLE:
            return new HiveDoublePrimitiveConverter( (DoubleObjectInspector)objectInspector );
          case FLOAT:
            return new HiveFloatPrimitiveConverter( (FloatObjectInspector)objectInspector );
          case INT:
            return new HiveIntegerPrimitiveConverter( (IntObjectInspector)objectInspector );
          case LONG:
            return new HiveLongPrimitiveConverter( (LongObjectInspector)objectInspector );
          case SHORT:
            return new HiveShortPrimitiveConverter( (ShortObjectInspector)objectInspector );
          case STRING:
            return new HiveStringPrimitiveConverter( (StringObjectInspector)objectInspector );
          case DATE:
          case TIMESTAMP:
          case VOID:
          case UNKNOWN:
          default:
            return new HiveDefaultPrimitiveConverter();
        }
      default :
        return new HiveDefaultPrimitiveConverter();
    }
  }
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:36,代码来源:HivePrimitiveConverterFactory.java

示例2: asIntLabel

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
private static int asIntLabel(@Nonnull final Object o,
        @Nonnull final BooleanObjectInspector booleanOI) {
    if (booleanOI.get(o)) {
        return 1;
    } else {
        return 0;
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:9,代码来源:FMeasureUDAF.java

示例3: asBooleanOI

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
@Nonnull
public static BooleanObjectInspector asBooleanOI(@Nonnull final ObjectInspector argOI)
        throws UDFArgumentException {
    if (!BOOLEAN_TYPE_NAME.equals(argOI.getTypeName())) {
        throw new UDFArgumentException("Argument type must be Boolean: " + argOI.getTypeName());
    }
    return (BooleanObjectInspector) argOI;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:9,代码来源:HiveUtils.java

示例4: createPrimitive

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
private Writable createPrimitive(final Object obj, final PrimitiveObjectInspector inspector)
    throws SerDeException {
  if (obj == null) {
    return null;
  }
  switch (inspector.getPrimitiveCategory()) {
  case VOID:
    return null;
  case BOOLEAN:
    return new BooleanWritable(((BooleanObjectInspector) inspector).get(obj) ? Boolean.TRUE : Boolean.FALSE);
  case BYTE:
    return new ByteWritable((byte) ((ByteObjectInspector) inspector).get(obj));
  case DOUBLE:
    return new DoubleWritable(((DoubleObjectInspector) inspector).get(obj));
  case FLOAT:
    return new FloatWritable(((FloatObjectInspector) inspector).get(obj));
  case INT:
    return new IntWritable(((IntObjectInspector) inspector).get(obj));
  case LONG:
    return new LongWritable(((LongObjectInspector) inspector).get(obj));
  case SHORT:
    return new ShortWritable((short) ((ShortObjectInspector) inspector).get(obj));
  case STRING:
    return new BinaryWritable(Binary.fromString(((StringObjectInspector) inspector).getPrimitiveJavaObject(obj)));
  default:
    throw new SerDeException("Unknown primitive : " + inspector.getPrimitiveCategory());
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:29,代码来源:ParquetHiveSerDe.java

示例5: write

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
@Override
void write(Object obj) throws IOException {
  super.write(obj, RawDatasizeConst.BOOLEAN_SIZE);
  if (obj != null) {
    boolean val = ((BooleanObjectInspector) inspector).get(obj);
    indexStatistics.updateBoolean(val);
    writer.write(val ? 1 : 0);
  }
}
 
开发者ID:facebookarchive,项目名称:hive-dwrf,代码行数:10,代码来源:WriterImpl.java

示例6: TestCopyBoolean

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
/**
 * Tests that after copying a lazy boolean object, calling materialize on the original and the
 * copy doesn't advance the tree reader twice
 * @throws Exception
 */
@Test
public void TestCopyBoolean() throws Exception {
  ReaderWriterProfiler.setProfilerOptions(null);
  OrcLazyBoolean lazyBoolean = new OrcLazyBoolean(new LazyBooleanTreeReader(0, 0) {
    int nextCalls = 0;

    @Override
    public Object next(Object previous) throws IOException {
      if (nextCalls == 0) {
        return new BooleanWritable(true);
      }

      throw new IOException("next should only be called once");
    }

    @Override
    protected boolean seekToRow(long currentRow) throws IOException {
      return true;
    }
  });

  BooleanObjectInspector booleanOI = (BooleanObjectInspector)
      OrcLazyObjectInspectorUtils.createLazyObjectInspector(TypeInfoFactory.booleanTypeInfo);

  OrcLazyBoolean lazyBoolean2 = (OrcLazyBoolean) booleanOI.copyObject(lazyBoolean);

  Assert.assertEquals(true, ((BooleanWritable) lazyBoolean.materialize()).get());
  Assert.assertEquals(true, ((BooleanWritable) lazyBoolean2.materialize()).get());
}
 
开发者ID:facebookarchive,项目名称:hive-dwrf,代码行数:35,代码来源:TestObjectInspector.java

示例7: setSafeValue

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
@Override
public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) {
  final boolean value = (boolean) ((BooleanObjectInspector)oi).getPrimitiveJavaObject(hiveFieldValue);
  ((NullableBitVector) outputVV).getMutator().setSafe(outputIndex, value ? 1 : 0);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:HiveFieldConverter.java

示例8: evaluate

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
  if (arguments[0] == null || arguments[0].get() == null) {
    return null;
  }

  Object input = arguments[0].get();
  switch(inputType) {
    case BOOLEAN:
      return ((BooleanObjectInspector)argumentOI).get(input) ? Boolean.TRUE : Boolean.FALSE;
    case BYTE:
      return new Byte(((ByteObjectInspector)argumentOI).get(input));
    case SHORT:
      return new Short(((ShortObjectInspector)argumentOI).get(input));
    case INT:
      return new Integer(((IntObjectInspector)argumentOI).get(input));
    case LONG:
      return new Long(((LongObjectInspector)argumentOI).get(input));
    case FLOAT:
      return new Float(((FloatObjectInspector)argumentOI).get(input));
    case DOUBLE:
      return new Double(((DoubleObjectInspector)argumentOI).get(input));
    case STRING:
      return PrimitiveObjectInspectorUtils.getString(input, (StringObjectInspector)argumentOI);
    case BINARY:
      return PrimitiveObjectInspectorUtils.getBinary(input, (BinaryObjectInspector) argumentOI).getBytes();
    case VARCHAR:
      return PrimitiveObjectInspectorUtils.getHiveVarchar(input, (HiveVarcharObjectInspector)argumentOI);
    case DATE:
      return PrimitiveObjectInspectorUtils.getDate(input, (DateObjectInspector) argumentOI);
    case TIMESTAMP:
      return PrimitiveObjectInspectorUtils.getTimestamp(input, (TimestampObjectInspector) argumentOI);
    case DECIMAL:
      // return type is a HiveVarchar
      HiveDecimal decimalValue =
          PrimitiveObjectInspectorUtils.getHiveDecimal(input, (HiveDecimalObjectInspector) argumentOI);
      return new HiveVarchar(decimalValue.toString(), HiveVarchar.MAX_VARCHAR_LENGTH);
  }

  throw new UnsupportedOperationException(String.format("Unexpected input type '%s' in Test UDF", inputType));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:42,代码来源:HiveTestUDFImpls.java

示例9: HiveBooleanPrimitiveConverter

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
public HiveBooleanPrimitiveConverter( final BooleanObjectInspector inspector ){
  this.inspector = inspector;
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:4,代码来源:HiveBooleanPrimitiveConverter.java

示例10: OrcBooleanPrimitiveConverter

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
public OrcBooleanPrimitiveConverter( final BooleanObjectInspector inspector ){
  this.inspector = inspector;
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:4,代码来源:OrcBooleanPrimitiveConverter.java

示例11: asBoolean

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
public Object asBoolean() {
	return ((BooleanObjectInspector) oi).get(obj);
}
 
开发者ID:CyberAgent,项目名称:hive-jq-udtf,代码行数:4,代码来源:HivePath.java

示例12: evaluate

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
  if (arguments[0] == null || arguments[0].get() == null) {
    return null;
  }

  Object input = arguments[0].get();
  switch(inputType) {
    case BOOLEAN:
      return ((BooleanObjectInspector)argumentOI).get(input) ? Boolean.TRUE : Boolean.FALSE;
    case BYTE:
      return new Byte(((ByteObjectInspector)argumentOI).get(input));
    case SHORT:
      return new Short(((ShortObjectInspector)argumentOI).get(input));
    case INT:
      return new Integer(((IntObjectInspector)argumentOI).get(input));
    case LONG:
      return new Long(((LongObjectInspector)argumentOI).get(input));
    case FLOAT:
      return new Float(((FloatObjectInspector)argumentOI).get(input));
    case DOUBLE:
      return new Double(((DoubleObjectInspector)argumentOI).get(input));
    case STRING:
      return PrimitiveObjectInspectorUtils.getString(input, (StringObjectInspector)argumentOI);
    case BINARY:
      return PrimitiveObjectInspectorUtils.getBinary(input, (BinaryObjectInspector) argumentOI).getBytes();
    case VARCHAR:
      if (outputType == PrimitiveCategory.CHAR) {
        HiveVarchar hiveVarchar = PrimitiveObjectInspectorUtils.getHiveVarchar(input, (HiveVarcharObjectInspector) argumentOI);
        return new HiveChar(hiveVarchar.getValue(), HiveChar.MAX_CHAR_LENGTH);
      } else {
        return PrimitiveObjectInspectorUtils.getHiveVarchar(input, (HiveVarcharObjectInspector)argumentOI);
      }
    case CHAR:
      return PrimitiveObjectInspectorUtils.getHiveChar(input, (HiveCharObjectInspector) argumentOI);
    case DATE:
      return PrimitiveObjectInspectorUtils.getDate(input, (DateObjectInspector) argumentOI);
    case TIMESTAMP:
      return PrimitiveObjectInspectorUtils.getTimestamp(input, (TimestampObjectInspector) argumentOI);
    case DECIMAL:
      // return type is a HiveVarchar
      HiveDecimal decimalValue =
          PrimitiveObjectInspectorUtils.getHiveDecimal(input, (HiveDecimalObjectInspector) argumentOI);
      return new HiveVarchar(decimalValue.toString(), HiveVarchar.MAX_VARCHAR_LENGTH);
  }

  throw new UnsupportedOperationException(String.format("Unexpected input type '%s' in Test UDF", inputType));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:49,代码来源:HiveTestUDFImpls.java

示例13: getBoolean

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
public Boolean getBoolean(Object data, ObjectInspector objectInspector) {
          return ((BooleanObjectInspector) objectInspector).get(data);
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:4,代码来源:DynamoDBDataParser.java

示例14: iterate

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
@Override
public void iterate(@SuppressWarnings("deprecation") AggregationBuffer agg,
        Object[] parameters) throws HiveException {
    FMeasureAggregationBuffer myAggr = (FMeasureAggregationBuffer) agg;
    boolean isList = HiveUtils.isListOI(actualOI) && HiveUtils.isListOI(predictedOI);

    final List<?> actual;
    final List<?> predicted;

    if (isList) {// array case
        if ("binary".equals(average)) {
            throw new UDFArgumentException(
                "\"-average binary\" is not supported when `predict` is array");
        }
        actual = ((ListObjectInspector) actualOI).getList(parameters[0]);
        predicted = ((ListObjectInspector) predictedOI).getList(parameters[1]);
    } else {//binary case
        if (HiveUtils.isBooleanOI(actualOI)) { // boolean case
            actual = Arrays.asList(asIntLabel(parameters[0],
                (BooleanObjectInspector) actualOI));
            predicted = Arrays.asList(asIntLabel(parameters[1],
                (BooleanObjectInspector) predictedOI));
        } else { // int case
            final int actualLabel = asIntLabel(parameters[0], (IntObjectInspector) actualOI);
            if (actualLabel == 0 && "binary".equals(average)) {
                actual = Collections.emptyList();
            } else {
                actual = Arrays.asList(actualLabel);
            }

            final int predictedLabel = asIntLabel(parameters[1],
                (IntObjectInspector) predictedOI);
            if (predictedLabel == 0 && "binary".equals(average)) {
                predicted = Collections.emptyList();
            } else {
                predicted = Arrays.asList(predictedLabel);
            }
        }
    }
    myAggr.iterate(actual, predicted);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:42,代码来源:FMeasureUDAF.java

示例15: serializePrimitive

import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; //导入依赖的package包/类
private static void serializePrimitive(BlockBuilder builder, Object object, PrimitiveObjectInspector inspector)
{
    requireNonNull(builder, "parent builder is null");

    if (object == null) {
        builder.appendNull();
        return;
    }

    switch (inspector.getPrimitiveCategory()) {
        case BOOLEAN:
            BooleanType.BOOLEAN.writeBoolean(builder, ((BooleanObjectInspector) inspector).get(object));
            return;
        case BYTE:
            BigintType.BIGINT.writeLong(builder, ((ByteObjectInspector) inspector).get(object));
            return;
        case SHORT:
            BigintType.BIGINT.writeLong(builder, ((ShortObjectInspector) inspector).get(object));
            return;
        case INT:
            BigintType.BIGINT.writeLong(builder, ((IntObjectInspector) inspector).get(object));
            return;
        case LONG:
            BigintType.BIGINT.writeLong(builder, ((LongObjectInspector) inspector).get(object));
            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:
            VarcharType.VARCHAR.writeSlice(builder, Slices.utf8Slice(((StringObjectInspector) inspector).getPrimitiveJavaObject(object)));
            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:
            VARBINARY.writeSlice(builder, Slices.wrappedBuffer(((BinaryObjectInspector) inspector).getPrimitiveJavaObject(object)));
            return;
    }
    throw new RuntimeException("Unknown primitive type: " + inspector.getPrimitiveCategory());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:47,代码来源:SerDeUtils.java


注:本文中的org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。