@Test public void rowWithNullsParsesAllCombinationsForCells() { LockDescriptor descriptor = AtlasCellLockDescriptor.of(TABLE.getQualifiedName(), ROW_WITH_ZEROS, NO_ZERO_COL); List<CellReference> expected = ImmutableList.of( Cell.create(new byte[] {1}, new byte[] {2, 0, 3, 0, 4, 5, 6}), Cell.create(new byte[] {1, 0, 2}, new byte[] {3, 0, 4, 5, 6}), Cell.create(new byte[] {1, 0, 2, 0, 3}, new byte[] {4, 5, 6})) .stream() .map(cell -> CellReference.of(TABLE, cell)) .collect(Collectors.toList()); assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor)).isEqualTo(expected); assertThat(AtlasLockDescriptorUtils.candidateCells(descriptor)) .contains(CellReference.of(TABLE, Cell.create(ROW_WITH_ZEROS, NO_ZERO_COL))); }
public static List<CellReference> candidateCells(LockDescriptor lockDescriptor) { Optional<TableRefAndRemainder> tableRefAndRemainder = tryParseTableRef(lockDescriptor); if (!tableRefAndRemainder.isPresent()) { return ImmutableList.of(); } TableReference tableRef = tableRefAndRemainder.get().tableRef(); ByteString remainingBytes = tableRefAndRemainder.get().remainder(); return IntStream.range(1, remainingBytes.size() - 2) .filter(index -> isZeroDelimiterIndex(remainingBytes, index)) .mapToObj(index -> createCellFromByteString(remainingBytes, index)) .map(cell -> CellReference.of(tableRef, cell)) .collect(Collectors.toList()); }
AtlasLockDescriptorUtils { public static List<CellReference> candidateCells(LockDescriptor lockDescriptor) { Optional<TableRefAndRemainder> tableRefAndRemainder = tryParseTableRef(lockDescriptor); if (!tableRefAndRemainder.isPresent()) { return ImmutableList.of(); } TableReference tableRef = tableRefAndRemainder.get().tableRef(); ByteString remainingBytes = tableRefAndRemainder.get().remainder(); return IntStream.range(1, remainingBytes.size() - 2) .filter(index -> isZeroDelimiterIndex(remainingBytes, index)) .mapToObj(index -> createCellFromByteString(remainingBytes, index)) .map(cell -> CellReference.of(tableRef, cell)) .collect(Collectors.toList()); } }
AtlasLockDescriptorUtils { public static List<CellReference> candidateCells(LockDescriptor lockDescriptor) { Optional<TableRefAndRemainder> tableRefAndRemainder = tryParseTableRef(lockDescriptor); if (!tableRefAndRemainder.isPresent()) { return ImmutableList.of(); } TableReference tableRef = tableRefAndRemainder.get().tableRef(); ByteString remainingBytes = tableRefAndRemainder.get().remainder(); return IntStream.range(1, remainingBytes.size() - 2) .filter(index -> isZeroDelimiterIndex(remainingBytes, index)) .mapToObj(index -> createCellFromByteString(remainingBytes, index)) .map(cell -> CellReference.of(tableRef, cell)) .collect(Collectors.toList()); } private  AtlasLockDescriptorUtils(); }
AtlasLockDescriptorUtils { public static List<CellReference> candidateCells(LockDescriptor lockDescriptor) { Optional<TableRefAndRemainder> tableRefAndRemainder = tryParseTableRef(lockDescriptor); if (!tableRefAndRemainder.isPresent()) { return ImmutableList.of(); } TableReference tableRef = tableRefAndRemainder.get().tableRef(); ByteString remainingBytes = tableRefAndRemainder.get().remainder(); return IntStream.range(1, remainingBytes.size() - 2) .filter(index -> isZeroDelimiterIndex(remainingBytes, index)) .mapToObj(index -> createCellFromByteString(remainingBytes, index)) .map(cell -> CellReference.of(tableRef, cell)) .collect(Collectors.toList()); } private  AtlasLockDescriptorUtils(); static List<CellReference> candidateCells(LockDescriptor lockDescriptor); static Optional<TableRefAndRemainder> tryParseTableRef(LockDescriptor lockDescriptor); }
AtlasLockDescriptorUtils { public static List<CellReference> candidateCells(LockDescriptor lockDescriptor) { Optional<TableRefAndRemainder> tableRefAndRemainder = tryParseTableRef(lockDescriptor); if (!tableRefAndRemainder.isPresent()) { return ImmutableList.of(); } TableReference tableRef = tableRefAndRemainder.get().tableRef(); ByteString remainingBytes = tableRefAndRemainder.get().remainder(); return IntStream.range(1, remainingBytes.size() - 2) .filter(index -> isZeroDelimiterIndex(remainingBytes, index)) .mapToObj(index -> createCellFromByteString(remainingBytes, index)) .map(cell -> CellReference.of(tableRef, cell)) .collect(Collectors.toList()); } private  AtlasLockDescriptorUtils(); static List<CellReference> candidateCells(LockDescriptor lockDescriptor); static Optional<TableRefAndRemainder> tryParseTableRef(LockDescriptor lockDescriptor);  }