-
Notifications
You must be signed in to change notification settings - Fork 19
/
TestHbAdmin.scala
100 lines (79 loc) · 2.99 KB
/
TestHbAdmin.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import top.spoofer.hbrdd._
import top.spoofer.hbrdd.config.HbRddConfig
import top.spoofer.hbrdd.hbsupport.{HbRddFamily, FamilyPropertiesStringSetter}
object TestHbAdmin {
val tableName = "test_hbrdd"
implicit val hbConfig = HbRddConfig()
private def createtable() = {
val admin = HbRddAdmin.apply()
val splitkeys = List("ooooo", "iiiii") //split keys
admin.createTable(tableName, splitkeys, "cf1", "cf2")
admin.close()
}
private def getPropertiesFamilys = {
val map1 = Map("maxversions" -> "1000", "ttl" -> "9999", "inmem" -> "false")
val fp1 = FamilyPropertiesStringSetter(map1)
val cf1 = HbRddFamily("ffff", fp1)
val map2 = Map("maxversions" -> "1000", "minversions" -> "2", "ttl" -> "9999", "blocksize" -> "222",
"inmem" -> "true", "bloomfilter" -> "rowcol", "scope" -> "1", "keepdeletecells" -> "false", "blockcache" -> "false")
val fp2 = FamilyPropertiesStringSetter(map2)
val cf2 = HbRddFamily("eeee", fp2)
println(cf2.getKeepDeletedCells.toString)
Set(cf1, cf2)
}
private def createtableByProperties() = {
val admin = HbRddAdmin.apply()
val splitkeys = List("ooooo", "iiiii") //split keys
admin.createTableByProperties("testProperties", this.getPropertiesFamilys, splitkeys)
admin.close()
}
private def deleteTable() = {
val admin = HbRddAdmin.apply()
admin.dropTable(tableName)
admin.close()
}
private def truncateTable() = {
val admin = HbRddAdmin.apply()
admin.truncateTable(tableName, preserveSplits = true)
admin.close()
}
private def tableSnapshot() = {
val admin = HbRddAdmin.apply()
admin.tableSnapshot(tableName)
admin.close()
}
private def testAddFamilies() = {
val map2 = Map("maxversions" -> "1000", "minversions" -> "2", "ttl" -> "9999", "blocksize" -> "222",
"inmem" -> "true", "bloomfilter" -> "rowcol", "scope" -> "1", "keepdeletecells" -> "false", "blockcache" -> "false")
val fp2 = FamilyPropertiesStringSetter(map2)
val cf2 = HbRddFamily("addcf", fp2)
val admin = HbRddAdmin.apply()
admin.addFamilies("testProperties", cf2)
admin.close()
}
private def testUpdateFamilies() = {
val map2 = Map("maxversions" -> "10001", "minversions" -> "3", "ttl" -> "9990", "blocksize" -> "2212",
"inmem" -> "false", "bloomfilter" -> "row", "scope" -> "0", "keepdeletecells" -> "true", "blockcache" -> "true")
val fp2 = FamilyPropertiesStringSetter(map2)
val cf2 = HbRddFamily("addcf", fp2)
val admin = HbRddAdmin.apply()
admin.updateFamilies("testProperties", cf2)
admin.close()
}
private def testDeleteFamilies() = {
val admin = HbRddAdmin.apply()
admin.deleteFamiliesByName("testProperties", "addcf")
admin.close()
}
def main(args: Array[String]) {
println("===")
// this.tableSnapshot()
// this.createtable()
// this.truncateTable()
// this.deleteTable()
// this.createtableByProperties()
// this.testAddFamilies()
// this.testUpdateFamilies()
// this.testDeleteFamilies()
}
}