/** * Note : Now only CPs can create cell with tags using the CP environment * @return A new cell which is having the extra tags also added to it. * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. * */ @Deprecated public static Cell createCell(Cell cell, List<Tag> tags) { return PrivateCellUtil.createCell(cell, tags); }
/** * Now only CPs can create cell with tags using the CP environment * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. */ @Deprecated public static Cell createCell(Cell cell, byte[] value, byte[] tags) { return PrivateCellUtil.createCell(cell, value, tags); }
/** * Now only CPs can create cell with tags using the CP environment * @return A new cell which is having the extra tags also added to it. * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. */ @Deprecated public static Cell createCell(Cell cell, byte[] tags) { return PrivateCellUtil.createCell(cell, tags); }
/** * Creates a mob ref delete marker. * @param cell The current delete marker. * @return A delete marker with the ref tag. */ public static Cell createMobRefDeleteMarker(Cell cell) { return PrivateCellUtil.createCell(cell, TagUtil.concatTags(REF_DELETE_MARKER_TAG_BYTES, cell)); }
/** * @return A new cell which is having the extra tags also added to it. */ public static Cell createCell(Cell cell, List<Tag> tags) { return createCell(cell, TagUtil.fromList(tags)); }
private static void addCellPermissions(final byte[] perms, Map<byte[], List<Cell>> familyMap) { // Iterate over the entries in the familyMap, replacing the cells therein // with new cells including the ACL data for (Map.Entry<byte[], List<Cell>> e: familyMap.entrySet()) { List<Cell> newCells = Lists.newArrayList(); for (Cell cell: e.getValue()) { // Prepend the supplied perms in a new ACL tag to an update list of tags for the cell List<Tag> tags = new ArrayList<>(); tags.add(new ArrayBackedTag(AccessControlLists.ACL_TAG_TYPE, perms)); Iterator<Tag> tagIterator = PrivateCellUtil.tagsIterator(cell); while (tagIterator.hasNext()) { tags.add(tagIterator.next()); } newCells.add(PrivateCellUtil.createCell(cell, tags)); } // This is supposed to be safe, won't CME e.setValue(newCells); } }
public static Cell createMobRefCell(Cell cell, byte[] fileName, byte[] refCellTags) { byte[] refValue = Bytes.add(Bytes.toBytes(cell.getValueLength()), fileName); return PrivateCellUtil.createCell(cell, refValue, TagUtil.concatTags(refCellTags, cell)); }
/** * Possibly rewrite incoming cell tags. */ void rewriteCellTags(Map<byte[], List<Cell>> familyMap, final Mutation m) { // Check if we have any work to do and early out otherwise // Update these checks as more logic is added here if (m.getTTL() == Long.MAX_VALUE) { return; } // From this point we know we have some work to do for (Map.Entry<byte[], List<Cell>> e: familyMap.entrySet()) { List<Cell> cells = e.getValue(); assert cells instanceof RandomAccess; int listSize = cells.size(); for (int i = 0; i < listSize; i++) { Cell cell = cells.get(i); List<Tag> newTags = TagUtil.carryForwardTags(null, cell); newTags = TagUtil.carryForwardTTLTag(newTags, m.getTTL()); // Rewrite the cell with the updated set of tags cells.set(i, PrivateCellUtil.createCell(cell, newTags)); } } }
return PrivateCellUtil.createCell(newCell, tags);
private Cell createNewCellWithTags(Mutation mutation, Cell newCell) throws IOException { List<Tag> tags = Lists.newArrayList(); CellVisibility cellVisibility = null; try { cellVisibility = mutation.getCellVisibility(); } catch (DeserializationException e) { throw new IOException(e); } if (cellVisibility == null) { return newCell; } // Prepend new visibility tags to a new list of tags for the cell // Don't check user auths for labels with Mutations when the user is super user boolean authCheck = authorizationEnabled && checkAuths && !(isSystemOrSuperUser()); tags.addAll(this.visibilityLabelService.createVisibilityExpTags(cellVisibility.getExpression(), true, authCheck)); // Carry forward all other tags Iterator<Tag> tagsItr = PrivateCellUtil.tagsIterator(newCell); while (tagsItr.hasNext()) { Tag tag = tagsItr.next(); if (tag.getType() != TagType.VISIBILITY_TAG_TYPE && tag.getType() != TagType.VISIBILITY_EXP_SERIALIZATION_FORMAT_TAG_TYPE) { tags.add(tag); } } return PrivateCellUtil.createCell(newCell, tags); }
Cell newCell = PrivateCellUtil.createCell(cell, nonVisTags); newEdit.add(newCell); } else {
@Test public void testHeapSize() { Cell originalCell = CellUtil.createCell(Bytes.toBytes("row"), Bytes.toBytes("value")); final int fakeTagArrayLength = 10; Cell trCell = PrivateCellUtil.createCell(originalCell, new byte[fakeTagArrayLength]); // Get the heapSize before the internal tags array in trCell are nuked long trCellHeapSize = ((HeapSize)trCell).heapSize(); // Make another TagRewriteCell with the original TagRewriteCell // This happens on systems with more than one RegionObserver/Coproc loaded (such as // VisibilityController and AccessController) Cell trCell2 = PrivateCellUtil.createCell(trCell, new byte[fakeTagArrayLength]); assertTrue("TagRewriteCell containing a TagRewriteCell's heapsize should be " + "larger than a single TagRewriteCell's heapsize", trCellHeapSize < ((HeapSize)trCell2).heapSize()); assertTrue("TagRewriteCell should have had nulled out tags array", ((HeapSize)trCell).heapSize() < trCellHeapSize); } }
@Override public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put m, WALEdit edit, Durability durability) throws IOException { byte[] attribute = m.getAttribute(NON_VISIBILITY); byte[] cf = null; List<Cell> updatedCells = new ArrayList<>(); if (attribute != null) { for (List<? extends Cell> edits : m.getFamilyCellMap().values()) { for (Cell cell : edits) { KeyValue kv = KeyValueUtil.ensureKeyValue(cell); if (cf == null) { cf = CellUtil.cloneFamily(kv); } Tag tag = new ArrayBackedTag((byte) NON_VIS_TAG_TYPE, attribute); List<Tag> tagList = new ArrayList<>(PrivateCellUtil.getTags(cell).size() + 1); tagList.add(tag); tagList.addAll(PrivateCellUtil.getTags(cell)); Cell newcell = PrivateCellUtil.createCell(kv, tagList); ((List<Cell>) updatedCells).add(newcell); } } m.getFamilyCellMap().remove(cf); // Update the family map m.getFamilyCellMap().put(cf, updatedCells); } } }
private static Cell reckonDelta(final Cell delta, final Cell currentCell, final byte[] columnFamily, final long now, Mutation mutation, Function<Cell, byte[]> supplier) throws IOException { // Forward any tags found on the delta. List<Tag> tags = TagUtil.carryForwardTags(delta); tags = TagUtil.carryForwardTTLTag(tags, mutation.getTTL()); if (currentCell != null) { tags = TagUtil.carryForwardTags(tags, currentCell); byte[] newValue = supplier.apply(currentCell); return ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY) .setRow(mutation.getRow(), 0, mutation.getRow().length) .setFamily(columnFamily, 0, columnFamily.length) // copy the qualifier if the cell is located in shared memory. .setQualifier(CellUtil.cloneQualifier(delta)) .setTimestamp(Math.max(currentCell.getTimestamp() + 1, now)) .setType(KeyValue.Type.Put.getCode()) .setValue(newValue, 0, newValue.length) .setTags(TagUtil.fromList(tags)) .build(); } else { PrivateCellUtil.updateLatestStamp(delta, now); return CollectionUtils.isEmpty(tags) ? delta : PrivateCellUtil.createCell(delta, tags); } }
Cell updatedCell = PrivateCellUtil.createCell(cell, tags); updatedCells.add(updatedCell);
/** * Now only CPs can create cell with tags using the CP environment * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. */ @Deprecated public static Cell createCell(Cell cell, byte[] value, byte[] tags) { return PrivateCellUtil.createCell(cell, value, tags); }
/** * Now only CPs can create cell with tags using the CP environment * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. */ @Deprecated public static Cell createCell(Cell cell, byte[] value, byte[] tags) { return PrivateCellUtil.createCell(cell, value, tags); }
/** * Now only CPs can create cell with tags using the CP environment * @return A new cell which is having the extra tags also added to it. * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. */ @Deprecated public static Cell createCell(Cell cell, byte[] tags) { return PrivateCellUtil.createCell(cell, tags); }
/** * Note : Now only CPs can create cell with tags using the CP environment * @return A new cell which is having the extra tags also added to it. * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. * */ @Deprecated public static Cell createCell(Cell cell, List<Tag> tags) { return PrivateCellUtil.createCell(cell, tags); }
/** * @return A new cell which is having the extra tags also added to it. */ public static Cell createCell(Cell cell, List<Tag> tags) { return createCell(cell, TagUtil.fromList(tags)); }