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  public Scan setEnableScanMetricsByRegion(final boolean enable) {
233    throw new UnsupportedOperationException(
234      "ImmutableScan does not allow access to setEnableScanMetricsByRegion");
235  }
236
237  @Override
238  @Deprecated
239  public Scan setAsyncPrefetch(boolean asyncPrefetch) {
240    throw new UnsupportedOperationException(
241      "ImmutableScan does not allow access to setAsyncPrefetch");
242  }
243
244  @Override
245  public Scan setLimit(int limit) {
246    throw new UnsupportedOperationException("ImmutableScan does not allow access to setLimit");
247  }
248
249  @Override
250  public Scan setOneRowLimit() {
251    throw new UnsupportedOperationException(
252      "ImmutableScan does not allow access to setOneRowLimit");
253  }
254
255  @Override
256  public Scan setReadType(ReadType readType) {
257    throw new UnsupportedOperationException("ImmutableScan does not allow access to setReadType");
258  }
259
260  @Override
261  Scan setMvccReadPoint(long mvccReadPoint) {
262    throw new UnsupportedOperationException(
263      "ImmutableScan does not allow access to setMvccReadPoint");
264  }
265
266  @Override
267  Scan resetMvccReadPoint() {
268    throw new UnsupportedOperationException(
269      "ImmutableScan does not allow access to resetMvccReadPoint");
270  }
271
272  @Override
273  public Scan setNeedCursorResult(boolean needCursorResult) {
274    throw new UnsupportedOperationException(
275      "ImmutableScan does not allow access to setNeedCursorResult");
276  }
277
278  @Override
279  public long getMaxResultSize() {
280    return this.delegateScan.getMaxResultSize();
281  }
282
283  @Override
284  public Map<byte[], NavigableSet<byte[]>> getFamilyMap() {
285    return Collections.unmodifiableMap(this.delegateScan.getFamilyMap());
286  }
287
288  @Override
289  public int numFamilies() {
290    return this.delegateScan.numFamilies();
291  }
292
293  @Override
294  public boolean hasFamilies() {
295    return this.delegateScan.hasFamilies();
296  }
297
298  @Override
299  public byte[][] getFamilies() {
300    final byte[][] families = this.delegateScan.getFamilies();
301    byte[][] cloneFamilies = new byte[families.length][];
302    for (int i = 0; i < families.length; i++) {
303      cloneFamilies[i] = Bytes.copy(families[i]);
304    }
305    return cloneFamilies;
306  }
307
308  @Override
309  public byte[] getStartRow() {
310    final byte[] startRow = this.delegateScan.getStartRow();
311    return Bytes.copy(startRow);
312  }
313
314  @Override
315  public boolean includeStartRow() {
316    return this.delegateScan.includeStartRow();
317  }
318
319  @Override
320  public byte[] getStopRow() {
321    final byte[] stopRow = this.delegateScan.getStopRow();
322    return Bytes.copy(stopRow);
323  }
324
325  @Override
326  public boolean includeStopRow() {
327    return this.delegateScan.includeStopRow();
328  }
329
330  @Override
331  public int getMaxVersions() {
332    return this.delegateScan.getMaxVersions();
333  }
334
335  @Override
336  public int getBatch() {
337    return this.delegateScan.getBatch();
338  }
339
340  @Override
341  public int getMaxResultsPerColumnFamily() {
342    return this.delegateScan.getMaxResultsPerColumnFamily();
343  }
344
345  @Override
346  public int getRowOffsetPerColumnFamily() {
347    return this.delegateScan.getRowOffsetPerColumnFamily();
348  }
349
350  @Override
351  public int getCaching() {
352    return this.delegateScan.getCaching();
353  }
354
355  @Override
356  public TimeRange getTimeRange() {
357    return this.delegateScan.getTimeRange();
358  }
359
360  @Override
361  public Filter getFilter() {
362    return this.delegateScan.getFilter();
363  }
364
365  @Override
366  public boolean hasFilter() {
367    return this.delegateScan.hasFilter();
368  }
369
370  @Override
371  public boolean getCacheBlocks() {
372    return this.delegateScan.getCacheBlocks();
373  }
374
375  @Override
376  public boolean isReversed() {
377    return this.delegateScan.isReversed();
378  }
379
380  @Override
381  public boolean getAllowPartialResults() {
382    return this.delegateScan.getAllowPartialResults();
383  }
384
385  @Override
386  public byte[] getACL() {
387    final byte[] acl = this.delegateScan.getACL();
388    return Bytes.copy(acl);
389  }
390
391  @Override
392  public Map<String, Object> getFingerprint() {
393    return Collections.unmodifiableMap(this.delegateScan.getFingerprint());
394  }
395
396  @Override
397  public Map<String, Object> toMap(int maxCols) {
398    return Collections.unmodifiableMap(this.delegateScan.toMap(maxCols));
399  }
400
401  @Override
402  public boolean isRaw() {
403    return this.delegateScan.isRaw();
404  }
405
406  @Override
407  public boolean isScanMetricsEnabled() {
408    return this.delegateScan.isScanMetricsEnabled();
409  }
410
411  @Override
412  public boolean isScanMetricsByRegionEnabled() {
413    return this.delegateScan.isScanMetricsByRegionEnabled();
414  }
415
416  @Override
417  public Boolean isAsyncPrefetch() {
418    return this.delegateScan.isAsyncPrefetch();
419  }
420
421  @Override
422  public int getLimit() {
423    return this.delegateScan.getLimit();
424  }
425
426  @Override
427  public ReadType getReadType() {
428    return this.delegateScan.getReadType();
429  }
430
431  @Override
432  long getMvccReadPoint() {
433    return this.delegateScan.getMvccReadPoint();
434  }
435
436  @Override
437  public boolean isNeedCursorResult() {
438    return this.delegateScan.isNeedCursorResult();
439  }
440
441  @Override
442  public byte[] getAttribute(String name) {
443    final byte[] attribute = this.delegateScan.getAttribute(name);
444    return Bytes.copy(attribute);
445  }
446
447  @Override
448  public Consistency getConsistency() {
449    return this.delegateScan.getConsistency();
450  }
451
452  @Override
453  public long getAttributeSize() {
454    return this.delegateScan.getAttributeSize();
455  }
456
457  @Override
458  public Map<String, byte[]> getAttributesMap() {
459    return Collections.unmodifiableMap(this.delegateScan.getAttributesMap());
460  }
461
462  @Override
463  public Boolean getLoadColumnFamiliesOnDemandValue() {
464    return this.delegateScan.getLoadColumnFamiliesOnDemandValue();
465  }
466
467  @Override
468  public int getPriority() {
469    return this.delegateScan.getPriority();
470  }
471
472  @Override
473  public Map<byte[], TimeRange> getColumnFamilyTimeRange() {
474    return Collections.unmodifiableMap(this.delegateScan.getColumnFamilyTimeRange());
475  }
476
477  @Override
478  public int getReplicaId() {
479    return this.delegateScan.getReplicaId();
480  }
481
482  @Override
483  public boolean doLoadColumnFamiliesOnDemand() {
484    return this.delegateScan.doLoadColumnFamiliesOnDemand();
485  }
486
487  @Override
488  public String getId() {
489    return this.delegateScan.getId();
490  }
491
492  @Override
493  public boolean isGetScan() {
494    return this.delegateScan.isGetScan();
495  }
496
497  @Override
498  public IsolationLevel getIsolationLevel() {
499    return this.delegateScan.getIsolationLevel();
500  }
501
502  @Override
503  public Authorizations getAuthorizations() throws DeserializationException {
504    return this.delegateScan.getAuthorizations();
505  }
506
507  @Override
508  public String toString(int maxCols) {
509    return this.delegateScan.toString(maxCols);
510  }
511
512  @Override
513  public String toString() {
514    return this.delegateScan.toString();
515  }
516
517  @Override
518  public Map<String, Object> toMap() {
519    return Collections.unmodifiableMap(this.delegateScan.toMap());
520  }
521
522  @Override
523  public String toJSON(int maxCols) throws IOException {
524    return this.delegateScan.toJSON(maxCols);
525  }
526
527  @Override
528  public String toJSON() throws IOException {
529    return this.delegateScan.toJSON();
530  }
531
532}