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