String tableName = "NiFi_Cassandra_Query_Record"; if (nrOfColumns > 0) { String tableNameFromMeta = columnDefinitions.getTable(0); if (!StringUtils.isBlank(tableNameFromMeta)) { tableName = tableNameFromMeta;
/** * Returns the table of first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the table of (the first occurrence of) column {@code name} in this metadata. * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getTable(String name) { return getTable(getFirstIdx(name)); }
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 table of first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the table of (the first occurrence of) column {@code name} in this metadata. * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getTable(String name) { return getTable(getFirstIdx(name)); }
/** * Returns the table of first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the table of (the first occurrence of) column {@code name} in this metadata. * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getTable(String name) { return getTable(getFirstIdx(name)); }
/** * Returns the table of first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the table of (the first occurrence of) column {@code name} in this metadata. * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getTable(String name) { return getTable(getFirstIdx(name)); }
/** * Returns the table of first occurrence of {@code name} in this metadata. * * @param name the name of the column. * @return the table of (the first occurrence of) column {@code name} in this metadata. * * @throws IllegalArgumentException if {@code name} is not in this metadata. */ public String getTable(String name) { return getTable(getFirstIdx(name)); }
@Override public String getTableName(int column) throws SQLException { String tableName=""; if(currentRow!=null){ tableName = currentRow.getColumnDefinitions().getTable(column-1); }else{ tableName = driverResultSet.getColumnDefinitions().getTable(column-1); } return tableName; }
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)); }
@Override public ParameterMetadata buildParameterMetadata(String nativeQuery) { PreparedStatement preparedStatement = session.prepare( nativeQuery ); ColumnDefinitions columnDefinitions = preparedStatement.getVariables(); OrdinalParameterDescriptor[] ordinalDescriptors = new OrdinalParameterDescriptor[columnDefinitions.size()]; if ( columnDefinitions.size() > 0 ) { // the cassandra metadata will give us the CQL type, but the type conversion system only goes // in hibernate->cassandra direction, so we can't turn it back into the required hibernate type. // instead we rely on the cached hibernate metadata from schema creation time String tableName = columnDefinitions.getTable( 0 ); Table table = metaDataCache.get( tableName ); for ( ColumnDefinitions.Definition definition : columnDefinitions ) { String name = definition.getName(); Column column = table.getColumn( Identifier.toIdentifier( name ) ); Type hibernateType = column.getValue().getType(); // cassandra side index is 0-based, hibernate side index is 1-based int index = columnDefinitions.getIndexOf( name ); ordinalDescriptors[index] = new OrdinalParameterDescriptor( index + 1, hibernateType, 0 ); } } return new ParameterMetadata( ordinalDescriptors, null ); } }
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); }
String tableName = "NiFi_Cassandra_Query_Record"; if (nrOfColumns > 0) { String tableNameFromMeta = columnDefinitions.getTable(0); if (!StringUtils.isBlank(tableNameFromMeta)) { tableName = tableNameFromMeta;