/** * Returns the specific tag of the given type * @param type the type of the tag * @return the specific tag if available or null */ default Optional<Tag> getTag(byte type) { return PrivateCellUtil.getTag(this, type); }
/** * Retrieve Cell's first tag, matching the passed in type * * @param cell The Cell * @param type Type of the Tag to retrieve * @return null if there is no tag of the passed in tag type * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. * Use {@link RawCell#getTag(byte)} */ @Deprecated public static Tag getTag(Cell cell, byte type) { Optional<Tag> tag = PrivateCellUtil.getTag(cell, type); if (tag.isPresent()) { return tag.get(); } else { return null; } }
@Override public Optional<Tag> getTag(byte type) { if (cell instanceof RawCell) { return ((RawCell) cell).getTag(type); } return PrivateCellUtil.getTag(cell, type); }
/** * Whether the current cell is a mob reference cell. * @param cell The current cell. * @return True if the cell has a mob reference tag, false if it doesn't. */ public static boolean isMobReferenceCell(Cell cell) { if (cell.getTagsLength() > 0) { Optional<Tag> tag = PrivateCellUtil.getTag(cell, TagType.MOB_REFERENCE_TAG_TYPE); if (tag.isPresent()) { return true; } } return false; }
/** * Gets the table name tag. * @param cell The current cell. * @return The table name tag. */ public static Tag getTableNameTag(Cell cell) { if (cell.getTagsLength() > 0) { Optional<Tag> tag = PrivateCellUtil.getTag(cell, TagType.MOB_TABLE_NAME_TAG_TYPE); if (tag.isPresent()) { return tag.get(); } } return null; }
/** * This verifies that each cell has a tag that is equal to its rowkey name. For this to work * the hbase instance must have HConstants.RPC_CODEC_CONF_KEY set to * KeyValueCodecWithTags.class.getCanonicalName()); * @param table table containing tagged cells * @throws IOException if problems reading table */ public static void verifyTags(Table table) throws IOException { ResultScanner s = table.getScanner(new Scan()); for (Result r : s) { for (Cell c : r.listCells()) { Optional<Tag> tag = PrivateCellUtil.getTag(c, TagType.MOB_TABLE_NAME_TAG_TYPE); if (!tag.isPresent()) { fail(c.toString() + " has null tag"); continue; } Tag t = tag.get(); byte[] tval = Tag.cloneValue(t); assertArrayEquals(c.toString() + " has tag" + Bytes.toString(tval), r.getRow(), tval); } } } }
Optional<Tag> tag = PrivateCellUtil.getTag(kv, TagType.MOB_TABLE_NAME_TAG_TYPE); if (!tag.isPresent()) { throw new IllegalStateException("Tag didn't stick to KV " + kv.toString());
@Override public Optional<Tag> getTag(byte type) { if (cell instanceof RawCell) { return ((RawCell) cell).getTag(type); } return PrivateCellUtil.getTag(cell, type); }
/** * Returns the specific tag of the given type * @param type the type of the tag * @return the specific tag if available or null */ default Optional<Tag> getTag(byte type) { return PrivateCellUtil.getTag(this, type); }
/** * Returns the specific tag of the given type * @param type the type of the tag * @return the specific tag if available or null */ default Optional<Tag> getTag(byte type) { return PrivateCellUtil.getTag(this, type); }
/** * Retrieve Cell's first tag, matching the passed in type * @param cell The Cell * @param type Type of the Tag to retrieve * @return null if there is no tag of the passed in tag type * @deprecated As of 2.0.0 and will be removed in HBase-3.0.0 * Use {@link RawCell#getTag(byte)} */ @Deprecated public static Tag getTag(Cell cell, byte type) { Optional<Tag> tag = PrivateCellUtil.getTag(cell, type); if (tag.isPresent()) { return tag.get(); } else { return null; } }
/** * Retrieve Cell's first tag, matching the passed in type * @param cell The Cell * @param type Type of the Tag to retrieve * @return null if there is no tag of the passed in tag type * @deprecated As of 2.0.0 and will be removed in HBase-3.0.0 * Use {@link RawCell#getTag(byte)} */ @Deprecated public static Tag getTag(Cell cell, byte type) { Optional<Tag> tag = PrivateCellUtil.getTag(cell, type); if (tag.isPresent()) { return tag.get(); } else { return null; } }
@Override public Optional<Tag> getTag(byte type) { if (cell instanceof RawCell) { return ((RawCell) cell).getTag(type); } return PrivateCellUtil.getTag(cell, type); }
/** * This verifies that each cell has a tag that is equal to its rowkey name. For this to work * the hbase instance must have HConstants.RPC_CODEC_CONF_KEY set to * KeyValueCodecWithTags.class.getCanonicalName()); * @param table table containing tagged cells * @throws IOException if problems reading table */ public static void verifyTags(Table table) throws IOException { ResultScanner s = table.getScanner(new Scan()); for (Result r : s) { for (Cell c : r.listCells()) { Optional<Tag> tag = PrivateCellUtil.getTag(c, TagType.MOB_TABLE_NAME_TAG_TYPE); if (!tag.isPresent()) { fail(c.toString() + " has null tag"); continue; } Tag t = tag.get(); byte[] tval = Tag.cloneValue(t); assertArrayEquals(c.toString() + " has tag" + Bytes.toString(tval), r.getRow(), tval); } } } }
Optional<Tag> tag = PrivateCellUtil.getTag(kv, TagType.MOB_TABLE_NAME_TAG_TYPE); if (!tag.isPresent()) { throw new IllegalStateException("Tag didn't stick to KV " + kv.toString());