/** * Reads a string from buf. The length is read first, followed by the chars. Each char is a single byte * @param in the input stream * @return the string read from buf */ public static String readString(DataInput in) throws IOException { int b=in.readByte(); if(b == 1) return in.readUTF(); return null; }
protected String looseUnmarshalString(DataInput dataIn) throws IOException { if (dataIn.readBoolean()) { return dataIn.readUTF(); } else { return null; } }
public PartitionDefinition(DataInput in) throws IOException { this.index = in.readUTF(); this.shardId = in.readInt(); if (in.readBoolean()) { this.slice = new Slice(in.readInt(), in.readInt()); } else { this.slice = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedSettings = StringUtils.asUTFString(utf); } else { this.serializedSettings = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedMapping = StringUtils.asUTFString(utf); } else { this.serializedMapping = null; } int length = in.readInt(); locations = new String[length]; for (int i = 0; i < length; i++) { locations[i] = in.readUTF(); } }
private Object readFieldValue(DataInput input) throws IOException { int type = input.readByte(); switch (type) { case 0: return null; case 1: return input.readInt(); case 2: return input.readLong(); case 3: return input.readFloat(); case 4: return input.readDouble(); case 5: return input.readUTF(); default: throw new RuntimeException("Unexpected field value type: " + type); } }
@Override public void readFields(DataInput in) throws IOException { super.readFields(in); limit = in.readInt(); offset = in.readInt(); boolean partitionColumnExists = in.readBoolean(); if (partitionColumnExists) { partitionColumn = in.readUTF(); } boolean lowerBoundExists = in.readBoolean(); if (lowerBoundExists) { lowerBound = in.readUTF(); } boolean upperBoundExists = in.readBoolean(); if (upperBoundExists) { upperBound = in.readUTF(); } }
@Override public void readFields(DataInput in) throws IOException { final int segmentsBytesLength = in.readInt(); final byte[] buf = new byte[segmentsBytesLength]; in.readFully(buf); segments = HadoopDruidIndexerConfig.JSON_MAPPER.readValue( buf, new TypeReference<List<WindowedDataSegment>>() { } ); locations = new String[in.readInt()]; for (int i = 0; i < locations.length; i++) { locations[i] = in.readUTF(); } } }
@SuppressWarnings("deprecation") protected String tightUnmarshalString(DataInput dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { if (bs.readBoolean()) { int size = dataIn.readShort(); byte data[] = new byte[size]; dataIn.readFully(data); // Yes deprecated, but we know what we are doing. // This allows us to create a String from a ASCII byte array. (no UTF-8 decoding) return new String(data, 0); } else { return dataIn.readUTF(); } } else { return null; } }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.name = in.readUTF(); this.expression = in.readUTF(); this.fromClause = in.readUTF(); this.loadEntries = in.readBoolean(); byte byteIndexType = in.readByte(); if (0 == byteIndexType) { this.indexType = IndexType.PRIMARY_KEY; } else if (1 == byteIndexType) { this.indexType = IndexType.HASH; } else { this.indexType = IndexType.FUNCTIONAL; } boolean isImportStr = in.readBoolean(); if (isImportStr) { this.importStr = in.readUTF(); } }
public static <T extends Object> T objectFromStream(DataInput in, ClassLoader loader) throws Exception { if(in == null) return null; byte b=in.readByte(); return (T)tmp.readObject(); case TYPE_BOOLEAN: return (T)(Boolean)in.readBoolean(); case TYPE_BYTE: return (T)(Byte)in.readByte(); case TYPE_CHAR: return (T)(Character)in.readChar(); case TYPE_DOUBLE: return (T)(Double)in.readDouble(); case TYPE_FLOAT: return (T)(Float)in.readFloat(); case TYPE_INT: return (T)(Integer)in.readInt(); case TYPE_LONG: return (T)(Long)in.readLong(); case TYPE_SHORT: return (T)(Short)in.readShort(); case TYPE_STRING: int str_len=in.readInt(); if(str_len == 0) return (T)""; byte[] tmp=new byte[str_len]; for(int i=0; i < str_len; i++) { tmp[i]=in.readByte(); return (T)in.readUTF(); case TYPE_BYTEARRAY: int len=in.readInt(); byte[] tmpbuf=new byte[len]; in.readFully(tmpbuf,0,tmpbuf.length); return (T)tmpbuf; default:
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); this.responseCode = in.readByte(); this.serviceName = in.readUTF(); this.objectName = DataSerializer.readObject(in); this.leaseExpireTime = in.readLong(); this.keyIfFailed = DataSerializer.readObject(in); this.lockId = in.readInt(); this.dlsSerialNumber = in.readInt(); }
public void readExternal(DataInput in) throws IOException { this.jobId = in.readUTF(); this.repeat = in.readInt(); this.startTime = in.readLong(); this.delay = in.readLong(); this.nextTime = in.readLong(); this.period = in.readLong(); this.cronEntry = in.readUTF(); this.location.readExternal(in); if (in.readBoolean()) { this.lastUpdate = new Location(); this.lastUpdate.readExternal(in); } }
@SuppressWarnings("deprecation") protected String tightUnmarshalString(DataInput dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { if (bs.readBoolean()) { int size = dataIn.readShort(); byte data[] = new byte[size]; dataIn.readFully(data); // Yes deprecated, but we know what we are doing. // This allows us to create a String from a ASCII byte array. (no UTF-8 decoding) return new String(data, 0); } else { return dataIn.readUTF(); } } else { return null; } }
protected String looseUnmarshalString(DataInput dataIn) throws IOException { if (dataIn.readBoolean()) { return dataIn.readUTF(); } else { return null; } }
@Override public void handle(DataInput input, final int correlationId) throws IOException { log.trace("SetKeyPair"); byte paramType = input.readByte(); if (paramType != STRING) { throw new IOException("Unexpected paramType"); } String name = input.readUTF(); paramType = input.readByte(); if (paramType != STRING) { throw new IOException("Unexpected paramType"); } String value = input.readUTF(); keyPairs.put(name, value); writeResponse(SET_KEY_PAIR, correlationId); } }
byte newClasses = in.readByte(); in.readByte(); in.readUTF(); int numEntries = in.readInt(); byte keyClassId = in.readByte(); assert (keyClassId == EVENT_MAP_TEXT_WRITABLE_ID); int keyLength = WritableUtils.readVInt(in); byte[] keyBytes = new byte[ keyLength ]; in.readFully( keyBytes, 0, keyLength ); String key = decoder.decode( ByteBuffer.wrap(keyBytes) ).toString(); byte[] valueBytes = new byte[ valueLength ]; in.readFully(valueBytes, 0, valueLength); String value = decoder.decode(ByteBuffer.wrap(valueBytes)).toString(); int bodyLength = in.readInt(); if (bodyLength != -1) { body = new byte[bodyLength]; in.readFully(body);