org.apache.hadoop.hbase.ExtendedCell Java Examples
The following examples show how to use
org.apache.hadoop.hbase.ExtendedCell.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableReporter.java From hbase-operator-tools with Apache License 2.0 | 5 votes |
/** * Estimate based on keyvalue's serialization format in the RPC layer. Note that there is an extra * SIZEOF_INT added to the size here that indicates the actual length of the cell for cases where * cell's are serialized in a contiguous format (For eg in RPCs). * @return Estimate of the <code>cell</code> size in bytes plus an extra SIZEOF_INT indicating the * actual cell length. */ public static int estimatedSerializedSizeOf(final Cell cell) { if (cell instanceof ExtendedCell) { return ((ExtendedCell) cell).getSerializedSize(true) + Bytes.SIZEOF_INT; } return getSumOfCellElementLengths(cell) + // Use the KeyValue's infrastructure size presuming that another implementation would have // same basic cost. KeyValue.ROW_LENGTH_SIZE + KeyValue.FAMILY_LENGTH_SIZE + // Serialization is probably preceded by a length (it is in the KeyValueCodec at least). Bytes.SIZEOF_INT; }
Example #2
Source File: MemStoreLABImpl.java From hbase with Apache License 2.0 | 5 votes |
/** * Clone the passed cell by copying its data into the passed buf and create a cell with a chunkid * out of it * @see #copyBBECToChunkCell(ByteBufferExtendedCell, ByteBuffer, int, int) */ private static Cell copyToChunkCell(Cell cell, ByteBuffer buf, int offset, int len) { int tagsLen = cell.getTagsLength(); if (cell instanceof ExtendedCell) { ((ExtendedCell) cell).write(buf, offset); } else { // Normally all Cell impls within Server will be of type ExtendedCell. Just considering the // other case also. The data fragments within Cell is copied into buf as in KeyValue // serialization format only. KeyValueUtil.appendTo(cell, buf, offset, true); } return createChunkCell(buf, offset, len, tagsLen, cell.getSequenceId()); }
Example #3
Source File: MapReduceExtendedCell.java From hbase with Apache License 2.0 | 5 votes |
@Override public ExtendedCell deepClone() { try { return (ExtendedCell) PrivateCellUtil.deepClone(cell); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } }
Example #4
Source File: Mutation.java From hbase with Apache License 2.0 | 5 votes |
Mutation add(Cell cell) throws IOException { //Checking that the row of the kv is the same as the mutation // TODO: It is fraught with risk if user pass the wrong row. // Throwing the IllegalArgumentException is more suitable I'd say. if (!CellUtil.matchingRows(cell, this.row)) { throw new WrongRowIOException("The row in " + cell.toString() + " doesn't match the original one " + Bytes.toStringBinary(this.row)); } byte[] family; if (cell instanceof IndividualBytesFieldCell) { family = cell.getFamilyArray(); } else { family = CellUtil.cloneFamily(cell); } if (family == null || family.length == 0) { throw new IllegalArgumentException("Family cannot be null"); } if (cell instanceof ExtendedCell) { getCellList(family).add(cell); } else { getCellList(family).add(new CellWrapper(cell)); } return this; }
Example #5
Source File: MetaDataUtil.java From phoenix with Apache License 2.0 | 5 votes |
/** * Iterates over the cells that are mutated by the put operation for the given column family and * column qualifier and conditionally modifies those cells to add a tags list. We only add tags * if the cell value does not match the passed valueArray. If we always want to add tags to * these cells, we can pass in a null valueArray * @param somePut Put operation * @param family column family of the cells * @param qualifier column qualifier of the cells * @param cellBuilder ExtendedCellBuilder object * @param valueArray byte array of values or null * @param tagArray byte array of tags to add to the cells */ public static void conditionallyAddTagsToPutCells(Put somePut, byte[] family, byte[] qualifier, ExtendedCellBuilder cellBuilder, byte[] valueArray, byte[] tagArray) { NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); List<Cell> newCells = Lists.newArrayList(); if (cells != null) { for (Cell cell : cells) { if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0 && (valueArray == null || !CellUtil.matchingValue(cell, valueArray))) { ExtendedCell extendedCell = cellBuilder .setRow(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()) .setFamily(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()) .setQualifier(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()) .setValue(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()) .setTimestamp(cell.getTimestamp()) .setType(cell.getType()) .setTags(TagUtil.concatTags(tagArray, cell)) .build(); // Replace existing cell with a cell that has the custom tags list newCells.add(extendedCell); } else { // Add cell as is newCells.add(cell); } } familyCellMap.put(family, newCells); } }
Example #6
Source File: AbstractMemStore.java From hbase with Apache License 2.0 | 4 votes |
private static Cell deepCopyIfNeeded(Cell cell) { if (cell instanceof ExtendedCell) { return ((ExtendedCell) cell).deepClone(); } return cell; }
Example #7
Source File: CellChunkImmutableSegment.java From hbase with Apache License 2.0 | 4 votes |
private void initializeCellSet(int numOfCells, MemStoreSegmentsIterator iterator, MemStoreCompactionStrategy.Action action) { int numOfCellsAfterCompaction = 0; int currentChunkIdx = 0; int offsetInCurentChunk = ChunkCreator.SIZEOF_CHUNK_HEADER; int numUniqueKeys=0; Cell prev = null; Chunk[] chunks = allocIndexChunks(numOfCells); while (iterator.hasNext()) { // the iterator hides the elimination logic for compaction boolean alreadyCopied = false; Cell c = iterator.next(); numOfCellsAfterCompaction++; assert(c instanceof ExtendedCell); if (((ExtendedCell)c).getChunkId() == ExtendedCell.CELL_NOT_BASED_ON_CHUNK) { // CellChunkMap assumes all cells are allocated on MSLAB. // Therefore, cells which are not allocated on MSLAB initially, // are copied into MSLAB here. c = copyCellIntoMSLAB(c, null); //no memstore sizing object to update alreadyCopied = true; } if (offsetInCurentChunk + ClassSize.CELL_CHUNK_MAP_ENTRY > chunks[currentChunkIdx].size) { currentChunkIdx++; // continue to the next index chunk offsetInCurentChunk = ChunkCreator.SIZEOF_CHUNK_HEADER; } if (action == MemStoreCompactionStrategy.Action.COMPACT && !alreadyCopied) { // for compaction copy cell to the new segment (MSLAB copy) c = maybeCloneWithAllocator(c, false); } offsetInCurentChunk = // add the Cell reference to the index chunk createCellReference((ByteBufferKeyValue)c, chunks[currentChunkIdx].getData(), offsetInCurentChunk); // the sizes still need to be updated in the new segment // second parameter true, because in compaction/merge the addition of the cell to new segment // is always successful updateMetaInfo(c, true, null); // updates the size per cell if(action == MemStoreCompactionStrategy.Action.MERGE_COUNT_UNIQUE_KEYS) { //counting number of unique keys if (prev != null) { if (!CellUtil.matchingRowColumnBytes(prev, c)) { numUniqueKeys++; } } else { numUniqueKeys++; } } prev = c; } if(action == MemStoreCompactionStrategy.Action.COMPACT) { numUniqueKeys = numOfCells; } else if(action != MemStoreCompactionStrategy.Action.MERGE_COUNT_UNIQUE_KEYS) { numUniqueKeys = CellSet.UNKNOWN_NUM_UNIQUES; } // build the immutable CellSet CellChunkMap ccm = new CellChunkMap(getComparator(), chunks, 0, numOfCellsAfterCompaction, false); this.setCellSet(null, new CellSet(ccm, numUniqueKeys)); // update the CellSet of this Segment }
Example #8
Source File: CellChunkImmutableSegment.java From hbase with Apache License 2.0 | 4 votes |
private void reinitializeCellSet( int numOfCells, KeyValueScanner segmentScanner, CellSet oldCellSet, MemStoreSizing memstoreSizing, MemStoreCompactionStrategy.Action action) { Cell curCell; Chunk[] chunks = allocIndexChunks(numOfCells); int currentChunkIdx = 0; int offsetInCurentChunk = ChunkCreator.SIZEOF_CHUNK_HEADER; int numUniqueKeys=0; Cell prev = null; try { while ((curCell = segmentScanner.next()) != null) { assert(curCell instanceof ExtendedCell); if (((ExtendedCell)curCell).getChunkId() == ExtendedCell.CELL_NOT_BASED_ON_CHUNK) { // CellChunkMap assumes all cells are allocated on MSLAB. // Therefore, cells which are not allocated on MSLAB initially, // are copied into MSLAB here. curCell = copyCellIntoMSLAB(curCell, memstoreSizing); } if (offsetInCurentChunk + ClassSize.CELL_CHUNK_MAP_ENTRY > chunks[currentChunkIdx].size) { // continue to the next metadata chunk currentChunkIdx++; offsetInCurentChunk = ChunkCreator.SIZEOF_CHUNK_HEADER; } offsetInCurentChunk = createCellReference((ByteBufferKeyValue) curCell, chunks[currentChunkIdx].getData(), offsetInCurentChunk); if(action == MemStoreCompactionStrategy.Action.FLATTEN_COUNT_UNIQUE_KEYS) { //counting number of unique keys if (prev != null) { if (!CellUtil.matchingRowColumn(prev, curCell)) { numUniqueKeys++; } } else { numUniqueKeys++; } } prev = curCell; } if(action != MemStoreCompactionStrategy.Action.FLATTEN_COUNT_UNIQUE_KEYS) { numUniqueKeys = CellSet.UNKNOWN_NUM_UNIQUES; } } catch (IOException ie) { throw new IllegalStateException(ie); } finally { segmentScanner.close(); } CellChunkMap ccm = new CellChunkMap(getComparator(), chunks, 0, numOfCells, false); // update the CellSet of this Segment this.setCellSet(oldCellSet, new CellSet(ccm, numUniqueKeys)); }
Example #9
Source File: BufferedDataBlockEncoder.java From hbase with Apache License 2.0 | 4 votes |
@Override public ExtendedCell deepClone() { // This is not used in actual flow. Throwing UnsupportedOperationException throw new UnsupportedOperationException(); }
Example #10
Source File: BufferedDataBlockEncoder.java From hbase with Apache License 2.0 | 4 votes |
@Override public ExtendedCell deepClone() { // This is not used in actual flow. Throwing UnsupportedOperationException throw new UnsupportedOperationException(); }