src/java/org/apache/cassandra/db/DefsTable.java
/** loads a version of keyspace definitions from storage */
loads a version of keyspace definitions from storage
loads a version of keyspace definitions from storage
public static synchronized Collection<KSMetaData> loadFromStorage(UUID version) throws IOException
    {
        DecoratedKey vkey = StorageService.getPartitioner().decorateKey(Migration.toUTF8Bytes(version));
        Table defs = Table.open(Table.SYSTEM_TABLE);
        ColumnFamilyStore cfStore = defs.getColumnFamilyStore(Migration.SCHEMA_CF);
        QueryFilter filter = QueryFilter.getIdentityFilter(vkey, new QueryPath(Migration.SCHEMA_CF));
        ColumnFamily cf = cfStore.getColumnFamily(filter);
        IColumn avroschema = cf.getColumn(DEFINITION_SCHEMA_COLUMN_NAME);
        if (avroschema == null)
            throw new RuntimeException("Cannot read system table! Are you upgrading a pre-release version?");
        ByteBuffer value = avroschema.value();
        Schema schema = Schema.parse(ByteBufferUtil.string(value));
        Collection<KSMetaData> keyspaces = new ArrayList<KSMetaData>();
        for (IColumn column : cf.getSortedColumns())
        {
            if (column.name().equals(DEFINITION_SCHEMA_COLUMN_NAME))
                continue;
            org.apache.cassandra.db.migration.avro.KsDef ks = SerDeUtils.deserialize(schema, column.value(), new org.apache.cassandra.db.migration.avro.KsDef());
            keyspaces.add(KSMetaData.fromAvro(ks));
        }
        return keyspaces;
    }
public static synchronized Collection < KSMetaData > loadFromStorage ( UUID version ) throws IOException { DecoratedKey vkey = StorageService . getPartitioner ( ) . decorateKey ( Migration . toUTF8Bytes ( version ) ) ; Table defs = Table . open ( Table . SYSTEM_TABLE ) ; ColumnFamilyStore cfStore = defs . getColumnFamilyStore ( Migration . SCHEMA_CF ) ; QueryFilter filter = QueryFilter . getIdentityFilter ( vkey , new QueryPath ( Migration . SCHEMA_CF ) ) ; ColumnFamily cf = cfStore . getColumnFamily ( filter ) ; IColumn avroschema = cf . getColumn ( DEFINITION_SCHEMA_COLUMN_NAME ) ; if ( avroschema == null ) throw new RuntimeException ( "Cannot read system table! Are you upgrading a pre-release version?" ) ; ByteBuffer value = avroschema . value ( ) ; Schema schema = Schema . parse ( ByteBufferUtil . string ( value ) ) ; Collection < KSMetaData > keyspaces = new ArrayList < KSMetaData > ( ) ; for ( IColumn column : cf . getSortedColumns ( ) ) { if ( column . name ( ) . equals ( DEFINITION_SCHEMA_COLUMN_NAME ) ) continue ; org . apache . cassandra . db . migration . avro . KsDef ks = SerDeUtils . deserialize ( schema , column . value ( ) , new org . apache . cassandra . db . migration . avro . KsDef ( ) ) ; keyspaces . add ( KSMetaData . fromAvro ( ks ) ) ; } return keyspaces ; }
loads a version of keyspace definitions from storage
loads a version of keyspace definitions from storage
// TODO: more polite way to handle this? // deserialize keyspaces using schema