1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1 |
import struct |
2 |
import sys |
|
3 |
||
4 |
# bytes per single LRU entry
|
|
5 |
blocksize=8 |
|
6 |
||
7 |
flru = open(sys.argv[1], 'rb') |
|
8 |
||
9 |
L = [] |
|
10 |
||
11 |
while True: |
|
12 |
s1 = flru.read(blocksize) |
|
13 |
if s1=="": |
|
14 |
break; |
|
15 |
# InnoDB uses big-endian format for storage
|
|
16 |
val = struct.unpack('>II', s1) |
|
17 |
if (val[0]>0) or (val[1]>0): |
|
18 |
L.append(val) |
|
19 |
||
20 |
print "Length:", len(L) |
|
21 |
L.sort() |
|
22 |
||
23 |
flru.close() |
|
24 |
||
25 |
fsorted = open(sys.argv[1], 'wb') |
|
26 |
for item in L: |
|
27 |
# InnoDB uses big-endian format for storage
|
|
28 |
pk=struct.pack('>II', item[0],item[1]) |
|
29 |
fsorted.write(pk) |
|
30 |
||
31 |
pk=struct.pack('>II',0,0); |
|
32 |
||
33 |
for i in range(0, 16*1024 / 8): |
|
34 |
fsorted.write(pk) |
|
35 |
||
36 |
fsorted.close() |
|
37 |
||
38 |
print "Done!" |