Java Code Examples for org.apache.hadoop.hbase.Cell#getQualifierLength()
The following examples show how to use
org.apache.hadoop.hbase.Cell#getQualifierLength() .
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: HBaseSpanViewer.java From incubator-retired-htrace with Apache License 2.0 | 6 votes |
public List<SpanProtos.Span> getSpans(long traceid) throws IOException { startClient(); List<SpanProtos.Span> spans = new ArrayList<SpanProtos.Span>(); Get get = new Get(Bytes.toBytes(traceid)); get.addFamily(this.cf); try { for (Cell cell : htable.get(get).listCells()) { InputStream in = new ByteArrayInputStream(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); spans.add(SpanProtos.Span.parseFrom(in)); } } catch (IOException e) { LOG.warn("Failed to get spans from HBase. " + e.getMessage()); stopClient(); } return spans; }
Example 2
Source File: IndexMaintainer.java From phoenix with Apache License 2.0 | 6 votes |
public ValueGetter createGetterFromKeyValues(final byte[] rowKey, Collection<? extends Cell> pendingUpdates) { final Map<ReferencingColumn, ImmutableBytesPtr> valueMap = Maps.newHashMapWithExpectedSize(pendingUpdates .size()); for (Cell kv : pendingUpdates) { // create new pointers to each part of the kv ImmutableBytesPtr family = new ImmutableBytesPtr(kv.getRowArray(),kv.getFamilyOffset(),kv.getFamilyLength()); ImmutableBytesPtr qual = new ImmutableBytesPtr(kv.getRowArray(), kv.getQualifierOffset(), kv.getQualifierLength()); ImmutableBytesPtr value = new ImmutableBytesPtr(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()); valueMap.put(new ReferencingColumn(family, qual), value); } return new ValueGetter() { @Override public ImmutableBytesPtr getLatestValue(ColumnReference ref) { if(ref.equals(dataEmptyKeyValueRef)) return null; return valueMap.get(ReferencingColumn.wrap(ref)); } @Override public byte[] getRowKey() { return rowKey; } }; }
Example 3
Source File: TransactionIdMapper.java From pinpoint with Apache License 2.0 | 6 votes |
@Override public List<TransactionId> mapRow(Result result, int rowNum) throws Exception { if (result.isEmpty()) { return Collections.emptyList(); } Cell[] rawCells = result.rawCells(); List<TransactionId> traceIdList = new ArrayList<>(rawCells.length); for (Cell cell : rawCells) { final byte[] qualifierArray = cell.getQualifierArray(); final int qualifierOffset = cell.getQualifierOffset(); final int qualifierLength = cell.getQualifierLength(); // increment by value of key TransactionId traceId = parseVarTransactionId(qualifierArray, qualifierOffset, qualifierLength); traceIdList.add(traceId); logger.debug("found traceId {}", traceId); } return traceIdList; }
Example 4
Source File: ScanQueryMatcher.java From hbase with Apache License 2.0 | 6 votes |
public Cell getKeyForNextColumn(Cell cell) { // We aren't sure whether any DeleteFamily cells exist, so we can't skip to next column. // TODO: Current way disable us to seek to next column quickly. Is there any better solution? // see HBASE-18471 for more details // see TestFromClientSide3#testScanAfterDeletingSpecifiedRow // see TestFromClientSide3#testScanAfterDeletingSpecifiedRowV2 if (cell.getQualifierLength() == 0) { Cell nextKey = PrivateCellUtil.createNextOnRowCol(cell); if (nextKey != cell) { return nextKey; } // The cell is at the end of row/family/qualifier, so it is impossible to find any DeleteFamily cells. // Let us seek to next column. } ColumnCount nextColumn = columns.getColumnHint(); if (nextColumn == null) { return PrivateCellUtil.createLastOnRowCol(cell); } else { return PrivateCellUtil.createFirstOnRowCol(cell, nextColumn.getBuffer(), nextColumn.getOffset(), nextColumn.getLength()); } }
Example 5
Source File: MetaDataUtil.java From phoenix with Apache License 2.0 | 6 votes |
public static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue) { 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) { Cell replacementCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), cell.getTimestamp(), KeyValue.Type.codeToType(cell.getType().getCode()), newValue, 0, newValue.length); newCells.add(replacementCell); } else { newCells.add(cell); } } familyCellMap.put(family, newCells); } }
Example 6
Source File: LocalIndexStoreFileScanner.java From phoenix with Apache License 2.0 | 5 votes |
private Cell getChangedKey(Cell next, boolean changeBottomKeys) { // If it is a top store file change the StartKey with SplitKey in Key //and produce the new value corresponding to the change in key byte[] changedKey = getNewRowkeyByRegionStartKeyReplacedWithSplitKey(next, changeBottomKeys); KeyValue changedKv = new KeyValue(changedKey, 0, changedKey.length, next.getFamilyArray(), next.getFamilyOffset(), next.getFamilyLength(), next.getQualifierArray(), next.getQualifierOffset(), next.getQualifierLength(), next.getTimestamp(), Type.codeToType(next.getTypeByte()), next.getValueArray(), next.getValueOffset(), next.getValueLength(), next.getTagsArray(), next.getTagsOffset(), next.getTagsLength()); return changedKv; }
Example 7
Source File: AgentStatMapperV2.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public List<T> mapRow(Result result, int rowNum) throws Exception { if (result.isEmpty()) { return Collections.emptyList(); } final byte[] distributedRowKey = result.getRow(); final String agentId = this.hbaseOperationFactory.getAgentId(distributedRowKey); final long baseTimestamp = this.hbaseOperationFactory.getBaseTimestamp(distributedRowKey); List<T> dataPoints = new ArrayList<>(); for (Cell cell : result.rawCells()) { if (CellUtil.matchingFamily(cell, HbaseColumnFamily.AGENT_STAT_STATISTICS.getName())) { Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); long timestampDelta = this.decoder.decodeQualifier(qualifierBuffer); AgentStatDecodingContext decodingContext = new AgentStatDecodingContext(); decodingContext.setAgentId(agentId); decodingContext.setBaseTimestamp(baseTimestamp); decodingContext.setTimestampDelta(timestampDelta); List<T> candidates = this.decoder.decodeValue(valueBuffer, decodingContext); for (T candidate : candidates) { if (filter(candidate)) { continue; } dataPoints.add(candidate); } } } // Reverse sort as timestamp is stored in a reversed order. dataPoints.sort(REVERSE_TIMESTAMP_COMPARATOR); return dataPoints; }
Example 8
Source File: ApplicationStatMapper.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public List<JoinStatBo> mapRow(Result result, int rowNum) throws Exception { if (result.isEmpty()) { return Collections.emptyList(); } final byte[] distributedRowKey = result.getRow(); final String applicationId = this.hbaseOperationFactory.getApplicationId(distributedRowKey); final long baseTimestamp = this.hbaseOperationFactory.getBaseTimestamp(distributedRowKey); List<JoinStatBo> dataPoints = new ArrayList<>(); for (Cell cell : result.rawCells()) { if (CellUtil.matchingFamily(cell, HbaseColumnFamily.APPLICATION_STAT_STATISTICS.getName())) { Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); long timestampDelta = this.decoder.decodeQualifier(qualifierBuffer); ApplicationStatDecodingContext decodingContext = new ApplicationStatDecodingContext(); decodingContext.setApplicationId(applicationId); decodingContext.setBaseTimestamp(baseTimestamp); decodingContext.setTimestampDelta(timestampDelta); List<JoinStatBo> candidates = this.decoder.decodeValue(valueBuffer, decodingContext); for (JoinStatBo candidate : candidates) { long timestamp = candidate.getTimestamp(); if (this.filter.filter(timestamp)) { continue; } dataPoints.add(candidate); } } } // Reverse sort as timestamp is stored in a reversed order. dataPoints.sort(REVERSE_TIMESTAMP_COMPARATOR); return dataPoints; }
Example 9
Source File: HostApplicationMapperVer2.java From pinpoint with Apache License 2.0 | 5 votes |
private AcceptApplication createAcceptedApplication(Cell cell) { Buffer reader = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); String host = reader.readPrefixedString(); String bindApplicationName = reader.readPrefixedString(); short bindServiceTypeCode = reader.readShort(); final Application bindApplication = applicationFactory.createApplication(bindApplicationName, bindServiceTypeCode); return new AcceptApplication(host, bindApplication); }
Example 10
Source File: BufferedDataBlockEncoder.java From hbase with Apache License 2.0 | 5 votes |
private int compareTypeBytes(Cell key, Cell right) { if (key.getFamilyLength() + key.getQualifierLength() == 0 && key.getTypeByte() == Type.Minimum.getCode()) { // left is "bigger", i.e. it appears later in the sorted order return 1; } if (right.getFamilyLength() + right.getQualifierLength() == 0 && right.getTypeByte() == Type.Minimum.getCode()) { return -1; } return 0; }
Example 11
Source File: RowColBloomHashKey.java From hbase with Apache License 2.0 | 5 votes |
public RowColBloomHashKey(Cell cell) { super(cell); rowLength = cell.getRowLength(); // We don't consider the family length for ROWCOL bloom. So subtract the famLen from the // length calculation. Timestamp and type are of no relevance here qualLength = cell.getQualifierLength(); }
Example 12
Source File: CodecPerformance.java From hbase with Apache License 2.0 | 5 votes |
static int getRoughSize(final Cell [] cells) { int size = 0; for (Cell c: cells) { size += c.getRowLength() + c.getFamilyLength() + c.getQualifierLength() + c.getValueLength(); size += Bytes.SIZEOF_LONG + Bytes.SIZEOF_BYTE; } return size; }
Example 13
Source File: CellUtils.java From phoenix-omid with Apache License 2.0 | 5 votes |
/** * Returns whether a cell contains a qualifier that is a shadow cell * column qualifier or not. * @param cell the cell to check if contains the shadow cell qualifier * @return whether the cell passed contains a shadow cell qualifier or not */ public static boolean isShadowCell(Cell cell) { byte[] qualifier = cell.getQualifierArray(); int qualOffset = cell.getQualifierOffset(); int qualLength = cell.getQualifierLength(); return endsWith(qualifier, qualOffset, qualLength, SHADOW_CELL_SUFFIX); }
Example 14
Source File: CellByteBufferArrayUtils.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
public static boolean matchingQualifierKeyValue(Cell keyValue, Cell other) { return !(keyValue == null || other == null || keyValue.getQualifierLength() != other.getQualifierLength()) && ArrayUtil.equals(CellUtils.getBuffer(keyValue), keyValue.getQualifierOffset(), CellUtils.getBuffer(other), other.getQualifierOffset(), other.getQualifierLength()); }
Example 15
Source File: PrefixKeyDeltaEncoder.java From hbase with Apache License 2.0 | 4 votes |
private void writeKeyExcludingCommon(Cell cell, int commonPrefix, DataOutputStream out) throws IOException { short rLen = cell.getRowLength(); if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) { // Previous and current rows are different. Need to write the differing part followed by // cf,q,ts and type PrivateCellUtil.writeRowKeyExcludingCommon(cell, rLen, commonPrefix, out); byte fLen = cell.getFamilyLength(); out.writeByte(fLen); PrivateCellUtil.writeFamily(out, cell, fLen); PrivateCellUtil.writeQualifier(out, cell, cell.getQualifierLength()); out.writeLong(cell.getTimestamp()); out.writeByte(cell.getTypeByte()); } else { // The full row key part is common. CF part will be common for sure as we deal with Cells in // same family. Just need write the differing part in q, ts and type commonPrefix = commonPrefix - (rLen + KeyValue.ROW_LENGTH_SIZE) - (cell.getFamilyLength() + KeyValue.FAMILY_LENGTH_SIZE); int qLen = cell.getQualifierLength(); int commonQualPrefix = Math.min(commonPrefix, qLen); int qualPartLenToWrite = qLen - commonQualPrefix; if (qualPartLenToWrite > 0) { PrivateCellUtil.writeQualifierSkippingBytes(out, cell, qLen, commonQualPrefix); } commonPrefix -= commonQualPrefix; // Common part in TS also? if (commonPrefix > 0) { int commonTimestampPrefix = Math.min(commonPrefix, KeyValue.TIMESTAMP_SIZE); if (commonTimestampPrefix < KeyValue.TIMESTAMP_SIZE) { byte[] curTsBuf = Bytes.toBytes(cell.getTimestamp()); out.write(curTsBuf, commonTimestampPrefix, KeyValue.TIMESTAMP_SIZE - commonTimestampPrefix); } commonPrefix -= commonTimestampPrefix; if (commonPrefix == 0) { out.writeByte(cell.getTypeByte()); } } else { out.writeLong(cell.getTimestamp()); out.writeByte(cell.getTypeByte()); } } }
Example 16
Source File: CellByteBufferArrayUtils.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
public static boolean matchingQualifier(Cell keyValue, byte[] qualifier) { return !(qualifier == null || keyValue == null || qualifier.length != keyValue.getQualifierLength()) && ArrayUtil.equals(CellUtils.getBuffer(keyValue), keyValue.getQualifierOffset(), qualifier, 0, keyValue.getQualifierLength()); }
Example 17
Source File: MergingServerOp.java From geowave with Apache License 2.0 | 4 votes |
protected Cell mergeList(final List<Cell> cells) { synchronized (MUTEX) { Mergeable currentMergeable = null; final Cell firstCell = cells.get(0); for (final Cell cell : cells) { final Mergeable mergeable = getMergeable( cell, // TODO consider avoiding extra byte array // allocations (which would require // persistence utils to be able to use // bytebuffer instead of byte[]) CellUtil.cloneValue(cell)); if (mergeable != null) { if (currentMergeable == null) { currentMergeable = mergeable; } else { currentMergeable.merge(mergeable); } } } final byte[] valueBinary = getBinary(currentMergeable); // this is basically a lengthy verbose form of cloning // in-place (without allocating new byte arrays) and // simply replacing the value with the new mergeable // value return new KeyValue( firstCell.getRowArray(), firstCell.getRowOffset(), firstCell.getRowLength(), firstCell.getFamilyArray(), firstCell.getFamilyOffset(), firstCell.getFamilyLength(), firstCell.getQualifierArray(), firstCell.getQualifierOffset(), firstCell.getQualifierLength(), firstCell.getTimestamp(), Type.codeToType(firstCell.getTypeByte()), valueBinary, 0, valueBinary.length, firstCell.getTagsArray(), firstCell.getTagsOffset(), firstCell.getTagsLength()); } }
Example 18
Source File: MapStatisticsCallerMapper.java From pinpoint with Apache License 2.0 | 4 votes |
@Override public LinkDataMap mapRow(Result result, int rowNum) throws Exception { if (result.isEmpty()) { return new LinkDataMap(); } logger.debug("mapRow:{}", rowNum); final byte[] rowKey = getOriginalKey(result.getRow()); final Buffer row = new FixedBuffer(rowKey); final Application caller = readCallerApplication(row); final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong()); // key is destApplicationName. final LinkDataMap linkDataMap = new LinkDataMap(); for (Cell cell : result.rawCells()) { final Buffer buffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); final Application callee = readCalleeApplication(buffer); if (filter.filter(callee)) { continue; } String calleeHost = buffer.readPrefixedString(); short histogramSlot = buffer.readShort(); boolean isError = histogramSlot == (short) -1; String callerAgentId = buffer.readPrefixedString(); long requestCount = getValueToLong(cell); if (logger.isDebugEnabled()) { logger.debug(" Fetched Caller.(New) {} {} -> {} (slot:{}/{}) calleeHost:{}", caller, callerAgentId, callee, histogramSlot, requestCount, calleeHost); } final short slotTime = (isError) ? (short) -1 : histogramSlot; if (StringUtils.isEmpty(calleeHost)) { calleeHost = callee.getName(); } linkDataMap.addLinkData(caller, callerAgentId, callee, calleeHost, timestamp, slotTime, requestCount); } return linkDataMap; }
Example 19
Source File: CellUtils.java From phoenix-omid with Apache License 2.0 | 4 votes |
@Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof CellId)) return false; CellId otherCellId = (CellId) o; Cell otherCell = otherCellId.getCell(); // Row comparison if (!CellUtil.matchingRow(otherCell, cell)) { return false; } // Family comparison if (!CellUtil.matchingFamily(otherCell, cell)) { return false; } // Qualifier comparison int qualifierLength = cell.getQualifierLength(); int qualifierOffset = cell.getQualifierOffset(); int otherQualifierLength = otherCell.getQualifierLength(); int otherQualifierOffset = otherCell.getQualifierOffset(); if (isShadowCell()) { qualifierLength = qualifierLengthFromShadowCellQualifier(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); qualifierOffset = qualifierOffsetFromShadowCellQualifier(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); } if (otherCellId.isShadowCell()) { otherQualifierLength = qualifierLengthFromShadowCellQualifier(otherCell.getQualifierArray(), otherCell.getQualifierOffset(), otherCell.getQualifierLength()); otherQualifierOffset = qualifierOffsetFromShadowCellQualifier(otherCell.getQualifierArray(), otherCell.getQualifierOffset(), otherCell.getQualifierLength()); } if (!Bytes.equals(cell.getQualifierArray(), qualifierOffset, qualifierLength, otherCell.getQualifierArray(), otherQualifierOffset, otherQualifierLength)) { return false; } // Timestamp comparison return otherCell.getTimestamp() == cell.getTimestamp(); }
Example 20
Source File: TableReporter.java From hbase-operator-tools with Apache License 2.0 | 4 votes |
/** * @return Sum of all elements that make up a key; does not include infrastructure, tags or * values. */ private static int getSumOfCellKeyElementLengths(final Cell cell) { return cell.getRowLength() + cell.getFamilyLength() + cell.getQualifierLength() + KeyValue.TIMESTAMP_TYPE_SIZE; }