@Override public long count() { return delegate.count(); }
@Override public long count(final boolean iPolymorphic) { return delegate.count(iPolymorphic); }
upperBound = oClass.count();
@Override public OResult next() { if (executed) { throw new IllegalStateException(); } long begin = profilingEnabled ? System.nanoTime() : 0; try { OClass clazz = ctx.getDatabase().getClass(target.getStringValue()); if (clazz == null) { throw new OCommandExecutionException("Class " + target.getStringValue() + " does not exist in the database schema"); } long size = clazz.count(); executed = true; OResultInternal result = new OResultInternal(); result.setProperty(alias, size); return result; } finally { if (profilingEnabled) { cost += (System.nanoTime() - begin); } } }
private List<OExecutionStepInternal> handleClassAsTargetWithIndexRecursive(String targetClass, Set<String> filterClusters, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { List<OExecutionStepInternal> result = handleClassAsTargetWithIndex(targetClass, filterClusters, info, ctx, profilingEnabled); if (result == null) { result = new ArrayList<>(); OClass clazz = ctx.getDatabase().getMetadata().getSchema().getClass(targetClass); if (clazz == null) { throw new OCommandExecutionException("Cannot find class " + targetClass); } if (clazz.count(false) != 0 || clazz.getSubclasses().size() == 0 || isDiamondHierarchy(clazz)) { return null; } Collection<OClass> subclasses = clazz.getSubclasses(); List<OInternalExecutionPlan> subclassPlans = new ArrayList<>(); for (OClass subClass : subclasses) { List<OExecutionStepInternal> subSteps = handleClassAsTargetWithIndexRecursive(subClass.getName(), filterClusters, info, ctx, profilingEnabled); if (subSteps == null || subSteps.size() == 0) { return null; } OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subSteps.stream().forEach(x -> subPlan.chain(x)); subclassPlans.add(subPlan); } if (subclassPlans.size() > 0) { result.add(new ParallelExecStep(subclassPlans, ctx, profilingEnabled)); } } return result.size() == 0 ? null : result; }
upperBound = filter.estimate(oClass, this.threshold, ctx); } else { upperBound = oClass.count();
final String className = parsedTarget.getTargetClasses().keySet().iterator().next(); final OClass cls = getDatabase().getMetadata().getImmutableSchemaSnapshot().getClass(className); count = cls.count(); } else if (parsedTarget.getTargetClusters() != null) { for (String cluster : parsedTarget.getTargetClusters().keySet()) {
throw new OCommandExecutionException("Cannot find class " + targetClass); if (clazz.count(false) != 0 || clazz.getSubclasses().size() == 0 || isDiamondHierarchy(clazz)) { return false;
@Override public long getDistributedTimeout() { final OClass cls = getDatabase().getMetadata().getSchema().getClass(className); if (className != null && cls != null) return getDatabase().getConfiguration().getValueAsLong(OGlobalConfiguration.DISTRIBUTED_COMMAND_QUICK_TASK_SYNCH_TIMEOUT) + (2 * cls.count()); return getDatabase().getConfiguration().getValueAsLong(OGlobalConfiguration.DISTRIBUTED_COMMAND_QUICK_TASK_SYNCH_TIMEOUT); }
throw new IllegalArgumentException("Class '" + iClassName + "' not found in database"); long totalOnDb = cls.count(iPolymorphic);
@Test public void testDeletionOfDependentClass2() { ODatabaseDocument db = wicket.getTester().getDatabase(); OSchema schema = db.getMetadata().getSchema(); OClass classAbs = schema.createAbstractClass("TestDeletionAbst"); OClass classA = schema.createClass("TestDeletionA", classAbs); ODocument doc = new ODocument(classA); doc.save(); assertEquals(1, classA.count()); OClass classB = schema.createClass("TestDeletionB", classA); doc = new ODocument(classB); doc.save(); assertEquals(1, classB.count()); assertEquals(2, classA.count()); schema.dropClass(classB.getName()); assertEquals(1, classA.count()); }
long count = oClass.count(); if (count > 1) { count = count / 2;
throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet"); final long recs = schemaClass.count(deep); if (recs > 0 && !unsafe) { if (schemaClass.isSubClassOf("V")) { if (deep && !unsafe) {// for multiple inheritance for (OClass subclass : subclasses) { long subclassRecs = schemaClass.count(); if (subclassRecs > 0) { if (subclass.isSubClassOf("V")) {
@Test public void testOQueryModelDBTouch() { OClass classA = wicket.getTester().getSchema().getClass("ClassA"); ODocument doc = new ODocument(classA); doc.field("other", Arrays.asList(doc)); OQueryModel<ODocument> queryModel = new OQueryModel<ODocument>("select from ClassA where :doc in other"); queryModel.setParameter("doc", new ODocumentModel(doc)); long was = classA.count(); assertTrue(doc.getIdentity().isNew()); assertEquals(0, queryModel.size()); assertTrue(doc.getIdentity().isNew()); assertEquals(was, classA.count()); }
@Override public OResultSet executeDDL(OCommandContext ctx) { OSchema schema = ctx.getDatabase().getMetadata().getSchema(); OClass clazz = schema.getClass(name.getStringValue()); if (clazz == null) { if (ifExists) { return new OInternalResultSet(); } throw new OCommandExecutionException("Class " + name.getStringValue() + " does not exist"); } if (!unsafe && clazz.count() > 0) { //check vertex or edge if (clazz.isVertexType()) { throw new OCommandExecutionException("'DROP CLASS' command cannot drop class '" + name.getStringValue() + "' because it contains Vertices. Use 'DELETE VERTEX' command first to avoid broken edges in a database, or apply the 'UNSAFE' keyword to force it"); } else if (clazz.isEdgeType()) { // FOUND EDGE CLASS throw new OCommandExecutionException("'DROP CLASS' command cannot drop class '" + name.getStringValue() + "' because it contains Edges. Use 'DELETE EDGE' command first to avoid broken vertices in a database, or apply the 'UNSAFE' keyword to force it"); } } schema.dropClass(name.getStringValue()); OInternalResultSet rs = new OInternalResultSet(); OResultInternal result = new OResultInternal(); result.setProperty("operation", "drop class"); result.setProperty("className", name.getStringValue()); rs.add(result); return rs; }
final long records = cls.count(true);