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