• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java OIndexFactory类的典型用法和代码示例

java 2次浏览

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

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

示例1: createIndex

点赞 2

import com.orientechnologies.orient.core.index.OIndexFactory; //导入依赖的package包/类
/**
 * Creates the SBTree index paired to this field within this logical index.
 */
protected void createIndex(final Class<?> keyClass) {
	final OIndexManager indexManager = getIndexManager();

	// Indexes have to be created outside transactions
	final String idxName = getSBTreeIndexName(keyClass);
	final boolean txWasOpen = graph.getGraph().getTransaction().isActive();
	if (txWasOpen) {
		graph.getConsole().println("Warning: prematurely committing a transaction so we can create index " + idxName);
		graph.saveDirty();
		graph.getGraph().commit();
	}

	// Index key type
	OType keyType = OType.STRING;
	if (keyClass == Byte.class || keyClass == Short.class || keyClass == Integer.class || keyClass == Long.class) {
		keyType = OType.INTEGER;
	} else if (keyClass == Float.class || keyClass == Double.class) {
		keyType = OType.DOUBLE;
	}

	// Create SBTree NOTUNIQUE index
    final OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.NOTUNIQUE.toString(), null);
	
	final OSimpleKeyIndexDefinition indexDef = new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.STRING, keyType);
	indexManager.createIndex(idxName, OClass.INDEX_TYPE.NOTUNIQUE.toString(), indexDef, null, null, null, null);
}
 

开发者ID:mondo-project,
项目名称:mondo-hawk,
代码行数:30,
代码来源:AbstractOrientIndex.java

示例2: ODocumentWrapper

点赞 2

import com.orientechnologies.orient.core.index.OIndexFactory; //导入依赖的package包/类
public <B extends TransientObject> ODocumentWrapper(B b){
    super();

    String className = b.getObjectType();
    this.setAllowChainedAccess(true);
    this.setLazyLoad(false);


    // dirty unreliable hack to add HighLanderIndexFactory to the list.
    if(!OIndexes.getIndexTypes().contains(ID))
    try {
        HighLanderIndexFactory f = new HighLanderIndexFactory();
        Set<OIndexFactory> set = new HashSet<OIndexFactory>();
        Iterator<OIndexFactory> ite = OIndexes.getAllFactories();
        while (ite.hasNext()) {
            set.add(ite.next());
        }
        set.add(f);
        ReflectionUtils.setFinalStatic(ReflectionUtils.getClassField(OIndexes.class, "FACTORIES"), set);
    } catch (Exception e) {
        throw new RuntimeException("Unable to create OrientDBWrapper");
    }

    if(getDatabase().getClusterIdByName(className) == -1){
        OClass object = getDatabase().getMetadata().getSchema().getOrCreateClass(className);
        object.createProperty(indexAttribute, OType.STRING)
                .setMandatory(true)
                .setNotNull(true)
                .setReadonly(true);
        object.createIndex(className, ID, indexAttribute);
        getDatabase().getMetadata().getSchema().save();
    }

    Map user = b.getUserData();
    Map meta = b.getMetaData();

    field(indexAttribute, b.getObjectKey(), OType.STRING);
    field("user_data", user);
    field("meta_data", meta);
    super.setClassNameIfExists(className);

    System.out.println("DB: " + getDatabase().getName() + " : " + this.getClassName() + " : " + getDatabase().getClusterIdByName(className));
}
 

开发者ID:williamwebb,
项目名称:divide,
代码行数:44,
代码来源:ODocumentWrapper.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)