Skip to content

Commit

Permalink
Remove some warnings. No longer pretty-print, it gets too large. Inde…
Browse files Browse the repository at this point in the history
…d ->{data} from collapsed, but prefix, so as to not stomper on internal keys
  • Loading branch information
omega committed Oct 27, 2008
1 parent 48bb017 commit 14d0a2c
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions lib/KiokuDB/Backend/AWS/SDB.pm
Expand Up @@ -32,7 +32,7 @@ use JSON;
sub _build_json {
my ($self) = @_;

JSON->new()->utf8->pretty;
JSON->new()->utf8; #->pretty;
}

use Data::Dump qw/dump/;
Expand Down Expand Up @@ -122,7 +122,6 @@ sub _entry {

# We inflate an ID into a propper object
$item = $self->_item($item);


# inflate it back into a KiokuDB::Entry-object
$self->response($item->get_attributes);
Expand All @@ -138,9 +137,11 @@ sub _entry {
}
}
}
# No length means no object
return undef unless $doc->{_obj};
my %doc = %{ $self->json->decode(Encode::decode_utf8($doc->{_obj})) };

return $self->expand_jspon(\%doc, root => delete $doc->{root});
return $self->expand_jspon(\%doc, backend_data => $item, root => delete $doc->{root});
}
=method get
Expand Down Expand Up @@ -168,16 +169,24 @@ sub insert {
my $obj = $self->_item($e->id);

# TODO handle some sort of prev-stuff here?
if ($e->prev) {
$e->backend_data($e->prev->backend_data);
} else {
$e->backend_data($obj);
}
my $attr = {
id => $collapsed->{id},
_obj => Encode::encode_utf8($self->json->encode($collapsed)),
exists => 1
};
$attr->{root} = $e->root if $e->root;
foreach my $k (keys %$collapsed) {
next if ref($collapsed->{$k});
# Add theese to toplevel
$attr->{$k} = Encode::encode_utf8($collapsed->{$k});
if (ref($collapsed->{data}) eq 'HASH') {
foreach my $k (keys %{$collapsed->{data}}) {
next if ref($collapsed->{data}->{$k});
# Add theese to toplevel, but not topple on the amazon stuff
$attr->{"idx_" . $k} = Encode::encode_utf8($collapsed->{data}->{$k});
}

}
$self->response($obj->post_attributes($attr));
}
Expand Down Expand Up @@ -214,11 +223,9 @@ sub exists {
sub search {
my $self = shift;
my %args = @_;
warn "PROPPER SEARCH";
$self->response($self->domain->query(\%args));

my @results = $self->_inflate_results($self->response->results);

return Data::Stream::Bulk::Array->new(
array => \@results,
);
Expand All @@ -227,14 +234,13 @@ sub search {

sub simple_search {
my ( $self, $proto ) = @_;
warn "SIMPLE SEARCH";
# convert $proto to a querystring
my @predicates = ("['root' = '1']");
foreach my $k (keys %$proto) {
my $v = $proto->{$k};
# We don't support complex queries for now
next if ref($v);
push(@predicates, "['$k' = '" . Encode::encode_utf8($v) . "']");
push(@predicates, "['idx_$k' = '" . Encode::encode_utf8($v) . "']");
}
my $q = join(' intersection ', @predicates);

Expand Down

0 comments on commit 14d0a2c

Please sign in to comment.