All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.stargate.db.query.Query Maven / Gradle / Ivy

There is a newer version: 2.1.0-BETA-19
Show newest version
package io.stargate.db.query;

import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.cassandra.stargate.exceptions.InvalidRequestException;
import org.apache.cassandra.stargate.utils.MD5Digest;

/**
 * A CQL query.
 *
 * 

Implementations of this class make no strong guarantees on the validity of the query they * represent; executing them may raise an {@link InvalidRequestException}. */ public interface Query { TypedValue.Codec valueCodec(); /** The (potentially empty) list of bind markers that remains to be bound in this query. */ List bindMarkers(); /** If this is a prepared query, it's prepared ID. */ Optional preparedId(); /** Creates a prepared copy of this query, using the provided prepared ID. */ Query withPreparedId(MD5Digest preparedId); /** * The query string that must be used to prepare this query. * *

Please note that the query string returned by this method may or may not be equal to the one * of {@link #toString()} (in particular, the query is allowed to prepare some of values that are * not part of {@link #bindMarkers()}, to optimize prepared statement caching for instance). */ String queryStringForPreparation(); B bindValues(List values); default B bind(Object... values) { return bind(Arrays.asList(values)); } default B bind(List values) { return bindValues(TypedValue.forJavaValues(valueCodec(), bindMarkers(), values)); } default B bindBuffers(ByteBuffer... values) { return bindBuffers(Arrays.asList(values)); } default B bindBuffers(List values) { return bindValues(TypedValue.forBytesValues(valueCodec(), bindMarkers(), values)); } /** * A valid CQL query string representation of this query (with bind markers for the values of * {@link #bindMarkers()}). */ @Override String toString(); }