public static CoveredColumn parse(String spec) { int sep = spec.indexOf(SEPARATOR); if (sep < 0) { throw new IllegalArgumentException(spec + " is not a valid specifier!"); } String family = spec.substring(0, sep); String qual = spec.substring(sep + 1); byte[] column = qual.length() == 0 ? null : Bytes.toBytes(qual); return new CoveredColumn(family, column); }
public CoveredColumn(String family, byte[] qualifier) { super(Bytes.toBytes(family), qualifier == null ? ColumnReference.ALL_QUALIFIERS : qualifier); this.familyString = family; this.hashCode = calcHashCode(family, qualifier); }
public String serialize() { return CoveredColumn.serialize(familyString, getQualifier()); }
/** * Check to see if any column matches the family/qualifier pair * @param family family to match against * @param qualifier qualifier to match, can be <tt>null</tt>, in which case we match all * qualifiers * @return <tt>true</tt> if any column matches, <tt>false</tt> otherwise */ public boolean matches(byte[] family, byte[] qualifier) { // families are always printable characters String fam = Bytes.toString(family); for (CoveredColumn column : columns) { if (column.matchesFamily(fam)) { // check the qualifier if (column.matchesQualifier(qualifier)) { return true; } } } return false; }
KeyValue first = ref.getFirstKeyValueForRow(currentRow); if (!kvs.seek(first)) { if (ref.matchesFamily(next.getFamilyArray(), next.getFamilyOffset(), next.getFamilyLength()) && ref.matchesQualifier(next.getQualifierArray(), next.getQualifierOffset(), next.getQualifierLength())) { byte[] v = CellUtil.cloneValue(next); if (!ref.allColumns()) { continue; while ((next = kvs.next()) != null) { if (!ref.matchesFamily(next.getFamilyArray(), next.getFamilyOffset(), next.getFamilyLength())) { break;
@Override public String toString() { String qualString = getQualifier() == null ? "null" : Bytes.toString(getQualifier()); return "CoveredColumn:[" + familyString + ":" + qualString + "]"; } }
/** * Check to see if any {@link CoveredColumn} in <tt>this</tt> matches the given family * @param family to check * @return <tt>true</tt> if any column covers the family */ public boolean matches(String family) { for (CoveredColumn column : columns) { if (column.matchesFamily(family)) { return true; } } return false; }
/** * @param specs * @param columns * @param index */ private void addIndexGroupToSpecs(Map<String, String> specs, ColumnGroup columns, int index) { // hbase.index.covered.group.<i> String prefix = INDEX_GROUP_PREFIX + Integer.toString(index); // set the table to which the group writes // hbase.index.covered.group.<i>.table specs.put(prefix + TABLE_SUFFIX, columns.getTable()); // a different key for each column in the group // hbase.index.covered.group.<i>.columns String columnPrefix = prefix + INDEX_GROUP_COVERAGE_SUFFIX; // hbase.index.covered.group.<i>.columns.count = <j> String columnsSizeKey = columnPrefix + COUNT; specs.put(columnsSizeKey, Integer.toString(columns.size())); // add each column in the group int i=0; for (CoveredColumn column : columns) { // hbase.index.covered.group.<i>.columns.<j> String nextKey = columnPrefix + "." + Integer.toString(i); String nextValue = column.serialize(); specs.put(nextKey, nextValue); i++; } }
public static List<ColumnGroup> getColumns(Configuration conf) { int count= conf.getInt(INDEX_GROUPS_COUNT_KEY, 0); if (count ==0) { return Collections.emptyList(); } // parse out all the column groups we should index List<ColumnGroup> columns = new ArrayList<ColumnGroup>(count); for (int i = 0; i < count; i++) { // parse out each group String prefix = INDEX_GROUP_PREFIX + i; // hbase.index.covered.group.<i>.table String table = conf.get(prefix + TABLE_SUFFIX); ColumnGroup group = new ColumnGroup(table); // parse out each column in the group // hbase.index.covered.group.<i>.columns String columnPrefix = prefix + INDEX_GROUP_COVERAGE_SUFFIX; // hbase.index.covered.group.<i>.columns.count = j String columnsSizeKey = columnPrefix + COUNT; int columnCount = conf.getInt(columnsSizeKey, 0); for(int j=0; j< columnCount; j++){ String columnKey = columnPrefix + "." + j; CoveredColumn column = CoveredColumn.parse(conf.get(columnKey)); group.add(column); } // add the group columns.add(group); } return columns; }
private static byte[] toIndexQualifier(CoveredColumn column) { return ArrayUtils.addAll(Bytes.toBytes(column.familyString + CoveredColumn.SEPARATOR), column.getQualifier()); }
ColumnGroup fam1 = new ColumnGroup(INDEX_TABLE); CoveredColumn col1 = new CoveredColumn(FAMILY, indexed_qualifer); fam1.add(col1); CoveredColumn col2 = new CoveredColumn(FAMILY2, null); fam1.add(col2); builder.addIndexGroup(fam1); ColumnGroup fam2 = new ColumnGroup(INDEX_TABLE2); CoveredColumn col3 = new CoveredColumn(FAMILY2, indexed_qualifer); fam2.add(col3); builder.addIndexGroup(fam2);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; CoveredColumn other = (CoveredColumn) obj; if (hashCode != other.hashCode) return false; if (!familyString.equals(other.familyString)) return false; return Bytes.equals(getQualifier(), other.getQualifier()); }
fam1.add(new CoveredColumn(family, CoveredColumn.ALL_QUALIFIERS)); CoveredColumnIndexSpecifierBuilder builder = new CoveredColumnIndexSpecifierBuilder(); builder.addIndexGroup(fam1);
String indexedTableName = getIndexTableName(); ColumnGroup columns = new ColumnGroup(indexedTableName); columns.add(new CoveredColumn(family, qual)); CoveredColumnIndexSpecifierBuilder builder = new CoveredColumnIndexSpecifierBuilder(); builder.addIndexGroup(columns);
fam1.add(new CoveredColumn(family, CoveredColumn.ALL_QUALIFIERS)); CoveredColumnIndexSpecifierBuilder builder = new CoveredColumnIndexSpecifierBuilder(); builder.addIndexGroup(fam1);