001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.regionserver; 019 020import org.apache.hadoop.hbase.HBaseInterfaceAudience; 021import org.apache.yetus.audience.InterfaceAudience; 022import org.apache.yetus.audience.InterfaceStability; 023 024/** 025 * This is a special {@link ScannerContext} subclass that is designed to be used globally when 026 * limits should not be enforced during invocations of {@link InternalScanner#next(java.util.List)} 027 * or {@link RegionScanner#next(java.util.List)}. 028 * <p> 029 * Instances of {@link NoLimitScannerContext} are immutable after construction. Any attempt to 030 * change the limits or progress of a {@link NoLimitScannerContext} will fail silently. The net 031 * effect is that all limit checks will return false, thus indicating that a limit has not been 032 * reached. 033 */ 034@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) 035@InterfaceStability.Evolving 036public class NoLimitScannerContext extends ScannerContext { 037 038 public NoLimitScannerContext() { 039 super(false, null, false); 040 } 041 042 /** 043 * Use this instance whenever limits do not need to be enforced. 044 */ 045 private static final ScannerContext NO_LIMIT = new NoLimitScannerContext(); 046 047 /** 048 * @return The static, immutable instance of {@link NoLimitScannerContext} to be used whenever 049 * limits should not be enforced 050 */ 051 public static final ScannerContext getInstance() { 052 return NO_LIMIT; 053 } 054 055 @Override 056 void setKeepProgress(boolean keepProgress) { 057 // Do nothing. NoLimitScannerContext instances are immutable post-construction 058 } 059 060 @Override 061 void setBatchProgress(int batchProgress) { 062 // Do nothing. NoLimitScannerContext instances are immutable post-construction 063 } 064 065 @Override 066 void setSizeProgress(long sizeProgress, long heapSizeProgress) { 067 // Do nothing. NoLimitScannerContext instances are immutable post-construction 068 } 069 070 @Override 071 void setProgress(int batchProgress, long sizeProgress, long heapSizeProgress) { 072 // Do nothing. NoLimitScannerContext instances are immutable post-construction 073 } 074 075 @Override 076 void clearProgress() { 077 // Do nothing. NoLimitScannerContext instances are immutable post-construction 078 } 079 080 @Override 081 void setSizeLimitScope(LimitScope scope) { 082 // Do nothing. NoLimitScannerContext instances are immutable post-construction 083 } 084 085 @Override 086 void setTimeLimitScope(LimitScope scope) { 087 // Do nothing. NoLimitScannerContext instances are immutable post-construction 088 } 089 090 @Override 091 NextState setScannerState(NextState state) { 092 // Do nothing. NoLimitScannerContext instances are immutable post-construction 093 return state; 094 } 095 096 @Override 097 boolean checkBatchLimit(LimitScope checkerScope) { 098 // No limits can be specified, thus return false to indicate no limit has been reached. 099 return false; 100 } 101 102 @Override 103 boolean checkSizeLimit(LimitScope checkerScope) { 104 // No limits can be specified, thus return false to indicate no limit has been reached. 105 return false; 106 } 107 108 @Override 109 boolean checkTimeLimit(LimitScope checkerScope) { 110 // No limits can be specified, thus return false to indicate no limit has been reached. 111 return false; 112 } 113 114 @Override 115 boolean checkAnyLimitReached(LimitScope checkerScope) { 116 return false; 117 } 118}