[ https://issues.apache.org/jira/browse/PHOENIX-5895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17225430#comment-17225430 ]
ASF GitHub Bot commented on PHOENIX-5895: ----------------------------------------- gjacoby126 commented on a change in pull request #951: URL: https://github.com/apache/phoenix/pull/951#discussion_r516334881 ########## File path: phoenix-core/src/it/java/org/apache/phoenix/replication/SystemCatalogWALEntryFilterIT.java ########## @@ -134,11 +135,16 @@ public void testSystemCatalogWALEntryFilter() throws Exception { //verify that the tenant view WAL.Entry passes the filter and the non-tenant view does not SystemCatalogWALEntryFilter filter = new SystemCatalogWALEntryFilter(); - Assert.assertNull(filter.filter(nonTenantEntry)); - WAL.Entry filteredTenantEntry = filter.filter(tenantEntry); + // Chain the system catalog WAL entry filter to ChainWALEntryFilter + ChainWALEntryFilter chainWALEntryFilter = new ChainWALEntryFilter(filter); + // Asserting the WALEdit for non tenant has cells before getting filtered + Assert.assertTrue(nonTenantEntry.getEdit().size() > 0); + // All the cells will get removed by the filter since they do not belong to tenant + Assert.assertTrue("Non tenant edits for system catalog got ", chainWALEntryFilter.filter(nonTenantEntry).getEdit().isEmpty()); Review comment: nit: system catalog get ########## File path: phoenix-core/src/main/java/org/apache/phoenix/replication/SystemCatalogWALEntryFilter.java ########## @@ -35,30 +36,30 @@ * be copied. This WALEntryFilter will only allow tenant-owned rows in SYSTEM.CATALOG to * be replicated. Data from all other tables is automatically passed. */ -public class SystemCatalogWALEntryFilter implements WALEntryFilter { +public class SystemCatalogWALEntryFilter implements WALEntryFilter, WALCellFilter { + // This is an optimization to just skip the cell filter if we do not care about + // cell filter for certain WALEdits. + private boolean skipCellFilter; @Override public WAL.Entry filter(WAL.Entry entry) { - + // We use the WALCellFilter to filter the cells from entry, WALEntryFilter + // should not block anything //if the WAL.Entry's table isn't System.Catalog or System.Child_Link, it auto-passes this filter - //TODO: when Phoenix drops support for pre-1.3 versions of HBase, redo as a WALCellFilter if (!SchemaUtil.isMetaTable(entry.getKey().getTableName().getName())){ - return entry; + skipCellFilter = true; + } else { + skipCellFilter = false; } + return entry; + } - List<Cell> cells = entry.getEdit().getCells(); - List<Cell> cellsToRemove = Lists.newArrayList(); - for (Cell cell : cells) { - if (!isTenantRowCell(cell)){ - cellsToRemove.add(cell); - } - } - cells.removeAll(cellsToRemove); - if (cells.size() > 0) { - return entry; - } else { - return null; + @Override + public Cell filterCell(WAL.Entry entry, Cell cell) { + if (skipCellFilter) { + return cell; } + return isTenantRowCell(cell) ? cell : null; } private boolean isTenantRowCell(Cell cell) { Review comment: @virajjasani - yes, I believe that will work. ImmutableBytesWritable.get() just returns the underlying byte array ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Leverage WALCellFilter in the SystemCatalogWALEntryFilter to replicate system > catalog table > ------------------------------------------------------------------------------------------- > > Key: PHOENIX-5895 > URL: https://issues.apache.org/jira/browse/PHOENIX-5895 > Project: Phoenix > Issue Type: Improvement > Components: core > Reporter: Sandeep Pal > Assignee: Sandeep Pal > Priority: Minor > -- This message was sent by Atlassian Jira (v8.3.4#803005)