~ubuntu-branches/ubuntu/raring/clucene-core/raring-proposed

« back to all changes in this revision

Viewing changes to src/core/CLucene/search/spans/SpanNearQuery.h

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-11 09:33:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120811093338-fgrx41ftqew3qt6a
Tags: 2.3.3.4-1
* New upstream release (Closes: #661703).
* Convert package to multiarch.
* Drop obsolete patches:
  - 01_add_missing_include_bug505667.diff
  - 02_posixness_fix_bug530308.diff
* Add patches:
  - Fixing_ZLIB_configuration_in_shared_CMakeLists.patch
  - Fix-pkgconfig-file-by-adding-clucene-shared-library.patch
  - Install-contribs-lib.patch
  - multiarch.patch
* Update debian/compat: bump to 8.
* Update debian/control:
  - update build dependencies (add cmake, libboost-dev and libz-dev).
  - bump Standards-Version to 3.9.3.
  - rename packages due to ABI bump: libclucene0ldbl -> libclucene-core1.
  - add libclucene-contribs1 package.
* Update debian/rules:
  - rewrite to use CMake.
  - add multiarch support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*------------------------------------------------------------------------------
 
2
 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
 
3
 *
 
4
 * Distributable under the terms of either the Apache License (Version 2.0) or
 
5
 * the GNU Lesser General Public License, as specified in the COPYING file.
 
6
 ------------------------------------------------------------------------------*/
 
7
#ifndef _lucene_search_spans_SpanNearQuery_
 
8
#define _lucene_search_spans_SpanNearQuery_
 
9
 
 
10
CL_CLASS_DEF(index, IndexReader);
 
11
#include "SpanQuery.h"
 
12
 
 
13
CL_NS_DEF2( search, spans )
 
14
 
 
15
/** Matches spans which are near one another.  One can specify <i>slop</i>, the
 
16
 * maximum number of intervening unmatched positions, as well as whether
 
17
 * matches are required to be in-order. */
 
18
class CLUCENE_EXPORT SpanNearQuery : public SpanQuery
 
19
{
 
20
private:
 
21
    SpanQuery **    clauses;
 
22
    size_t          clausesCount;
 
23
    bool            bDeleteClauses;
 
24
 
 
25
    int32_t         slop;
 
26
    bool            inOrder;
 
27
 
 
28
    TCHAR *         field;
 
29
 
 
30
protected:
 
31
    SpanNearQuery( const SpanNearQuery& clone );
 
32
 
 
33
public:
 
34
    /** Construct a SpanNearQuery.  Matches spans matching a span from each
 
35
     * clause, with up to <code>slop</code> total unmatched positions between
 
36
     * them.  * When <code>inOrder</code> is true, the spans from each clause
 
37
     * must be * ordered as in <code>clauses</code>. */
 
38
    template<class ClauseIterator>
 
39
    SpanNearQuery( ClauseIterator first, ClauseIterator last, int32_t slop, bool inOrder, bool bDeleteClauses )
 
40
    {
 
41
        // CLucene specific: at least one clause must be here
 
42
        if( first ==  last )
 
43
            _CLTHROWA( CL_ERR_IllegalArgument, "Missing query clauses." );
 
44
 
 
45
        this->bDeleteClauses = bDeleteClauses;
 
46
        this->clausesCount = last - first;
 
47
        this->clauses = _CL_NEWARRAY( SpanQuery *, clausesCount );
 
48
        this->field = NULL;
 
49
 
 
50
        // copy clauses array into an array and check fields
 
51
        for( size_t i = 0; first != last; first++, i++ )
 
52
        {
 
53
            SpanQuery * clause = *first;
 
54
            if( i == 0 )
 
55
            {
 
56
                setField( clause->getField() );
 
57
            }
 
58
            else if( 0 != _tcscmp( clause->getField(), field ))
 
59
            {
 
60
                _CLTHROWA( CL_ERR_IllegalArgument, "Clauses must have same field." );
 
61
            }
 
62
            this->clauses[ i ] = clause;
 
63
        }
 
64
 
 
65
        this->slop = slop;
 
66
        this->inOrder = inOrder;
 
67
    }
 
68
 
 
69
    virtual ~SpanNearQuery();
 
70
 
 
71
    CL_NS(search)::Query * clone() const;
 
72
 
 
73
    static const char * getClassName();
 
74
        const char * getObjectName() const;
 
75
 
 
76
    /** Return the clauses whose spans are matched.
 
77
     * CLucene: pointer to the internal array
 
78
     */
 
79
    SpanQuery ** getClauses() const;
 
80
    size_t getClausesCount() const;
 
81
 
 
82
    /** Return the maximum number of intervening unmatched positions permitted.*/
 
83
    int32_t getSlop() const;
 
84
 
 
85
    /** Return true if matches are required to be in-order.*/
 
86
    bool isInOrder() const;
 
87
 
 
88
    const TCHAR * getField() const;
 
89
 
 
90
    /** Returns a collection of all terms matched by this query.
 
91
     * @deprecated use extractTerms instead
 
92
     * @see #extractTerms(Set)
 
93
     */
 
94
//    public Collection getTerms()
 
95
 
 
96
    void extractTerms( CL_NS(search)::TermSet * terms ) const;
 
97
 
 
98
    CL_NS(search)::Query * rewrite( CL_NS(index)::IndexReader * reader );
 
99
 
 
100
    using Query::toString;
 
101
    TCHAR* toString( const TCHAR* field ) const;
 
102
    bool equals( Query* other ) const;
 
103
    size_t hashCode() const;
 
104
 
 
105
    Spans * getSpans( CL_NS(index)::IndexReader * reader );
 
106
 
 
107
protected:
 
108
    void setField( const TCHAR * field );
 
109
};
 
110
 
 
111
CL_NS_END2
 
112
#endif // _lucene_search_spans_SpanNearQuery_