Permalink
Browse files

Fix a Get bug

  • Loading branch information...
1 parent e3d9c77 commit 37874352080b644a9c67aaa57a2fb3bd0be9fdae @uprush uprush committed Mar 18, 2012
View
@@ -20,7 +20,7 @@
<!-- some variables used -->
<property name="lib.dir" value="lib" />
<property name="build.dir" value="build" />
- <property name="version" value="0.0.1" />
+ <property name="version" value="0.1.0" />
<!-- =================================
target: resolve
@@ -18,7 +18,6 @@
package sculptor.framework;
import java.util.List;
-import java.util.Set;
/**
* HBase上のテーブルに紐づいたクラスを定義
@@ -32,7 +31,7 @@
/** 紐づいているテーブル名 */
String table;
/** List of column family */
- Set<String> columnFamilies;
+ String[] columnFamilies;
/** フィールドのリスト */
List<HFieldDescriptor> hFieldDescriptors;
@@ -72,7 +71,7 @@ public String getTable() {
return hFieldDescriptors;
}
- public Set<String> getColumnFamilies() {
+ public String[] getColumnFamilies() {
return columnFamilies;
}
@@ -25,7 +25,6 @@
import java.util.Calendar;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.apache.commons.lang.math.RandomUtils;
import org.apache.hadoop.conf.Configuration;
@@ -239,7 +238,7 @@ public D get(D d) throws IOException {
return null;
}
Get g = new Get(rowkey);
- Set<String> families = HEntity.getColumnFamilies(d.getClass());
+ String[] families = Sculptor.descriptors.get(tableName).columnFamilies;
for (String family : families) {
byte[] bFamily = Bytes.toBytes(family);
g.addFamily(bFamily);
@@ -50,6 +50,7 @@ public static HClassDescriptor getClassInfo(Class<? extends HEntity> clazz) {
hClassDescriptor.entityClassName = clazz.getCanonicalName();
hClassDescriptor.table = clazz.getAnnotation(Table.class).name();
hClassDescriptor.hFieldDescriptors = getFields(clazz);
+ hClassDescriptor.columnFamilies = getColumnFamilies(clazz);
return hClassDescriptor;
}
@@ -78,13 +79,15 @@ public static HClassDescriptor getClassInfo(Class<? extends HEntity> clazz) {
* @param clazz the entity class
* @return Set contains all column families
*/
- public static Set<String> getColumnFamilies(Class<? extends HEntity> clazz) {
+ public static String[] getColumnFamilies(Class<? extends HEntity> clazz) {
List<HFieldDescriptor> hfields = getFields(clazz);
Set<String> columnFamilies = new HashSet<String>();
for (HFieldDescriptor hfield : hfields) {
- columnFamilies.add(hfield.family);
+ if (hfield.family != null) {
+ columnFamilies.add(hfield.family);
+ }
}
- return columnFamilies;
+ return columnFamilies.toArray(new String[0]);
}
/**

0 comments on commit 3787435

Please sign in to comment.