Commit 50c3645b2905141f4c1c234133f19cabc724539c

Authored by joel ago
1 parent 7016288a5a
Exists in master

initial setting

Showing 1 changed file with 15 additions and 2 deletions Side-by-side Diff

app/com/piki_ds/utils/hbase/PikiHbase.scala View file @ 50c3645
... ... @@ -4,6 +4,7 @@
4 4 import java.util.Date
5 5  
6 6 import com.piki_ds.utils.hbase.Base62
  7 +import org.apache.hadoop.hbase.io.compress.Compression.Algorithm
7 8 import org.apache.hadoop.hbase.{HColumnDescriptor, TableName, HTableDescriptor}
8 9 import org.apache.hadoop.hbase.client._
9 10 import org.apache.hadoop.hbase.filter.{PrefixFilter}
... ... @@ -106,7 +107,9 @@
106 107 val tableDescriptor = new HTableDescriptor(TableName.valueOf(tableName))
107 108 admin.disableTable(tableName)
108 109 cfNames.map(cf => {
109   - tableDescriptor.addFamily(new HColumnDescriptor(cf))
  110 + val family = new HColumnDescriptor(cf)
  111 + family.setCompressionType(Algorithm.SNAPPY)
  112 + tableDescriptor.addFamily(family)
110 113 })
111 114 } catch {
112 115 case e: Exception => {
... ... @@ -121,6 +124,7 @@
121 124 val admin = new HBaseAdmin(PikiHbaseConfig.conf)
122 125 val tableDescriptor = new HTableDescriptor(TableName.valueOf(tableName))
123 126 admin.createTable(tableDescriptor)
  127 + admin.enableTable(tableName)
124 128 logger.info(s"table created $tableName")
125 129 } catch {
126 130 case e: Exception => {
127 131  
... ... @@ -234,8 +238,17 @@
234 238 scanner.close
235 239  
236 240 table.close()
237   - connection.close()
238 241  
  242 + Thread.sleep(3000)
  243 +
  244 + //create table readHistory
  245 + //createTable("readHistory")
  246 + //addColumnFamily("readHistory", List("f1"))
  247 +
  248 + PikiHbase.listTables(connection).foreach(println)
  249 +
  250 + connection.close()
  251 + println("program end")
239 252 }
240 253 }