info.archinnov.achilles.query.slice.SliceQueryRoot Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of achilles-core Show documentation
Show all versions of achilles-core Show documentation
CQL implementation for Achilles using Datastax Java driver
/*
* Copyright (C) 2012-2014 DuyHai DOAN
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package info.archinnov.achilles.query.slice;
import static info.archinnov.achilles.query.slice.SliceQueryProperties.SliceType;
import static java.util.Arrays.asList;
import java.util.Iterator;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.util.concurrent.FutureCallback;
import info.archinnov.achilles.async.AchillesFuture;
import info.archinnov.achilles.type.Empty;
import info.archinnov.achilles.internal.metadata.holder.EntityMeta;
import info.archinnov.achilles.internal.persistence.operations.SliceQueryExecutor;
import info.archinnov.achilles.internal.validation.Validator;
import info.archinnov.achilles.type.ConsistencyLevel;
public abstract class SliceQueryRoot> {
private static final Logger log = LoggerFactory.getLogger(SliceQueryRoot.class);
protected final SliceQueryExecutor sliceQueryExecutor;
protected final Class entityClass;
protected final EntityMeta meta;
protected final SliceQueryProperties properties;
protected SliceQueryRoot(SliceQueryExecutor sliceQueryExecutor, Class entityClass, EntityMeta meta, SliceType sliceType) {
this.sliceQueryExecutor = sliceQueryExecutor;
this.entityClass = entityClass;
this.meta = meta;
this.properties = SliceQueryProperties.builder(meta, entityClass, sliceType);
}
protected void withPartitionComponentsInternal(Object... partitionKeyComponents) {
log.trace("Add partition key components {}", partitionKeyComponents);
Validator.validateNotEmpty(partitionKeyComponents, "Partition key components should not be empty");
meta.forSliceQuery().validatePartitionComponents(partitionKeyComponents);
SliceQueryRoot.this.properties.partitionKeys(asList(partitionKeyComponents));
SliceQueryRoot.this.properties.partitionKeysName(meta.forSliceQuery().getPartitionKeysName(partitionKeyComponents.length));
}
protected void withPartitionComponentsINInternal(Object... partitionKeyComponentsIn) {
log.trace("Add partition key components for IN clause {}", partitionKeyComponentsIn);
meta.forSliceQuery().validatePartitionComponentsIn(partitionKeyComponentsIn);
SliceQueryRoot.this.properties.andPartitionKeysIn(asList(partitionKeyComponentsIn));
SliceQueryRoot.this.properties.lastPartitionKeyName(meta.forSliceQuery().getLastPartitionKeyName());
}
protected void andPartitionKeysINInternal(Object... partitionKeyComponentsIn) {
log.trace("Add partition key components for IN clause {}", partitionKeyComponentsIn);
final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy