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


Java OIndex类代码示例

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


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

示例1: checkIndexUniqueness

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
@Override
public <T extends MeshElement> T checkIndexUniqueness(String indexName, T element, Object key) {
	FramedGraph graph = Tx.getActive().getGraph();
	OrientBaseGraph orientBaseGraph = unwrapCurrentGraph();

	OrientVertexType vertexType = orientBaseGraph.getVertexType(element.getClass().getSimpleName());
	if (vertexType != null) {
		OIndex<?> index = vertexType.getClassIndex(indexName);
		if (index != null) {
			Object recordId = index.get(key);
			if (recordId != null) {
				if (recordId.equals(element.getElement().getId())) {
					return null;
				} else {
					return (T) graph.getFramedVertexExplicit(element.getClass(), recordId);
				}
			}
		}
	}
	return null;
}
 
开发者ID:gentics,项目名称:mesh,代码行数:22,代码来源:OrientDBDatabase.java

示例2: build

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
public OIndex build(final ODatabaseDocumentTx db) {
  checkState(!propertyNames.isEmpty(), "At least one property is required");
  checkState(propertyTypes.size() == propertyNames.size(), "A type must be defined for each property");

  List<OCollate> collates = null;
  if (caseInsensitive) {
    collates = Lists.transform(propertyNames, n -> new OCaseInsensitiveCollate());
  }

  ODocument metadata = new ODocument();
  if (ignoreNullValues) {
    metadata.field("ignoreNullValues", true);
  }

  OIndexDefinition indexDefinition = OIndexDefinitionFactory.createIndexDefinition(type, propertyNames, propertyTypes,
      collates, indexType.name(), null);

  return db.getMetadata().getIndexManager().createIndex(name, indexType.name(), indexDefinition,
      type.getPolymorphicClusterIds(), null, metadata.fields() > 0 ? metadata : null);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:21,代码来源:OIndexBuilder.java

示例3: getIndexedElements

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
private <ElementType extends OrientElement> Stream<ElementType> getIndexedElements(
        OIndex<Object> index,
        Iterator<Object> valuesIter,
        BiFunction<OrientGraph, OIdentifiable, ElementType> newElement) {
    return executeWithConnectionCheck(() -> {
        makeActive();

        if (index == null) {
            return Collections.<ElementType> emptyList().stream();
        } else {
            if (!valuesIter.hasNext()) {
                return index.cursor().toValues().stream().map(id -> newElement.apply(this, id));
            } else {
                Stream<Object> convertedValues = StreamUtils.asStream(valuesIter).map(value -> convertValue(index, value));
                Stream<OIdentifiable> ids = convertedValues.flatMap(v -> lookupInIndex(index, v)).filter(r -> r != null);
                Stream<ORecord> records = ids.map(id -> id.getRecord());
                return records.map(r -> newElement.apply(this, getRawDocument(r)));
            }
        }
    });
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:22,代码来源:OrientGraph.java

示例4: vertexUniqueIndexLookupWithValue

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
@Test
public void vertexUniqueIndexLookupWithValue() {
    OrientGraph graph = newGraph();
    createVertexIndexLabel(graph, vertexLabel1);
    String value = "value1";

    // verify index created
    Assert.assertEquals(graph.getIndexedKeys(Vertex.class, vertexLabel1), new HashSet<>(Collections.singletonList(key)));
    Assert.assertEquals(graph.getIndexedKeys(Vertex.class, vertexLabel2), new HashSet<>(Collections.emptyList()));
    Assert.assertEquals(graph.getIndexedKeys(Edge.class, vertexLabel1), new HashSet<>(Collections.emptyList()));

    Vertex v1 = graph.addVertex(label, vertexLabel1, key, value);
    Vertex v2 = graph.addVertex(label, vertexLabel2, key, value);

    // looking deep into the internals here - I can't find a nicer way to
    // auto verify that an index is actually used
    GraphTraversal<Vertex, Vertex> traversal = graph.traversal().V().has(label, P.eq(vertexLabel1)).has(key, P.eq(value));

    OIndex index = findUsedIndex(traversal).iterator().next().index;
    Assert.assertEquals(1, index.getSize());
    Assert.assertEquals(v1.id(), index.get(value));

    List<Vertex> result = traversal.toList();
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(v1.id(), result.get(0).id());
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:27,代码来源:OrientGraphIndexTest.java

示例5: executeIndexQuery

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
@Override
public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) {
  OIndexCursor cursor;
  Object key;
  key = keyParams.get(0);

  Map<String, Object> queryParams = new HashMap<String, Object>();
  queryParams.put(SpatialQueryBuilderAbstract.GEO_FILTER, SpatialQueryBuilderOverlap.NAME);
  queryParams.put(SpatialQueryBuilderAbstract.SHAPE, key);

  long start = System.currentTimeMillis();
  OLuceneAbstractResultSet indexResult = (OLuceneAbstractResultSet) index.get(queryParams);
  if (indexResult == null || indexResult instanceof OIdentifiable)
    cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, new OSpatialCompositeKey(keyParams));
  else
    cursor = new OIndexCursorCollectionValue(((Collection<OIdentifiable>) indexResult), new OSpatialCompositeKey(
        keyParams));

  if (indexResult != null)
    indexResult.sendLookupTime(iContext, start);
  return cursor;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:23,代码来源:OLuceneOverlapOperator.java

示例6: searchForIndex

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
protected OIndex searchForIndex(OFromClause target, OExpression[] args) {

    // TODO Check if target is a class otherwise exception

    OFromItem item = target.getItem();
    OBaseIdentifier identifier = item.getIdentifier();
    String fieldName = args[0].toString();

    Set<OIndex<?>> indexes = getDb().getMetadata().getIndexManager().getClassInvolvedIndexes(identifier.toString(), fieldName);
    for (OIndex<?> index : indexes) {
      if (index.getInternal() instanceof OLuceneSpatialIndex) {
        return index;
      }
    }
    return null;
  }
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:17,代码来源:OSpatialFunctionAbstract.java

示例7: results

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
protected LuceneResultSet results(OFromClause target, OExpression[] args, OCommandContext ctx) {
  OIndex oIndex = searchForIndex(target, args);
  if (oIndex != null) {
    Map<String, Object> queryParams = new HashMap<String, Object>();
    queryParams.put(SpatialQueryBuilderAbstract.GEO_FILTER, operator());
    Object shape;
    if (args[1].getValue() instanceof OJson) {
      OJson json = (OJson) args[1].getValue();
      ODocument doc = new ODocument().fromJSON(json.toString());
      shape = doc.toMap();
    } else {
      shape = args[1].execute(null, ctx);
    }
    queryParams.put(SpatialQueryBuilderAbstract.SHAPE, shape);
    return (LuceneResultSet) oIndex.get(queryParams);
  }
  return null;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:19,代码来源:OSpatialFunctionAbstract.java

示例8: testIndexingPolygon

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
@Test(enabled = true)
public void testIndexingPolygon() throws IOException {

  InputStream systemResourceAsStream = ClassLoader.getSystemResourceAsStream("germany.json");

  ODocument doc = new ODocument().fromJSON(systemResourceAsStream);

  Map geometry = doc.field("geometry");

  String type = (String) geometry.get("type");
  ODocument location = new ODocument("O" + type);
  location.field("coordinates", geometry.get("coordinates"));
  ODocument germany = new ODocument("Place");
  germany.field("name", "Germany");
  germany.field("location", location);
  databaseDocumentTx.save(germany);

  OIndex<?> index = databaseDocumentTx.getMetadata().getIndexManager().getIndex("Place.location");

  Assert.assertEquals(index.getSize(), 1);
  queryPolygon();

}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:24,代码来源:LuceneSpatialPolygonTest.java

示例9: getOrCreateFieldIndex

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
protected OIndex<?> getOrCreateFieldIndex(final String field, final Class<?> valueClass) {
	final String idxName = getSBTreeIndexName(valueClass);
	final OIndexManager indexManager = getIndexManager();
	OIndex<?> idx = indexManager.getIndex(idxName);

	if (idx == null) {
		createIndex(valueClass);

		// We need to fetch again the index: using the one that was just
		// created will result in multithreading exceptions from OrientDB
		idx = indexManager.getIndex(idxName);

		if (type == IndexType.NODE) {
			graph.getIndexStore().addNodeFieldIndex(name, field);
		} else {
			graph.getIndexStore().addEdgeFieldIndex(name, field);
		}
	}

	return idx;
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:22,代码来源:AbstractOrientIndex.java

示例10: remove

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
@Override
public void remove(IGraphNode n) {
	final OrientNode oNode = (OrientNode)n;

	final OIdentifiable toRemove = oNode.getId().isPersistent() ? oNode.getId() : oNode.getDocument();
	List<Entry<String, Map<String, List<Object>>>> indices = oNode.removeIndexFields(escapedName);
	for (Entry<String, Map<String, List<Object>>> index : indices) {
		final String indexName = index.getKey();
		OIndex<?> oIndex = getIndexManager().getIndex(indexName);
		for (Entry<String, List<Object>> idxEntry : index.getValue().entrySet()) {
			final String field = idxEntry.getKey();
			for (Object key : idxEntry.getValue()) {
				oIndex.remove(new OCompositeKey(field, key), toRemove);
			}
		}
	}
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:18,代码来源:OrientNodeIndex.java

示例11: getData

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
@Override
public Collection<OIndex<?>> getData() {
	OClass oClass = oClassModel.getObject();
	if(oClass==null)
	{
		return null;
	}
	else if(allIndexesModel==null||Boolean.TRUE.equals(allIndexesModel.getObject()))
	{
		return oClass.getIndexes();
	}
	else
	{
		return oClass.getClassIndexes();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:17,代码来源:ListOIndexesModel.java

示例12: testOIndexDataProvider

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
@Test
public void testOIndexDataProvider()
{
	OSchema schema = wicket.getTester().getSchema();
	OClass oClass = schema.getClass("OUser");
	OIndexesDataProvider provider = new OIndexesDataProvider(oClass, true);
	provider.setSort("name", SortOrder.ASCENDING);
	Iterator<? extends OIndex<?>> it = provider.iterator(0, -1);
	List<OIndex<?>> allIndexes = new ArrayList<OIndex<?>>(oClass.getIndexes());
	while(it.hasNext())
	{
		OIndex<?> oIndex = it.next();
		assertTrue(allIndexes.remove(provider.model(oIndex).getObject()));
	}
	assertTrue(allIndexes.size()==0);
	provider.detach();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:18,代码来源:TestModels.java

示例13: testListModels

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
@Test
public void testListModels()
{
	IModel<String> classNameModel = Model.of();
	IModel<OClass> classModel = new OClassModel(classNameModel);
	IModel<List<OProperty>> propertiesModel = new ListOPropertiesModel(classModel, null);
	IModel<List<OIndex<?>>> indexesModel = new ListOIndexesModel(classModel, null);
	List<OProperty> properties = propertiesModel.getObject();
	List<OIndex<?>> indexes = indexesModel.getObject();
	assertNotNull(properties);
	assertNotNull(indexes);
	assertTrue(properties.isEmpty());
	assertTrue(indexes.isEmpty());
	classModel.detach();
	propertiesModel.detach();
	indexesModel.detach();
	
	classNameModel.setObject("OUser");
	properties = propertiesModel.getObject();
	indexes = indexesModel.getObject();
	assertNotNull(properties);
	assertNotNull(indexes);
	assertFalse(properties.isEmpty());
	assertFalse(indexes.isEmpty());
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:26,代码来源:TestModels.java

示例14: isIndexCorrect

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
private boolean isIndexCorrect(final IndexValidationSupport support, final OClass.INDEX_TYPE type,
                               final FulltextIndex annotation) {
    final OIndex classIndex = support.getIndex();
    final ODocument metadata = classIndex.getConfiguration();
    final Iterable<String> field = metadata.field(STOP_WORDS);
    return support
            .isIndexSigns(metadata.field(INDEX_RADIX),
                    metadata.field(IGNORE_CHARS),
                    metadata.field(SEPARATOR_CHARS),
                    metadata.field(MIN_WORD_LENGTH),
                    Sets.newHashSet(field))
            .matchRequiredSigns(type, annotation.indexRadix(),
                    annotation.ignoreChars(),
                    annotation.separatorChars(),
                    annotation.minWordLength(),
                    Sets.newHashSet(annotation.stopWords()));
}
 
开发者ID:xvik,项目名称:guice-persist-orient,代码行数:18,代码来源:FulltextIndexFieldExtension.java

示例15: involvedIndex

import com.orientechnologies.orient.core.index.OIndex; //导入依赖的package包/类
protected OLuceneFullTextIndex involvedIndex(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition,
    Object iLeft, Object iRight) {

  ODocument doc = iRecord.getRecord();
  Set<OIndex<?>> classInvolvedIndexes = getDatabase().getMetadata().getIndexManager()
      .getClassInvolvedIndexes(doc.getClassName(), fields(iCondition));

  OLuceneFullTextIndex idx = null;
  for (OIndex<?> classInvolvedIndex : classInvolvedIndexes) {

    if (classInvolvedIndex.getInternal() instanceof OLuceneFullTextIndex) {
      idx = (OLuceneFullTextIndex) classInvolvedIndex.getInternal();
      break;
    }
  }
  return idx;
}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:18,代码来源:OLuceneTextOperator.java


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