Commit 2dc1e2e0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1b3a514b
This diff is collapsed.
This diff is collapsed.
......@@ -33,7 +33,7 @@ import (
// kv is one (key, value) pair.
type kv struct {
key KEY
key int64
value interface{}
}
......@@ -52,7 +52,7 @@ type testEntry struct {
// bmapping represents Get of Bucket or BTree.
type bmapping interface {
Get(context.Context, KEY) (interface{}, bool, error)
Get(context.Context, int64) (interface{}, bool, error)
}
func TestBTree(t *testing.T) {
......@@ -89,11 +89,11 @@ func TestBTree(t *testing.T) {
want := ""
switch tt.kind {
case kindBucket:
if _, ok = obj.(*Bucket); !ok {
if _, ok = obj.(*LOBucket); !ok {
want = "Bucket"
}
case kindBTree:
if _, ok = obj.(*BTree); !ok {
if _, ok = obj.(*LOBTree); !ok {
want = "BTree"
}
default:
......@@ -132,12 +132,12 @@ func TestBTree(t *testing.T) {
if err != nil {
t.Fatal(err)
}
B3, ok := xB3.(*BTree)
B3, ok := xB3.(*LOBTree)
if !ok {
t.Fatalf("B3: %v; got %T; want BTree", B3_oid, xB3)
}
for i := KEY(0); i <= B3_maxkey; i++ {
for i := int64(0); i <= B3_maxkey; i++ {
v, ok, err := B3.Get(ctx, i)
if err != nil {
t.Fatal(err)
......@@ -151,21 +151,21 @@ func TestBTree(t *testing.T) {
}
// verifyFirstBucket verifies that b.firstbucket is correct and returns it.
var verifyFirstBucket func(b *BTree) *Bucket
verifyFirstBucket = func(b *BTree) *Bucket {
var verifyFirstBucket func(b *LOBTree) *LOBucket
verifyFirstBucket = func(b *LOBTree) *LOBucket {
err := b.PActivate(ctx); X(err)
defer b.PDeactivate()
var firstbucket *Bucket
var firstbucket *LOBucket
switch child := b.data[0].child.(type) {
default:
t.Fatalf("btree(%s): child[0] is %T", b.POid(), b.data[0].child)
case *BTree:
case *LOBTree:
firstbucket = verifyFirstBucket(child)
case *Bucket:
case *LOBucket:
firstbucket = child
}
......
#!/bin/bash -e
# btree.go.in -> specialized with concrete types
# gen-btree KIND KEY out
# Copyright (C) 2017 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
KIND=$1
KEY=$2
out=$3
kind=${KIND,,} # IO -> io
input=$(dirname $0)/btree.go.in
echo "// Code generated by gen-btree; DO NOT EDIT." >$out
echo >>$out
sed \
-e "s/<kind>/$kind/g" \
-e "s/<KIND>/$KIND/g" \
-e "s/KEY/$KEY/g" \
-e "s/\bBTree\b/${KIND}BTree/g" \
-e "s/\bEntry\b/${KIND}Entry/g" \
-e "s/\bBucket\b/${KIND}Bucket/g" \
-e "s/\bBucketEntry\b/${KIND}BucketEntry/g" \
-e "s/\bbtreeState\b/${kind}btreeState/g" \
-e "s/\bbucketState\b/${kind}bucketState/g" \
$input >>$out
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment