Java 类com.datastax.driver.core.MaterializedViewMetadata 实例源码

项目:state-channels    文件:ClusteredLoader.java   
public ClusteredLoader(Mapper<Data> mapper, Class<Data> dataClass, Class<CKey> ckeyClass, String tableName) {
    MappingManager manager = mapper.getManager();
    session = manager.getSession();
    this.mapper = manager.mapper(dataClass);

    String keyspace = mapper.getTableMetadata().getKeyspace().getName();
    MaterializedViewMetadata mv = mapper.getTableMetadata().getKeyspace().getMaterializedView(tableName);
    AbstractTableMetadata tableMetadata = mv == null ? mapper.getTableMetadata().getKeyspace().getTable(tableName) : mv;
    if (tableMetadata == null) {
        throw new IllegalArgumentException("No table or materialized view " + keyspace + "." + tableName + "found");
    }

    List<ColumnMetadata> primaryKey = tableMetadata.getPrimaryKey();
    String pkEq = exceptLast(primaryKey).stream()
        .map(c -> c.getName() + "=?")
        .collect(Collectors.joining(" and "));

    List<ColumnMetadata> clusteringColumns = tableMetadata.getClusteringColumns();

    String orderByDesc = orderBy(clusteringColumns, "DESC");
    String orderByAsc = orderBy(clusteringColumns, "ASC");

    String indexColumn = clusteringColumns.get(clusteringColumns.size() - 1).getName();
    indexAccessor = CassandraUtil.findProperty(dataClass, ckeyClass, indexColumn);

    selectUnbounded = prepare(String.format("select * from %s.%s where " + pkEq + " order by %s limit ?", keyspace, tableName, orderByDesc));
    selectBefore = prepare(String.format("select * from %s.%s where "+pkEq+" and %s < ? order by %s limit ?", keyspace, tableName, indexColumn, orderByDesc));
    selectAfter = prepare(String.format("select * from %s.%s where "+pkEq+" and %s > ? order by %s limit ?", keyspace, tableName, indexColumn, orderByDesc));
    selectBeforeAfter = prepare(String.format("select * from %s.%s where "+pkEq+" and %s < ? and %s > ? order by %s limit ?", keyspace, tableName, indexColumn, indexColumn, orderByDesc));

    selectUnboundedAsc = prepare(String.format("select * from %s.%s where "+pkEq+" order by %s limit ?", keyspace, tableName, orderByAsc));
    selectBeforeAsc = prepare(String.format("select * from %s.%s where "+pkEq+" and %s < ? order by %s limit ?", keyspace, tableName, indexColumn, orderByAsc));
    selectAfterAsc = prepare(String.format("select * from %s.%s where "+pkEq+" and %s > ? order by %s limit ?", keyspace, tableName, indexColumn, orderByAsc));
    selectBeforeAfterAsc = prepare(String.format("select * from %s.%s where "+pkEq+" and %s < ? and %s > ? order by %s limit ?", keyspace, tableName, indexColumn, indexColumn, orderByAsc));

    selectByIdKey = prepare(String.format("select * from %s.%s where "+pkEq+" and %s=?", keyspace, tableName, indexColumn));
    deleteByIdKey = prepare(String.format("delete from %s.%s where "+pkEq+" and %s=?", keyspace, tableName, indexColumn));
    selectAllById = prepare(String.format("select * from %s.%s where " + pkEq, keyspace, tableName));
    deleteAllById = prepare(String.format("delete from %s.%s where "+pkEq, keyspace, tableName));
}
项目:metacat    文件:CassandraConnectorDatabaseService.java   
/**
 * {@inheritDoc}
 */
@Override
public List<QualifiedName> listViewNames(
    @Nonnull @NonNull final ConnectorRequestContext context,
    @Nonnull @NonNull final QualifiedName databaseName
) {
    final String catalogName = databaseName.getCatalogName();
    final String keyspace = databaseName.getDatabaseName();
    log.debug("Attempting to get materialized view names for keyspace {} due to request {}", keyspace, context);
    try {
        final KeyspaceMetadata keyspaceMetadata = this.getCluster().getMetadata().getKeyspace(keyspace);
        if (keyspaceMetadata == null) {
            throw new DatabaseNotFoundException(databaseName);
        }

        final ImmutableList.Builder<QualifiedName> viewsBuilder = ImmutableList.builder();
        for (final MaterializedViewMetadata view : keyspaceMetadata.getMaterializedViews()) {
            viewsBuilder.add(
                QualifiedName.ofView(catalogName, keyspace, view.getBaseTable().getName(), view.getName())
            );
        }

        final List<QualifiedName> views = viewsBuilder.build();
        log.debug("Successfully found {} views for keyspace {} due to request {}", views.size(), keyspace, context);
        return views;
    } catch (final DriverException de) {
        log.error(de.getMessage(), de);
        throw this.getExceptionMapper().toConnectorException(de, databaseName);
    }
}
项目:calcite    文件:CassandraSchema.java   
@Override protected Map<String, Table> getTableMap() {
  final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder();
  for (TableMetadata table : getKeyspace().getTables()) {
    String tableName = table.getName();
    builder.put(tableName, new CassandraTable(this, tableName));

    for (MaterializedViewMetadata view : table.getViews()) {
      String viewName = view.getName();
      builder.put(viewName, new CassandraTable(this, viewName, true));
    }
  }
  return builder.build();
}
项目:taulukko-commons-ceu    文件:KeyspaceMetadata.java   
public MaterializedViewMetadata getMaterializedView(String name)
throws CEUException;
项目:taulukko-commons-ceu    文件:KeyspaceMetadata.java   
public Collection<MaterializedViewMetadata> getMaterializedViews()
throws CEUException;
项目:taulukko-commons-ceu    文件:DSKeyspaceMetadata.java   
public MaterializedViewMetadata getMaterializedView(String name) {
    return keyspaceMetadata.getMaterializedView(name);
}
项目:taulukko-commons-ceu    文件:DSKeyspaceMetadata.java   
public Collection<MaterializedViewMetadata> getMaterializedViews() {
    return keyspaceMetadata.getMaterializedViews();
}
项目:hawkular-metrics    文件:DataAccessImpl.java   
@Override public void onMaterializedViewChanged(MaterializedViewMetadata materializedViewMetadata,
MaterializedViewMetadata materializedViewMetadata1) {}
项目:hawkular-metrics    文件:GCGraceSecondsManager.java   
@Override
public void onMaterializedViewAdded(MaterializedViewMetadata view) {

}
项目:hawkular-metrics    文件:GCGraceSecondsManager.java   
@Override
public void onMaterializedViewRemoved(MaterializedViewMetadata view) {

}
项目:hawkular-metrics    文件:GCGraceSecondsManager.java   
@Override
public void onMaterializedViewChanged(MaterializedViewMetadata current, MaterializedViewMetadata previous) {

}
项目:hawkular-metrics    文件:DataAccessImpl.java   
@Override public void onMaterializedViewAdded(MaterializedViewMetadata materializedViewMetadata) {}
项目:hawkular-metrics    文件:DataAccessImpl.java   
@Override public void onMaterializedViewRemoved(MaterializedViewMetadata materializedViewMetadata) {}