Skip to content

Commit d00a280

Browse files
committed
wasm
1 parent 4d8e150 commit d00a280

18 files changed

Lines changed: 888 additions & 766 deletions

secretary/example/main.go

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,7 @@ func main() {
1414
os.Exit(1)
1515
}
1616

17-
users, userErr := s.NewBTree(
18-
"users",
19-
4,
20-
32,
21-
1024,
22-
125,
23-
1000,
24-
)
25-
26-
images, imagesErr := s.NewBTree(
27-
"images",
28-
8,
29-
32,
30-
1024*1024,
31-
125,
32-
1000,
33-
)
34-
if userErr != nil || imagesErr != nil {
35-
utils.Log(userErr, imagesErr)
36-
}
37-
38-
sortedRecords := secretary.SampleSortedKeyRecords(64)
39-
images.SortedRecordSet(sortedRecords)
40-
41-
for _, r := range sortedRecords {
42-
users.SetKV(r.Key, r.Value)
43-
}
44-
45-
users.SetKV([]byte("0000000000000196"), []byte("Hello:196"))
46-
users.SetKV([]byte("0000000000000197"), []byte("Hello:197"))
47-
users.SetKV([]byte("0000000000000198"), []byte("Hello:198"))
48-
users.SetKV([]byte("0000000000000199"), []byte("Hello:199"))
17+
secretary.DummyInitTrees(s)
4918

5019
s.Serve()
5120
}

secretary/helper.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,38 @@ func SampleSortedKeyRecords(numkeys int) (records []*Record) {
2323
}
2424
return sortedRecords
2525
}
26+
27+
func DummyInitTrees(s *Secretary) {
28+
users, userErr := s.NewBTree(
29+
"users",
30+
4,
31+
32,
32+
1024,
33+
125,
34+
1000,
35+
)
36+
37+
images, imagesErr := s.NewBTree(
38+
"images",
39+
8,
40+
32,
41+
1024*1024,
42+
125,
43+
1000,
44+
)
45+
if userErr != nil || imagesErr != nil {
46+
utils.Log(userErr, imagesErr)
47+
}
48+
49+
sortedRecords := SampleSortedKeyRecords(64)
50+
images.SortedRecordSet(sortedRecords)
51+
52+
for _, r := range sortedRecords {
53+
users.SetKV(r.Key, r.Value)
54+
}
55+
56+
users.SetKV([]byte("0000000000000196"), []byte("Hello:196"))
57+
users.SetKV([]byte("0000000000000197"), []byte("Hello:197"))
58+
users.SetKV([]byte("0000000000000198"), []byte("Hello:198"))
59+
users.SetKV([]byte("0000000000000199"), []byte("Hello:199"))
60+
}

secretary/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ For a B+ tree of order m :
2828
*/
2929
func (tree *BTree) NodeVerify(node *Node) error {
3030
// A node is either a leaf (has records) or an internal node (has children), not both
31-
if (node.records != nil && node.children != nil) || (node.records == nil && node.children == nil) {
31+
if tree.root != node && ((node.records != nil && node.children != nil) || (node.records == nil && node.children == nil)) {
3232
return ErrorNodeIsEitherLeaforInternal
3333
}
3434

secretary/secretaryui/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,6 @@
226226
</div>
227227
</div>
228228

229-
<button id="add-btn">ADD</button>
230-
<button onClick="allTree();">AllTree</button>
231-
<button onClick="set();">SET</button>
232-
233229
<div id="info-box"></div>
234230

235231
<div id="result"></div>
-5.25 MB
Binary file not shown.

0 commit comments

Comments
 (0)