org.apache.kylin.common.util.Bytes.equals()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.apache.kylin.common.util.Bytes.equals()方法的一些代码示例,展示了Bytes.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.equals()方法的具体详情如下:
包路径:org.apache.kylin.common.util.Bytes
类名称:Bytes
方法名:equals

Bytes.equals介绍

暂无

代码示例

代码示例来源:origin: apache/kylin

@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);
}

代码示例来源:origin: apache/kylin

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;
}

代码示例来源:origin: apache/kylin

@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);
}

代码示例来源:origin: org.apache.kylin/kylin-job

private boolean isNull(byte[] v) {
  for (byte[] nullByte : nullBytes) {
    if (Bytes.equals(v, nullByte))
      return true;
  }
  return false;
}

代码示例来源:origin: org.apache.kylin/kylin-core-common

@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);
}

代码示例来源:origin: org.apache.kylin/kylin-invertedindex

@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;
}

代码示例来源:origin: org.apache.kylin/kylin-core-common

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;
}

代码示例来源:origin: org.apache.kylin/kylin-common

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;
}

相关文章