View Javadoc

1   /**
2    * Copyright 2010 The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package org.apache.hadoop.hbase.client;
22  
23  import org.apache.hadoop.hbase.HColumnDescriptor;
24  import org.apache.hadoop.hbase.HTableDescriptor;
25  
26  /**
27   * Read-only table descriptor.
28   */
29  public class UnmodifyableHTableDescriptor extends HTableDescriptor {
30    /** Default constructor */
31    public UnmodifyableHTableDescriptor() {
32  	  super();
33    }
34  
35    /*
36     * Create an unmodifyable copy of an HTableDescriptor
37     * @param desc
38     */
39    UnmodifyableHTableDescriptor(final HTableDescriptor desc) {
40      super(desc.getName(), getUnmodifyableFamilies(desc), desc.getValues());
41    }
42  
43  
44    /*
45     * @param desc
46     * @return Families as unmodifiable array.
47     */
48    private static HColumnDescriptor[] getUnmodifyableFamilies(
49        final HTableDescriptor desc) {
50      HColumnDescriptor [] f = new HColumnDescriptor[desc.getFamilies().size()];
51      int i = 0;
52      for (HColumnDescriptor c: desc.getFamilies()) {
53        f[i++] = c;
54      }
55      return f;
56    }
57  
58    /**
59     * Does NOT add a column family. This object is immutable
60     * @param family HColumnDescriptor of familyto add.
61     */
62    @Override
63    public void addFamily(final HColumnDescriptor family) {
64      throw new UnsupportedOperationException("HTableDescriptor is read-only");
65    }
66  
67    /**
68     * @param column
69     * @return Column descriptor for the passed family name or the family on
70     * passed in column.
71     */
72    @Override
73    public HColumnDescriptor removeFamily(final byte [] column) {
74      throw new UnsupportedOperationException("HTableDescriptor is read-only");
75    }
76  
77    /**
78     * @see org.apache.hadoop.hbase.HTableDescriptor#setReadOnly(boolean)
79     */
80    @Override
81    public void setReadOnly(boolean readOnly) {
82      throw new UnsupportedOperationException("HTableDescriptor is read-only");
83    }
84  
85    /**
86     * @see org.apache.hadoop.hbase.HTableDescriptor#setValue(byte[], byte[])
87     */
88    @Override
89    public void setValue(byte[] key, byte[] value) {
90      throw new UnsupportedOperationException("HTableDescriptor is read-only");
91    }
92  
93    /**
94     * @see org.apache.hadoop.hbase.HTableDescriptor#setValue(java.lang.String, java.lang.String)
95     */
96    @Override
97    public void setValue(String key, String value) {
98      throw new UnsupportedOperationException("HTableDescriptor is read-only");
99    }
100 
101   /**
102    * @see org.apache.hadoop.hbase.HTableDescriptor#setMaxFileSize(long)
103    */
104   @Override
105   public void setMaxFileSize(long maxFileSize) {
106     throw new UnsupportedOperationException("HTableDescriptor is read-only");
107   }
108 
109   /**
110    * @see org.apache.hadoop.hbase.HTableDescriptor#setMemStoreFlushSize(long)
111    */
112   @Override
113   public void setMemStoreFlushSize(long memstoreFlushSize) {
114     throw new UnsupportedOperationException("HTableDescriptor is read-only");
115   }
116 
117 //  /**
118 //   * @see org.apache.hadoop.hbase.HTableDescriptor#addIndex(org.apache.hadoop.hbase.client.tableindexed.IndexSpecification)
119 //   */
120 //  @Override
121 //  public void addIndex(IndexSpecification index) {
122 //    throw new UnsupportedOperationException("HTableDescriptor is read-only");
123 //  }
124 }