当前位置: 首页>>代码示例>>Java>>正文


Java IndexType类代码示例

本文整理汇总了Java中org.apache.cassandra.config.IndexType的典型用法代码示例。如果您正苦于以下问题:Java IndexType类的具体用法?Java IndexType怎么用?Java IndexType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexType类属于org.apache.cassandra.config包,在下文中一共展示了IndexType类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: announceMigration

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
public void announceMigration() throws InvalidRequestException, ConfigurationException
{
    logger.debug("Updating column {} definition for index {}", columnName, indexName);
    CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).clone();
    ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);

    if (cd.getIndexType() != null && ifNotExists)
        return;

    if (isCustom)
        cd.setIndexType(IndexType.CUSTOM, Collections.singletonMap(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, indexClass));
    else if (cfm.getCfDef().isComposite)
        cd.setIndexType(IndexType.COMPOSITES, Collections.<String, String>emptyMap());
    else
        cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap());

    cd.setIndexName(indexName);
    cfm.addDefaultIndexNames();
    MigrationManager.announceColumnFamilyUpdate(cfm, false);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:21,代码来源:CreateIndexStatement.java

示例2: announceMigration

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
public boolean announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
    IndexTarget target = rawTarget.prepare(cfm);
    logger.debug("Updating column {} definition for index {}", target.column, indexName);
    ColumnDefinition cd = cfm.getColumnDefinition(target.column);

    if (cd.getIndexType() != null && ifNotExists)
        return false;

    if (properties.isCustom)
    {
        cd.setIndexType(IndexType.CUSTOM, properties.getOptions());
    }
    else if (cfm.comparator.isCompound())
    {
        Map<String, String> options = Collections.emptyMap();
        // For now, we only allow indexing values for collections, but we could later allow
        // to also index map keys, so we record that this is the values we index to make our
        // lives easier then.
        if (cd.type.isCollection() && cd.type.isMultiCell())
            options = ImmutableMap.of(target.isCollectionKeys ? SecondaryIndex.INDEX_KEYS_OPTION_NAME
                                                              : SecondaryIndex.INDEX_VALUES_OPTION_NAME, "");
        cd.setIndexType(IndexType.COMPOSITES, options);
    }
    else
    {
        cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap());
    }

    cd.setIndexName(indexName);
    cfm.addDefaultIndexNames();
    MigrationManager.announceColumnFamilyUpdate(cfm, false, isLocalOnly);
    return true;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:36,代码来源:CreateIndexStatement.java

示例3: announceMigration

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
public boolean announceMigration(boolean isLocalOnly) throws RequestValidationException
{
    logger.debug("Updating column {} definition for index {}", target.column, indexName);
    CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
    ColumnDefinition cd = cfm.getColumnDefinition(target.column);

    if (cd.getIndexType() != null && ifNotExists)
        return false;

    if (properties.isCustom)
    {
        cd.setIndexType(IndexType.CUSTOM, properties.getOptions());
    }
    else if (cfm.comparator.isCompound())
    {
        Map<String, String> options = Collections.emptyMap();
        // For now, we only allow indexing values for collections, but we could later allow
        // to also index map keys, so we record that this is the values we index to make our
        // lives easier then.
        if (cd.type.isCollection())
            options = ImmutableMap.of(target.isCollectionKeys ? "index_keys" : "index_values", "");
        cd.setIndexType(IndexType.COMPOSITES, options);
    }
    else
    {
        cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap());
    }

    cd.setIndexName(indexName);
    cfm.addDefaultIndexNames();
    MigrationManager.announceColumnFamilyUpdate(cfm, false, isLocalOnly);
    return true;
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:34,代码来源:CreateIndexStatement.java

示例4: announceMigration

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
public void announceMigration() throws RequestValidationException
{
    for(IndexTarget target: columnNames){
        logger.debug("Updating column {} definition for index {}", target.column, indexName);
        CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).clone();
        ColumnDefinition cd = cfm.getColumnDefinition(target.column);

        if (cd.getIndexType() != null && ifNotExists)
            return;

        if (properties.isCustom)
        {
            cd.setIndexType(IndexType.CUSTOM, properties.getOptions());
        }
        else if (cfm.comparator.isCompound())
        {
            Map<String, String> options = Collections.emptyMap();
            // For now, we only allow indexing values for collections, but we could later allow
            // to also index map keys, so we record that this is the values we index to make our
            // lives easier then.
            if (cd.type.isCollection())
                options = ImmutableMap.of(target.isCollectionKeys ? "index_keys" : "index_values", "");
            cd.setIndexType(IndexType.COMPOSITES, options);
        }
        else
        {
            cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap());
        }

        cd.setIndexName(indexName);
        cfm.addDefaultIndexNames();
        MigrationManager.announceColumnFamilyUpdate(cfm, false);
    }
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:35,代码来源:CreateIndexStatement.java

