@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ByteArray o = (ByteArray) obj; if (this.data == null && o.data == null) return true; else if (this.data == null || o.data == null) return false; else return Bytes.equals(this.data, this.offset, this.length, o.data, o.offset, o.length); }
public static boolean equals(List<byte[]> a, List<byte[]> b) { if (a == null) { return b == null; } if (b == null) { return false; } if (a.size() != b.size()) { return false; } for (int i = 0; i < a.size(); ++i) { if (!Bytes.equals(a.get(i), b.get(i))) { return false; } } return true; }
@Test public void testProject() { byte[] bytes1 = new byte[] { -1, -2, -3, -4 }; byte[] bytes2 = new byte[] { 1, 2, 3, 4 }; byte[] bytes3 = new byte[] { 1, 99, 100, 4 }; byte[] bytes4 = new byte[] { 1, 1, 1, 5 }; AggrKey rowKey = sample.getAggrKey(newCellWithRowKey(bytes1)); AggrKey rowKey2 = sample.getAggrKey(newCellWithRowKey(bytes2)); assertTrue(rowKey == rowKey2); // no extra object creation assertTrue(Bytes.equals(rowKey.get(), rowKey.offset(), rowKey.length(), bytes2, 0, bytes2.length)); rowKey2 = rowKey.copy(); // explicit object creation assertTrue(rowKey != rowKey2); rowKey = sample.getAggrKey(newCellWithRowKey(bytes1)); assertTrue(rowKey.hashCode() != rowKey2.hashCode()); assertTrue(rowKey.equals(rowKey2) == false); assertTrue(rowKey.compareTo(rowKey2) > 0); // unsigned compare rowKey = sample.getAggrKey(newCellWithRowKey(bytes3)); assertTrue(rowKey.hashCode() == rowKey2.hashCode()); assertTrue(rowKey.equals(rowKey2) == true); assertTrue(rowKey.compareTo(rowKey2) == 0); rowKey = sample.getAggrKey(newCellWithRowKey(bytes4)); assertTrue(rowKey.hashCode() != rowKey2.hashCode()); assertTrue(rowKey.equals(rowKey2) == false); assertTrue(rowKey.compareTo(rowKey2) > 0); }
private boolean isNull(byte[] v) { for (byte[] nullByte : nullBytes) { if (Bytes.equals(v, nullByte)) return true; } return false; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ByteArray o = (ByteArray) obj; if (this.data == null && o.data == null) return true; else if (this.data == null || o.data == null) return false; else return Bytes.equals(this.data, this.offset, this.length, o.data, o.offset, o.length); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; CompressedValueContainer other = (CompressedValueContainer) obj; if (size != other.size) return false; if (valueLen != other.valueLen) return false; if (!Bytes.equals(uncompressed, 0, size * valueLen, uncompressed, 0, size * valueLen)) return false; return true; }
public static boolean equals(List<byte[]> a, List<byte[]> b) { if (a == null) { return b == null; } if (b == null) { return false; } if (a.size() != b.size()) { return false; } for (int i = 0; i < a.size(); ++i) { if (!Bytes.equals(a.get(i), b.get(i))) { return false; } } return true; }
public static boolean equals(List<byte[]> a, List<byte[]> b) { if (a == null) { if (b == null) { return true; } return false; } if (b == null) { return false; } if (a.size() != b.size()) { return false; } for (int i = 0; i < a.size(); ++i) { if (!Bytes.equals(a.get(i), b.get(i))) { return false; } } return true; }