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.client; 019 020import java.io.IOException; 021import java.util.Collections; 022import java.util.Map; 023import java.util.NavigableSet; 024import org.apache.hadoop.hbase.exceptions.DeserializationException; 025import org.apache.hadoop.hbase.filter.Filter; 026import org.apache.hadoop.hbase.io.TimeRange; 027import org.apache.hadoop.hbase.security.access.Permission; 028import org.apache.hadoop.hbase.security.visibility.Authorizations; 029import org.apache.hadoop.hbase.util.Bytes; 030import org.apache.yetus.audience.InterfaceAudience; 031 032/** 033 * Immutable version of Scan 034 */ 035@InterfaceAudience.Private 036public final class ImmutableScan extends Scan { 037 038 private final Scan delegateScan; 039 040 /** 041 * Create Immutable instance of Scan from given Scan object 042 * @param scan Copy all values from Scan 043 */ 044 public ImmutableScan(Scan scan) { 045 this.delegateScan = scan; 046 } 047 048 @Override 049 public Scan addFamily(byte[] family) { 050 throw new UnsupportedOperationException("ImmutableScan does not allow access to addFamily"); 051 } 052 053 @Override 054 public Scan addColumn(byte[] family, byte[] qualifier) { 055 throw new UnsupportedOperationException("ImmutableScan does not allow access to addColumn"); 056 } 057 058 @Override 059 public Scan setTimeRange(long minStamp, long maxStamp) { 060 throw new UnsupportedOperationException("ImmutableScan does not allow access to setTimeRange"); 061 } 062 063 @Override 064 public Scan setTimestamp(long timestamp) { 065 throw new UnsupportedOperationException("ImmutableScan does not allow access to setTimestamp"); 066 } 067 068 @Override 069 public Scan setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp) { 070 throw new UnsupportedOperationException( 071 "ImmutableScan does not allow access to setColumnFamilyTimeRange"); 072 } 073 074 @Override 075 public Scan withStartRow(byte[] startRow) { 076 throw new UnsupportedOperationException("ImmutableScan does not allow access to withStartRow"); 077 } 078 079 @Override 080 public Scan withStartRow(byte[] startRow, boolean inclusive) { 081 throw new UnsupportedOperationException("ImmutableScan does not allow access to withStartRow"); 082 } 083 084 @Override 085 public Scan withStopRow(byte[] stopRow) { 086 throw new UnsupportedOperationException("ImmutableScan does not allow access to withStopRow"); 087 } 088 089 @Override 090 public Scan withStopRow(byte[] stopRow, boolean inclusive) { 091 throw new UnsupportedOperationException("ImmutableScan does not allow access to withStopRow"); 092 } 093 094 @Override 095 public Scan setStartStopRowForPrefixScan(byte[] rowPrefix) { 096 throw new UnsupportedOperationException( 097 "ImmutableScan does not allow access to setStartStopRowForPrefixScan"); 098 } 099 100 @Override 101 public Scan readAllVersions() { 102 throw new UnsupportedOperationException( 103 "ImmutableScan does not allow access to readAllVersions"); 104 } 105 106 @Override 107 public Scan readVersions(int versions) { 108 throw new UnsupportedOperationException("ImmutableScan does not allow access to readVersions"); 109 } 110 111 @Override 112 public Scan setBatch(int batch) { 113 throw new UnsupportedOperationException("ImmutableScan does not allow access to setBatch"); 114 } 115 116 @Override 117 public Scan setMaxResultsPerColumnFamily(int limit) { 118 throw new UnsupportedOperationException( 119 "ImmutableScan does not allow access to setMaxResultsPerColumnFamily"); 120 } 121 122 @Override 123 public Scan setRowOffsetPerColumnFamily(int offset) { 124 throw new UnsupportedOperationException( 125 "ImmutableScan does not allow access to setRowOffsetPerColumnFamily"); 126 } 127 128 @Override 129 public Scan setCaching(int caching) { 130 throw new UnsupportedOperationException("ImmutableScan does not allow access to setCaching"); 131 } 132 133 @Override 134 public Scan setMaxResultSize(long maxResultSize) { 135 throw new UnsupportedOperationException( 136 "ImmutableScan does not allow access to setMaxResultSize"); 137 } 138 139 @Override 140 public Scan setFilter(Filter filter) { 141 throw new UnsupportedOperationException("ImmutableScan does not allow access to setFilter"); 142 } 143 144 @Override 145 public Scan setFamilyMap(Map<byte[], NavigableSet<byte[]>> familyMap) { 146 throw new UnsupportedOperationException("ImmutableScan does not allow access to setFamilyMap"); 147 } 148 149 @Override 150 public Scan setCacheBlocks(boolean cacheBlocks) { 151 throw new UnsupportedOperationException( 152 "ImmutableScan does not allow access to setCacheBlocks"); 153 } 154 155 @Override 156 public Scan setReversed(boolean reversed) { 157 throw new UnsupportedOperationException("ImmutableScan does not allow access to setReversed"); 158 } 159 160 @Override 161 public Scan setAllowPartialResults(final boolean allowPartialResults) { 162 throw new UnsupportedOperationException( 163 "ImmutableScan does not allow access to setAllowPartialResults"); 164 } 165 166 @Override 167 public Scan setLoadColumnFamiliesOnDemand(boolean value) { 168 throw new UnsupportedOperationException( 169 "ImmutableScan does not allow access to setLoadColumnFamiliesOnDemand"); 170 } 171 172 @Override 173 public Scan setRaw(boolean raw) { 174 throw new UnsupportedOperationException("ImmutableScan does not allow access to setRaw"); 175 } 176 177 @Override 178 public Scan setAttribute(String name, byte[] value) { 179 throw new UnsupportedOperationException("ImmutableScan does not allow access to setAttribute"); 180 } 181 182 @Override 183 public Scan setId(String id) { 184 throw new UnsupportedOperationException("ImmutableScan does not allow access to setId"); 185 } 186 187 @Override 188 public Scan setAuthorizations(Authorizations authorizations) { 189 throw new UnsupportedOperationException( 190 "ImmutableScan does not allow access to setAuthorizations"); 191 } 192 193 @Override 194 public Scan setACL(Map<String, Permission> perms) { 195 throw new UnsupportedOperationException("ImmutableScan does not allow access to setACL"); 196 } 197 198 @Override 199 public Scan setACL(String user, Permission perms) { 200 throw new UnsupportedOperationException("ImmutableScan does not allow access to setACL"); 201 } 202 203 @Override 204 public Scan setConsistency(Consistency consistency) { 205 throw new UnsupportedOperationException( 206 "ImmutableScan does not allow access to setConsistency"); 207 } 208 209 @Override 210 public Scan setReplicaId(int id) { 211 throw new UnsupportedOperationException("ImmutableScan does not allow access to setReplicaId"); 212 } 213 214 @Override 215 public Scan setIsolationLevel(IsolationLevel level) { 216 throw new UnsupportedOperationException( 217 "ImmutableScan does not allow access to setIsolationLevel"); 218 } 219 220 @Override 221 public Scan setPriority(int priority) { 222 throw new UnsupportedOperationException("ImmutableScan does not allow access to setPriority"); 223 } 224 225 @Override 226 public Scan setScanMetricsEnabled(final boolean enabled) { 227 throw new UnsupportedOperationException( 228 "ImmutableScan does not allow access to setScanMetricsEnabled"); 229 } 230 231 @Override 232 @Deprecated 233 public Scan setAsyncPrefetch(boolean asyncPrefetch) { 234 throw new UnsupportedOperationException( 235 "ImmutableScan does not allow access to setAsyncPrefetch"); 236 } 237 238 @Override 239 public Scan setLimit(int limit) { 240 throw new UnsupportedOperationException("ImmutableScan does not allow access to setLimit"); 241 } 242 243 @Override 244 public Scan setOneRowLimit() { 245 throw new UnsupportedOperationException( 246 "ImmutableScan does not allow access to setOneRowLimit"); 247 } 248 249 @Override 250 public Scan setReadType(ReadType readType) { 251 throw new UnsupportedOperationException("ImmutableScan does not allow access to setReadType"); 252 } 253 254 @Override 255 Scan setMvccReadPoint(long mvccReadPoint) { 256 throw new UnsupportedOperationException( 257 "ImmutableScan does not allow access to setMvccReadPoint"); 258 } 259 260 @Override 261 Scan resetMvccReadPoint() { 262 throw new UnsupportedOperationException( 263 "ImmutableScan does not allow access to resetMvccReadPoint"); 264 } 265 266 @Override 267 public Scan setNeedCursorResult(boolean needCursorResult) { 268 throw new UnsupportedOperationException( 269 "ImmutableScan does not allow access to setNeedCursorResult"); 270 } 271 272 @Override 273 public long getMaxResultSize() { 274 return this.delegateScan.getMaxResultSize(); 275 } 276 277 @Override 278 public Map<byte[], NavigableSet<byte[]>> getFamilyMap() { 279 return Collections.unmodifiableMap(this.delegateScan.getFamilyMap()); 280 } 281 282 @Override 283 public int numFamilies() { 284 return this.delegateScan.numFamilies(); 285 } 286 287 @Override 288 public boolean hasFamilies() { 289 return this.delegateScan.hasFamilies(); 290 } 291 292 @Override 293 public byte[][] getFamilies() { 294 final byte[][] families = this.delegateScan.getFamilies(); 295 byte[][] cloneFamilies = new byte[families.length][]; 296 for (int i = 0; i < families.length; i++) { 297 cloneFamilies[i] = Bytes.copy(families[i]); 298 } 299 return cloneFamilies; 300 } 301 302 @Override 303 public byte[] getStartRow() { 304 final byte[] startRow = this.delegateScan.getStartRow(); 305 return Bytes.copy(startRow); 306 } 307 308 @Override 309 public boolean includeStartRow() { 310 return this.delegateScan.includeStartRow(); 311 } 312 313 @Override 314 public byte[] getStopRow() { 315 final byte[] stopRow = this.delegateScan.getStopRow(); 316 return Bytes.copy(stopRow); 317 } 318 319 @Override 320 public boolean includeStopRow() { 321 return this.delegateScan.includeStopRow(); 322 } 323 324 @Override 325 public int getMaxVersions() { 326 return this.delegateScan.getMaxVersions(); 327 } 328 329 @Override 330 public int getBatch() { 331 return this.delegateScan.getBatch(); 332 } 333 334 @Override 335 public int getMaxResultsPerColumnFamily() { 336 return this.delegateScan.getMaxResultsPerColumnFamily(); 337 } 338 339 @Override 340 public int getRowOffsetPerColumnFamily() { 341 return this.delegateScan.getRowOffsetPerColumnFamily(); 342 } 343 344 @Override 345 public int getCaching() { 346 return this.delegateScan.getCaching(); 347 } 348 349 @Override 350 public TimeRange getTimeRange() { 351 return this.delegateScan.getTimeRange(); 352 } 353 354 @Override 355 public Filter getFilter() { 356 return this.delegateScan.getFilter(); 357 } 358 359 @Override 360 public boolean hasFilter() { 361 return this.delegateScan.hasFilter(); 362 } 363 364 @Override 365 public boolean getCacheBlocks() { 366 return this.delegateScan.getCacheBlocks(); 367 } 368 369 @Override 370 public boolean isReversed() { 371 return this.delegateScan.isReversed(); 372 } 373 374 @Override 375 public boolean getAllowPartialResults() { 376 return this.delegateScan.getAllowPartialResults(); 377 } 378 379 @Override 380 public byte[] getACL() { 381 final byte[] acl = this.delegateScan.getACL(); 382 return Bytes.copy(acl); 383 } 384 385 @Override 386 public Map<String, Object> getFingerprint() { 387 return Collections.unmodifiableMap(this.delegateScan.getFingerprint()); 388 } 389 390 @Override 391 public Map<String, Object> toMap(int maxCols) { 392 return Collections.unmodifiableMap(this.delegateScan.toMap(maxCols)); 393 } 394 395 @Override 396 public boolean isRaw() { 397 return this.delegateScan.isRaw(); 398 } 399 400 @Override 401 public boolean isScanMetricsEnabled() { 402 return this.delegateScan.isScanMetricsEnabled(); 403 } 404 405 @Override 406 public Boolean isAsyncPrefetch() { 407 return this.delegateScan.isAsyncPrefetch(); 408 } 409 410 @Override 411 public int getLimit() { 412 return this.delegateScan.getLimit(); 413 } 414 415 @Override 416 public ReadType getReadType() { 417 return this.delegateScan.getReadType(); 418 } 419 420 @Override 421 long getMvccReadPoint() { 422 return this.delegateScan.getMvccReadPoint(); 423 } 424 425 @Override 426 public boolean isNeedCursorResult() { 427 return this.delegateScan.isNeedCursorResult(); 428 } 429 430 @Override 431 public byte[] getAttribute(String name) { 432 final byte[] attribute = this.delegateScan.getAttribute(name); 433 return Bytes.copy(attribute); 434 } 435 436 @Override 437 public Consistency getConsistency() { 438 return this.delegateScan.getConsistency(); 439 } 440 441 @Override 442 public long getAttributeSize() { 443 return this.delegateScan.getAttributeSize(); 444 } 445 446 @Override 447 public Map<String, byte[]> getAttributesMap() { 448 return Collections.unmodifiableMap(this.delegateScan.getAttributesMap()); 449 } 450 451 @Override 452 public Boolean getLoadColumnFamiliesOnDemandValue() { 453 return this.delegateScan.getLoadColumnFamiliesOnDemandValue(); 454 } 455 456 @Override 457 public int getPriority() { 458 return this.delegateScan.getPriority(); 459 } 460 461 @Override 462 public Map<byte[], TimeRange> getColumnFamilyTimeRange() { 463 return Collections.unmodifiableMap(this.delegateScan.getColumnFamilyTimeRange()); 464 } 465 466 @Override 467 public int getReplicaId() { 468 return this.delegateScan.getReplicaId(); 469 } 470 471 @Override 472 public boolean doLoadColumnFamiliesOnDemand() { 473 return this.delegateScan.doLoadColumnFamiliesOnDemand(); 474 } 475 476 @Override 477 public String getId() { 478 return this.delegateScan.getId(); 479 } 480 481 @Override 482 public boolean isGetScan() { 483 return this.delegateScan.isGetScan(); 484 } 485 486 @Override 487 public IsolationLevel getIsolationLevel() { 488 return this.delegateScan.getIsolationLevel(); 489 } 490 491 @Override 492 public Authorizations getAuthorizations() throws DeserializationException { 493 return this.delegateScan.getAuthorizations(); 494 } 495 496 @Override 497 public String toString(int maxCols) { 498 return this.delegateScan.toString(maxCols); 499 } 500 501 @Override 502 public String toString() { 503 return this.delegateScan.toString(); 504 } 505 506 @Override 507 public Map<String, Object> toMap() { 508 return Collections.unmodifiableMap(this.delegateScan.toMap()); 509 } 510 511 @Override 512 public String toJSON(int maxCols) throws IOException { 513 return this.delegateScan.toJSON(maxCols); 514 } 515 516 @Override 517 public String toJSON() throws IOException { 518 return this.delegateScan.toJSON(); 519 } 520 521}