@Override public Cell getNextCellHint(Cell currentKV) { // skip to the next range's start row return PrivateCellUtil.createFirstOnRow(range.startRow, 0, (short) range.startRow.length); }
public long estimatedSerializedSizeOf() { long ret = 0; for (Cell cell: cells) { ret += PrivateCellUtil.estimatedSerializedSizeOf(cell); } return ret; }
/** * @param cell The Cell * @return Tags in the given Cell as a List * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. * Use {@link RawCell#getTags()} */ @Deprecated public static List<Tag> getTags(Cell cell) { return PrivateCellUtil.getTags(cell); }
@Override public void serialize(Cell kv) throws IOException { dos.writeInt(PrivateCellUtil.estimatedSerializedSizeOf(kv) - Bytes.SIZEOF_INT); PrivateCellUtil.writeCell(kv, dos, true); } }
private void appendDeleteFamilyBloomFilter(final Cell cell) throws IOException { if (!PrivateCellUtil.isDeleteFamily(cell) && !PrivateCellUtil.isDeleteFamilyVersion(cell)) { return; } // increase the number of delete family in the store file deleteFamilyCnt++; if (this.deleteFamilyBloomFilterWriter != null) { deleteFamilyBloomContext.writeBloom(cell); } }
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); } }
/** * Returns true if the first range start1...end1 overlaps with the second range * start2...end2, assuming the byte arrays represent row keys * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. */ @Deprecated public static boolean overlappingKeys(final byte[] start1, final byte[] end1, final byte[] start2, final byte[] end2) { return PrivateCellUtil.overlappingKeys(start1, end1, start2, end2); }
/** * Creates a list of tags in the current cell * @return a list of tags */ default Iterator<Tag> getTags() { return PrivateCellUtil.tagsIterator(this); }
/** * 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); }
/** * Allows cloning the tags in the cell to a new byte[] * @return the byte[] having the tags */ default byte[] cloneTags() { return PrivateCellUtil.cloneTags(this); }
static long calcEstimatedSize(Result rs) { long estimatedHeapSizeOfResult = 0; // We don't make Iterator here for (Cell cell : rs.rawCells()) { estimatedHeapSizeOfResult += PrivateCellUtil.estimatedSizeOfCell(cell); } return estimatedHeapSizeOfResult; }
private void updateSequenceId(final Iterable<List<Cell>> cellItr, final long sequenceId) throws IOException { for (List<Cell> cells: cellItr) { if (cells == null) return; for (Cell cell : cells) { PrivateCellUtil.setSequenceId(cell, sequenceId); } } }
assertEquals(Type.Put.getCode(), offheapKV.getTypeByte()); List<Tag> resTags = PrivateCellUtil.getTags(offheapKV); Tag tag1 = resTags.get(0); assertEquals(t1.getType(), tag1.getType()); assertEquals(Tag.getValueAsString(t2), Tag.getValueAsString(tag2)); Tag res = PrivateCellUtil.getTag(offheapKV, (byte) 2).get(); assertEquals(Tag.getValueAsString(t2), Tag.getValueAsString(tag2)); assertFalse(PrivateCellUtil.getTag(offheapKV, (byte) 3).isPresent());
if (PrivateCellUtil.isDeleteFamily(kv)) { Delete deleteFamily = new Delete(key.get()); deleteFamily.add(kv);
@Override public long append(RegionInfo info, WALKeyImpl key, WALEdit edits, boolean inMemstore) throws IOException { WriteEntry writeEntry = key.getMvcc().begin(); if (!edits.isReplay()) { for (Cell cell : edits.getCells()) { PrivateCellUtil.setSequenceId(cell, writeEntry.getWriteNumber()); } } key.setWriteEntry(writeEntry); if (!this.listeners.isEmpty()) { final long start = System.nanoTime(); long len = 0; for (Cell cell : edits.getCells()) { len += PrivateCellUtil.estimatedSerializedSizeOf(cell); } final long elapsed = (System.nanoTime() - start) / 1000000L; for (WALActionsListener listener : this.listeners) { listener.postAppend(len, elapsed, key, edits); } } return -1; }
haveToSeek = reader.passesGeneralRowColBloomFilter(kv); } else if (canOptimizeForNonNullColumn && ((PrivateCellUtil.isDeleteFamily(kv) || PrivateCellUtil.isDeleteFamilyVersion(kv)))) { setCurrentCell(PrivateCellUtil.createFirstOnRowColTS(kv, maxTimestampInFile)); } else { setCurrentCell(PrivateCellUtil.createLastOnRowCol(kv));
@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); } } }
Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, a, b)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, c, a, b)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, a, c)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(b, c, a, c)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, c, b, c)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, d, b, c)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(b, c, a, d)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(empty, b, a, b)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(empty, b, a, c)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, b)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, c)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, empty, a, b)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, empty, a, c)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(a, b, empty, empty)); Assert.assertTrue(PrivateCellUtil.overlappingKeys(empty, empty, a, b)); Assert.assertFalse(PrivateCellUtil.overlappingKeys(a, b, c, d)); Assert.assertFalse(PrivateCellUtil.overlappingKeys(c, d, a, b)); Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, c, d)); Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, c, empty)); Assert.assertFalse(PrivateCellUtil.overlappingKeys(b, c, d, empty)); Assert.assertFalse(PrivateCellUtil.overlappingKeys(c, d, b, c)); Assert.assertFalse(PrivateCellUtil.overlappingKeys(c, empty, b, c)); Assert.assertFalse(PrivateCellUtil.overlappingKeys(d, empty, b, c));
/** * @param cell The Cell * @return Tags in the given Cell as a List */ public static List<Tag> getTags(Cell cell) { List<Tag> tags = new ArrayList<>(); Iterator<Tag> tagsItr = tagsIterator(cell); while (tagsItr.hasNext()) { tags.add(tagsItr.next()); } return tags; }
/** * 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; } }