Commit 80653ece authored by Leigh B Stoller's avatar Leigh B Stoller

Add GetNodeFeatures() method, returns a hash.

parent c8294768
...@@ -166,6 +166,7 @@ sub LookupRow($$) ...@@ -166,6 +166,7 @@ sub LookupRow($$)
$self->{"RSRV"} = undef; $self->{"RSRV"} = undef;
$self->{"TYPEINFO"} = undef; $self->{"TYPEINFO"} = undef;
$self->{"ATTRS"} = undef; $self->{"ATTRS"} = undef;
$self->{"FEATURES"} = undef;
$self->{"IFACES"} = undef; $self->{"IFACES"} = undef;
$self->{"WAROW"} = undef; $self->{"WAROW"} = undef;
$self->{"HASH"} = {}; $self->{"HASH"} = {};
...@@ -196,6 +197,7 @@ sub DESTROY { ...@@ -196,6 +197,7 @@ sub DESTROY {
$self->{"RSRV"} = undef; $self->{"RSRV"} = undef;
$self->{"TYPEINFO"} = undef; $self->{"TYPEINFO"} = undef;
$self->{"ATTRS"} = undef; $self->{"ATTRS"} = undef;
$self->{"FEATURES"} = undef;
$self->{"IFACES"} = undef; $self->{"IFACES"} = undef;
$self->{"HASH"} = undef; $self->{"HASH"} = undef;
$self->{"WAROW"} = undef; $self->{"WAROW"} = undef;
...@@ -236,6 +238,7 @@ sub MakeFake($$$$) ...@@ -236,6 +238,7 @@ sub MakeFake($$$$)
$self->{"RSRV"} = $rsrvrow; $self->{"RSRV"} = $rsrvrow;
$self->{"TYPEINFO"} = undef; $self->{"TYPEINFO"} = undef;
$self->{"ATTRS"} = undef; $self->{"ATTRS"} = undef;
$self->{"FEATURES"} = undef;
$self->{"IFACES"} = undef; $self->{"IFACES"} = undef;
$self->{"WAROW"} = undef; $self->{"WAROW"} = undef;
$self->{"HASH"} = {}; $self->{"HASH"} = {};
...@@ -282,6 +285,7 @@ sub BulkLookup($$$) ...@@ -282,6 +285,7 @@ sub BulkLookup($$$)
$node->{"RSRV"} = undef; $node->{"RSRV"} = undef;
$node->{"TYPEINFO"} = undef; $node->{"TYPEINFO"} = undef;
$node->{"ATTRS"} = undef; $node->{"ATTRS"} = undef;
$self->{"FEATURES"} = undef;
$node->{"IFACES"} = undef; $node->{"IFACES"} = undef;
$node->{"WAROW"} = undef; $node->{"WAROW"} = undef;
$node->{"HASH"} = {}; $node->{"HASH"} = {};
...@@ -592,6 +596,7 @@ sub Refresh($) ...@@ -592,6 +596,7 @@ sub Refresh($)
$self->{"RSRV"} = undef; $self->{"RSRV"} = undef;
$self->{"TYPEINFO"} = undef; $self->{"TYPEINFO"} = undef;
$self->{"ATTRS"} = undef; $self->{"ATTRS"} = undef;
$self->{"FEATURES"} = undef;
$self->{"IFACES"} = undef; $self->{"IFACES"} = undef;
$self->{"WAROW"} = undef; $self->{"WAROW"} = undef;
return 0; return 0;
...@@ -1372,6 +1377,37 @@ sub GetNodeAttributes($) ...@@ -1372,6 +1377,37 @@ sub GetNodeAttributes($)
return $self->{"ATTRS"}; return $self->{"ATTRS"};
} }
#
# Return a hash of the node features for this node.
#
sub GetNodeFeatures($)
{
my ($self) = @_;
return undef
if (!ref($self));
my $node_id = $self->node_id();
if (!defined($self->{"FEATURES"})) {
my $query_result =
DBQueryWarn("select * from node_features ".
"where node_id='$node_id'");
return -1
if (!defined($query_result));
$self->{"FEATURES"} = {};
while (my $row = $query_result->fetchrow_hashref()) {
my $feature = $row->{'feature'};
my $weight = $row->{'weight'};
$self->{"FEATURES"}->{$feature} = $weight;
}
}
return $self->{"FEATURES"};
}
# #
# Return type info. We cache this in the instance since node_type stuff # Return type info. We cache this in the instance since node_type stuff
# does not change much. # does not change much.
......
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