/** * Get the column name from a meta table key. Does not check if the metaTableKey is a valid * FijiTableAnnotator meta table key. This method is package private for testing. * * @param table HBaseFijiTable in which the column from the specified key lives. This will be used * for column name translation. * @param metaTableKey the meta table key from which to get the column name. * @return the column name stored in the given meta table key. * @throws NoSuchColumnException in case the column does not exist in the table. */ static FijiColumnName columnFromMetaTableKey( final HBaseFijiTable table, final String metaTableKey ) throws NoSuchColumnException { final HBaseColumnNameTranslator translator = table.getColumnNameTranslator(); // Everything between the prefix and the annotation key. final String hbaseColumnString = metaTableKey.substring(METATABLE_KEY_PREFIX.length(), metaTableKey.lastIndexOf('.')); // Everything before the first ':'. final String hbaseFamily = hbaseColumnString.substring(0, hbaseColumnString.indexOf(':')); // Everything after the first ':'. The +1 excludes the ':' itself. final String hbaseQualifier = hbaseColumnString.substring(hbaseColumnString.indexOf(':') + 1); final HBaseColumnName hbaseColumn = new HBaseColumnName(hbaseFamily, hbaseQualifier); return translator.toFijiColumnName(hbaseColumn); }
/** * Get the meta table key for the given column name and annotation key. This method is package * private for testing. * * @param table HBaseFijiTable in which the specified column lives. This will be used for * column name translation. * @param columnName the name of the column from which to get the meta table key. * @param key the annotation key from which to get the meta table key. * @return the meta table key for the given column name and annotation key. * @throws NoSuchColumnException in case the column does not exist in the table. */ static String getMetaTableKey( final HBaseFijiTable table, final FijiColumnName columnName, final String key ) throws NoSuchColumnException { final HBaseColumnNameTranslator translator = table.getColumnNameTranslator(); Preconditions.checkArgument(isValidAnnotationKey(key), "Annotation key: %s does not conform to " + "required pattern: %s", key, ALLOWED_ANNOTATION_KEY_PATTERN); return String.format("%s%s.%s", METATABLE_KEY_PREFIX, translator.toHBaseColumnName(columnName), key); }
/** {@inheritDoc} */ @Override public <T> Iterable<FijiCell<T>> asIterable(String family, String qualifier) { final FijiColumnName column = FijiColumnName.create(family, qualifier); Preconditions.checkArgument( mDataRequest.getRequestForColumn(column) != null, "Column %s has no data request.", column); return new CellIterable<T>(column, this, mTable.getColumnNameTranslator()); }
/** {@inheritDoc} */ @Override public <T> Iterator<FijiCell<T>> iterator(String family, String qualifier) throws IOException { final FijiColumnName column = FijiColumnName.create(family, qualifier); Preconditions.checkArgument( mDataRequest.getRequestForColumn(column) != null, "Column %s has no data request.", column); return new FijiCellIterator<T>(this, column, mTable.getColumnNameTranslator()); }
/** {@inheritDoc} */ @Override public <T> Iterable<FijiCell<T>> asIterable(String family) { final FijiColumnName column = FijiColumnName.create(family, null); Preconditions.checkArgument( mDataRequest.getRequestForColumn(column) != null, "Column %s has no data request.", column); Preconditions.checkState(mTableLayout.getFamilyMap().get(family).isMapType(), "asIterable(String family) is only enabled" + " on map type column families. The column family [%s], is a group type column family." + " Please use the asIterable(String family, String qualifier) method.", family); return new CellIterable<T>(column, this, mTable.getColumnNameTranslator()); }
/** {@inheritDoc} */ @Override public <T> Iterator<FijiCell<T>> iterator(String family) throws IOException { final FijiColumnName column = FijiColumnName.create(family, null); Preconditions.checkArgument( mDataRequest.getRequestForColumn(column) != null, "Column %s has no data request.", column); Preconditions.checkState(mTableLayout.getFamilyMap().get(family).isMapType(), "iterator(String family) is only enabled" + " on map type column families. The column family [%s], is a group type column family." + " Please use the iterator(String family, String qualifier) method.", family); return new FijiCellIterator<T>(this, column, mTable.getColumnNameTranslator()); }
/** {@inheritDoc} */ @Override public void deleteCell(EntityId entityId, String family, String qualifier, long timestamp) throws IOException { final HBaseColumnName hbaseColumnName = mTable.getColumnNameTranslator() .toHBaseColumnName(FijiColumnName.create(family, qualifier)); final Delete delete = new Delete(entityId.getHBaseRowKey()) .deleteColumn(hbaseColumnName.getFamily(), hbaseColumnName.getQualifier(), timestamp); updateBuffer(delete); }