public List filterCellsForSnapshot()

in hbase-client/src/main/java/org/apache/omid/transaction/SnapshotFilterImpl.java [420:494]


    public List<Cell> filterCellsForSnapshot(List<Cell> rawCells, HBaseTransaction transaction,
                                      int versionsToRequest, Map<String, Long> familyDeletionCache, Map<String,byte[]> attributeMap) throws IOException {

        assert (rawCells != null && transaction != null && versionsToRequest >= 1);

        List<Cell> keyValuesInSnapshot = new ArrayList<>();
        List<Get> pendingGetsList = new ArrayList<>();

        int numberOfVersionsToFetch = versionsToRequest * 2;
        if (numberOfVersionsToFetch < 1) {
            numberOfVersionsToFetch = versionsToRequest;
        }

        Map<Long, Long> commitCache = buildCommitCache(rawCells);
        buildFamilyDeletionCache(transaction, rawCells, familyDeletionCache, commitCache, attributeMap);

        ImmutableList<Collection<Cell>> filteredCells;
        if (transaction.getVisibilityLevel() == VisibilityLevel.SNAPSHOT_ALL) {
            filteredCells = groupCellsByColumnFilteringShadowCells(rawCells);
        } else {
            filteredCells = groupCellsByColumnFilteringShadowCellsAndFamilyDeletion(rawCells);
        }

        for (Collection<Cell> columnCells : filteredCells) {
            boolean snapshotValueFound = false;
            Cell oldestCell = null;
            for (Cell cell : columnCells) {
                oldestCell = cell;
                if (getTSIfInTransaction(cell, transaction).isPresent() ||
                        getTSIfInSnapshot(cell, transaction, commitCache).isPresent()) {

                    if (transaction.getVisibilityLevel() == VisibilityLevel.SNAPSHOT_ALL) {
                        keyValuesInSnapshot.add(cell);
                        if (getTSIfInTransaction(cell, transaction).isPresent()) {
                            snapshotValueFound = false;
                            continue;
                        } else {
                            snapshotValueFound = true;
                            break;
                        }
                    } else {
                        if (!checkFamilyDeletionCache(cell, transaction, familyDeletionCache, commitCache) &&
                                !CellUtils.isTombstone(cell)) {
                            keyValuesInSnapshot.add(cell);
                        }
                        snapshotValueFound = true;
                        break;

                    }
                }
            }
            if (!snapshotValueFound) {
                assert (oldestCell != null);
                Get pendingGet = createPendingGet(oldestCell, numberOfVersionsToFetch);
                for (Map.Entry<String,byte[]> entry : attributeMap.entrySet()) {
                    pendingGet.setAttribute(entry.getKey(), entry.getValue());
                }
                pendingGetsList.add(pendingGet);
            }
        }

        if (!pendingGetsList.isEmpty()) {
            Result[] pendingGetsResults = tableAccessWrapper.get(pendingGetsList);
            for (Result pendingGetResult : pendingGetsResults) {
                if (!pendingGetResult.isEmpty()) {
                    keyValuesInSnapshot.addAll(
                        filterCellsForSnapshot(pendingGetResult.listCells(), transaction, numberOfVersionsToFetch, familyDeletionCache, attributeMap));
                }
            }
        }

        Collections.sort(keyValuesInSnapshot, CellComparator.getInstance());

        return keyValuesInSnapshot;
    }