BytesWritable bw1 = ((BinaryObjectInspector) poi1).getPrimitiveWritableObject(o1); BytesWritable bw2 = ((BinaryObjectInspector) poi2).getPrimitiveWritableObject(o2); return bw1.compareTo(bw2);
public void testCompare() throws Exception { byte[][] values = new byte[][]{"abc".getBytes(), "ad".getBytes(), "abcd".getBytes(), "".getBytes(), "b".getBytes()}; BytesWritable[] buf = new BytesWritable[values.length]; for(int i=0; i < values.length; ++i) { buf[i] = new BytesWritable(values[i]); } // check to make sure the compare function is symetric and reflexive for(int i=0; i < values.length; ++i) { for(int j=0; j < values.length; ++j) { assertTrue(buf[i].compareTo(buf[j]) == -buf[j].compareTo(buf[i])); assertTrue((i == j) == (buf[i].compareTo(buf[j]) == 0)); } } assertTrue(buf[0].compareTo(buf[1]) < 0); assertTrue(buf[1].compareTo(buf[2]) > 0); assertTrue(buf[2].compareTo(buf[3]) > 0); assertTrue(buf[3].compareTo(buf[4]) < 0); }
private boolean isNextMetricTheSame(Text nextRow) { byte[] next = nextRow.getBytes(); if (next.length > prevMetricBytes.getLength() && 0 == prevMetricBytes.compareTo(next, 0, prevMetricBytes.getLength()) && nextRow.charAt(prevMetricBytes.getLength()) == 0x00) { return true; } else { return false; } }
@Override public int compareTo(UnionWritable other) { if (index == other.getIndex()) { return value.compareTo(other.getValue()); } return index - other.getIndex(); }
@Test public void testCompare() throws Exception { byte[][] values = new byte[][]{"abc".getBytes(), "ad".getBytes(), "abcd".getBytes(), "".getBytes(), "b".getBytes()}; BytesWritable[] buf = new BytesWritable[values.length]; for(int i=0; i < values.length; ++i) { buf[i] = new BytesWritable(values[i]); } // check to make sure the compare function is symetric and reflexive for(int i=0; i < values.length; ++i) { for(int j=0; j < values.length; ++j) { assertTrue(buf[i].compareTo(buf[j]) == -buf[j].compareTo(buf[i])); assertTrue((i == j) == (buf[i].compareTo(buf[j]) == 0)); } } assertTrue(buf[0].compareTo(buf[1]) < 0); assertTrue(buf[1].compareTo(buf[2]) > 0); assertTrue(buf[2].compareTo(buf[3]) > 0); assertTrue(buf[3].compareTo(buf[4]) < 0); }
@Test public void testCompare() throws Exception { byte[][] values = new byte[][]{"abc".getBytes(), "ad".getBytes(), "abcd".getBytes(), "".getBytes(), "b".getBytes()}; BytesWritable[] buf = new BytesWritable[values.length]; for(int i=0; i < values.length; ++i) { buf[i] = new BytesWritable(values[i]); } // check to make sure the compare function is symetric and reflexive for(int i=0; i < values.length; ++i) { for(int j=0; j < values.length; ++j) { assertTrue(buf[i].compareTo(buf[j]) == -buf[j].compareTo(buf[i])); assertTrue((i == j) == (buf[i].compareTo(buf[j]) == 0)); } } assertTrue(buf[0].compareTo(buf[1]) < 0); assertTrue(buf[1].compareTo(buf[2]) > 0); assertTrue(buf[2].compareTo(buf[3]) > 0); assertTrue(buf[3].compareTo(buf[4]) < 0); }
zeroBuf.toString(), copyBuf.toString()); assertTrue("compare order objects with same backing array should be equal", zeroBuf.compareTo(copyBuf) == 0); assertTrue("hash of objects with same backing array should be equal", zeroBuf.hashCode() == copyBuf.hashCode());
zeroBuf.toString(), copyBuf.toString()); assertTrue("compare order objects with same backing array should be equal", zeroBuf.compareTo(copyBuf) == 0); assertTrue("hash of objects with same backing array should be equal", zeroBuf.hashCode() == copyBuf.hashCode());
BytesWritable bw1 = ((BinaryObjectInspector) poi1).getPrimitiveWritableObject(o1); BytesWritable bw2 = ((BinaryObjectInspector) poi2).getPrimitiveWritableObject(o2); return bw1.compareTo(bw2);
BytesWritable bw1 = ((BinaryObjectInspector) poi1).getPrimitiveWritableObject(o1); BytesWritable bw2 = ((BinaryObjectInspector) poi2).getPrimitiveWritableObject(o2); return bw1.compareTo(bw2);
BytesWritable bw1 = ((BinaryObjectInspector) poi1).getPrimitiveWritableObject(o1); BytesWritable bw2 = ((BinaryObjectInspector) poi2).getPrimitiveWritableObject(o2); return bw1.compareTo(bw2);
BytesWritable bw1 = ((BinaryObjectInspector) poi1).getPrimitiveWritableObject(o1); BytesWritable bw2 = ((BinaryObjectInspector) poi2).getPrimitiveWritableObject(o2); return bw1.compareTo(bw2);