/** * bindKeyspaceIdQuery creates a BoundKeyspaceIdQuery. */ public static BoundKeyspaceIdQuery bindKeyspaceIdQuery(String keyspace, Iterable<byte[]> keyspaceIds, String query, Map<String, ?> vars) { return bindKeyspaceIdQuery(keyspace, keyspaceIds, bindQuery(query, vars)); }
/** * bindShardQuery creates a BoundShardQuery. */ public static BoundShardQuery bindShardQuery(String keyspace, Iterable<String> shards, String query, Map<String, ?> vars) { return bindShardQuery(keyspace, shards, bindQuery(query, vars)); }
/** * bindQuery creates a BoundQuery from query and vars. */ public static BoundQuery bindQuery(String query, Map<String, ?> vars) { BoundQuery.Builder boundQueryBuilder = BoundQuery.newBuilder().setSql(query); if (vars != null) { for (Map.Entry<String, ?> entry : vars.entrySet()) { boundQueryBuilder.putBindVariables(entry.getKey(), buildBindVariable(entry.getValue())); } } return boundQueryBuilder.build(); }
@Override public ListenableFuture<List<CursorWithError>> apply( Vtgate.ExecuteBatchResponse response) throws Exception { Proto.checkError(response.getError()); return Futures.immediateFuture( Proto.fromQueryResponsesToCursorList(response.getResultsList())); } },
int errno = Proto.getErrno(rpcError.getMessage()); String sqlState = Proto.getSQLState(rpcError.getMessage()); throw new BatchUpdateException(rpcError.toString(), sqlState, errno, updateCounts);
public Cursor streamExecuteKeyspaceIds(Context ctx, String query, String keyspace, Iterable<byte[]> keyspaceIds, @Nullable Map<String, ?> bindVars, TabletType tabletType, Query.ExecuteOptions.IncludedFields includedFields) throws SQLException { StreamExecuteKeyspaceIdsRequest.Builder requestBuilder = StreamExecuteKeyspaceIdsRequest .newBuilder() .setQuery(Proto.bindQuery(checkNotNull(query), bindVars)) .setKeyspace(checkNotNull(keyspace)) .addAllKeyspaceIds( Iterables.transform(checkNotNull(keyspaceIds), Proto.BYTE_ARRAY_TO_BYTE_STRING)) .setTabletType(checkNotNull(tabletType)) .setOptions(Query.ExecuteOptions.newBuilder() .setIncludedFields(includedFields)); if (ctx.getCallerId() != null) { requestBuilder.setCallerId(ctx.getCallerId()); } return new StreamCursor(client.streamExecuteKeyspaceIds(ctx, requestBuilder.build())); }
@Override public ListenableFuture<List<Cursor>> apply(ExecuteBatchShardsResponse response) throws Exception { Proto.checkError(response.getError()); return Futures.<List<Cursor>>immediateFuture( Proto.toCursorList(response.getResultsList())); } },
@Override public ListenableFuture<Cursor> apply(ExecuteResponse response) throws Exception { Proto.checkError(response.getError()); return Futures.<Cursor>immediateFuture(new SimpleCursor(response.getResult())); } },
StatusRuntimeException sre = (StatusRuntimeException) e; int errno = Proto.getErrno(sre.getMessage()); String sqlState = Proto.getSQLState(sre.getMessage());
public Cursor streamExecuteShards(Context ctx, String query, String keyspace, Iterable<String> shards, @Nullable Map<String, ?> bindVars, TabletType tabletType, Query.ExecuteOptions.IncludedFields includedFields) throws SQLException { StreamExecuteShardsRequest.Builder requestBuilder = StreamExecuteShardsRequest.newBuilder() .setQuery(Proto.bindQuery(checkNotNull(query), bindVars)) .setKeyspace(checkNotNull(keyspace)) .addAllShards(checkNotNull(shards)) .setTabletType(checkNotNull(tabletType)) .setOptions(Query.ExecuteOptions.newBuilder() .setIncludedFields(includedFields)); if (ctx.getCallerId() != null) { requestBuilder.setCallerId(ctx.getCallerId()); } return new StreamCursor(client.streamExecuteShards(ctx, requestBuilder.build())); }
@Override public ListenableFuture<List<Cursor>> apply(ExecuteBatchKeyspaceIdsResponse response) throws Exception { Proto.checkError(response.getError()); return Futures.<List<Cursor>>immediateFuture( Proto.toCursorList(response.getResultsList())); } },
@Override public ListenableFuture<List<CursorWithError>> apply( Vtgate.ExecuteBatchResponse response) throws Exception { setSession(response.getSession()); Proto.checkError(response.getError()); return Futures.immediateFuture( Proto.fromQueryResponsesToCursorList(response.getResultsList())); } },
@Override public ListenableFuture<Cursor> apply(ExecuteShardsResponse response) throws Exception { Proto.checkError(response.getError()); return Futures.<Cursor>immediateFuture(new SimpleCursor(response.getResult())); } },
int errno = getErrno(error.getMessage()); String sqlState = getSQLState(error.getMessage());
queries.add(i, Proto.bindQuery(checkNotNull(queryList.get(i)), bindVarsList == null ? null : bindVarsList.get(i)));
@Override public ListenableFuture<List<Cursor>> apply(ExecuteBatchShardsResponse response) throws Exception { setSession(response.getSession()); Proto.checkError(response.getError()); return Futures.<List<Cursor>>immediateFuture( Proto.toCursorList(response.getResultsList())); } },
@Override public ListenableFuture<List<CursorWithError>> apply(Vtgate.ExecuteBatchResponse response) throws Exception { vtSession.setSession(response.getSession()); Proto.checkError(response.getError()); return Futures.immediateFuture( Proto.fromQueryResponsesToCursorList(response.getResultsList())); } }, directExecutor()));
@Override public ListenableFuture<Cursor> apply(ExecuteEntityIdsResponse response) throws Exception { Proto.checkError(response.getError()); return Futures.<Cursor>immediateFuture(new SimpleCursor(response.getResult())); } },
public Cursor streamExecuteKeyRanges(Context ctx, String query, String keyspace, Iterable<? extends KeyRange> keyRanges, @Nullable Map<String, ?> bindVars, TabletType tabletType, Query.ExecuteOptions.IncludedFields includedFields) throws SQLException { StreamExecuteKeyRangesRequest.Builder requestBuilder = StreamExecuteKeyRangesRequest .newBuilder() .setQuery(Proto.bindQuery(checkNotNull(query), bindVars)) .setKeyspace(checkNotNull(keyspace)) .addAllKeyRanges(checkNotNull(keyRanges)) .setTabletType(checkNotNull(tabletType)) .setOptions(Query.ExecuteOptions.newBuilder() .setIncludedFields(includedFields)); if (ctx.getCallerId() != null) { requestBuilder.setCallerId(ctx.getCallerId()); } return new StreamCursor(client.streamExecuteKeyRanges(ctx, requestBuilder.build())); }
@Override public ListenableFuture<List<Cursor>> apply( ExecuteBatchKeyspaceIdsResponse response) throws Exception { setSession(response.getSession()); Proto.checkError(response.getError()); return Futures.<List<Cursor>>immediateFuture( Proto.toCursorList(response.getResultsList())); } },