List of usage examples for java.io DataInput readUTF
String readUTF() throws IOException;
From source file:com.aliyun.odps.io.TupleReaderWriter.java
@SuppressWarnings("unchecked") private static Writable readDatum(DataInput in, byte type) throws IOException { switch (type) { case TUPLE:/*from ww w. j a va 2 s . co m*/ int sz = in.readInt(); // if sz == 0, we construct an "empty" tuple - // presumably the writer wrote an empty tuple! if (sz < 0) { throw new IOException("Invalid size " + sz + " for a tuple"); } Tuple tp = new Tuple(sz); for (int i = 0; i < sz; i++) { byte b = in.readByte(); tp.set(i, readDatum(in, b)); } return tp; case NULL: return null; case INTWRITABLE: IntWritable iw = new IntWritable(); iw.readFields(in); return iw; case LONGWRITABLE: LongWritable lw = new LongWritable(); lw.readFields(in); return lw; case DATETIMEWRITABLE: DatetimeWritable dtw = new DatetimeWritable(); dtw.readFields(in); return dtw; case DOUBLEWRITABLE: DoubleWritable dw = new DoubleWritable(); dw.readFields(in); return dw; case BOOLEANWRITABLE: BooleanWritable bw = new BooleanWritable(); bw.readFields(in); return bw; case BYTESWRITABLE: BytesWritable bsw = new BytesWritable(); bsw.readFields(in); return bsw; case TEXT: Text t = new Text(); t.readFields(in); return t; case NULLWRITABLE: NullWritable nw = NullWritable.get(); nw.readFields(in); return nw; case UNKNOWN: String clsName = in.readUTF(); try { Class<? extends Writable> cls = (Class<? extends Writable>) Class.forName(clsName); Writable w = (Writable) ReflectionUtils.newInstance(cls, null); w.readFields(in); return w; } catch (RuntimeException re) { LOG.info(re.getMessage()); throw new IOException(re); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } default: throw new RuntimeException("Unexpected data type " + type + " found in stream."); } }
From source file:com.chinamobile.bcbsp.sync.SuperStepCommand.java
@Override public void readFields(DataInput in) throws IOException { this.commandType = in.readInt(); this.initWritePath = Text.readString(in); this.initReadPath = Text.readString(in); this.ableCheckPoint = in.readInt(); this.nextSuperStepNum = in.readInt(); this.oldCheckPoint = in.readInt(); int count = in.readInt(); this.aggValues = new String[count]; for (int i = 0; i < count; i++) { this.aggValues[i] = Text.readString(in); }//from www. j av a 2 s.co m int size = WritableUtils.readVInt(in); if (size > 0) { String[] partitionToWMName = WritableUtils.readCompressedStringArray(in); this.partitionToWorkerManagerNameAndPort = new HashMap<Integer, String>(); for (int j = 0; j < size; j++) { this.partitionToWorkerManagerNameAndPort.put(j, partitionToWMName[j]); } } this.migrateStaffIDs = in.readUTF(); this.migrateVertexCommand.readFields(in); }
From source file:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java
@SuppressWarnings("unchecked") private void readLegacyStashedLockRequests(DataInput in) throws IOException, PickleException { int size = in.readInt(); for (int i = 0; i < size; i++) { String key = in.readUTF(); BrandedItem item = getMessageFromQueue(key); item.calls.add(createRpcCall("com.mobicage.capi.messaging.messageLocked", (Map<String, Object>) JSONValue.parse(in.readUTF()))); }/* www .j a va 2 s .c o m*/ }
From source file:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java
@SuppressWarnings("unchecked") private void readLegacyStashedMemberStatusUpdates(DataInput in) throws IOException, PickleException { int size = in.readInt(); for (int i = 0; i < size; i++) { String key = in.readUTF(); BrandedItem item = getMessageFromQueue(key); int updatesCount = in.readInt(); for (int j = 0; j < updatesCount; j++) { item.calls.add(createRpcCall("com.mobicage.capi.messaging.updateMessageMemberStatus", (Map<String, Object>) JSONValue.parse(in.readUTF()))); }//from w ww .j a va 2 s .c om } }
From source file:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java
@SuppressWarnings("unchecked") private void deserializeStashedLegacyManager(int version, DataInput in) throws IOException, PickleException { int msgQueueSize = in.readInt(); for (int i = 0; i < msgQueueSize; i++) { try {/*from ww w . ja v a 2 s . com*/ Message message = new Message((Map<String, Object>) JSONValue.parse(in.readUTF())); mQueue.add(new BrandedItem(message)); } catch (IncompleteMessageException e) { L.bug(e); } } if (version == 3) { readLegacyStashedMemberStatusUpdates(in); } if (version >= 2) { int friendQueueSize = in.readInt(); for (int i = 0; i < friendQueueSize; i++) { try { FriendTO friend = new FriendTO((Map<String, Object>) JSONValue.parse(in.readUTF())); mQueue.add(new BrandedItem(BrandedItem.TYPE_FRIEND, friend, friend.descriptionBranding)); } catch (IncompleteMessageException e) { L.bug(e); } } } }
From source file:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java
@Override public void readFromPickle(int version, DataInput in) throws IOException, PickleException { T.dontCare();// w w w. j a v a 2s .c om if (version < 4) { deserializeStashedLegacyManager(version, in); } else { // Read branding queue int queueSize = in.readInt(); for (int i = 0; i < queueSize; i++) { @SuppressWarnings("unchecked") Map<String, Object> jsonMap = (Map<String, Object>) JSONValue.parse(in.readUTF()); try { mQueue.add(new BrandedItem(jsonMap)); } catch (IncompleteMessageException e) { L.bug(e); } } if (version < 6) { readLegacyStashedMemberStatusUpdates(in); if (version >= 5) { readLegacyStashedLockRequests(in); } } if (version >= 7) { int downloadQueueSize = in.readInt(); for (int i = 0; i < downloadQueueSize; i++) { @SuppressWarnings("unchecked") Map<String, Object> jsonMap = (Map<String, Object>) JSONValue.parse(in.readUTF()); try { final BrandedItem item = new BrandedItem(jsonMap); mDownloadMgrQueue.put(item.downloadId, item); } catch (IncompleteMessageException e) { L.bug(e); } } } } }
From source file:org.apache.accumulo.core.client.mapreduce.RangeInputSplit.java
@Override public void readFields(DataInput in) throws IOException { range.readFields(in);//from w ww. ja va2s. c om tableName = in.readUTF(); tableId = in.readUTF(); int numLocs = in.readInt(); locations = new String[numLocs]; for (int i = 0; i < numLocs; ++i) locations[i] = in.readUTF(); if (in.readBoolean()) { isolatedScan = in.readBoolean(); } if (in.readBoolean()) { offline = in.readBoolean(); } if (in.readBoolean()) { localIterators = in.readBoolean(); } if (in.readBoolean()) { mockInstance = in.readBoolean(); } if (in.readBoolean()) { int numColumns = in.readInt(); List<String> columns = new ArrayList<String>(numColumns); for (int i = 0; i < numColumns; i++) { columns.add(in.readUTF()); } fetchedColumns = InputConfigurator.deserializeFetchedColumns(columns); } if (in.readBoolean()) { String strAuths = in.readUTF(); auths = new Authorizations(strAuths.getBytes(Constants.UTF8)); } if (in.readBoolean()) { principal = in.readUTF(); } if (in.readBoolean()) { int ordinal = in.readInt(); this.tokenSource = TokenSource.values()[ordinal]; switch (this.tokenSource) { case INLINE: String tokenClass = in.readUTF(); byte[] base64TokenBytes = in.readUTF().getBytes(Constants.UTF8); byte[] tokenBytes = Base64.decodeBase64(base64TokenBytes); this.token = AuthenticationTokenSerializer.deserialize(tokenClass, tokenBytes); break; case FILE: this.tokenFile = in.readUTF(); break; default: throw new IOException("Cannot parse unknown TokenSource ordinal"); } } if (in.readBoolean()) { instanceName = in.readUTF(); } if (in.readBoolean()) { zooKeepers = in.readUTF(); } if (in.readBoolean()) { level = Level.toLevel(in.readInt()); } }
From source file:org.apache.bigtop.bigpetstore.generator.PetStoreTransactionInputSplit.java
public void readFields(DataInput dataInputStream) throws IOException { records = dataInputStream.readInt(); state = State.valueOf(dataInputStream.readUTF()); customerIdRange = Range.between(dataInputStream.readLong(), dataInputStream.readLong()); }
From source file:org.apache.carbondata.core.metadata.schema.table.DataMapSchema.java
@Override public void readFields(DataInput in) throws IOException { this.dataMapName = in.readUTF(); this.providerName = in.readUTF(); boolean isRelationIdentifierExists = in.readBoolean(); if (isRelationIdentifierExists) { this.relationIdentifier = new RelationIdentifier(null, null, null); this.relationIdentifier.readFields(in); }//from ww w . j ava 2 s . c o m boolean isChildSchemaExists = in.readBoolean(); if (isChildSchemaExists) { this.childSchema = new TableSchema(); this.childSchema.readFields(in); } int mapSize = in.readShort(); this.properties = new HashMap<>(mapSize); for (int i = 0; i < mapSize; i++) { String key = in.readUTF(); String value = in.readUTF(); this.properties.put(key, value); } }
From source file:org.apache.geode.internal.InternalDataSerializer.java
/** * Reads an instance of {@code String} from a {@code DataInput} given the header byte already * being read. The return value may be {@code null}. * * @throws IOException A problem occurs while reading from {@code in} * * @since GemFire 5.7/*from ww w . ja va 2s.c o m*/ */ public static String readString(DataInput in, byte header) throws IOException { if (header == DSCODE.STRING_BYTES) { int len = in.readUnsignedShort(); if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "Reading STRING_BYTES of len={}", len); } byte[] buf = new byte[len]; in.readFully(buf, 0, len); return new String(buf, 0); // intentionally using deprecated constructor } else if (header == DSCODE.STRING) { if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "Reading utf STRING"); } return in.readUTF(); } else if (header == DSCODE.NULL_STRING) { if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "Reading NULL_STRING"); } return null; } else if (header == DSCODE.HUGE_STRING_BYTES) { int len = in.readInt(); if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "Reading HUGE_STRING_BYTES of len={}", len); } byte[] buf = new byte[len]; in.readFully(buf, 0, len); return new String(buf, 0); // intentionally using deprecated constructor } else if (header == DSCODE.HUGE_STRING) { int len = in.readInt(); if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "Reading HUGE_STRING of len={}", len); } char[] buf = new char[len]; for (int i = 0; i < len; i++) { buf[i] = in.readChar(); } return new String(buf); } else { String s = "Unknown String header " + header; throw new IOException(s); } }