|
| 1 | +/* |
| 2 | + * DISCLAIMER |
| 3 | + * |
| 4 | + * Copyright 2016 ArangoDB GmbH, Cologne, Germany |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + * |
| 18 | + * Copyright holder is ArangoDB GmbH, Cologne, Germany |
| 19 | + */ |
| 20 | + |
| 21 | +package com.arangodb.model; |
| 22 | + |
| 23 | +import com.arangodb.arch.NoRawTypesInspection; |
| 24 | +import com.arangodb.entity.IndexType; |
| 25 | + |
| 26 | + |
| 27 | +/** |
| 28 | + * @author Michele Rastelli |
| 29 | + * @see <a href="https://docs.arangodb.com/devel/develop/http-api/indexes/multi-dimensional">API Documentation</a> |
| 30 | + * @since ArangoDB 3.12 |
| 31 | + */ |
| 32 | +@NoRawTypesInspection |
| 33 | +public abstract class AbstractMDIndexOptions<T extends AbstractMDIndexOptions<T>> extends IndexOptions<T> { |
| 34 | + |
| 35 | + private Iterable<String> fields; |
| 36 | + private Boolean unique; |
| 37 | + private MDIFieldValueTypes fieldValueTypes; |
| 38 | + private Boolean estimates; |
| 39 | + private Boolean sparse; |
| 40 | + private Iterable<String> storedValues; |
| 41 | + |
| 42 | + |
| 43 | + public AbstractMDIndexOptions() { |
| 44 | + super(); |
| 45 | + } |
| 46 | + |
| 47 | + public abstract IndexType getType(); |
| 48 | + |
| 49 | + public Iterable<String> getFields() { |
| 50 | + return fields; |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @param fields A list of attribute names used for each dimension. Array expansions are not allowed. |
| 55 | + * @return options |
| 56 | + */ |
| 57 | + T fields(final Iterable<String> fields) { |
| 58 | + this.fields = fields; |
| 59 | + return getThis(); |
| 60 | + } |
| 61 | + |
| 62 | + public Boolean getUnique() { |
| 63 | + return unique; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @param unique if true, then create a unique index |
| 68 | + * @return options |
| 69 | + */ |
| 70 | + public T unique(final Boolean unique) { |
| 71 | + this.unique = unique; |
| 72 | + return getThis(); |
| 73 | + } |
| 74 | + |
| 75 | + public MDIFieldValueTypes getFieldValueTypes() { |
| 76 | + return fieldValueTypes; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * @param fieldValueTypes must be {@link MDIFieldValueTypes#DOUBLE}, currently only doubles are supported as values. |
| 81 | + * @return options |
| 82 | + */ |
| 83 | + public T fieldValueTypes(final MDIFieldValueTypes fieldValueTypes) { |
| 84 | + this.fieldValueTypes = fieldValueTypes; |
| 85 | + return getThis(); |
| 86 | + } |
| 87 | + |
| 88 | + public Boolean getEstimates() { |
| 89 | + return estimates; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * @param estimates controls whether index selectivity estimates are maintained for the index. Not maintaining index |
| 94 | + * selectivity estimates can have a slightly positive impact on write performance. |
| 95 | + * The downside of turning off index selectivity estimates is that the query optimizer is not able |
| 96 | + * to determine the usefulness of different competing indexes in AQL queries when there are |
| 97 | + * multiple candidate indexes to choose from. |
| 98 | + * The estimates attribute is optional and defaults to true if not set. |
| 99 | + * It cannot be disabled for non-unique multi-dimensional indexes because they have a fixed |
| 100 | + * selectivity estimate of 1. |
| 101 | + * @return options |
| 102 | + */ |
| 103 | + public T estimates(final Boolean estimates) { |
| 104 | + this.estimates = estimates; |
| 105 | + return getThis(); |
| 106 | + } |
| 107 | + |
| 108 | + public Boolean getSparse() { |
| 109 | + return sparse; |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * @param sparse if true, then create a sparse index |
| 114 | + * @return options |
| 115 | + */ |
| 116 | + public T sparse(final Boolean sparse) { |
| 117 | + this.sparse = sparse; |
| 118 | + return getThis(); |
| 119 | + } |
| 120 | + |
| 121 | + public Iterable<String> getStoredValues() { |
| 122 | + return storedValues; |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * @param storedValues can contain an array of paths to additional attributes to store in the index. |
| 127 | + * These additional attributes cannot be used for index lookups or for sorting, but they can be |
| 128 | + * used for projections. This allows an index to fully cover more queries and avoid extra |
| 129 | + * document lookups. |
| 130 | + * You can have the same attributes in storedValues and fields as the attributes in fields |
| 131 | + * cannot be used for projections, but you can also store additional attributes that are not |
| 132 | + * listed in fields. |
| 133 | + * Attributes in storedValues cannot overlap with the attributes specified in prefixFields. |
| 134 | + * Non-existing attributes are stored as null values inside storedValues. |
| 135 | + * The maximum number of attributes in storedValues is 32. |
| 136 | + * @return options |
| 137 | + */ |
| 138 | + public T storedValues(final Iterable<String> storedValues) { |
| 139 | + this.storedValues = storedValues; |
| 140 | + return getThis(); |
| 141 | + } |
| 142 | + |
| 143 | +} |
0 commit comments