/** * Returns {@code true} iff there are matching {@link WhileMatchFilter} labels or no {@link * WhileMatchFilter} labels. */ private static boolean hasMatchingLabels(Row row) { int inLabelCount = 0; int outLabelCount = 0; for (Family family : row.getFamiliesList()) { for (Column column : family.getColumnsList()) { for (Cell cell : column.getCellsList()) { for (String label : cell.getLabelsList()) { // TODO(kevinsi4508): Make sure {@code label} is a {@link WhileMatchFilter} label. // TODO(kevinsi4508): Handle multiple {@link WhileMatchFilter} labels. if (label.endsWith(WHILE_MATCH_FILTER_IN_LABEL_SUFFIX)) { inLabelCount++; } else if (label.endsWith(WHILE_MATCH_FILTER_OUT_LABEL_SUFFIX)) { outLabelCount++; } } } } } // Checks if there is mismatching {@link WhileMatchFilter} label. if (inLabelCount != outLabelCount) { return false; } return true; }
private static List<ReadRowsResponse> createResponses() { List<ReadRowsResponse> responses = new ArrayList<>(1); for (int i = 0; i < 1; i++) { String rowKey = String.format("rowKey-%s", i); byte[] value = RandomStringUtils.randomAlphanumeric(10000).getBytes(); Preconditions.checkArgument( !Strings.isNullOrEmpty("Family1"), "Family name may not be null or empty"); Family.Builder familyBuilder = Family.newBuilder().setName("Family1"); Column.Builder columnBuilder = Column.newBuilder(); columnBuilder.setQualifier(ByteString.copyFromUtf8("Qaulifier")); if (value != null) { Cell.Builder cellBuilder = Cell.newBuilder(); cellBuilder.setTimestampMicros(0L); cellBuilder.setValue(ByteString.copyFrom(value)); columnBuilder.addCells(cellBuilder); } familyBuilder.addColumns(columnBuilder); Chunk contentChunk = Chunk.newBuilder().setRowContents(familyBuilder).build(); Chunk rowCompleteChunk = Chunk.newBuilder().setCommitRow(true).build(); ReadRowsResponse response = ReadRowsResponse.newBuilder() .addChunks(contentChunk) .addChunks(rowCompleteChunk) .setRowKey(ByteString.copyFromUtf8(rowKey)) .build(); responses.add(response); } return responses; }