/** * @param bb ByteBuffer having serialized object, including the type information * @param type serialized type information * @return the size of this type */ private static int readSize(ByteBuffer bb) { return readSize(bb, bb.get()); }
@SuppressWarnings("unchecked") private int compareBinInterSedesBag(ByteBuffer bb1, ByteBuffer bb2, byte dt1, byte dt2) throws IOException { int s1 = bb1.position(); int s2 = bb2.position(); int l1 = bb1.remaining(); int l2 = bb2.remaining(); // first compare sizes int bsz1 = readSize(bb1, dt1); int bsz2 = readSize(bb2, dt2); if (bsz1 > bsz2) return 1; else if (bsz1 < bsz2) return -1; else { DataInputBuffer buffer1 = new DataInputBuffer(); DataInputBuffer buffer2 = new DataInputBuffer(); buffer1.reset(bb1.array(), s1, l1); buffer2.reset(bb2.array(), s2, l2); DataBag bag1 = (DataBag) mSedes.readDatum(buffer1, dt1); DataBag bag2 = (DataBag) mSedes.readDatum(buffer2, dt2); bb1.position(buffer1.getPosition()); bb2.position(buffer2.getPosition()); return bag1.compareTo(bag2); } }
type2 = getGeneralizedDataType(dt2); if (type1 == type2) { int sz1 = readSize(bb1, bb1.get()); int sz2 = readSize(bb2, bb2.get()); byte[] ca1 = new byte[sz1]; byte[] ca2 = new byte[sz2]; type2 = getGeneralizedDataType(dt2); if (type1 == type2) { int sz1 = readSize(bb1, bb1.get()); int sz2 = readSize(bb2, bb2.get()); byte[] ca1 = new byte[sz1]; byte[] ca2 = new byte[sz2]; type2 = getGeneralizedDataType(dt2); if (type1 == type2) { int basz1 = readSize(bb1, dt1); int basz2 = readSize(bb2, dt2); rc = WritableComparator.compareBytes( bb1.array(), bb1.position(), basz1, type2 = getGeneralizedDataType(dt2); if (type1 == type2) { int casz1 = readSize(bb1, dt1); int casz2 = readSize(bb2, dt2); String str1 = null, str2 = null; try { int tsz1 = readSize(bb1, dt1);
@SuppressWarnings("unchecked") private int compareBinInterSedesMap(ByteBuffer bb1, ByteBuffer bb2, byte dt1, byte dt2) throws ExecException, IOException { int s1 = bb1.position(); int s2 = bb2.position(); int l1 = bb1.remaining(); int l2 = bb2.remaining(); // first compare sizes int bsz1 = readSize(bb1, dt1); int bsz2 = readSize(bb2, dt2); if (bsz1 > bsz2) return 1; else if (bsz1 < bsz2) return -1; else { DataInputBuffer buffer1 = new DataInputBuffer(); DataInputBuffer buffer2 = new DataInputBuffer(); buffer1.reset(bb1.array(), s1, l1); buffer2.reset(bb2.array(), s2, l2); Map<String, Object> map1 = (Map<String, Object>) mSedes.readDatum(buffer1, dt1); Map<String, Object> map2 = (Map<String, Object>) mSedes.readDatum(buffer2, dt2); bb1.position(buffer1.getPosition()); bb2.position(buffer2.getPosition()); return DataType.compare(map1, map2, DataType.MAP, DataType.MAP); } }