@Override public boolean equals(Object right_obj) { if (right_obj instanceof Value) { return compareTo(right_obj) == 0; } return false; }
/** * Compares the bytes in this object to the specified byte array * * @return true if the contents of this Value is equivalent to the supplied byte array * @since 2.0.0 */ public boolean contentEquals(byte[] right_obj) { return compareTo(right_obj) == 0; }
/** * Define the sort order of the BytesWritable. * * @param right_obj * The other bytes writable * @return Positive if left is bigger than right, 0 if they are equal, and negative if left is * smaller than right. */ @Override public int compareTo(Object right_obj) { return compareTo(((Value) right_obj).get()); }
@Override public boolean equals(Object right_obj) { // compare with byte[] for backwards compatibility, but this is generally a pretty bad practice if (right_obj instanceof byte[]) { return compareTo((byte[]) right_obj) == 0; } if (right_obj instanceof Value) { return compareTo(right_obj) == 0; } return false; }
/** * Define the sort order of the BytesWritable. * * @param right_obj * The other bytes writable * @return Positive if left is bigger than right, 0 if they are equal, and negative if left is * smaller than right. */ @Override public int compareTo(Object right_obj) { return compareTo(((Value) right_obj).get()); }
private long batchScan(Connector c, String tableName, List<Range> ranges, int threads) throws Exception { BatchScanner bs = c.createBatchScanner(tableName, TestIngest.AUTHS, threads); bs.setRanges(ranges); int count = 0; long t1 = System.currentTimeMillis(); byte rval[] = new byte[50]; Random random = new Random(); for (Entry<Key,Value> entry : bs) { count++; int row = VerifyIngest.getRow(entry.getKey()); int col = VerifyIngest.getCol(entry.getKey()); if (row < 0 || row >= NUM_TO_INGEST) { throw new Exception("unexcepted row " + row); } rval = TestIngest.genRandomValue(random, rval, 2, row, col); if (entry.getValue().compareTo(rval) != 0) { throw new Exception("unexcepted value row=" + row + " col=" + col); } } long t2 = System.currentTimeMillis(); bs.close(); if (count != NUM_TO_INGEST) { throw new Exception("Batch Scan did not return expected number of values " + count); } return t2 - t1; }
String.format("%1$s < %2$s", prevValue, entry.getValue())); assertTrue(prevValue.compareTo(entry.getValue()) > 0);
bytesRead += val.length; Value value = new Value(val); if (value.compareTo(ev) != 0) { log.error("unexpected value (" + rowKey + " " + colf + " " + colq + " : saw " + value + " expected " + new Value(ev)); if (entry.getValue().compareTo(value) != 0) { log.error("unexpected value, rowNum : " + rowNum + " colNum : " + colNum); log.error(" saw = " + new String(entry.getValue().get()) + " expected = "
@Test public void testSingleShard() { agg.reset(); BitSet bitSet = new BitSet(20); bitSet.set(20); Value val = new Value(bitSet.toByteArray()); Value result = agg.reduce(new Key("key"), Iterators.singletonIterator(val)); assertNotNull(result); assertNotNull(result.get()); assertNotNull(val.get()); assertEquals(0, val.compareTo(result.get())); }
@Test public void testSingleUid() { agg.reset(); Builder b = createNewUidList(); b.setCOUNT(1); b.setIGNORE(false); b.addUID(UUID.randomUUID().toString()); Uid.List uidList = b.build(); Value val = new Value(uidList.toByteArray()); Value result = agg.reduce(new Key("key"), Iterators.singletonIterator(val)); assertNotNull(result); assertNotNull(result.get()); assertNotNull(val.get()); assertEquals(0, val.compareTo(result.get())); }