Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private[hbase] class HBaseCatalog(@transient hbaseContext: HBaseSQLContext)
}
}

// TODO: suggest to create this before hand, like in constructor?
val admin = new HBaseAdmin(configuration)
val avail = admin.isTableAvailable(MetaData)

Expand Down Expand Up @@ -272,33 +273,38 @@ private[hbase] class HBaseCatalog(@transient hbaseContext: HBaseSQLContext)
relationMapCache.remove(processTableName(tableName))
}

def createMetadataTable(admin: HBaseAdmin) = {
private def createMetadataTable(admin: HBaseAdmin) = {
val descriptor = new HTableDescriptor(TableName.valueOf(MetaData))
val columnDescriptor = new HColumnDescriptor(ColumnFamily)
descriptor.addFamily(columnDescriptor)
admin.createTable(descriptor)
}

def checkHBaseTableExists(hbaseTableName: String): Boolean = {
private def checkHBaseTableExists(hbaseTableName: String): Boolean = {
val admin = new HBaseAdmin(configuration)
admin.tableExists(hbaseTableName)
}

def checkLogicalTableExist(tableName: String): Boolean = {
private def checkLogicalTableExist(tableName: String): Boolean = {
val admin = new HBaseAdmin(configuration)

/* TODO: suggest to move the creation of MetadataTable to constructor,
otherwise need to check this every time create/delete table */
if (!checkHBaseTableExists(MetaData)) {
// create table
createMetadataTable(admin)
}

// TODO: suggest to cache this table as member in the class instead of creating it everytime
// TODO: HTable seems deprecated, should use Connection.getTable(TableName) instead
val table = new HTable(configuration, MetaData)
val get = new Get(Bytes.toBytes(tableName))
val result = table.get(get)

result.size() > 0
}

def checkFamilyExists(hbaseTableName: String, family: String): Boolean = {
private def checkFamilyExists(hbaseTableName: String, family: String): Boolean = {
val admin = new HBaseAdmin(configuration)
val tableDescriptor = admin.getTableDescriptor(TableName.valueOf(hbaseTableName))
tableDescriptor.hasFamily(Bytes.toBytes(family))
Expand Down