/** * @see #writeSignedVarLong(long, DataOutput) */ public static int writeSignedVarInt(int value, DataOutput out) throws IOException { // Great trick from http://code.google.com/apis/protocolbuffers/docs/encoding.html#types return writeUnsignedVarInt((value << 1) ^ (value >> 31), out); }
private static int writeLength(long[] values, DataOutput out) throws IOException { final int length = values.length; writeUnsignedVarInt(length, out); return length; }
/** * @see #writeSignedVarLong(long, DataOutput) */ public static int writeSignedVarInt(int value, DataOutput out) throws IOException { // Great trick from http://code.google.com/apis/protocolbuffers/docs/encoding.html#types return writeUnsignedVarInt((value << 1) ^ (value >> 31), out); }
/** * Writes the length of the array * * @return the number of bytes written * @throws IOException */ private static int writeLength(int[] values, DataOutput out) throws IOException { final int length = values.length; return writeUnsignedVarInt(length, out); }
/** * Writes the length of the array * * @return the number of bytes written * @throws IOException */ private static int writeLength(int[] values, DataOutput out) throws IOException { final int length = values.length; return writeUnsignedVarInt(length, out); }
@Override public void writeDoubleArray(double[] field, DataOutput data) throws IOException { writeUnsignedVarInt(field.length, data); for (double d : field) data.writeDouble(d); }
@Override public void writeLongArray(long[] field, DataOutput data) throws IOException { writeUnsignedVarInt(field.length, data); for (long l : (long[]) field) data.writeLong(l); }
@Override public void writeLongArray(long[] field, DataOutput data) throws IOException { writeUnsignedVarInt(field.length, data); for (long l : (long[]) field) data.writeLong(l); }
@Override public void writeByteArray(byte[] field, DataOutput data) throws IOException { writeUnsignedVarInt(field.length, data); data.write(field); }
@Override public void writeFloatArray(float[] field, DataOutput data) throws IOException { writeUnsignedVarInt(field.length, data); for (float f : field) data.writeFloat(f); }
@Override public void writeIntArray(int[] field, DataOutput data) throws IOException { writeUnsignedVarInt(field.length, data); for (int i : (int[]) field) data.writeInt(i); }
public void objectToEntry(Map<String, String> props, DataOutput output) throws IOException { Varint.writeUnsignedVarInt(props.size(), output); for (Map.Entry<String, String> e : props.entrySet()) { output.writeUTF(e.getKey()); output.writeUTF(e.getValue()); } } }
public void objectToEntry(List<ObjectId> list, DataOutput output) throws IOException { int len = list.size(); Varint.writeUnsignedVarInt(len, output); for (int i = 0; i < len; i++) { OID.objectToEntry(list.get(i), output); } }
public void objectToEntry(List<ObjectId> list, DataOutput output) throws IOException { int len = list.size(); Varint.writeUnsignedVarInt(len, output); for (int i = 0; i < len; i++) { OID.objectToEntry(list.get(i), output); } }
public static void encode(DataOutput out, RevTree tree) throws IOException { // object type out.write(RevObject.TYPE.TREE.ordinal()); final long totalSize = tree.size(); final int totalSubtrees = tree.numTrees(); Varint.writeUnsignedVarLong(totalSize, out); Varint.writeUnsignedVarInt(totalSubtrees, out); }
@Override public void writeBucket(final int index, final Bucket bucket, DataOutput data, Envelope envBuff) throws IOException { writeUnsignedVarInt(index, data); data.write(bucket.getObjectId().getRawValue()); envBuff.setToNull(); bucket.expand(envBuff); writeBounds(envBuff,data); }
public void writeCommit(RevCommit commit, DataOutput data) throws IOException { data.write(commit.getTreeId().getRawValue()); final int nParents = commit.getParentIds().size(); writeUnsignedVarInt(nParents, data); for (ObjectId pId : commit.getParentIds()) { data.write(pId.getRawValue()); } writePerson(commit.getAuthor(), data); writePerson(commit.getCommitter(), data); data.writeUTF(commit.getMessage()); }
public void writeFeatureType(RevFeatureType object, DataOutput data) throws IOException { writeName(object.getName(), data); ImmutableList<PropertyDescriptor> descriptors = object.descriptors(); writeUnsignedVarInt(descriptors.size(), data); for (PropertyDescriptor desc : object.type().getDescriptors()) { writeProperty(desc, data); } }
public void writeCommit(RevCommit commit, DataOutput data) throws IOException { commit.getTreeId().writeTo(data); final int nParents = commit.getParentIds().size(); writeUnsignedVarInt(nParents, data); for (ObjectId pId : commit.getParentIds()) { pId.writeTo(data); } writePerson(commit.getAuthor(), data); writePerson(commit.getCommitter(), data); data.writeUTF(commit.getMessage()); }
@Override protected void writeBucket(final Bucket bucket, DataOutput data, Envelope envBuff) throws IOException { writeUnsignedVarInt(bucket.getIndex(), data); bucket.getObjectId().writeTo(data); envBuff.setToNull(); bucket.expand(envBuff); writeBounds(envBuff, data); }