/** * Returns the keyspace of the first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the keyspace of (the first occurrence of) column {@code name} in this metadata. * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getKeyspace(String name) { return getKeyspace(getFirstIdx(name)); }
/** {@inheritDoc} */ @Override public String getKeyspace() { ColumnDefinitions defs = statement.getPreparedId().boundValuesMetadata.variables; return defs.size() == 0 ? null : defs.getKeyspace(0); }
private static int[] computePkIndices(Metadata clusterMetadata, ColumnDefinitions boundColumns) { List<ColumnMetadata> partitionKeyColumns = null; int[] pkIndexes = null; KeyspaceMetadata km = clusterMetadata.getKeyspace(Metadata.quote(boundColumns.getKeyspace(0))); if (km != null) { TableMetadata tm = km.getTable(Metadata.quote(boundColumns.getTable(0))); if (tm != null) { partitionKeyColumns = tm.getPartitionKey(); pkIndexes = new int[partitionKeyColumns.size()]; for (int i = 0; i < pkIndexes.length; ++i) pkIndexes[i] = -1; } } // Note: we rely on the fact CQL queries cannot span multiple tables. If that change, we'll have // to get smarter. for (int i = 0; i < boundColumns.size(); i++) maybeGetIndex(boundColumns.getName(i), i, partitionKeyColumns, pkIndexes); return allSet(pkIndexes) ? pkIndexes : null; }
/** * Returns the keyspace of the first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the keyspace of (the first occurrence of) column {@code name} in this metadata. * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getKeyspace(String name) { return getKeyspace(getFirstIdx(name)); }
/** * Returns the keyspace of the first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the keyspace of (the first occurrence of) column {@code name} in this metadata. * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getKeyspace(String name) { return getKeyspace(getFirstIdx(name)); }
/** * Returns the keyspace of the first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the keyspace of (the first occurrence of) column {@code name} in this metadata. * * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getKeyspace(String name) { return getKeyspace(getFirstIdx(name)); }
/** * Returns the keyspace of the first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the keyspace of (the first occurrence of) column {@code name} in this metadata. * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getKeyspace(String name) { return getKeyspace(getFirstIdx(name)); }
/** * {@inheritDoc} */ @Override public String getKeyspace() { return statement.getPreparedId().metadata.size() == 0 ? null : statement.getPreparedId().metadata.getKeyspace(0); }
/** * {@inheritDoc} */ @Override public String getKeyspace() { return statement.getPreparedId().metadata.size() == 0 ? null : statement.getPreparedId().metadata.getKeyspace(0); }
/** * {@inheritDoc} */ @Override public String getKeyspace() { return statement.getPreparedId().metadata.size() == 0 ? null : statement.getPreparedId().metadata.getKeyspace(0); }
/** * Returns the keyspace this query operates on. * <p> * This method will always return a non-{@code null} value (unless the statement * has no variables, but you should avoid prepared statement in the first in that * case). The keyspace returned will be the one corresponding to the first * variable prepared in this statement (which in almost all case will be <i>the</i> * keyspace for the operation, though it's possible in CQL to build a batch * statement that acts on multiple keyspace). * * @return the keyspace for this statement (see above), or {@code null} if the * statement has no variables. */ @Override public String getKeyspace() { return statement.getPreparedId().metadata.size() == 0 ? null : statement.getPreparedId().metadata.getKeyspace(0); }
private static int[] computePkIndices(Metadata clusterMetadata, ColumnDefinitions boundColumns) { List<ColumnMetadata> partitionKeyColumns = null; int[] pkIndexes = null; KeyspaceMetadata km = clusterMetadata.getKeyspace(Metadata.quote(boundColumns.getKeyspace(0))); if (km != null) { TableMetadata tm = km.getTable(Metadata.quote(boundColumns.getTable(0))); if (tm != null) { partitionKeyColumns = tm.getPartitionKey(); pkIndexes = new int[partitionKeyColumns.size()]; for (int i = 0; i < pkIndexes.length; ++i) pkIndexes[i] = -1; } } // Note: we rely on the fact CQL queries cannot span multiple tables. If that change, we'll have to get smarter. for (int i = 0; i < boundColumns.size(); i++) maybeGetIndex(boundColumns.getName(i), i, partitionKeyColumns, pkIndexes); return allSet(pkIndexes) ? pkIndexes : null; }
private static int[] computePkIndices(Metadata clusterMetadata, ColumnDefinitions boundColumns) { List<ColumnMetadata> partitionKeyColumns = null; int[] pkIndexes = null; KeyspaceMetadata km = clusterMetadata.getKeyspace(Metadata.quote(boundColumns.getKeyspace(0))); if (km != null) { TableMetadata tm = km.getTable(Metadata.quote(boundColumns.getTable(0))); if (tm != null) { partitionKeyColumns = tm.getPartitionKey(); pkIndexes = new int[partitionKeyColumns.size()]; for (int i = 0; i < pkIndexes.length; ++i) pkIndexes[i] = -1; } } // Note: we rely on the fact CQL queries cannot span multiple tables. If that change, we'll have to get smarter. for (int i = 0; i < boundColumns.size(); i++) maybeGetIndex(boundColumns.getName(i), i, partitionKeyColumns, pkIndexes); return allSet(pkIndexes) ? pkIndexes : null; }
private static int[] computePkIndices(Metadata clusterMetadata, ColumnDefinitions boundColumns) { List<ColumnMetadata> partitionKeyColumns = null; int[] pkIndexes = null; KeyspaceMetadata km = clusterMetadata.getKeyspace(Metadata.quote(boundColumns.getKeyspace(0))); if (km != null) { TableMetadata tm = km.getTable(Metadata.quote(boundColumns.getTable(0))); if (tm != null) { partitionKeyColumns = tm.getPartitionKey(); pkIndexes = new int[partitionKeyColumns.size()]; for (int i = 0; i < pkIndexes.length; ++i) pkIndexes[i] = -1; } } // Note: we rely on the fact CQL queries cannot span multiple tables. If that change, we'll have to get smarter. for (int i = 0; i < boundColumns.size(); i++) maybeGetIndex(boundColumns.getName(i), i, partitionKeyColumns, pkIndexes); return allSet(pkIndexes) ? pkIndexes : null; }
/** * Gets the query plan for a {@code BoundStatement}. * * @param loggedKeyspace the logged keyspace of the statement * @param statement the statement * @return the query plan, or null when no plan can be determined */ private Iterator<Host> getQueryPlan(String loggedKeyspace, BoundStatement statement) { PreparedStatement pstmt = statement.preparedStatement(); String query = pstmt.getQueryString(); ColumnDefinitions variables = pstmt.getVariables(); // Look up the hosts for the partition key. Skip statements that do not have bind variables. if (variables.size() == 0) return null; logger.debug("getQueryPlan: keyspace = " + loggedKeyspace + ", query = " + query); int key = getKey(statement); if (key < 0) return null; TableSplitMetadata tableSplitMetadata = clusterMetadata.getTableSplitMetadata(variables.getKeyspace(0), variables.getTable(0)); if (tableSplitMetadata == null) { return null; } return new UpHostIterator(loggedKeyspace, statement, tableSplitMetadata.getHosts(key)); }
static DefaultPreparedStatement fromMessage(Responses.Result.Prepared msg, Metadata clusterMetadata, String query, String queryKeyspace) { assert msg.metadata.columns != null; ColumnDefinitions defs = msg.metadata.columns; if (defs.size() == 0) return new DefaultPreparedStatement(new PreparedId(msg.statementId, defs, msg.resultMetadata.columns, null), query, queryKeyspace); List<ColumnMetadata> partitionKeyColumns = null; int[] pkIndexes = null; KeyspaceMetadata km = clusterMetadata.getKeyspace(defs.getKeyspace(0)); if (km != null) { TableMetadata tm = km.getTable(defs.getTable(0)); if (tm != null) { partitionKeyColumns = tm.getPartitionKey(); pkIndexes = new int[partitionKeyColumns.size()]; for (int i = 0; i < pkIndexes.length; ++i) pkIndexes[i] = -1; } } // Note: we rely on the fact CQL queries cannot span multiple tables. If that change, we'll have to get smarter. for (int i = 0; i < defs.size(); i++) maybeGetIndex(defs.getName(i), i, partitionKeyColumns, pkIndexes); PreparedId prepId = new PreparedId(msg.statementId, defs, msg.resultMetadata.columns, allSet(pkIndexes) ? pkIndexes : null); return new DefaultPreparedStatement(prepId, query, queryKeyspace); }