public HeartbeatResponse(Boolean isXLearningTrainCompleted, Long timeStamp) { this.isXLearningTrainCompleted = new BooleanWritable(isXLearningTrainCompleted); this.interResultTimeStamp = new LongWritable(timeStamp); }
/** * Convert from a string to boolean. This is called for CAST(... AS BOOLEAN) * * @param i * The string value to convert * @return BooleanWritable */ public BooleanWritable evaluate(Text i) { if (i == null) { return null; } boolean b = PrimitiveObjectInspectorUtils.parseBoolean(i.getBytes(), 0, i.getLength()); booleanWritable.set(b); return booleanWritable; }
public LazyBoolean(LazyBoolean copy) { super(copy); data = new BooleanWritable(copy.data.get()); }
public BooleanWritable readBoolean(BooleanWritable bw) throws IOException { if (bw == null) { bw = new BooleanWritable(); } bw.set(in.readBool()); return bw; }
private Writable allocateWritable(Type type) { switch (type) { case BYTE: return new ByteWritable(); case BOOL: return new BooleanWritable(); case INT: return new IntWritable(); case SHORT: return new ShortWritable(); case LONG: return new LongWritable(); case FLOAT: return new FloatWritable(); case DOUBLE: return new DoubleWritable(); case STRING: return new Text(); default: assert false; // not supported } return null; }
switch (poi.getPrimitiveCategory()) { case INT: return Bytes.toBytes(((IntWritable) writable).get()); case BOOLEAN: return Bytes.toBytes(((BooleanWritable) writable).get()); case LONG: return Bytes.toBytes(((LongWritable) writable).get()); case FLOAT: return Bytes.toBytes(((FloatWritable) writable).get()); case DOUBLE: return Bytes.toBytes(((DoubleWritable) writable).get()); return Bytes.toBytes(((ShortWritable) writable).get()); case STRING: return Bytes.toBytes(((Text) writable).toString()); case BYTE: return Bytes.toBytes(((ByteWritable) writable).get());
writable = new BooleanWritable(); ((BooleanWritable) writable).set(deserializeRead.currentBoolean); writable = new IntWritable(); ((IntWritable) writable).set(deserializeRead.currentInt); writable = new LongWritable(); ((LongWritable) writable).set(deserializeRead.currentLong); writable = new FloatWritable(); ((FloatWritable) writable).set(deserializeRead.currentFloat); writable = new BytesWritable(); ((BytesWritable) writable).set( deserializeRead.currentBytes, deserializeRead.currentBytesStart, writable = new Text(); ((Text) writable).set( deserializeRead.currentBytes, deserializeRead.currentBytesStart,
@Override public void readFields(DataInput in) throws IOException { Text outputNameText = new Text(); outputNameText.readFields(in); outputNamePrefix = outputNameText.toString(); outputNum = in.readInt(); BooleanWritable hasSharedOutputs = new BooleanWritable(); hasSharedOutputs.readFields(in); if (hasSharedOutputs.get()) { Text sharedOutputNamePrefixText = new Text(); sharedOutputNamePrefixText.readFields(in); sharedOutputNamePrefix = sharedOutputNamePrefixText.toString(); sharedOutputNum = in.readInt(); } }
private void runAndVerify(String str, String regex, Boolean expResult, GenericUDF udf) throws HiveException { DeferredObject valueObj0 = new DeferredJavaObject(str != null ? new Text(str) : null); DeferredObject valueObj1 = new DeferredJavaObject(regex != null ? new Text(regex) : null); DeferredObject[] args = { valueObj0, valueObj1 }; BooleanWritable output = (BooleanWritable) udf.evaluate(args); if (expResult == null) { assertNull(output); } else { assertNotNull(output); assertEquals("regexp() test ", expResult.booleanValue(), output.get()); } } }
generator.writeUTF8String(text.getBytes(), 0, text.getLength()); generator.writeNumber(((IntWritable) writable).get()); generator.writeNumber(((LongWritable) writable).get()); generator.writeNumber(((FloatWritable) writable).get()); generator.writeBoolean(((BooleanWritable) writable).get()); generator.writeBinary(bw.getBytes(), 0, bw.getLength());
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Object targetObject = targetOI.getPrimitiveJavaObject(arguments[0].get()); if (targetObject == null) { return null; return null; case BOOLEAN: ((BooleanWritable)returnObj).set((Boolean)result); return returnObj; case BYTE: return returnObj; case STRING: ((Text)returnObj).set((String)result); return returnObj; case TIMESTAMP: return returnObj; case BINARY: ((BytesWritable)returnObj).set((byte[])result, 0, ((byte[]) result).length); return returnObj; case DECIMAL:
@Test public void testMap() { LinkedMapWritable map = new LinkedMapWritable(); map.put(new Text("key"), new IntWritable(1)); map.put(new BooleanWritable(Boolean.TRUE), new ArrayWritable(new String[] { "one", "two" })); writableTypeToJson(map); }
@Override public void write(DataOutput out) throws IOException { new Text(outputNamePrefix).write(out); out.writeInt(outputNum); if (sharedOutputNamePrefix != null) { new BooleanWritable(true).write(out); new Text(sharedOutputNamePrefix).write(out); out.writeInt(sharedOutputNum); } else { new BooleanWritable(false).write(out); } }
public void readFields(DataInput in) throws IOException { BooleanWritable flag = new BooleanWritable(false); flag.readFields(in); double[] xUpdated = null; if (flag.get()) { DoubleArrayWritable reader = new DoubleArrayWritable(); reader.readFields(in); xUpdated = reader.get(); flag.set(false); flag.readFields(in); if (flag.get()) { DoubleArrayWritable reader = new DoubleArrayWritable(); reader.readFields(in); uInitial = reader.get(); flag.set(false); flag.readFields(in); if (flag.get()) { DoubleArrayWritable reader = new DoubleArrayWritable(); reader.readFields(in); zUpdated = reader.get(); flag.set(false); primalObjectiveValue.readFields(in);
private Writable getWritableValue(TypeInfo ti, long value) { if (ti.equals(TypeInfoFactory.byteTypeInfo)) { return new ByteWritable((byte) value); } else if (ti.equals(TypeInfoFactory.shortTypeInfo)) { return new ShortWritable((short) value); } else if (ti.equals(TypeInfoFactory.intTypeInfo)) { return new IntWritable( (int) value); } else if (ti.equals(TypeInfoFactory.longTypeInfo)) { return new LongWritable( (long) value); } else if (ti.equals(TypeInfoFactory.booleanTypeInfo)) { return new BooleanWritable( value == 0 ? false : true); } else if (ti.equals(TypeInfoFactory.timestampTypeInfo)) { Timestamp ts = new Timestamp(value); TimestampWritableV2 tw = new TimestampWritableV2( org.apache.hadoop.hive.common.type.Timestamp.ofEpochMilli(ts.getTime(), ts.getNanos())); return tw; } return null; }
public void write(DataOutput out) throws IOException { new BooleanWritable(null != context.getXUpdated()).write(out); if (null != context.getXUpdated()) { writer.set(context.getXUpdated()); writer.write(out); } new BooleanWritable(null != context.getUInitial()).write(out); if (null != context.getUInitial()) { writer.set(context.getUInitial()); writer.write(out); } new BooleanWritable(null != context.getZUpdated()).write(out); if (null != context.getZUpdated()) { writer.set(context.getZUpdated()); writer.write(out); } new DoubleWritable(context.getRho()).write(out); new DoubleWritable(context.getLambdaValue()).write(out); new DoubleWritable(context.getPrimalObjectiveValue()).write(out); new LongWritable(context.getCount()).write(out); }