001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2009 Sun Microsystems, Inc. 025 * Portions Copyright 2014 ForgeRock AS 026 */ 027package org.forgerock.opendj.ldap.spi; 028 029import java.util.Collection; 030 031import org.forgerock.opendj.ldap.ByteSequence; 032 033/** 034 * A factory for creating arbitrarily complex index queries. This 035 * interface is implemented by the underlying backend implementation 036 * and passed to extensible matching rules so that they can construct 037 * arbitrarily complex index queries. 038 * 039 * @param <T> 040 * The type of query created by this factory. 041 */ 042public interface IndexQueryFactory<T> { 043 044 /** 045 * Returns a query requesting an index record matching the provided key. 046 * 047 * @param indexID 048 * An identifier of the index type. 049 * @param key 050 * A byte sequence containing the key. 051 * @return A query requesting the index record matching the key. 052 */ 053 T createExactMatchQuery(String indexID, ByteSequence key); 054 055 /** 056 * Returns a query requesting all index records. A backend implementation 057 * may choose to return all or no records as part of the optimization. 058 * 059 * @return A query requesting all index records. 060 */ 061 T createMatchAllQuery(); 062 063 /** 064 * Returns a query requesting all index records in the specified range. 065 * 066 * @param indexID 067 * An identifier of the index type. 068 * @param lower 069 * The lower bound of the range. A 0 length byte array indicates no 070 * lower bound and the range will start from the smallest key. 071 * @param upper 072 * The upper bound of the range. A 0 length byte array indicates no 073 * upper bound and the range will end at the largest key. 074 * @param lowerIncluded 075 * true if a key exactly matching the lower bound is included in 076 * the range, false if only keys strictly greater than the lower 077 * bound are included. This value is ignored if the lower bound is 078 * not specified. 079 * @param upperIncluded 080 * true if a key exactly matching the upper bound is included in 081 * the range, false if only keys strictly less than the upper bound 082 * are included. This value is ignored if the upper bound is not 083 * specified. 084 * @return A query requesting all index records in the specified range. 085 */ 086 T createRangeMatchQuery(String indexID, ByteSequence lower, 087 ByteSequence upper, boolean lowerIncluded, boolean upperIncluded); 088 089 /** 090 * Returns a query which returns the intersection of a collection of 091 * sub-queries. 092 * 093 * @param subqueries 094 * A collection of sub-queries. 095 * @return A query which returns the intersection of a collection of 096 * sub-queries. 097 */ 098 T createIntersectionQuery(Collection<T> subqueries); 099 100 /** 101 * Returns a query which combines the results of a collection of 102 * sub-queries. 103 * 104 * @param subqueries 105 * A collection of sub-queries. 106 * @return A query which combines the results of a collection of 107 * sub-queries. 108 */ 109 T createUnionQuery(Collection<T> subqueries); 110 111 /** 112 * Returns the indexing options for this factory. 113 * 114 * @return the indexing options for this factory. 115 */ 116 IndexingOptions getIndexingOptions(); 117}