Class: Roma::MakeRecentData

Inherits:
Object
  • Object
show all
Defined in:
lib/roma/tools/mkrecent.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv = nil) ⇒ MakeRecentData

Returns a new instance of MakeRecentData.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/roma/tools/mkrecent.rb', line 16

def initialize(argv = nil)
  if argv.length != 6
    STDERR.puts "usage:mkrecent dgst-bits div-bits divnum storage-path1 storage-path2 recent-storage-path"
    exit
  end

  dgst_bits = argv[0].to_i
  div_bits = argv[1].to_i
  @divnum = argv[2].to_i
  @strgpath1 = argv[3]
  @strgpath2 = argv[4]
  @recentpath = argv[5]

  @vnodes = []
  (2**div_bits).times{|i|
    @vnodes << ( i<<(dgst_bits-div_bits) )
  }
end

Instance Method Details

#close_storageObject



84
85
86
87
88
# File 'lib/roma/tools/mkrecent.rb', line 84

def close_storage
  @st1.closedb
  @st2.closedb
  @rst.closedb
end

#exec(hname) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/roma/tools/mkrecent.rb', line 90

def exec(hname)
  n = 0
  @vnodes.each{|vn|
    printf "#{hname}:#{n}/#{@vnodes.length}\r"
    n+=1
    buf = @st1.dump(vn)
    @rst.load( buf ) if buf
    buf = @st2.dump(vn)
    @rst.load( buf ) if buf
  }
end

#open_storage(p1, p2, rp) ⇒ Object



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
# File 'lib/roma/tools/mkrecent.rb', line 55

def open_storage(p1,p2,rp)
  puts "Open #{p1}"
  @st1 = ropen(p1)
  @st1.each_vn_dump_sleep = 0
  exit unless @st1
  puts "Open #{p2}"
  @st2 = ropen(p2)
  @st2.each_vn_dump_sleep = 0
  unless @st2
    STDERR.puts ""
    @st1.closedb
    exit
  end

  if @st1.class != @st2.class
    STDERR.puts "#{p1} and #{p2} that file type is different."
    @st1.closedb
    @st2.closedb
    exit
  end

  puts "Open #{rp}"
  @rst = @st1.class.new
  @rst.divnum = @divnum
  @rst.vn_list = @vnodes
  @rst.storage_path = rp
  @rst.opendb
end

#suiteObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/roma/tools/mkrecent.rb', line 35

def suite
  if File::directory?(@recentpath)
    STDERR.puts "#{@recentpath} exists."
    exit
  end

  Dir::mkdir(@recentpath)

  Dir::glob("#{@strgpath1}/*").each{|dir|
    next unless File::directory?(dir)
    hname = dir[dir.rindex('/')+1..-1]
    open_storage(dir,
                 "#{@strgpath2}/#{hname}",
                 "#{@recentpath}/#{hname}")
    exec(hname)

    close_storage
  }
end