public void add(byte[] family, byte[] qualifier) { if (family == null || qualifier == null) return; Column col = new Column(family, qualifier); if (cols.contains(col)) return; len += Bytes.SIZEOF_INT + col.length; cols.add(col); }
public Columns(byte[] old) { if (old == null || old.length == 0) { return; } int pos = 0; int count = Bytes.toInt(old, pos); pos += Bytes.SIZEOF_INT; for (int i = 0; i < count; ++i) { int columnLen = Bytes.toInt(old, pos); pos += Bytes.SIZEOF_INT; cols.add(Column.fromBytes(old, pos, columnLen)); pos += columnLen; len += Bytes.SIZEOF_INT + columnLen; } }
public byte[] toByteArray() { byte[] ret = new byte[Bytes.SIZEOF_INT + len]; int pos = 0; pos = Bytes.putInt(ret, pos, cols.size()); for (Column col : cols) { pos = Bytes.putInt(ret, pos, col.length); pos = col.toBytes(ret, pos); } return ret; }
public boolean contains(byte[] family, byte[] qualifier) { return cols.contains(new Column(family, qualifier)); }
public static Column fromBytes(byte[] bytes, int pos, int length) { int familyLen = Bytes.toInt(bytes, pos); pos += Bytes.SIZEOF_INT; byte[] family = new byte[familyLen]; Bytes.putBytes(family, 0, bytes, pos, familyLen); pos += familyLen; int qualifierLen = length - Bytes.SIZEOF_INT - familyLen; byte[] qualifier = new byte[qualifierLen]; Bytes.putBytes(qualifier, 0, bytes, pos, qualifierLen); return new Column(family, qualifier); }