public void writeExternal(ObjectOutput out) throws IOException { out.writeBoolean(reply); out.writeInt(uuid.length); out.write(uuid, 0, uuid.length); out.writeInt(rpcId.length); out.write(rpcId, 0, rpcId.length); out.writeObject(message); }
/** * Write this out. * * @exception IOException error writing to log stream */ public synchronized void writeExternal(ObjectOutput out) throws IOException { out.writeLong(getPrevblk()); out.writeLong(getNextblk()); out.writeShort(getBytesused()); out.writeShort(getBytesinuse()); out.writeLong(getPageLSN()); if (getBytesused() == datasize) out.write(data); else out.write(data, 0, getBytesused()); }
@Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); out.writeInt(request.serializedMessage.length); out.write(request.serializedMessage); out.writeBoolean(request.signed); if (request.signed) { out.writeInt(request.serializedMessageSignature.length); out.write(request.serializedMessageSignature); } }
@Override public void writeExternal(ObjectOutput out) throws IOException { out.write(this.cardinality & 0xFF); out.write((this.cardinality >>> 8) & 0xFF); if (BufferUtil.isBackedBySimpleArray(content)) { short[] a = content.array(); for (int k = 0; k < this.cardinality; ++k) { out.writeShort(Short.reverseBytes(a[k])); } } else { for (int k = 0; k < this.cardinality; ++k) { out.writeShort(Short.reverseBytes(content.get(k))); } } }
@Override protected void writeObject(ObjectOutput out, Object obj) throws IOException { BigInteger val = (BigInteger) obj; byte[] bytes = val.toByteArray(); out.writeInt(bytes.length); out.write(bytes); }
protected void writePackager(ObjectOutput out) throws IOException { out.writeByte('P'); String pclass = packager.getClass().getName(); byte[] b = pclass.getBytes(); out.writeShort(b.length); out.write(b); }
/** {@inheritDoc} */ public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); byte[] data = path.getBytes(Constants.DEFAULT_ENCODING); out.writeInt(data.length); out.write(data); }
@Override public void writeExternal(ObjectOutput out) throws IOException { byte[] bytes = getBytes(); out.writeInt(bytes.length); out.writeInt(this.numFields); out.write(bytes); }
public void writeString(final String s) throws IOException { final ObjectOutput out = this.out; if (s != null) { final int cn = s.length(); ASCII: if (cn <= BA_LENGTH) { for (int ci = 0; ci < cn; ) { if ((s.charAt(ci++) & 0xffffff00) != 0) { break ASCII; } } if (cn <= 8) { out.writeInt(-cn); out.writeBytes(s); return; } else { out.writeInt(-cn); s.getBytes(0, cn, this.ba, 0); out.write(this.ba, 0, cn); return; } } out.writeInt(cn); out.writeChars(s); return; } else { out.writeInt(Integer.MIN_VALUE); return; } }
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(2); out.writeInt(548); out.writeInt(348); byte[] bytes = new byte[1024]; for (int i = 0; i < 548; i++) { bytes[i] = 1; } out.write(bytes, 0, 548); bytes = new byte[1024]; for (int i = 0; i < 348; i++) { bytes[i] = 2; } out.write(bytes, 0, 348); }
protected void writeHeader(ObjectOutput out) throws IOException { int len = header.getLength(); if (len > 0) { out.writeByte('H'); out.writeShort(len); out.write(header.pack()); } }
@Override protected void writeObject(ObjectOutput out, Object obj) throws IOException { BigDecimal val = (BigDecimal) obj; out.writeInt(val.scale()); BigInteger unscaled = val.unscaledValue(); byte[] bytes = unscaled.toByteArray(); out.writeInt(bytes.length); out.write(bytes); }
@Override protected void writeObject(ObjectOutput out, Object obj) throws IOException { byte[] bytes = ((BinaryType) obj).getBytes(); out.writeInt( bytes .length); // in theory this could be a short, but we're not strictly enforcing the // length out.write(bytes); }
// support function to allow ordinary byte [] to be written in same fashion public static void writeBytes(ObjectOutput out, byte[] buffer, int offset, int length) throws IOException { if (length < 256 && length != MAGIC_LENGTH_INDICATING_32_BIT_SIZE) { out.writeByte(length); } else { out.writeByte(MAGIC_LENGTH_INDICATING_32_BIT_SIZE); out.writeInt(length); } out.write(buffer, offset, length); }
public void writeExternal(ObjectOutput out) throws IOException { out.writeBoolean(this.buffer != null); if (this.buffer != null) { out.writeInt(this.buffer.capacity()); out.writeInt(this.buffer.limit()); out.writeInt(this.buffer.position()); for (int i = 0; i < this.buffer.capacity(); i++) { out.write(this.buffer.get(i)); } } }
@Override protected void writeObject(ObjectOutput out, Object obj) throws IOException { DefaultDataTypes dataType = getDataTypeManager().getDataType(obj.getClass()); int code = dataType.ordinal(); out.writeByte((byte) code); if (code == DataTypeManagerService.DefaultDataTypes.BOOLEAN.ordinal()) { if (Boolean.TRUE.equals(obj)) { out.write((byte) 1); } else { out.write((byte) 0); } } else if (code <= highestKnownCode && code != DataTypeManagerService.DefaultDataTypes.OBJECT.ordinal()) { dataType = DataTypeManagerService.DefaultDataTypes.valueOf(getTeiidVersion(), code); ColumnSerializer s = getSerializer(dataType.getId(), (byte) 1); s.writeObject(out, obj); } else { super.writeObject(out, obj); } }
@Override public void writeExternal(ObjectOutput out) throws IOException { // writeBytes(out, buffer, offset, length); if (length < 256 && length != MAGIC_LENGTH_INDICATING_32_BIT_SIZE) { out.writeByte(length); } else { out.writeByte(MAGIC_LENGTH_INDICATING_32_BIT_SIZE); out.writeInt(length); } out.write(buffer, offset, length); }
/** * For Externalizable * * @see Externalizable */ public void writeExternal(ObjectOutput out) throws IOException { // if (this.transientPort == 0) { // InternalDistributedSystem.getLoggerI18n().warning( // LocalizedStrings.DEBUG, // "externalizing a client ID with zero port: " + this.toString(), // new Exception("Stack trace")); // } Assert.assertTrue(this.identity.length <= BYTES_32KB); out.writeShort(this.identity.length); out.write(this.identity); out.writeInt(this.uniqueId); }
/* This implementation compacts the isNull and boolean data for non-null values into a byte[] * by using a 8 bit mask that is bit-shifted to mask each value. */ @Override public void writeColumn(ObjectOutput out, int col, List<? extends List<?>> batch) throws IOException { int currentByte = 0; int mask = 0x80; Object obj; for (int row = 0; row < batch.size(); row++) { // Write the isNull value obj = batch.get(row).get(col); if (obj == null) { currentByte |= mask; } mask >>= 1; // Shift the mask to the next bit if (mask == 0) { // If the current byte has been used up, write it and reset. out.write(currentByte); currentByte = 0; mask = 0x80; } if (obj != null) { // Write the boolean value if it's not null if (((Boolean) obj).booleanValue()) { currentByte |= mask; } mask >>= 1; if (mask == 0) { out.write(currentByte); currentByte = 0; mask = 0x80; } } } // Invariant mask != 0 // If we haven't reached the eight-row mark then the loop would not have written this byte // Write the final byte containing data for th extra rows, if it exists. if (mask != 0x80) { out.write(currentByte); } }
/** * Packs the (boolean) information about whether data values in the column are null into bytes so * that we send ~n/8 instead of n bytes. * * @param out * @param col * @param batch * @throws IOException * @since 4.2 */ static void writeIsNullData(ObjectOutput out, int col, List<? extends List<?>> batch) throws IOException { int numBytes = batch.size() / 8, row = 0, currentByte = 0; for (int byteNum = 0; byteNum < numBytes; byteNum++, row += 8) { currentByte = (batch.get(row).get(col) == null) ? 0x80 : 0; if (batch.get(row + 1).get(col) == null) currentByte |= 0x40; if (batch.get(row + 2).get(col) == null) currentByte |= 0x20; if (batch.get(row + 3).get(col) == null) currentByte |= 0x10; if (batch.get(row + 4).get(col) == null) currentByte |= 0x08; if (batch.get(row + 5).get(col) == null) currentByte |= 0x04; if (batch.get(row + 6).get(col) == null) currentByte |= 0x02; if (batch.get(row + 7).get(col) == null) currentByte |= 0x01; out.write(currentByte); } if (batch.size() % 8 > 0) { currentByte = 0; for (int mask = 0x80; row < batch.size(); row++, mask >>= 1) { if (batch.get(row).get(col) == null) currentByte |= mask; } out.write(currentByte); } }
@Override public void writeObject(ObjectOutput output, OffHeapEmbeddedMetadata object) throws IOException { int number = numbers.get(object.getClass(), -1); output.write(number); switch (number) { case EXPIRABLE: output.writeLong(object.lifespan()); output.writeLong(object.maxIdle()); break; } output.writeObject(object.version()); }
/** * Distill the BigDecimal to a byte array and write out: * * <UL> * <LI>scale (zero or positive) as a byte * <LI>length of byte array as a byte * <LI>the byte array * </UL> */ public void writeExternal(ObjectOutput out) throws IOException { // never called when value is null if (SanityManager.DEBUG) SanityManager.ASSERT(!isNull()); int scale; byte[] byteArray; if (value != null) { scale = value.scale(); // J2SE 5.0 introduced negative scale value for BigDecimals. // In previouse Java releases a negative scale was not allowed // (threw an exception on setScale and the constructor that took // a scale). // // Thus the Derby format for DECIMAL implictly assumed a // positive or zero scale value, and thus now must explicitly // be positive. This is to allow databases created under J2SE 5.0 // to continue to be supported under JDK 1.3/JDK 1.4, ie. to continue // the platform independence, independent of OS/cpu and JVM. // // If the scale is negative set the scale to be zero, this results // in an unchanged value with a new scale. A BigDecimal with a // negative scale by definition is a whole number. // e.g. 1000 can be represented by: // a BigDecimal with scale -3 (unscaled value of 1) // or a BigDecimal with scale 0 (unscaled value of 1000) if (scale < 0) { scale = 0; value = value.setScale(0); } BigInteger bi = value.unscaledValue(); byteArray = bi.toByteArray(); } else { scale = rawScale; byteArray = rawData; } if (SanityManager.DEBUG) { if (scale < 0) SanityManager.THROWASSERT( "DECIMAL scale at writeExternal is negative " + scale + " value " + toString()); } out.writeByte(scale); out.writeByte(byteArray.length); out.write(byteArray); }
public void writeExternal(ObjectOutput out) throws IOException { // public String version; byte[] bytes = version.getBytes(); out.writeInt(bytes.length); out.write(bytes); // public Group group; group.writeExternal(out); // public ViewID id; id.writeExternal(out); // public ViewID[] previous; out.writeInt(previous.length); for (int i = 0; i < previous.length; i++) previous[i].writeExternal(out); // public Endpt[] view; out.writeInt(view.length); for (int i = 0; i < view.length; i++) view[i].writeExternal(out); // public InetWithPort[] addresses; out.writeInt(addresses.length); for (int i = 0; i < addresses.length; i++) { bytes = addresses[i].getAddress().getAddress(); out.writeInt(bytes.length); out.write(bytes); out.writeInt(addresses[i].getPort()); } }
@Override public void writeExternal(final ObjectOutput out) throws IOException { out.writeUTF(id); out.writeInt(version); out.writeLong(block); /* * Note: offset not written when serialized and always zero when * de-serialized. */ out.writeInt(len); /* length */ out.write(b, off, len); /* data */ }
@Override public void writeObject(ObjectOutput output, Document doc) throws IOException { // Write the type byte ... output.writeByte(1); byte[] bytes = Bson.write(doc); // Write the number of bytes ... output.writeInt(bytes.length); // Write the BSON output ... output.write(bytes); // Try to read the bytes back in, and if there's a failure, then write out the doc ... try { Bson.read(new ByteArrayInputStream(bytes)); } catch (RuntimeException e) { // Print the original document ... System.err.println("Failed to write and read BSON document: "); System.err.println(Json.write(doc)); } }
@Override public void writeExternal(ObjectOutput out) throws IOException { FileSystemProto.Directory.Builder dirBuilder = FileSystemProto.Directory.newBuilder(); dirBuilder.setPath(getPath()); dirBuilder.setLastModified(getLastModified()); FileSystemProto.File.Builder fileBuilder = FileSystemProto.File.newBuilder(); for (CacheFileProto child : children) { fileBuilder.clear(); fileBuilder.setName(child.getShortName()); fileBuilder.setIsDirectory(child.isDirectory()); fileBuilder.setLastModified(child.getLastModified()); fileBuilder.setLength(child.getLength()); dirBuilder.addFiles(fileBuilder); } thredds.filesystem.FileSystemProto.Directory dirProto = dirBuilder.build(); byte[] b = dirProto.toByteArray(); out.writeInt(b.length); out.write(b); }
@Override public void writeObject(ObjectOutput output, ByteBufferImpl b) throws IOException { UnsignedNumeric.writeUnsignedInt(output, b.length); output.write(b.buf, b.offset, b.length); }
public void writeExternal(ObjectOutput out) throws IOException { out.writeLong(id); out.writeInt(content.length); out.write(content); }
public void write(int b) throws IOException { out.write(b); }
public void write(byte[] b, int off, int len) throws IOException { out.write(b, off, len); }