@Override public boolean[] deserialize(boolean[] reuse, DataInputView source) throws IOException { final int len = source.readInt(); reuse = new boolean[len]; for (int i = 0; i < len; i++) { reuse[i] = source.readBoolean(); } return reuse; }
@Override public VertexWithRankAndDangling readWithKeyDenormalization(VertexWithRankAndDangling reuse, DataInputView source) throws IOException { reuse.setVertexID(source.readLong() + Long.MIN_VALUE); reuse.setRank(source.readDouble()); reuse.setDangling(source.readBoolean()); return reuse; }
@Override public int compare(DataInputView firstSource, DataInputView secondSource) throws IOException { final int fs = firstSource.readBoolean() ? 1 : 0; final int ss = secondSource.readBoolean() ? 1 : 0; int comp = fs - ss; return ascendingComparison ? comp : -comp; }
@Override public double[] deserialize(double[] reuse, DataInputView source) throws IOException { final int len = source.readInt(); reuse = new double[len]; for (int i = 0; i < len; i++) { reuse[i] = source.readDouble(); } return reuse; }
@Override public VertexWithRank readWithKeyDenormalization(VertexWithRank reuse, DataInputView source) throws IOException { reuse.setVertexID(source.readLong() + Long.MIN_VALUE); reuse.setRank(source.readDouble()); return reuse; }
@Override public int compare(DataInputView firstSource, DataInputView secondSource) throws IOException { double l1 = firstSource.readDouble(); double l2 = secondSource.readDouble(); int comp = (l1 < l2 ? -1 : (l1 > l2 ? 1 : 0)); return ascendingComparison ? comp : -comp; }
@Override public void write(final DataInputView source, int numBytes) throws IOException { for (; numBytes > 0; numBytes -= 1024) { final byte[] buffer = new byte[Math.min(numBytes, 1024)]; source.readFully(buffer); this.write(buffer); } } }
@Override public void copy(DataInputView in, DataOutputView target) throws IOException { int len = in.readUnsignedByte(); target.writeByte(len); if (len >= HIGH_BIT) { int shift = 7; int curr; len = len & 0x7f; while ((curr = in.readUnsignedByte()) >= HIGH_BIT) { len |= (curr & 0x7f) << shift; shift += 7; target.writeByte(curr); } len |= curr << shift; } for (int i = 0; i < len; i++) { int c = in.readUnsignedByte(); target.writeByte(c); if (c >= HIGH_BIT) { int curr; while ((curr = in.readUnsignedByte()) >= HIGH_BIT) { target.writeByte(curr); } } } }
@Override public VertexWithRankAndDangling deserialize(VertexWithRankAndDangling target, DataInputView source) throws IOException { target.setVertexID(source.readLong()); target.setRank(source.readDouble()); target.setDangling(source.readBoolean()); return target; }