/[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

Contents of /trunk/bin/mongodb2shards.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 261 - (show 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 #!/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 my $name = 'pxelator';
12 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 my $q;
20 #$q = {"package.name" => "dnsd", "source" => "upstream"};
21
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 $o->{_id} .= ''; # convert _id to scalar
30 Sack::Shard::add( $o );
31 }
32 Sack::Shard::finish;
33

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26