/** * @param cell the cell to get the qualifier from * @param charset the charset that was used to encode the cell's qualifier * @param base64encodeValues whether or not to base64 encode the returned string * * @return the String representation of the cell's qualifier */ public static String getCellQualifier(final ResultCell cell, final Charset charset, final boolean base64encodeValues) { if (base64encodeValues) { ByteBuffer cellQualifierBuffer = ByteBuffer.wrap(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); ByteBuffer base64Buffer = Base64.getEncoder().encode(cellQualifierBuffer); return new String(base64Buffer.array(), StandardCharsets.UTF_8); } else { return new String(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), charset); } }
@Override public void handle(byte[] row, ResultCell[] resultCells) { numRows += 1; for( final ResultCell resultCell : resultCells ){ lastResultBytes = Arrays.copyOfRange(resultCell.getValueArray(), resultCell.getValueOffset(), resultCell.getValueLength() + resultCell.getValueOffset()); } } public int numRows() {
public boolean contains(final ResultCell cell) { if (cell.getTimestamp() != latestTimestamp) { return false; } final byte[] row = Arrays.copyOfRange(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength() + cell.getRowOffset()); final String rowHash = new String(row, StandardCharsets.UTF_8); final Set<String> cellHashes = matchingCellHashes.get(rowHash); if (cellHashes == null) { return false; } final byte[] cellValue = Arrays.copyOfRange(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength() + cell.getValueOffset()); final String cellHash = new String(cellValue, StandardCharsets.UTF_8); return cellHashes.contains(cellHash); }
private ResultCell getResultCell(Cell cell) { final ResultCell resultCell = new ResultCell(); resultCell.setRowArray(cell.getRowArray()); resultCell.setRowOffset(cell.getRowOffset()); resultCell.setRowLength(cell.getRowLength()); resultCell.setFamilyArray(cell.getFamilyArray()); resultCell.setFamilyOffset(cell.getFamilyOffset()); resultCell.setFamilyLength(cell.getFamilyLength()); resultCell.setQualifierArray(cell.getQualifierArray()); resultCell.setQualifierOffset(cell.getQualifierOffset()); resultCell.setQualifierLength(cell.getQualifierLength()); resultCell.setTimestamp(cell.getTimestamp()); resultCell.setTypeByte(cell.getTypeByte()); resultCell.setSequenceId(cell.getSequenceId()); resultCell.setValueArray(cell.getValueArray()); resultCell.setValueOffset(cell.getValueOffset()); resultCell.setValueLength(cell.getValueLength()); resultCell.setTagsArray(cell.getTagsArray()); resultCell.setTagsOffset(cell.getTagsOffset()); resultCell.setTagsLength(cell.getTagsLength()); return resultCell; }
final byte[] qualifier = Arrays.copyOfRange(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierOffset() + cell.getQualifierLength()); final byte[] value = Arrays.copyOfRange(cell.getValueArray(), cell.getValueOffset(), cell.getValueOffset() + cell.getValueLength()); values.put(new String(qualifier, charset), new String(value, charset));
@Override public String serialize(byte[] rowKey, ResultCell[] cells) { final StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.append("{"); final String row = new String(rowKey, charset); jsonBuilder.append("\"row\":") .append("\"") .append(StringEscapeUtils.escapeJson(row)) .append("\""); jsonBuilder.append(", \"cells\": {"); int i = 0; for (final ResultCell cell : cells) { final String cellFamily = new String(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), charset); final String cellQualifier = new String(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), charset); if (i > 0) { jsonBuilder.append(", "); } jsonBuilder.append("\"") .append(StringEscapeUtils.escapeJson(cellFamily)) .append(":") .append(StringEscapeUtils.escapeJson(cellQualifier)) .append("\":\"") .append(StringEscapeUtils.escapeJson(new String(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength(), charset))) .append("\""); i++; } jsonBuilder.append("}}"); return jsonBuilder.toString(); }
private ResultCell getResultCell(Cell cell) { final ResultCell resultCell = new ResultCell(); resultCell.setRowArray(cell.getRowArray()); resultCell.setRowOffset(cell.getRowOffset()); resultCell.setRowLength(cell.getRowLength()); resultCell.setFamilyArray(cell.getFamilyArray()); resultCell.setFamilyOffset(cell.getFamilyOffset()); resultCell.setFamilyLength(cell.getFamilyLength()); resultCell.setQualifierArray(cell.getQualifierArray()); resultCell.setQualifierOffset(cell.getQualifierOffset()); resultCell.setQualifierLength(cell.getQualifierLength()); resultCell.setTimestamp(cell.getTimestamp()); resultCell.setTypeByte(cell.getTypeByte()); resultCell.setSequenceId(cell.getSequenceId()); resultCell.setValueArray(cell.getValueArray()); resultCell.setValueOffset(cell.getValueOffset()); resultCell.setValueLength(cell.getValueLength()); resultCell.setTagsArray(cell.getTagsArray()); resultCell.setTagsOffset(cell.getTagsOffset()); resultCell.setTagsLength(cell.getTagsLength()); return resultCell; }
final byte[] qualifier = Arrays.copyOfRange(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierOffset() + cell.getQualifierLength()); final byte[] value = Arrays.copyOfRange(cell.getValueArray(), cell.getValueOffset(), cell.getValueOffset() + cell.getValueLength()); values.put(new String(qualifier, charset), new String(value, charset));
if (cell.getTimestamp() > latestCellTimestamp) { latestCellTimestamp = cell.getTimestamp(); if (cell.getTimestamp() == latestCellTimestamp) { if (lastResult == null || !lastResult.contains(cell)) { allSeen = false; final long ts = cell.getTimestamp(); if (ts == latestCellTimestamp) { final byte[] rowValue = Arrays.copyOfRange(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength() + cell.getRowOffset()); final byte[] cellValue = Arrays.copyOfRange(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength() + cell.getValueOffset());
private ResultCell getResultCell(Cell cell) { final ResultCell resultCell = new ResultCell(); resultCell.setRowArray(cell.getRowArray()); resultCell.setRowOffset(cell.getRowOffset()); resultCell.setRowLength(cell.getRowLength()); resultCell.setFamilyArray(cell.getFamilyArray()); resultCell.setFamilyOffset(cell.getFamilyOffset()); resultCell.setFamilyLength(cell.getFamilyLength()); resultCell.setQualifierArray(cell.getQualifierArray()); resultCell.setQualifierOffset(cell.getQualifierOffset()); resultCell.setQualifierLength(cell.getQualifierLength()); resultCell.setTimestamp(cell.getTimestamp()); resultCell.setTypeByte(cell.getTypeByte()); resultCell.setSequenceId(cell.getSequenceId()); resultCell.setValueArray(cell.getValueArray()); resultCell.setValueOffset(cell.getValueOffset()); resultCell.setValueLength(cell.getValueLength()); resultCell.setTagsArray(cell.getTagsArray()); resultCell.setTagsOffset(cell.getTagsOffset()); resultCell.setTagsLength(cell.getTagsLength()); return resultCell; }
final byte[] qualifier = Arrays.copyOfRange(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierOffset() + cell.getQualifierLength()); final byte[] value = Arrays.copyOfRange(cell.getValueArray(), cell.getValueOffset(), cell.getValueOffset() + cell.getValueLength()); values.put(new String(qualifier, charset), new String(value, charset));
@Override public void handle(byte[] row, ResultCell[] resultCells) { numRows += 1; for( final ResultCell resultCell : resultCells ){ lastResultBytes = Arrays.copyOfRange(resultCell.getValueArray(), resultCell.getValueOffset(), resultCell.getValueLength() + resultCell.getValueOffset()); } } public int numRows() {
/** * @param cell the cell to get the value from * @param charset the charset that was used to encode the cell's value * @param base64encodeValues whether or not to base64 encode the returned string * * @return the String representation of the cell's value */ public static String getCellValue(final ResultCell cell, final Charset charset, final boolean base64encodeValues) { if (base64encodeValues) { ByteBuffer cellValueBuffer = ByteBuffer.wrap(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); ByteBuffer base64Buffer = Base64.getEncoder().encode(cellValueBuffer); return new String(base64Buffer.array(), StandardCharsets.UTF_8); } else { return new String(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength(), charset); } }
@Override public void handle(byte[] row, ResultCell[] resultCells) { numRows += 1; for( final ResultCell resultCell : resultCells ){ lastResultBytes = Arrays.copyOfRange(resultCell.getValueArray(), resultCell.getValueOffset(), resultCell.getValueLength() + resultCell.getValueOffset()); } } public int numRows() {