@Override public void deserialize(DataInput in) throws IOException { // little endian this.cardinality = 0; for (int k = 0; k < bitmap.length; ++k) { bitmap[k] = Long.reverseBytes(in.readLong()); this.cardinality += Long.bitCount(bitmap[k]); } }
public void readFields(DataInput in) throws IOException { this.blockId = in.readLong(); this.numBytes = in.readLong(); this.generationStamp = in.readLong(); if (numBytes < 0) { throw new IOException("Unexpected block size: " + numBytes); } }
private void readCapabilities(DataInput in) throws IOException { long capabilities = in.readLong(); long frequentCapabilities = in.readLong(); for (int i = 0; i < 64; i++) { if ((capabilities & (1L << i)) != 0L) node.setCapability(i); if ((frequentCapabilities & (1L << i)) != 0L) node.clearCapabilityIsFrequent(i); } }
public void readFrom(DataInput in) throws Exception { status = in.readInt(); classname = Bits.readString(in); name = Bits.readString(in); start_time = in.readLong(); stop_time = in.readLong(); failure_type = Bits.readString(in); failure_msg = Bits.readString(in); stack_trace = Bits.readString(in); }
// Used for internal Hadoop purposes // Describes how to read this node from across a network public void readFields(DataInput in) throws IOException { nodeid = in.readLong(); pageRank = in.readDouble(); long next = in.readLong(); ArrayList<Long> ins = new ArrayList<Long>(); while (next != -1) { ins.add(next); next = in.readLong(); } outgoing = new long[ins.size()]; for (int i = 0; i < ins.size(); i++) { outgoing[i] = ins.get(i); } }
@SuppressWarnings("deprecation") public void readFields(DataInput in) throws IOException { rpcVersion = in.readLong(); declaringClassProtocolName = UTF8.readString(in); methodName = UTF8.readString(in); clientVersion = in.readLong(); clientMethodsHash = in.readInt(); parameters = new Object[in.readInt()]; parameterClasses = new Class[parameters.length]; ObjectWritable objectWritable = new ObjectWritable(); for (int i = 0; i < parameters.length; i++) { parameters[i] = ObjectWritable.readObject(in, objectWritable, this.conf); parameterClasses[i] = objectWritable.getDeclaredClass(); } }
private static Node deserializeNode(DataInput input) throws IOException { int level = input.readUnsignedByte(); long value = input.readLong(); double weight = input.readDouble(); return new Node(value, level, weight); }
@Override public void readFields(DataInput input) throws IOException { byte[] tableNameBytes = Bytes.readByteArray(input); PName tableName = new PNameImpl(tableNameBytes); PTableType tableType = PTableType.values()[WritableUtils.readVInt(input)]; long sequenceNumber = WritableUtils.readVLong(input); long timeStamp = input.readLong(); byte[] pkNameBytes = Bytes.readByteArray(input); String pkName = pkNameBytes.length == 0 ? null : Bytes.toString(pkNameBytes); int nColumns = WritableUtils.readVInt(input); List<PColumn> columns = Lists.newArrayListWithExpectedSize(nColumns); for (int i = 0; i < nColumns; i++) { PColumn column = new PColumnImpl(); column.readFields(input); columns.add(column); } Map<String, byte[][]> guidePosts = new HashMap<String, byte[][]>(); int size = WritableUtils.readVInt(input); for (int i = 0; i < size; i++) { String key = WritableUtils.readString(input); int valueSize = WritableUtils.readVInt(input); byte[][] value = new byte[valueSize][]; for (int j = 0; j < valueSize; j++) { value[j] = Bytes.readByteArray(input); } guidePosts.put(key, value); } PTableStats stats = new PTableStatsImpl(guidePosts); init(tableName, tableType, timeStamp, sequenceNumber, pkName, columns, stats); }
public static QuantileDigest deserialize(DataInput input) { try { double maxError = input.readDouble(); double alpha = input.readDouble(); QuantileDigest result = new QuantileDigest(maxError, alpha); result.landmarkInSeconds = input.readLong(); result.min = input.readLong(); result.max = input.readLong(); result.totalNodeCount = input.readInt(); Deque<Node> stack = new ArrayDeque<>(); for (int i = 0; i < result.totalNodeCount; i++) { int flags = input.readByte(); Node node = deserializeNode(input); if ((flags & Flags.HAS_RIGHT) != 0) { node.right = stack.pop(); } if ((flags & Flags.HAS_LEFT) != 0) { node.left = stack.pop(); } stack.push(node); result.weightedCount += node.weightedCount; if (node.weightedCount >= ZERO_WEIGHT_THRESHOLD) { result.nonZeroNodeCount++; } } if (!stack.isEmpty()) { Preconditions.checkArgument( stack.size() == 1, "Tree is corrupted. Expected a single root node"); result.root = stack.pop(); } return result; } catch (IOException e) { throw Throwables.propagate(e); } }
public void readFields(DataInput in) throws IOException { blockToken.readFields(in); this.corrupt = in.readBoolean(); offset = in.readLong(); this.b = new Block(); b.readFields(in); int count = in.readInt(); this.locs = new DatanodeInfo[count]; for (int i = 0; i < locs.length; i++) { locs[i] = new DatanodeInfo(); locs[i].readFields(in); } }
@Test public void testRead1SPP64BPS() throws IOException { // 1 sample per pixel, 64 bits per sample (gray) FastByteArrayOutputStream out = new FastByteArrayOutputStream(32); DataOutput dataOut = new DataOutputStream(out); dataOut.writeLong(0x00000000); dataOut.writeLong(81985529216486895L); dataOut.writeLong(81985529216486895L); dataOut.writeLong(-163971058432973790L); InputStream in = new HorizontalDeDifferencingStream(out.createInputStream(), 4, 1, 64, ByteOrder.BIG_ENDIAN); DataInput dataIn = new DataInputStream(in); // Row 1 assertEquals(0, dataIn.readLong()); assertEquals(81985529216486895L, dataIn.readLong()); assertEquals(163971058432973790L, dataIn.readLong()); assertEquals(0, dataIn.readLong()); // EOF assertEquals(-1, in.read()); }
/** * Reads a primitive value of the specified class type from the stream. * * @param in A stream to read from. * @param cls A class type of the primitive. * @return A primitive. * @throws IOException If an I/O error occurs. */ static Object readPrimitive(DataInput in, Class cls) throws IOException { if (cls == byte.class) return in.readByte(); if (cls == short.class) return in.readShort(); if (cls == int.class) return in.readInt(); if (cls == long.class) return in.readLong(); if (cls == float.class) return in.readFloat(); if (cls == double.class) return in.readDouble(); if (cls == boolean.class) return in.readBoolean(); if (cls == char.class) return in.readChar(); throw new IllegalArgumentException(); }
/** Implement readFields of Writable */ public void readFields(DataInput in) throws IOException { this.offset = in.readLong(); this.length = in.readLong(); int numNames = in.readInt(); this.names = new String[numNames]; for (int i = 0; i < numNames; i++) { Text name = new Text(); name.readFields(in); names[i] = name.toString(); } int numHosts = in.readInt(); for (int i = 0; i < numHosts; i++) { Text host = new Text(); host.readFields(in); hosts[i] = host.toString(); } int numTops = in.readInt(); Text path = new Text(); for (int i = 0; i < numTops; i++) { path.readFields(in); topologyPaths[i] = path.toString(); } }
public void readFrom(DataInput in) throws Exception { type = Type.values()[in.readByte()]; // We can't use Util.readObject since it's size is limited to 2^15-1 try { short first = in.readShort(); if (first == -1) { object = Util.readGenericStreamable(in); } else { ByteBuffer bb = ByteBuffer.allocate(4); bb.putShort(first); bb.putShort(in.readShort()); int size = bb.getInt(0); byte[] bytes = new byte[size]; in.readFully(bytes, 0, size); object = Util.objectFromByteBuffer(bytes); } } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException("Exception encountered while serializing execution request", e); } request = in.readLong(); }
void a(DataInput datainput) { a = datainput.readLong(); }
/** Read a {@link Writable}, {@link String}, primitive type, or an array of the preceding. */ @SuppressWarnings("unchecked") public static Object readObject(DataInput in, ObjectWritable objectWritable, Configuration conf) throws IOException { String className = UTF8.readString(in); Class<?> declaredClass = PRIMITIVE_NAMES.get(className); if (declaredClass == null) { declaredClass = loadClass(conf, className); } Object instance; if (declaredClass.isPrimitive()) { // primitive types if (declaredClass == Boolean.TYPE) { // boolean instance = Boolean.valueOf(in.readBoolean()); } else if (declaredClass == Character.TYPE) { // char instance = Character.valueOf(in.readChar()); } else if (declaredClass == Byte.TYPE) { // byte instance = Byte.valueOf(in.readByte()); } else if (declaredClass == Short.TYPE) { // short instance = Short.valueOf(in.readShort()); } else if (declaredClass == Integer.TYPE) { // int instance = Integer.valueOf(in.readInt()); } else if (declaredClass == Long.TYPE) { // long instance = Long.valueOf(in.readLong()); } else if (declaredClass == Float.TYPE) { // float instance = Float.valueOf(in.readFloat()); } else if (declaredClass == Double.TYPE) { // double instance = Double.valueOf(in.readDouble()); } else if (declaredClass == Void.TYPE) { // void instance = null; } else { throw new IllegalArgumentException("Not a primitive: " + declaredClass); } } else if (declaredClass.isArray()) { // array int length = in.readInt(); instance = Array.newInstance(declaredClass.getComponentType(), length); for (int i = 0; i < length; i++) { Array.set(instance, i, readObject(in, conf)); } } else if (declaredClass == String.class) { // String instance = UTF8.readString(in); } else if (declaredClass.isEnum()) { // enum instance = Enum.valueOf((Class<? extends Enum>) declaredClass, UTF8.readString(in)); } else { // Writable Class instanceClass = null; String str = UTF8.readString(in); instanceClass = loadClass(conf, str); Writable writable = WritableFactories.newInstance(instanceClass, conf); writable.readFields(in); instance = writable; if (instanceClass == NullInstance.class) { // null declaredClass = ((NullInstance) instance).declaredClass; instance = null; } } if (objectWritable != null) { // store values objectWritable.declaredClass = declaredClass; objectWritable.instance = instance; } return instance; }
@Override public void readFields(DataInput in) throws IOException { /* * extract pkt len. * * GPSQL-1107: * The DataInput might already be empty (EOF), but we can't check it beforehand. * If that's the case, pktlen is updated to -1, to mark that the object is still empty. * (can be checked with isEmpty()). */ pktlen = readPktLen(in); if (isEmpty()) { return; } /* extract the version and col cnt */ int version = in.readShort(); int curOffset = 4 + 2; int colCnt; /* !!! Check VERSION !!! */ if (version != GPDBWritable.VERSION && version != GPDBWritable.PREV_VERSION) { throw new IOException( "Current GPDBWritable version(" + GPDBWritable.VERSION + ") does not match input version(" + version + ")"); } if (version == GPDBWritable.VERSION) { errorFlag = in.readByte(); curOffset += 1; } colCnt = in.readShort(); curOffset += 2; /* Extract Column Type */ colType = new int[colCnt]; DBType[] coldbtype = new DBType[colCnt]; for (int i = 0; i < colCnt; i++) { int enumType = (in.readByte()); curOffset += 1; if (enumType == DBType.BIGINT.ordinal()) { colType[i] = BIGINT.getOID(); coldbtype[i] = DBType.BIGINT; } else if (enumType == DBType.BOOLEAN.ordinal()) { colType[i] = BOOLEAN.getOID(); coldbtype[i] = DBType.BOOLEAN; } else if (enumType == DBType.FLOAT8.ordinal()) { colType[i] = FLOAT8.getOID(); coldbtype[i] = DBType.FLOAT8; } else if (enumType == DBType.INTEGER.ordinal()) { colType[i] = INTEGER.getOID(); coldbtype[i] = DBType.INTEGER; } else if (enumType == DBType.REAL.ordinal()) { colType[i] = REAL.getOID(); coldbtype[i] = DBType.REAL; } else if (enumType == DBType.SMALLINT.ordinal()) { colType[i] = SMALLINT.getOID(); coldbtype[i] = DBType.SMALLINT; } else if (enumType == DBType.BYTEA.ordinal()) { colType[i] = BYTEA.getOID(); coldbtype[i] = DBType.BYTEA; } else if (enumType == DBType.TEXT.ordinal()) { colType[i] = TEXT.getOID(); coldbtype[i] = DBType.TEXT; } else { throw new IOException("Unknown GPDBWritable.DBType ordinal value"); } } /* Extract null bit array */ byte[] nullbytes = new byte[getNullByteArraySize(colCnt)]; in.readFully(nullbytes); curOffset += nullbytes.length; boolean[] colIsNull = byteArrayToBooleanArray(nullbytes, colCnt); /* extract column value */ colValue = new Object[colCnt]; for (int i = 0; i < colCnt; i++) { if (!colIsNull[i]) { /* Skip the alignment padding */ int skipbytes = roundUpAlignment(curOffset, coldbtype[i].getAlignment()) - curOffset; for (int j = 0; j < skipbytes; j++) { in.readByte(); } curOffset += skipbytes; /* For fixed length type, increment the offset according to type type length here. * For var length type (BYTEA, TEXT), we'll read 4 byte length header and the * actual payload. */ int varcollen = -1; if (coldbtype[i].isVarLength()) { varcollen = in.readInt(); curOffset += 4 + varcollen; } else { curOffset += coldbtype[i].getTypeLength(); } switch (DataType.get(colType[i])) { case BIGINT: { colValue[i] = in.readLong(); break; } case BOOLEAN: { colValue[i] = in.readBoolean(); break; } case FLOAT8: { colValue[i] = in.readDouble(); break; } case INTEGER: { colValue[i] = in.readInt(); break; } case REAL: { colValue[i] = in.readFloat(); break; } case SMALLINT: { colValue[i] = in.readShort(); break; } /* For BYTEA column, it has a 4 byte var length header. */ case BYTEA: { colValue[i] = new byte[varcollen]; in.readFully((byte[]) colValue[i]); break; } /* For text formatted column, it has a 4 byte var length header * and it's always null terminated string. * So, we can remove the last "\0" when constructing the string. */ case TEXT: { byte[] data = new byte[varcollen]; in.readFully(data, 0, varcollen); colValue[i] = new String(data, 0, varcollen - 1, CHARSET); break; } default: throw new IOException("Unknown GPDBWritable ColType"); } } } /* Skip the ending alignment padding */ int skipbytes = roundUpAlignment(curOffset, 8) - curOffset; for (int j = 0; j < skipbytes; j++) { in.readByte(); } curOffset += skipbytes; if (errorFlag != 0) { throw new IOException("Received error value " + errorFlag + " from format"); } }
public void readFields(DataInput in) throws IOException { this.genstamp = in.readLong(); if (this.genstamp < 0) { throw new IOException("Bad Generation Stamp: " + this.genstamp); } }
void readTagContents(DataInput datainput) throws IOException { longValue = datainput.readLong(); }
void func_736_a(DataInput p_736_1_) throws IOException { field_1095_a = p_736_1_.readLong(); }
@Override public void readFrom(DataInput in) throws Exception { super.readFrom(in); threadId = in.readLong(); }