@Override
	public void writeExternal(ObjectOutput out) throws IOException {

		boolean compress = enableCompressedSerializationOutput;

		byte[] compressedData = null;
		int compressedLen = -1;

		if (empty || data == null) {
			compress = false;
		}
		else if (compress) {
			// attempt to compress data
			compressedData = new byte[data.length];
			compressedLen = deflateData(data, compressedData);
			if (compressedLen < 0) {
				compress = false; // compression ineffective
			}
		}

		out.writeInt(FORMAT_VERSION);
		out.writeBoolean(compress);

		out.writeInt(id);
		out.writeBoolean(dirty);
		out.writeBoolean(empty);

		if (data == null) {
			out.writeInt(-1);
		}
		else {

			out.writeInt(data.length);

			if (compress) {
				out.writeInt(compressedLen); // compressed buf size
				out.write(compressedData, 0, compressedLen);
			}
			else if (data != null) {
				out.write(data);
			}
		}
	}
Copy data from another buffer into this buffer.
@param offset offset within this buffer.
@param buf source buffer
@param bufOffset source buffer offset
@param length amount of data to copy.
@throws IndexOutOfBoundsException is thrown if parameters result in
data access beyond the buffer size.
Ghidra/Framework/DB/src/main/java/db/buffers/DataBuffer.java