Skip to content

Commit

Permalink
Item10596: add META:CREATEINFO to Mongodb for speeeeeeed - and happen…
Browse files Browse the repository at this point in the history
… to eliminate look ups for rev1 data

git-svn-id: http://svn.foswiki.org/trunk/MongoDBPlugin@11621 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed May 4, 2011
1 parent 40a5d09 commit 4e0834f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/Foswiki/Plugins/MongoDBPlugin.pm
Expand Up @@ -264,6 +264,7 @@ sub _updateTopic {
my $options = shift;

#print STDERR "-update($web, $topic)\n" if DEBUG;
$savedMeta->getRev1Info('createdate');

my $meta = {
_web => $web,
Expand All @@ -272,8 +273,8 @@ sub _updateTopic {

foreach my $key ( keys(%$savedMeta) ) {

#print STDERR "------------------ importing $key - "
# . ref( $savedMeta->{$key} ) . "\n";
# print STDERR "------------------ importing $key - "
# . ref( $savedMeta->{$key} ) . "\n";
next if ( $key eq '_session' );

#not totally sure if there's a benefit to using / not the _indices
Expand Down Expand Up @@ -326,6 +327,16 @@ sub _updateTopic {

#print STDERR Dumper($savedMeta->{$key})."\n";
#print STDERR "\n######################################################## BOOOOOOOOM\n";
if ( $key eq '_getRev1Info' ) {
$key = 'CREATEINFO';
$meta->{'CREATEINFO'} = $savedMeta->{_getRev1Info}->{rev1info};
#lets numericafy them
$meta->{'CREATEINFO'}->{version} = int($meta->{'CREATEINFO'}->{version});
$meta->{'CREATEINFO'}->{date} = int($meta->{'CREATEINFO'}->{date});
#use Data::Dumper;
#print STDERR "$topic: ".(defined($savedMeta->{'TOPICINFO'}[0]->{version})?($savedMeta->{'TOPICINFO'}[0]->{version}):'undef')." ".Dumper($meta->{'CREATEINFO'})."\n";
}

next;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Foswiki/Plugins/MongoDBPlugin/HoistMongoDB.pm
Expand Up @@ -460,6 +460,7 @@ my %js_func_map = (

sub convertFunction {
my ( $value, $key ) = @_;

if ( ( $key eq '#lc' )
or ( $key eq '#uc' )
or ( $key eq '#length' )
Expand All @@ -486,6 +487,9 @@ sub convertFunction {
my $ref =
'foswiki_getRef(\'localhost\', foswiki_getDatabaseName(this._web)+\'.current\', this._web, '
. convertStringToJS( $$value[0] ) . ')';

ASSERT($addr =~ /this/) if DEBUG

$addr =~ s/this/$ref/;
return $addr;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Foswiki/Plugins/MongoDBPlugin/Meta.pm
Expand Up @@ -147,6 +147,9 @@ sub loadFromBSONData {

$this->{_loadedRev} =
Foswiki::Store::cleanUpRevID( $this->{TOPICINFO}[0]->{version} );

$this->{_getRev1Info}->{rev1info} = $data->{'CREATEINFO'};
delete $this->{CREATEINFO};

# SMELL: removed see getLoadedRev - should remove any
# non-numeric rev's (like the $rev stuff from svn)
Expand Down

0 comments on commit 4e0834f

Please sign in to comment.