/[Sack]/trunk/bin/mongodb2shards.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/bin/mongodb2shards.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 261 - (hide annotations)
Sun Jan 31 16:44:33 2010 UTC (14 years, 4 months ago) by dpavlin
File MIME type: text/plain
File size: 670 byte(s)
import everything from pxelator

1 dpavlin 257 #!/usr/bin/perl
2    
3     use lib 'lib';
4     use Sack::Shard;
5    
6     use Data::Dump qw(dump);
7     use autodie;
8    
9     use MongoDB;
10    
11 dpavlin 261 my $name = 'pxelator';
12 dpavlin 257 my $shard_size = 5000;
13    
14    
15     my $connection = MongoDB::Connection->new(host => '10.60.0.91', port => 27017);
16     my $database = $connection->get_database('pxelator');
17     my $collection = $database->get_collection('audit');
18    
19 dpavlin 261 my $q;
20     #$q = {"package.name" => "dnsd", "source" => "upstream"};
21 dpavlin 257
22     warn "# mongodb query: ", dump($q), $/;
23    
24     my $cursor = $collection->query($q);
25    
26     Sack::Shard::create( $name, $cursor->count, $shard_size );
27    
28     while( my $o = $cursor->next ) {
29 dpavlin 261 $o->{_id} .= ''; # convert _id to scalar
30 dpavlin 257 Sack::Shard::add( $o );
31     }
32     Sack::Shard::finish;
33    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26