id integer primary key,
name text,
depth integer,
- parent_seqn integer,
+ parent_id integer,
self_size integer,
kids_size integer,
kids_node_count integer,
- child_seqns text
+ child_ids text
)
});
my $node_ins_sth = $dbh->prepare(q{
$x->{self_size} = $self_size;
if (my $parent = $stack[-1]) {
# link to parent
- $x->{parent_seqn} = $parent->{id};
+ $x->{parent_id} = $parent->{id};
# accumulate into parent
$parent->{kids_node_count} += 1 + ($x->{kids_node_count}||0);
$parent->{kids_size} += $self_size + $x->{kids_size};
- push @{$parent->{child_seqn}}, $x->{id};
+ push @{$parent->{child_id}}, $x->{id};
}
# output
# ...
}
if ($dbh) {
$node_ins_sth->execute(
- $x->{id}, $x->{name}, $x->{depth}, $x->{parent_seqn},
+ $x->{id}, $x->{name}, $x->{depth}, $x->{parent_id},
$x->{self_size}, $x->{kids_size}, $x->{kids_node_count},
- $x->{child_seqn} ? join(",", @{$x->{child_seqn}}) : undef
+ $x->{child_id} ? join(",", @{$x->{child_id}}) : undef
);
# XXX attribs
}
my ($id, $depth) = @_;
my $node = MemView->selectrow_hashref("select * from node where id = ?", undef, $id)
or die "Node '$id' not found";
- if ($node->{child_seqns}) {
- my @child_seqns = split /,/, $node->{child_seqns};
+ if ($node->{child_ids}) {
+ my @child_ids = split /,/, $node->{child_ids};
my $children;
- if (@child_seqns == 1) {
- my $child = _fetch_node_tree($child_seqns[0], $depth); # same depth
+ if (@child_ids == 1) {
+ my $child = _fetch_node_tree($child_ids[0], $depth); # same depth
# merge node into child
- # XXX id, depth, parent_seqn
+ # XXX id, depth, parent_id
warn "Merged $node->{name} #$node->{id} with only child $child->{name} #$child->{id}\n";
$child->{name} = "$node->{name} + $child->{name}";
$child->{$_} += $node->{$_} for (qw(self_size));
- $child->{$_} = $node->{$_} for (qw(parent_seqn));
+ $child->{$_} = $node->{$_} for (qw(parent_id));
+
+ $child->{_ids_merged} .= ",$node->{id}";
+ my @child_ids = split /,/, $node->{child_ids};
+ $child->{child_count} = @child_ids;
+
$node = $child;
}
elsif ($depth) {
- $children = [ map { _fetch_node_tree($_, $depth-1) } @child_seqns ];
+ $children = [ map { _fetch_node_tree($_, $depth-1) } @child_ids ];
$node->{children} = $children;
$node->{child_count} = @$children;
}
//where to inject the visualization
injectInto: 'infovis',
//show only one tree level
- levelsToShow: 2,
+ levelsToShow: 1,
//parent box title heights
- titleHeight: 10,
+ titleHeight: 11,
//enable animations
animate: animate,
//box offsets
}
},
//duration of the animations
- duration: 1000,
+ duration: 500,
//Enable tips
Tips: {
enable: true,
+ "</div><div class=\"tip-text\">";
var data = node.data;
- //"child_seqns" => 4,
- //"depth" => 2,
- //"id" => 3,
- //"kids_node_count" => 4426,
- //"kids_size" => 560058,
- //"name" => "SV(PVHV)",
- //"parent_seqn" => 2,
- //"self_size" => 1080,
-
- html += sprintf("Name: %s<br />\n", data.name);
html += sprintf("Size: %d (%d + %d)<br />", data.self_size+data.kids_size, data.self_size, data.kids_size);
if (data.child_count) {
html += sprintf("Children: %d of %d<br />", data.child_count, data.kids_node_count);
}
- html += JSON.stringify(data, undefined, 4);
+ html += sprintf("Depth: %d<br />", data.depth);
+ html += sprintf("Parent: %d<br />", data.parent_id);
+ html += sprintf("Id: %s%s<br />", node.id, data._ids_merged ? data._ids_merged : "");
+ //html += JSON.stringify(data, undefined, 4);
tip.innerHTML = html;
}