Source:
List<List<Entry>> filterNotExistColumnFamilyEdits(final List<List<Entry>> oldEntryList) { List<List<Entry>> entryList = new ArrayList<>(); Map<TableName, Set<String>> existColumnFamilyMap = new HashMap<>(); try (Connection localConn = ConnectionFactory.createConnection(ctx.getLocalConfiguration()); Admin localAdmin = localConn.getAdmin()) { for (List<Entry> oldEntries : oldEntryList) { List<Entry> entries = new ArrayList<>(); for (Entry e : oldEntries) { TableName tableName = e.getKey().getTableName(); if (!existColumnFamilyMap.containsKey(tableName)) { try { Set<String> cfs = localAdmin.getDescriptor(tableName).getColumnFamilyNames().stream() .map(Bytes::toString).collect(Collectors.toSet()); existColumnFamilyMap.put(tableName, cfs); } catch (Exception ex) { LOG.warn("Exception getting cf names for local table {}", tableName, ex); entries.add(e); continue; } } Set<String> existColumnFamilies = existColumnFamilyMap.get(tableName); Set<String> missingCFs = new HashSet<>(); WALEdit walEdit = new WALEdit(); walEdit.getCells().addAll(e.getEdit().getCells()); WALUtil.filterCells(walEdit, cell -> { String cf = Bytes.toString(CellUtil.cloneFamily(cell)); if (existColumnFamilies.contains(cf)) { return cell; } else { missingCFs.add(cf); return null; } }); if (!walEdit.isEmpty()) { Entry newEntry = new Entry(e.getKey(), walEdit); entries.add(newEntry); } if (!missingCFs.isEmpty()) { LOG.warn( "Missing column family detected at sink, local column family also does not exist," + "filtering edits for table '{}',column family '{}", tableName, missingCFs); } } if (!entries.isEmpty()) { entryList.add(entries); } } } catch (IOException iox) { LOG.warn("Exception when creating connection to check local table", iox); return oldEntryList; } return entryList; }

Target:
List<List<Entry>> filterNotExistColumnFamilyEdits(final List<List<Entry>> oldEntryList) { List<List<Entry>> entryList = new ArrayList<>(); Map<TableName, Set<String>> existColumnFamilyMap = new HashMap<>(); try (Connection localConn = ConnectionFactory.createConnection(ctx.getLocalConfiguration()); Admin localAdmin = localConn.getAdmin()) { for (List<Entry> oldEntries : oldEntryList) { List<Entry> entries = new ArrayList<>(); for (Entry e : oldEntries) { TableName tableName = e.getKey().getTableName(); if (!existColumnFamilyMap.containsKey(tableName)) { try { Set<String> cfs = localAdmin.getDescriptor(tableName).getColumnFamilyNames().stream() .map(Bytes::toString).collect(Collectors.toSet()); existColumnFamilyMap.put(tableName, cfs); } catch (Exception ex) { LOG.warn("Exception getting cf names for local table {}", tableName, ex); entries.add(e); continue; } } Set<String> existColumnFamilies = existColumnFamilyMap.get(tableName); Set<String> missingCFs = new HashSet<>(); WALEdit walEdit = new WALEdit(); walEdit.getCells().addAll(e.getEdit().getCells()); WALUtil.filterCells(walEdit, cell -> { String cf = Bytes.toString(CellUtil.cloneFamily(cell)); if (existColumnFamilies.contains(cf)) { return cell; } else { missingCFs.add(cf); return null; } }); if (!walEdit.isEmpty()) { Entry newEntry = new Entry(e.getKey(), walEdit); entries.add(newEntry); } if (!missingCFs.isEmpty()) { LOG.warn( "Missing column family detected at sink, local column family also does not exist," + " filtering edits for table '{}',column family '{}'", tableName, missingCFs); } } if (!entries.isEmpty()) { entryList.add(entries); } } } catch (IOException iox) { LOG.warn("Exception when creating connection to check local table", iox); return oldEntryList; } return entryList; }