sandeepvinayak commented on a change in pull request #951:
URL: https://github.com/apache/phoenix/pull/951#discussion_r517140962



##########
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:
       yes, it should be same, I will change that 
   ```java
     public byte [] get() {
       if (this.bytes == null) {
         throw new IllegalStateException("Uninitialiized. Null constructor " +
           "called w/o accompaying readFields invocation");
       }
       return this.bytes;
     }
   ```




----------------------------------------------------------------
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


Reply via email to