mocnii has asked for the wisdom of the Perl Monks concerning the following question:
and replaced it withsub _read_body { my ($self) = @_; my @response; while (1) { my $buf; my $n = $self->_get_socket()->read_entity_body($buf, 1024); die "can't read response: $!" unless defined $n; last unless $n; push @response, split (/\n/, $buf); } return \@response; }
My pull request is here: https://github.com/elcamlost/perl-DBD-ClickHouse/pull/4, but is not accepted (nor fixed). This fix works but the problem is that now everything is doubled in memory (and this is used to select from database so it can be huge). I'm looking for a suggestion how to make it less memory hungry or simply cleaner. I tried to use other module (HTTP-ClickHouse), but it has the same bug so this is obviously something that is easy to get wrong.sub _read_body { my ($self) = @_; my @response; + my $content = ''; while (1) { my $buf; my $n = $self->_get_socket()->read_entity_body($buf, 1024); die "can't read response: $!" unless defined $n; last unless $n; - push @response, split (/\n/, $buf); + $content .= $buf; } + push @response, split (/\n/, $content); + return \@response; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to split rows coming from the database
by Corion (Patriarch) on Nov 08, 2016 at 13:55 UTC | |
by mocnii (Acolyte) on Nov 08, 2016 at 14:37 UTC | |
by Corion (Patriarch) on Nov 08, 2016 at 14:54 UTC | |
by mocnii (Acolyte) on Nov 09, 2016 at 10:01 UTC |