/** * @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() {
@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); }
@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(); }
for (final ResultCell cell : resultCells) { 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));
for (final ResultCell cell : resultCells) { 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 (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());
@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() {
for (final ResultCell cell : resultCells) { 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));