Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Aggregation error from perl driver run_command
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chris Matta  
View profile  
 More options Nov 14 2012, 1:43 pm
From: Chris Matta <cma...@gmail.com>
Date: Wed, 14 Nov 2012 10:43:32 -0800 (PST)
Local: Wed, Nov 14 2012 1:43 pm
Subject: Re: Aggregation error from perl driver run_command

I just fixed it, it was a combination of things...

the @pipeline had to be passed in as a reference, and the arrays I was
defining in the '$subtract' and '$mod' operations were defined with ( )
instead of [ ];

On Wednesday, November 14, 2012 1:25:20 PM UTC-5, Stephen Lee wrote:

> Judging from the C++ source of the BSON implementation in MongoDB, I'd
> guess that the 'exception: wrong type for field (pipeline) 3 != 4' refers
> to the parser expecting either an Object (type == 3) and got an Array (type
> == 4) or the other way around.

> Which line of your Perl script throws the error?  If it's the "print
> Dumper(\@pipeline)" line, could you try "print Dumper-ing" just the
> $project and $group individually?  I'm guessing that your Mongo shell JSON
> to Perl translation might have an error, but after a quick glance, I don't
> quite see it.

> On Tuesday, November 13, 2012 5:03:20 PM UTC-5, Chris Matta wrote:

>> Sorry, documents look like this:

>> {
>>         "_id" : ObjectId("5097ffa800ba62343500f7ec"),
>>         "adaptor_id" : "DKA-2NL",
>>         "processor_id" : NumberLong(5),
>>         "datetime" : ISODate("2012-11-05T17:25:00Z"),
>>         "array_serial" : NumberLong(12345),
>>         "metric" : 26.989082,
>>         "processor_type" : "DKP"
>> }

>> On Tuesday, November 13, 2012 4:58:21 PM UTC-5, Chris Matta wrote:

>>> I'm trying to implement an aggregation function I've gotten to
>>> successfully work in javascript in perl, but I keep getting the error
>>> 'exception: wrong type for field (pipeline) 3 != 4'. Any ideas where I
>>> could be going wrong?

>>> my $project = Tie::IxHash->new(
>>>                         "year" => { '$year' => '$datetime'},
>>>                         "month" => {'$month' => '$datetime'},
>>>                         "day" => {'$dayOfMonth' => '$datetime'},
>>>                         "hour" => { '$hour' => '$datetime'},
>>>                         # the minute field is being rounded down to the
>>> nearest resolution
>>>                         "minute" => {'$subtract' => (
>>>                                             {'$minute' => '$datetime'},
>>>                                             {'$mod' => ({'$minute' =>
>>> '$datetime'}, $resolution)}
>>>                                                      )},
>>>                         array_serial => 1,
>>>                         adaptor_id => 1,
>>>                         processor_id => 1,
>>>                         processor_type => 1,
>>>                         metric => 1
>>>                 );

>>>     my $group = Tie::IxHash->new(
>>>                         _id => { array_serial => '$array_serial',
>>>                                 adaptor_id => '$adaptor_id',
>>>                                 processor_id => '$processor_id',
>>>                                 processor_type => '$processor_type',
>>>                                 year => '$year',
>>>                                 month => '$month',
>>>                                 day => '$day',
>>>                                 hour => '$hour',
>>>                                 minute => '$minute'
>>>                             },
>>>                         metric => {
>>>                             '$avg' => '$metric'
>>>                         }
>>>                 );

>>>     my @pipeline = (
>>>                     {'$match' => $query},
>>>                     {'$project' => $project},
>>>                     { '$group' => $group }
>>>                     );
>>>     print Dumper(\@pipeline);
>>>     my $aggregateCommand = Tie::IxHash->new(aggregate => $collection,
>>> pipeline => @pipeline);

>>>     my $result = $db->run_command($aggregateCommand);

>>>     print Dumper($result);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.