[
https://issues.apache.org/jira/browse/PHOENIX-7108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17828578#comment-17828578
]
ASF GitHub Bot commented on PHOENIX-7108:
-----------------------------------------
jpisaac commented on code in PR #1855:
URL: https://github.com/apache/phoenix/pull/1855#discussion_r1531462861
##########
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java:
##########
@@ -160,17 +240,390 @@ public void close() throws IOException {
storeScanner.close();
}
+ private enum MatcherType {
+ VIEW_INDEXES, GLOBAL_VIEWS, TENANT_VIEWS
+ }
+
+ private interface TTLTracker {
+ void setTTL(Cell firstCell);
+ RowContext getRowContext();
+ }
+ private class NonPartitionedTableTTLTracker implements TTLTracker {
+
+ private long ttl;
+ private RowContext rowContext;
+
+ public NonPartitionedTableTTLTracker(PTable pTable,
RegionCoprocessorEnvironment env, Store store) {
+ boolean isSystemTable = pTable.getType() == PTableType.SYSTEM;
+ if (isSystemTable) {
+ ColumnFamilyDescriptor cfd = store.getColumnFamilyDescriptor();
+ ttl = cfd.getTimeToLive();
+ } else {
+ ttl = pTable.getTTL() != TTL_NOT_DEFINED ? pTable.getTTL() :
DEFAULT_TTL;
+ }
+ LOGGER.info(String.format("NonPartitionedTableTTLTracker params:-
(physical-name=%s, ttl=%d, isSystemTable=%s)",
+ pTable.getName().toString(), ttl*1000, isSystemTable));
+ }
+
+ @Override
+ public void setTTL(Cell firstCell) {
+ this.rowContext = new RowContext();
+ this.rowContext.setTTL(ttl);
+
+ }
+
+ @Override
+ public RowContext getRowContext() {
+ if (this.rowContext == null) {
+ this.rowContext = new RowContext();
+ this.rowContext.setTTL(ttl);
+ }
+ return rowContext;
+ }
+ }
+
+ private class PartitionedTableTTLTracker implements TTLTracker {
+ private final Logger LOGGER = LoggerFactory.getLogger(
+ PartitionedTableTTLTracker.class);
+ private PTable baseTable;
+ private TableTTLInfoCache ttlCache;
+ private RowKeyMatcher globalViewMatcher;
+ private RowKeyMatcher tenantViewMatcher;
+ private RowKeyMatcher viewIndexMatcher;
+
+ // Default or Table-Level TTL
+ private long ttl;
+ private RowContext rowContext;
+
+ private boolean isIndexTable = false;
+ private boolean isMultiTenant = false;
+ private boolean isSalted = false;
+ private int startingPKPosition;
+ private RowKeyParser rowKeyParser;
+
+ public PartitionedTableTTLTracker(PTable table,
RegionCoprocessorEnvironment env,
+ boolean isSalted, boolean isIndexTable) {
+
+ try {
+ this.baseTable = table;
+ this.ttlCache = new TableTTLInfoCache();
+ this.rowKeyParser = new RowKeyParser(baseTable);
+ this.ttl = table.getTTL() != TTL_NOT_DEFINED ? table.getTTL()
: DEFAULT_TTL;
+ this.isIndexTable = isIndexTable || localIndex ;
+ this.isSalted = isSalted;
+ this.isMultiTenant = table.isMultiTenant();
+
+ int startingPKPosition = 0;
+ if (this.isMultiTenant && this.isSalted && this.isIndexTable) {
Review Comment:
As discussed offline created a more verbose if then else statement for the 8
conditions.
> Provide support for pruning expired rows of views using Phoenix level
> compactions
> ---------------------------------------------------------------------------------
>
> Key: PHOENIX-7108
> URL: https://issues.apache.org/jira/browse/PHOENIX-7108
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: Jacob Isaac
> Assignee: Jacob Isaac
> Priority: Major
>
> Modify Phoenix compaction framework introduced in PHOENIX-6888 to prune TTL
> expired rows of views.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)