@Override public void getIndexes(final Collection<OIndex<?>> indexes) { delegate.getIndexes(indexes); }
@Override public Set<OIndex<?>> getIndexes() { return delegate.getIndexes(); }
@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(); } }
@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(); } }
@Override public Collection<OIndex<?>> getAllIndexes() { final Set<OIndex<?>> indexes = owner.getIndexes(); final List<OIndex<?>> indexList = new LinkedList<OIndex<?>>(); for (final OIndex<?> index : indexes) { final OIndexDefinition indexDefinition = index.getDefinition(); if (indexDefinition.getFields().contains(name)) indexList.add(index); } return indexList; }
private void checkNotIndexed(OClass oClass) { Set<OIndex<?>> indexes = oClass.getIndexes(); if (indexes != null && indexes.size() > 0) { throw new OCommandExecutionException("Cannot rename class '" + oClass.getName() + "' because it has indexes defined on it. Drop indexes before or use UNSAFE (at your won risk)"); } }
private OLuceneFullTextIndex searchForIndex(OCommandContext ctx, String className) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata.getSchema().getClass(className).getIndexes().stream() .filter(idx -> idx instanceof OLuceneFullTextIndex).map(idx -> (OLuceneFullTextIndex) idx).collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many full-text indices on given class: " + className); } return indices.size() == 0 ? null : indices.get(0); }
@Override public void getIndexes(final Collection<OIndex<?>> indexes) { initSuperClasses(); getClassIndexes(indexes); for (OClass superClass : superClasses) { superClass.getIndexes(indexes); } }
private OLuceneFullTextIndex searchForIndex(OCommandContext ctx, String className) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata .getSchema() .getClass(className) .getIndexes() .stream() .filter(idx -> idx instanceof OLuceneFullTextIndex) .map(idx -> (OLuceneFullTextIndex) idx) .collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many full-text indices on given class: " + className); } return indices.size() == 0 ? null : indices.get(0); }
private OLuceneFullTextIndex searchForIndex(String className, OCommandContext ctx, List<String> fieldNames) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata.getSchema().getClass(className).getIndexes().stream() .filter(idx -> idx instanceof OLuceneFullTextIndex).map(idx -> (OLuceneFullTextIndex) idx) .filter(idx -> intersect(idx.getDefinition().getFields(), fieldNames)).collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many indices matching given field name: " + String.join(",", fieldNames)); } return indices.size() == 0 ? null : indices.get(0); }
@Override public void getIndexes(final Collection<OIndex<?>> indexes) { acquireSchemaReadLock(); try { getClassIndexes(indexes); for (OClass superClass : superClasses) { superClass.getIndexes(indexes); } } finally { releaseSchemaReadLock(); } }
protected OLuceneSpatialIndex searchForIndex(OFromClause target, OExpression[] args) { OMetadata dbMetadata = getDb().getMetadata(); OFromItem item = target.getItem(); OIdentifier identifier = item.getIdentifier(); String fieldName = args[0].toString(); String className = identifier.getStringValue(); List<OLuceneSpatialIndex> indices = dbMetadata .getSchema() .getClass(className) .getIndexes() .stream() .filter(idx -> idx instanceof OLuceneSpatialIndex) .map(idx -> (OLuceneSpatialIndex) idx) .filter(idx -> intersect(idx.getDefinition().getFields(), Arrays.asList(fieldName))) .collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many indices matching given field name: " + String.join(",", fieldName)); } return indices.size() == 0 ? null : indices.get(0); }
private void checkIndexes(ODocument document, TYPE hookType) { document = checkForLoading(document); final OClass cls = document.getSchemaClass(); if (cls != null) { final Collection<OIndex<?>> indexes = cls.getIndexes(); switch (hookType) { case BEFORE_CREATE: checkIndexedPropertiesOnCreation(document, indexes); break; case BEFORE_UPDATE: checkIndexedPropertiesOnUpdate(document, indexes); break; default: throw new IllegalArgumentException("Invalid hook type: " + hookType); } } }
return; final Collection<OIndex<?>> indexes = new ArrayList<OIndex<?>>(cls.getIndexes());
public void register(final ODatabaseDocumentTx db, @Nullable final Runnable initializer) { checkNotNull(db); OSchema schema = db.getMetadata().getSchema(); OClass type = schema.getClass(typeName); if (type == null) { int clusters = getMinimumClusters(); type = clusters > 0 ? schema.createClass(typeName, clusters) : schema.createClass(typeName); defineType(db, type); log.debug("Created schema type '{}': properties={}, indexes={}", type, type.properties(), type.getIndexes() ); if (initializer != null) { log.debug("Running initializer: {}", initializer); initializer.run(); } } this.dbName = db.getName(); this.schemaType = type; if (sendEvents() && entityHook != null) { entityHook.enableEvents(this); } if (resolveConflicts() && conflictHook != null) { conflictHook.enableConflictResolution(this); if (!conflictHook.equals(db.getConflictStrategy())) { db.setConflictStrategy(conflictHook); } } }
clusterNames[i] = database.getClusterNameById(clustersToIndex[i]); for (OIndex<?> index : superClass.getIndexes()) for (String clusterName : clusterNames) if (clusterName != null)
@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(); }
private void addIndexesEntries(ODocument document) { document = checkForLoading(document); // STORE THE RECORD IF NEW, OTHERWISE ITS RID final OIdentifiable rid = document.getIdentity().isPersistent() ? document.placeholder() : document; final OClass cls = document.getSchemaClass(); if (cls != null) { final Collection<OIndex<?>> indexes = cls.getIndexes(); for (final OIndex<?> index : indexes) { final Object key = index.getDefinition().getDocumentValueToIndex(document); // SAVE A COPY TO AVOID PROBLEM ON RECYCLING OF THE RECORD if (key instanceof Collection) { for (final Object keyItem : (Collection<?>) key) if (keyItem != null) index.put(keyItem, rid); } else if (key != null) index.put(key, rid); } } }
OIndex<?> realizedNewIndex = ((IPrototype<OIndex<?>>)newIndex).realizePrototype(); assertEquals(1, property.getAllIndexes().size()); assertEquals(1, newClass.getIndexes().size()); realizedNewIndex = ((IPrototype<OIndex<?>>)newIndex).realizePrototype(); assertEquals(1, property.getAllIndexes().size()); assertEquals(2, newClass.getIndexes().size()); assertEquals("test123", realizedNewIndex.getMetadata().field("test"));
tester.assertRenderedPage(OPropertyPage.class); Collection<OIndex<?>> indexes = oClass.getIndexes(); for (OIndex<?> oIndex : indexes)