List of usage examples for java.io DataInput readInt
int readInt() throws IOException;
From source file:org.apache.pig.data.BinInterSedes.java
/** * Expects binInterSedes data types (NOT DataType types!) * <p>//from w ww .j a v a 2s. c o m * * @see org.apache.pig.data.InterSedes#readDatum(java.io.DataInput, byte) */ @Override public Object readDatum(DataInput in, byte type) throws IOException, ExecException { switch (type) { case TUPLE_0: case TUPLE_1: case TUPLE_2: case TUPLE_3: case TUPLE_4: case TUPLE_5: case TUPLE_6: case TUPLE_7: case TUPLE_8: case TUPLE_9: case TUPLE: case TINYTUPLE: case SMALLTUPLE: return SedesHelper.readGenericTuple(in, type); case BAG: case TINYBAG: case SMALLBAG: return readBag(in, type); case MAP: case TINYMAP: case SMALLMAP: return readMap(in, type); case INTERNALMAP: return readInternalMap(in); case INTEGER_0: return Integer.valueOf(0); case INTEGER_1: return Integer.valueOf(1); case INTEGER_INBYTE: return Integer.valueOf(in.readByte()); case INTEGER_INSHORT: return Integer.valueOf(in.readShort()); case INTEGER: return Integer.valueOf(in.readInt()); case LONG_0: return Long.valueOf(0); case LONG_1: return Long.valueOf(1); case LONG_INBYTE: return Long.valueOf(in.readByte()); case LONG_INSHORT: return Long.valueOf(in.readShort()); case LONG_ININT: return Long.valueOf(in.readInt()); case LONG: return Long.valueOf(in.readLong()); case DATETIME: return new DateTime(in.readLong(), DateTimeZone.forOffsetMillis(in.readShort() * ONE_MINUTE)); case FLOAT: return Float.valueOf(in.readFloat()); case DOUBLE: return Double.valueOf(in.readDouble()); case BIGINTEGER: return readBigInteger(in); case BIGDECIMAL: return readBigDecimal(in); case BOOLEAN_TRUE: return Boolean.valueOf(true); case BOOLEAN_FALSE: return Boolean.valueOf(false); case BYTE: return Byte.valueOf(in.readByte()); case TINYBYTEARRAY: case SMALLBYTEARRAY: case BYTEARRAY: return new DataByteArray(SedesHelper.readBytes(in, type)); case CHARARRAY: case SMALLCHARARRAY: return SedesHelper.readChararray(in, type); case GENERIC_WRITABLECOMPARABLE: return readWritable(in); case SCHEMA_TUPLE_BYTE_INDEX: case SCHEMA_TUPLE_SHORT_INDEX: case SCHEMA_TUPLE: return readSchemaTuple(in, type); case NULL: return null; default: throw new RuntimeException("Unexpected data type " + type + " found in stream."); } }
From source file:bobs.is.compress.sevenzip.SevenZFile.java
private void readUnpackInfo(final DataInput header, final Archive archive) throws IOException { int nid = header.readUnsignedByte(); if (nid != NID.kFolder) { throw new IOException("Expected kFolder, got " + nid); }//from ww w. j a va2 s . c o m final long numFolders = readUint64(header); final Folder[] folders = new Folder[(int) numFolders]; archive.folders = folders; final int external = header.readUnsignedByte(); if (external != 0) { throw new IOException("External unsupported"); } for (int i = 0; i < (int) numFolders; i++) { folders[i] = readFolder(header); } nid = header.readUnsignedByte(); if (nid != NID.kCodersUnpackSize) { throw new IOException("Expected kCodersUnpackSize, got " + nid); } for (final Folder folder : folders) { folder.unpackSizes = new long[(int) folder.totalOutputStreams]; for (int i = 0; i < folder.totalOutputStreams; i++) { folder.unpackSizes[i] = readUint64(header); } } nid = header.readUnsignedByte(); if (nid == NID.kCRC) { final BitSet crcsDefined = readAllOrBits(header, (int) numFolders); for (int i = 0; i < (int) numFolders; i++) { if (crcsDefined.get(i)) { folders[i].hasCrc = true; folders[i].crc = 0xffffFFFFL & Integer.reverseBytes(header.readInt()); } else { folders[i].hasCrc = false; } } nid = header.readUnsignedByte(); } if (nid != NID.kEnd) { throw new IOException("Badly terminated UnpackInfo"); } }
From source file:org.apache.geode.internal.InternalDataSerializer.java
/** * Read the data from in and register it with this class. TODO: loadRegistrations is unused * /*from ww w . j a va2s. c om*/ * @throws IllegalArgumentException if a registration fails */ public static void loadRegistrations(DataInput in) throws IOException { while (in.readInt() != 0) { Class dsClass = null; boolean skip = false; try { dsClass = DataSerializer.readClass(in); } catch (ClassNotFoundException ignored) { skip = true; } if (skip) { continue; } register(dsClass, /* dsId, */ true); } }
From source file:org.apache.geode.internal.InternalDataSerializer.java
/** read a set of Long objects */ public static Set<Long> readSetOfLongs(DataInput in) throws IOException { int size = in.readInt(); if (size < 0) { return null; } else {//from w ww. j a va2s .c o m Set result = new HashSet(size); boolean longIDs = in.readBoolean(); for (int i = 0; i < size; i++) { long l = longIDs ? in.readLong() : in.readInt(); result.add(l); } return result; } }
From source file:org.apache.geode.internal.InternalDataSerializer.java
/** read a set of Long objects */ public static List<Long> readListOfLongs(DataInput in) throws IOException { int size = in.readInt(); if (size < 0) { return null; } else {/*w w w . ja v a 2s . c om*/ List result = new LinkedList(); boolean longIDs = in.readBoolean(); for (int i = 0; i < size; i++) { long l = longIDs ? in.readLong() : in.readInt(); result.add(l); } return result; } }
From source file:org.apache.geode.internal.InternalDataSerializer.java
private static Object readPdxSerializable(final DataInput in) throws IOException, ClassNotFoundException { int len = in.readInt(); int typeId = in.readInt(); InternalCache internalCache = GemFireCacheImpl .getForPdx("PDX registry is unavailable because the Cache has been closed."); PdxType pdxType = internalCache.getPdxRegistry().getType(typeId); if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "readPdxSerializable pdxType={}", pdxType); }/*from w ww . j a v a 2 s . co m*/ if (pdxType == null) { throw new IllegalStateException("Unknown pdx type=" + typeId); } DMStats dmStats = getDMStats(internalCache); dmStats.incPdxDeserialization(len + 9); // check if PdxInstance needs to be returned. if (pdxType.getNoDomainClass() || internalCache.getPdxReadSerializedByAnyGemFireServices()) { dmStats.incPdxInstanceCreations(); return new PdxInstanceImpl(pdxType, in, len); } else { PdxReaderImpl pdxReader = new PdxReaderImpl(pdxType, in, len); return pdxReader.getObject(); } }
From source file:org.apache.hadoop.mapred.ReduceTask.java
@Override public void readFields(DataInput in) throws IOException { super.readFields(in); numMaps = in.readInt(); }
From source file:org.apache.hadoop.mapred.RecoverReducerTask.java
@Override public void readFields(DataInput in) throws IOException { super.readFields(in); numMaps = in.readInt(); }
From source file:hybridewah.HybridBitmap.java
/** * Deserialize./* w w w . j a v a2 s . c o m*/ * * @param in * the DataInput stream * @throws IOException * Signals that an I/O exception has occurred. */ public void deserialize(DataInput in) throws IOException { this.sizeinbits = in.readInt(); this.actualsizeinwords = in.readInt(); if (this.buffer.length < this.actualsizeinwords) { this.buffer = new long[this.actualsizeinwords]; } for (int k = 0; k < this.actualsizeinwords; ++k) this.buffer[k] = in.readLong(); this.rlw = new RunningLengthWord(this.buffer, in.readInt()); }
From source file:org.apache.geode.internal.InternalDataSerializer.java
/** * Write a variable length long the old way (pre 7.0). Use this only in contexts where you might * need to communicate with pre 7.0 members or files. *//*from w ww.j a v a2 s .c o m*/ public static long readVLOld(DataInput in) throws IOException { byte code = in.readByte(); long result; if (code < 0) { // mask off sign bit result = code & 0x7F; result <<= 8; result |= in.readByte() & 0xFF; } else if (code <= MAX_BYTE_VL) { result = code; } else if (code == INT_VL) { result = in.readInt(); } else if (code == LONG_VL) { result = in.readLong(); } else { throw new IllegalStateException("unexpected variable length code=" + code); } return result; }