aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/query/query_term_decoder.cpp
blob: f3bc04dccb103e019d93928b9539f4f69917f710 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "query_term_decoder.h"
#include <vespa/searchlib/query/streaming/query.h>
#include <vespa/vespalib/util/exceptions.h>

namespace search {

using namespace search::streaming;

QueryTermSimple::UP
QueryTermDecoder::decodeTerm(QueryPacketT term)
{
    QueryTermSimple::UP result;
    QueryNodeResultFactory factory;
    Query query(factory, term);
    if (query.valid() && (dynamic_cast<const QueryTerm *>(&query.getRoot()))) {
        result.reset(static_cast<QueryTerm *>(Query::steal(std::move(query)).release()));
    } else {
        throw vespalib::IllegalStateException("Failed decoding query term");
    }
    return result;
}

}