Changeset: f584fadb4847 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f584fadb4847
Modified Files:
clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
Branch: default
Log Message:
MapiPP: fetch results progressively, bug #2891
In the current implementation, MapiPP.pm fetches all results from a
query which could result in high memory consumption, if not exhaust.
Fetching results only when needed allows processing large result sets.
diffs (52 lines):
diff --git a/clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
b/clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
--- a/clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
+++ b/clients/perl/MonetDB-CLI-MapiPP/MonetDB/CLI/MapiPP.pm
@@ -105,16 +105,6 @@ sub query
}
# TODO: table_name
}
- do {
- my @cols = split(/,\t */, $h->{row});
- my $i = -1;
- while (++$i < @cols) {
- $cols[$i] =~ s/^\[ //;
- $cols[$i] =~ s/[ \t]+\]$//;
- $cols[$i] = MonetDB::CLI::MapiPP->unquote($cols[$i]);
- }
- push(@{$self->{rows}}, [@cols]);
- } while (($tpe = $h->getReply()) > 0);
} elsif ($tpe == -1) {
# error
die $h->{errstr};
@@ -176,8 +166,20 @@ sub length
sub fetch
{
my ($self) = @_;
-
- return if ++$self->{i} > $#{$self->{rows}};
+
+ return if ++$self->{i} >= $self->{affrows};
+
+ my @cols = split(/,\t */, $self->{h}->{row});
+ my $i = -1;
+ while (++$i < @cols) {
+ $cols[$i] =~ s/^\[ //;
+ $cols[$i] =~ s/[ \t]+\]$//;
+ $cols[$i] = MonetDB::CLI::MapiPP->unquote($cols[$i]);
+ }
+ $self->{currow} = [@cols];
+
+ $self->{h}->getReply();
+
return $self->{colcnt};
}
@@ -185,7 +187,7 @@ sub field
{
my ($self, $fnr) = @_;
- return $self->{rows}[$self->{i}][$fnr];
+ return $self->{currow}[$fnr];
}
sub finish
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list