1# See the file LICENSE for redistribution information.
2#
3# Copyright (c) 2001,2008 Oracle.  All rights reserved.
4#
5# $Id: bigfile001.tcl,v 12.8 2008/04/22 09:39:29 winter Exp $
6#
7# TEST	bigfile001
8# TEST	Create a database greater than 4 GB in size.  Close, verify.
9# TEST	Grow the database somewhat.  Close, reverify.  Lather, rinse,
10# TEST	repeat.  Since it will not work on all systems, this test is
11# TEST	not run by default.
12proc bigfile001 { { itemsize 4096 } \
13    { nitems 1048576 } { growby 5000 } { growtms 2 } args } {
14	source ./include.tcl
15
16	set method "btree"
17	set args [convert_args $method $args]
18	set omethod [convert_method $method]
19	global is_fat32
20	if { $is_fat32 } {
21		puts "Skipping bigfile001 for FAT32 file system."
22		return
23	}
24	puts "Bigfile001: $method ($args) $nitems * $itemsize bytes of data"
25
26	env_cleanup $testdir
27
28	# Create the database.  Use 64K pages;  we want a good fill
29	# factor, and page size doesn't matter much.  Use a 50MB
30	# cache;  that should be manageable, and will help
31	# performance.
32	set dbname $testdir/big.db
33
34	set db [eval {berkdb_open -create} {-pagesize 65536 \
35	    -cachesize {0 50000000 0}} $omethod $args $dbname]
36	error_check_good db_open [is_valid_db $db] TRUE
37
38	puts "\tBigfile001.a: Creating database..."
39	flush stdout
40
41	set data [string repeat z $itemsize]
42
43	for { set i 0 } { $i < $nitems } { incr i } {
44		set key key[format %08u $i]
45
46		error_check_good db_put($i) [$db put $key $data] 0
47
48		if { $i % 50000 == 0 } {
49			set pct [expr 100 * $i / $nitems]
50			puts "\tBigfile001.a: $pct%..."
51			flush stdout
52		}
53	}
54	puts "\tBigfile001.a: 100%."
55	error_check_good db_close [$db close] 0
56
57	puts "\tBigfile001.b: Verifying database..."
58	error_check_good verify \
59	    [verify_dir $testdir "\t\t" 0 0 1 50000000] 0
60
61	puts "\tBigfile001.c: Grow database $growtms times by $growby items"
62
63	for { set j 0 } { $j < $growtms } { incr j } {
64		set db [eval {berkdb_open} {-cachesize {0 50000000 0}} $dbname]
65		error_check_good db_open [is_valid_db $db] TRUE
66		puts -nonewline "\t\tBigfile001.c.1: Adding $growby items..."
67		flush stdout
68		for { set i 0 } { $i < $growby } { incr i } {
69			set key key[format %08u $i].$j
70			error_check_good db_put($j.$i) [$db put $key $data] 0
71		}
72		error_check_good db_close [$db close] 0
73		puts "done."
74
75		puts "\t\tBigfile001.c.2: Verifying database..."
76		error_check_good verify($j) \
77		    [verify_dir $testdir "\t\t\t" 0 0 1 50000000] 0
78	}
79}
80