示例5: testMemtableUpdateWithRangeTombstonesUpdatesSecondaryIndex

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
@Test
public void testMemtableUpdateWithRangeTombstonesUpdatesSecondaryIndex() throws Exception
{
    Keyspace table = Keyspace.open(KSNAME);
    ColumnFamilyStore cfs = table.getColumnFamilyStore(CFNAME);
    ByteBuffer key = ByteBufferUtil.bytes("k5");
    ByteBuffer indexedColumnName = ByteBufferUtil.bytes(1);

    cfs.truncateBlocking();
    cfs.disableAutoCompaction();
    cfs.setCompactionStrategyClass(SizeTieredCompactionStrategy.class.getCanonicalName());
    if (cfs.indexManager.getIndexForColumn(indexedColumnName) == null)
    {
        ColumnDefinition cd = ColumnDefinition.regularDef(cfs.metadata, indexedColumnName, cfs.getComparator().asAbstractType(), 0)
                                              .setIndex("test_index", IndexType.CUSTOM, ImmutableMap.of(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, TestIndex.class.getName()));
        cfs.indexManager.addIndexedColumn(cd);
    }

    TestIndex index = ((TestIndex)cfs.indexManager.getIndexForColumn(indexedColumnName));
    index.resetCounts();

    Mutation rm = new Mutation(KSNAME, key);
    for (int i = 0; i < 10; i++)
        add(rm, i, 0);
    rm.apply();

    // We should have indexed 1 column
    assertEquals(1, index.inserts.size());

    rm = new Mutation(KSNAME, key);
    ColumnFamily cf = rm.addOrGet(CFNAME);
    for (int i = 0; i < 10; i += 2)
        delete(cf, 0, 7, 0);
    rm.apply();

    // verify that the 1 indexed column was removed from the index
    assertEquals(1, index.deletes.size());
    assertEquals(index.deletes.get(0), index.inserts.get(0));
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:40,代码来源:RangeTombstoneTest.java

示例6: announceMigration

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
public void announceMigration() throws RequestValidationException
{
    logger.debug("Updating column {} definition for index {}", target.column, indexName);
    CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
    ColumnDefinition cd = cfm.getColumnDefinition(target.column);

    if (cd.getIndexType() != null && ifNotExists)
        return;

    if (properties.isCustom)
    {
        cd.setIndexType(IndexType.CUSTOM, properties.getOptions());
    }
    else if (cfm.comparator.isCompound())
    {
        Map<String, String> options = Collections.emptyMap();
        // For now, we only allow indexing values for collections, but we could later allow
        // to also index map keys, so we record that this is the values we index to make our
        // lives easier then.
        if (cd.type.isCollection())
            options = ImmutableMap.of(target.isCollectionKeys ? "index_keys" : "index_values", "");
        cd.setIndexType(IndexType.COMPOSITES, options);
    }
    else
    {
        cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap());
    }

    cd.setIndexName(indexName);
    cfm.addDefaultIndexNames();
    MigrationManager.announceColumnFamilyUpdate(cfm, false);
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:33,代码来源:CreateIndexStatement.java

示例7: testOverwritesToDeletedColumns

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
@Test
public void testOverwritesToDeletedColumns() throws Exception
{
    Keyspace table = Keyspace.open(KSNAME);
    ColumnFamilyStore cfs = table.getColumnFamilyStore(CFNAME);
    ByteBuffer key = ByteBufferUtil.bytes("k6");
    ByteBuffer indexedColumnName = ByteBufferUtil.bytes(1);

    cfs.truncateBlocking();
    cfs.disableAutoCompaction();
    cfs.setCompactionStrategyClass(SizeTieredCompactionStrategy.class.getCanonicalName());
    if (cfs.indexManager.getIndexForColumn(indexedColumnName) == null)
    {
        ColumnDefinition cd = new ColumnDefinition(cfs.metadata, indexedColumnName, Int32Type.instance, null, ColumnDefinition.Kind.REGULAR);
        cd.setIndex("test_index", IndexType.CUSTOM, ImmutableMap.of(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, TestIndex.class.getName()));
        cfs.indexManager.addIndexedColumn(cd);
    }

    TestIndex index = ((TestIndex)cfs.indexManager.getIndexForColumn(indexedColumnName));
    index.resetCounts();

    Mutation rm = new Mutation(KSNAME, key);
    add(rm, 1, 0);
    rm.apply();

    // add a RT which hides the column we just inserted
    rm = new Mutation(KSNAME, key);
    ColumnFamily cf = rm.addOrGet(CFNAME);
    delete(cf, 0, 1, 1);
    rm.apply();

    // now re-insert that column
    rm = new Mutation(KSNAME, key);
    add(rm, 1, 2);
    rm.apply();

    cfs.forceBlockingFlush();

    // We should have 1 insert and 1 update to the indexed "1" column
    // CASSANDRA-6640 changed index update to just update, not insert then delete
    assertEquals(1, index.inserts.size());
    assertEquals(1, index.updates.size());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:44,代码来源:RangeTombstoneTest.java

示例8: runCompactionWithRangeTombstoneAndCheckSecondaryIndex

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
private void runCompactionWithRangeTombstoneAndCheckSecondaryIndex() throws Exception
{
    Keyspace table = Keyspace.open(KSNAME);
    ColumnFamilyStore cfs = table.getColumnFamilyStore(CFNAME);
    ByteBuffer key = ByteBufferUtil.bytes("k5");
    ByteBuffer indexedColumnName = ByteBufferUtil.bytes(1);

    cfs.truncateBlocking();
    cfs.disableAutoCompaction();
    cfs.setCompactionStrategyClass(SizeTieredCompactionStrategy.class.getCanonicalName());
    if (cfs.indexManager.getIndexForColumn(indexedColumnName) == null)
    {
        ColumnDefinition cd = ColumnDefinition.regularDef(cfs.metadata, indexedColumnName, cfs.getComparator().asAbstractType(), 0)
                                              .setIndex("test_index", IndexType.CUSTOM, ImmutableMap.of(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, TestIndex.class.getName()));
        cfs.indexManager.addIndexedColumn(cd);
    }

    TestIndex index = ((TestIndex)cfs.indexManager.getIndexForColumn(indexedColumnName));
    index.resetCounts();

    Mutation rm = new Mutation(KSNAME, key);
    for (int i = 0; i < 10; i++)
        add(rm, i, 0);
    rm.apply();
    cfs.forceBlockingFlush();

    rm = new Mutation(KSNAME, key);
    ColumnFamily cf = rm.addOrGet(CFNAME);
    for (int i = 0; i < 10; i += 2)
        delete(cf, 0, 7, 0);
    rm.apply();
    cfs.forceBlockingFlush();

    // We should have indexed 1 column
    assertEquals(1, index.inserts.size());

    CompactionManager.instance.performMaximal(cfs);

    // compacted down to single sstable
    assertEquals(1, cfs.getSSTables().size());

    // verify that the 1 indexed column was removed from the index
    assertEquals(1, index.deletes.size());
    assertEquals(index.deletes.get(0), index.inserts.get(0));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:46,代码来源:RangeTombstoneTest.java

示例9: testMemtableUpdateWithRangeTombstonesUpdatesSecondaryIndex

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
@Test
public void testMemtableUpdateWithRangeTombstonesUpdatesSecondaryIndex() throws Exception
{
    Keyspace table = Keyspace.open(KSNAME);
    ColumnFamilyStore cfs = table.getColumnFamilyStore(CFNAME);
    ByteBuffer key = ByteBufferUtil.bytes("k5");
    ByteBuffer indexedColumnName = ByteBufferUtil.bytes(1);

    cfs.truncateBlocking();
    cfs.disableAutoCompaction();
    cfs.setCompactionStrategyClass(SizeTieredCompactionStrategy.class.getCanonicalName());
    if (cfs.indexManager.getIndexForColumn(indexedColumnName) == null)
    {
        ColumnDefinition cd = new ColumnDefinition(indexedColumnName,
                                                   cfs.getComparator(),
                                                   IndexType.CUSTOM,
                                                   ImmutableMap.of(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, TestIndex.class.getName()),
                                                   "test_index",
                                                   0,
                                                   null);
        cfs.indexManager.addIndexedColumn(cd);
    }

    TestIndex index = ((TestIndex)cfs.indexManager.getIndexForColumn(indexedColumnName));
    index.resetCounts();

    RowMutation rm = new RowMutation(KSNAME, key);
    for (int i = 0; i < 10; i++)
        add(rm, i, 0);
    rm.apply();

    // We should have indexed 1 column
    assertEquals(1, index.inserts.size());

    rm = new RowMutation(KSNAME, key);
    ColumnFamily cf = rm.addOrGet(CFNAME);
    for (int i = 0; i < 10; i += 2)
        delete(cf, 0, 7, 0);
    rm.apply();

    // verify that the 1 indexed column was removed from the index
    assertEquals(1, index.deletes.size());
    assertEquals(index.deletes.get(0), index.inserts.get(0));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:45,代码来源:RangeTombstoneTest.java

示例10: runCompactionWithRangeTombstoneAndCheckSecondaryIndex

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
private void runCompactionWithRangeTombstoneAndCheckSecondaryIndex() throws Exception
{
    Keyspace table = Keyspace.open(KSNAME);
    ColumnFamilyStore cfs = table.getColumnFamilyStore(CFNAME);
    ByteBuffer key = ByteBufferUtil.bytes("k5");
    ByteBuffer indexedColumnName = ByteBufferUtil.bytes(1);

    cfs.truncateBlocking();
    cfs.disableAutoCompaction();
    cfs.setCompactionStrategyClass(SizeTieredCompactionStrategy.class.getCanonicalName());
    if (cfs.indexManager.getIndexForColumn(indexedColumnName) == null)
    {
        ColumnDefinition cd = new ColumnDefinition(indexedColumnName,
                                                   cfs.getComparator(),
                                                   IndexType.CUSTOM,
                                                   ImmutableMap.of(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, TestIndex.class.getName()),
                                                   "test_index",
                                                   0,
                                                   null);
        cfs.indexManager.addIndexedColumn(cd);
    }

    TestIndex index = ((TestIndex)cfs.indexManager.getIndexForColumn(indexedColumnName));
    index.resetCounts();

    RowMutation rm = new RowMutation(KSNAME, key);
    for (int i = 0; i < 10; i++)
        add(rm, i, 0);
    rm.apply();
    cfs.forceBlockingFlush();

    rm = new RowMutation(KSNAME, key);
    ColumnFamily cf = rm.addOrGet(CFNAME);
    for (int i = 0; i < 10; i += 2)
        delete(cf, 0, 7, 0);
    rm.apply();
    cfs.forceBlockingFlush();

    // We should have indexed 1 column
    assertEquals(1, index.inserts.size());

    CompactionManager.instance.performMaximal(cfs);

    // compacted down to single sstable
    assertEquals(1, cfs.getSSTables().size());

    // verify that the 1 indexed column was removed from the index
    assertEquals(1, index.deletes.size());
    assertEquals(index.deletes.get(0), index.inserts.get(0));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:51,代码来源:RangeTombstoneTest.java

示例11: testOverwritesToDeletedColumns

import org.apache.cassandra.config.IndexType; //导入依赖的package包/类
@Test
public void testOverwritesToDeletedColumns() throws Exception
{
    Keyspace table = Keyspace.open(KSNAME);
    ColumnFamilyStore cfs = table.getColumnFamilyStore(CFNAME);
    ByteBuffer key = ByteBufferUtil.bytes("k6");
    ByteBuffer indexedColumnName = ByteBufferUtil.bytes(1);

    cfs.truncateBlocking();
    cfs.disableAutoCompaction();
    cfs.setCompactionStrategyClass(SizeTieredCompactionStrategy.class.getCanonicalName());
    if (cfs.indexManager.getIndexForColumn(indexedColumnName) == null)
    {
        ColumnDefinition cd = new ColumnDefinition(cfs.metadata, indexedColumnName, Int32Type.instance, null, ColumnDefinition.Kind.REGULAR);
        cd.setIndex("test_index", IndexType.CUSTOM, ImmutableMap.of(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, TestIndex.class.getName()));
        cfs.indexManager.addIndexedColumn(cd);
    }

    TestIndex index = ((TestIndex)cfs.indexManager.getIndexForColumn(indexedColumnName));
    index.resetCounts();

    Mutation rm = new Mutation(KSNAME, key);
    add(rm, 1, 0);
    rm.apply();

    // add a RT which hides the column we just inserted
    rm = new Mutation(KSNAME, key);
    ColumnFamily cf = rm.addOrGet(CFNAME);
    delete(cf, 0, 1, 1);
    rm.apply();

    // now re-insert that column
    rm = new Mutation(KSNAME, key);
    add(rm, 1, 2);
    rm.apply();

    cfs.forceBlockingFlush();

    // We should have 1 insert and 1 update to the indexed "1" column
    // CASSANDRA-6640 changed index update to just update, not insert then delete
    assertEquals(1, index.inserts.size());
    assertEquals(1, index.updates.size());

    CompactionManager.instance.performMaximal(cfs);

    // verify that the "1" indexed column removed from the index
    // After CASSANDRA-6640, deletion only happens once
    assertEquals(1, index.deletes.size());
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:50,代码来源:RangeTombstoneTest.java


注:本文中的org.apache.cassandra.config.IndexType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。