Skip to content

Commit

Permalink
PHOENIX-1406 Use preCompact hook instead of preCompactScannerOpen for…
Browse files Browse the repository at this point in the history
… stats collection
  • Loading branch information
jtaylor-sfdc committed Nov 5, 2014
1 parent 86dff2c commit 1fb89e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,12 @@ public long getMaxResultSize() {
}

@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
Store store, List<? extends KeyValueScanner> scanners, ScanType scanType,
long earliestPutTs, InternalScanner s) throws IOException {
InternalScanner internalScan = s;
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c,
final Store store, InternalScanner scanner, final ScanType scanType)
throws IOException {
TableName table = c.getEnvironment().getRegion().getRegionInfo().getTable();
if (!table.getNameAsString().equals(PhoenixDatabaseMetaData.SYSTEM_STATS_NAME)
&& scanType.equals(ScanType.COMPACT_DROP_DELETES)) {
InternalScanner internalScanner = scanner;
if (scanType.equals(ScanType.COMPACT_DROP_DELETES)) {
try {
boolean useCurrentTime =
c.getEnvironment().getConfiguration().getBoolean(QueryServices.STATS_USE_CURRENT_TIME_ATTRIB,
Expand All @@ -468,8 +467,7 @@ public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEn
// the cells and use that.
long clientTimeStamp = useCurrentTime ? TimeKeeper.SYSTEM.getCurrentTime() : StatisticsCollector.NO_TIMESTAMP;
StatisticsCollector stats = new StatisticsCollector(c.getEnvironment(), table.getNameAsString(), clientTimeStamp);
internalScan =
stats.createCompactionScanner(c.getEnvironment().getRegion(), store, scanners, scanType, earliestPutTs, s);
internalScanner = stats.createCompactionScanner(c.getEnvironment().getRegion(), store, scanner);
} catch (IOException e) {
// If we can't reach the stats table, don't interrupt the normal
// compaction operation, just log a warning.
Expand All @@ -478,7 +476,7 @@ public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEn
}
}
}
return internalScan;
return internalScanner;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,30 +193,12 @@ public void collectStatistics(final List<Cell> results) {
}
}

public InternalScanner createCompactionScanner(HRegion region, Store store,
List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s) throws IOException {
public InternalScanner createCompactionScanner(HRegion region, Store store, InternalScanner s) throws IOException {
// See if this is for Major compaction
InternalScanner internalScan = s;
if (scanType.equals(ScanType.COMPACT_DROP_DELETES)) {
// this is the first CP accessed, so we need to just create a major
// compaction scanner, just
// like in the compactor
if (s == null) {
Scan scan = new Scan();
scan.setMaxVersions(store.getFamily().getMaxVersions());
long smallestReadPoint = store.getSmallestReadPoint();
internalScan = new StoreScanner(store, store.getScanInfo(), scan, scanners, scanType,
smallestReadPoint, earliestPutTs);
}
if (logger.isDebugEnabled()) {
logger.debug("Compaction scanner created for stats");
}
InternalScanner scanner = getInternalScanner(region, store, internalScan, store.getColumnFamilyName());
if (scanner != null) {
internalScan = scanner;
}
if (logger.isDebugEnabled()) {
logger.debug("Compaction scanner created for stats");
}
return internalScan;
return getInternalScanner(region, store, s, store.getColumnFamilyName());
}

public void collectStatsDuringSplit(Configuration conf, HRegion l, HRegion r,
Expand Down

0 comments on commit 1fb89e4

Please sign in to comment.