-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-14194 Add config property for default max result
- Loading branch information
Showing
9 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
core/src/main/java/org/infinispan/configuration/cache/QueryConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.infinispan.configuration.cache; | ||
|
||
import org.infinispan.commons.configuration.AbstractTypedPropertiesConfiguration; | ||
import org.infinispan.commons.configuration.attributes.AttributeDefinition; | ||
import org.infinispan.commons.configuration.attributes.AttributeSet; | ||
import org.infinispan.commons.configuration.attributes.Matchable; | ||
|
||
/** | ||
* Configures query options and defaults | ||
*/ | ||
public class QueryConfiguration extends AbstractTypedPropertiesConfiguration implements Matchable<QueryConfiguration> { | ||
|
||
public static final AttributeDefinition<Integer> DEFAULT_MAX_RESULT = AttributeDefinition.builder(org.infinispan.configuration.parsing.Attribute.DEFAULT_MAX_RESULT, 100).immutable().build(); | ||
|
||
static AttributeSet attributeDefinitionSet() { | ||
return new AttributeSet(QueryConfiguration.class, AbstractTypedPropertiesConfiguration.attributeSet(), DEFAULT_MAX_RESULT); | ||
} | ||
|
||
protected QueryConfiguration(AttributeSet attributes) { | ||
super(attributes); | ||
} | ||
|
||
/** | ||
* Applies the given value as maxResults as a default to any query (indexed, non-indexed and hybrid). | ||
* Having a default maxResult dramatically improves the performance of the queries for which a maxResults is not explicitly defined. | ||
*/ | ||
public int defaultMaxResult() { | ||
return attributes.attribute(DEFAULT_MAX_RESULT).get(); | ||
} | ||
|
||
public AttributeSet attributes() { | ||
return attributes; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
core/src/main/java/org/infinispan/configuration/cache/QueryConfigurationBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.infinispan.configuration.cache; | ||
|
||
import static org.infinispan.configuration.cache.QueryConfiguration.DEFAULT_MAX_RESULT; | ||
|
||
import org.infinispan.commons.configuration.Builder; | ||
import org.infinispan.commons.configuration.attributes.AttributeSet; | ||
|
||
public class QueryConfigurationBuilder extends AbstractConfigurationChildBuilder implements Builder<QueryConfiguration> { | ||
|
||
private final AttributeSet attributes; | ||
|
||
public QueryConfigurationBuilder(ConfigurationBuilder builder) { | ||
super(builder); | ||
attributes = QueryConfiguration.attributeDefinitionSet(); | ||
} | ||
|
||
/** | ||
* Applies the given value as maxResults as a default to any query (indexed, non-indexed and hybrid). | ||
* Having a default maxResult dramatically improves the performance of the queries for which a maxResults is not explicitly defined. | ||
* | ||
* @param defaultMaxResult The value to apply | ||
* @return <code>this</code>, for method chaining | ||
*/ | ||
public QueryConfigurationBuilder defaultMaxResult(int defaultMaxResult) { | ||
attributes.attribute(DEFAULT_MAX_RESULT).set(defaultMaxResult); | ||
return this; | ||
} | ||
|
||
public int defaultMaxResult() { | ||
return attributes.attribute(DEFAULT_MAX_RESULT).get(); | ||
} | ||
|
||
@Override | ||
public QueryConfiguration create() { | ||
return new QueryConfiguration(attributes.protect()); | ||
} | ||
|
||
@Override | ||
public QueryConfigurationBuilder read(QueryConfiguration template) { | ||
attributes.read(template.attributes()); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters