deletes all rows from m:n table that are not used in relatedObjects

@param cod
@param obj
@param collectionIterator
@param mnKeys
16589
public void deleteMtoNImplementor(CollectionDescriptor cod, Object obj, Iterator collectionIterator, Collection mnKeys)
    {
        if(mnKeys.isEmpty() || collectionIterator == null)
        {
            return;
        }
        List workList = new ArrayList(mnKeys);
        MtoNBroker.Key relatedObjKeys;
        ClassDescriptor relatedCld = pb.getDescriptorRepository().getDescriptorFor(cod.getItemClass());
        Object relatedObj;

        // remove keys of relatedObject from the existing m:n rows in workList
        while(collectionIterator.hasNext())
        {
            relatedObj = collectionIterator.next();
            relatedObjKeys = new MtoNBroker.Key(pb.serviceBrokerHelper().getKeyValues(relatedCld, relatedObj, true));
            workList.remove(relatedObjKeys);
        }

        // delete all remaining keys in workList
        ClassDescriptor cld = pb.getDescriptorRepository().getDescriptorFor(obj.getClass());
        ValueContainer[] pkValues = pb.serviceBrokerHelper().getKeyValues(cld, obj);

        String[] pkColumns = cod.getFksToThisClass();
        String[] fkColumns = cod.getFksToItemClass();
        String table = cod.getIndirectionTable();
        String deleteStmt;

        ValueContainer[] fkValues;
        Iterator iter = workList.iterator();
        while(iter.hasNext())
        {
            fkValues = ((MtoNBroker.Key) iter.next()).m_containers;
            deleteStmt = pb.serviceSqlGenerator().getDeleteMNStatement(table, pkColumns, fkColumns);
            pb.serviceJdbcAccess().executeUpdateSQL(deleteStmt, cld, pkValues, fkValues);
        }
    }
694760
def _delete_collection(self, ctx):
        
        assert isinstance(ctx, ResourceQueryContext)

        filter_by = ctx.get_filter_by()
        q = self._orm.query(self.model_cls)

        if filter_by is not None:
            q = self.to_filter(q, filter_by)

        return q.delete()
412323
@Override
  public <T> T remove(Object objectToRemove, String collectionName) {
    if (null == objectToRemove) {
      throw new InvalidJsonDbApiUsageException("Null Object cannot be removed from DB");
    }
    Util.ensureNotRestricted(objectToRemove);

    CollectionMetaData collectionMeta = cmdMap.get(collectionName);
    collectionMeta.getCollectionLock().writeLock().lock();
    try {
      @SuppressWarnings("unchecked")
      Map<Object, T> collection = (Map<Object, T>) collectionsRef.get().get(collectionName);
      if (null == collection) {
        throw new InvalidJsonDbApiUsageException("Collection by name '" + collectionName + "' not found. Create collection first.");
      }

      CollectionMetaData cmd = cmdMap.get(collectionName);
      Object id = Util.getIdForEntity(objectToRemove, cmd.getIdAnnotatedFieldGetterMethod());
      if (!collection.containsKey(id)) {
        throw new InvalidJsonDbApiUsageException(String.format("Objects with Id %s not found in collection %s", id, collectionName));
      }

      JsonWriter jw;
      try {
        jw = new JsonWriter(dbConfig, cmd, collectionName, fileObjectsRef.get().get(collectionName));
      } catch (IOException ioe) {
        logger.error("Failed to obtain writer for " + collectionName, ioe);
        throw new JsonDBException("Failed to save " + collectionName, ioe);
      }
      boolean substractResult = jw.removeFromJsonFile(collection, id);
      if(substractResult) {
        T objectRemoved = collection.remove(id);
        // Don't need to clone it, this object no more exists in the collection
        return objectRemoved;
      } else {
        return null;
      }
    } finally {
      collectionMeta.getCollectionLock().writeLock().unlock();
    }
  }
1341667
public void deleteFromIndexes(DecoratedKey key, List<Cell> indexedColumnsInRow, OpOrder.Group opGroup)
    {
        // Update entire row only once per row level index
        Set<Class<? extends SecondaryIndex>> cleanedRowLevelIndexes = null;

        for (Cell cell : indexedColumnsInRow)
        {
            for (SecondaryIndex index : indexFor(cell.name()))
            {
                if (index instanceof PerRowSecondaryIndex)
                {
                    if (cleanedRowLevelIndexes == null)
                        cleanedRowLevelIndexes = new HashSet<>();
                    if (cleanedRowLevelIndexes.add(index.getClass()))
                        ((PerRowSecondaryIndex) index).delete(key, opGroup);
                }
                else
                {
                    ((PerColumnSecondaryIndex) index).deleteForCleanup(key.getKey(), cell, opGroup);
                }
            }
        }
    }
56880
private void deleteByQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
    {
        if (logger.isDebugEnabled())
        {
            logger.debug("deleteByQuery " + cld.getClassNameOfObject() + ", " + query);
        }

        if (query instanceof QueryBySQL)
        {
            String sql = ((QueryBySQL) query).getSql();
            this.dbAccess.executeUpdateSQL(sql, cld);
        }
        else
        {
            // if query is Identity based transform it to a criteria based query first
            if (query instanceof QueryByIdentity)
            {
                QueryByIdentity qbi = (QueryByIdentity) query;
                Object oid = qbi.getExampleObject();
                // make sure it's an Identity
                if (!(oid instanceof Identity))
                {
                    oid = serviceIdentity().buildIdentity(oid);
                }
                query = referencesBroker.getPKQuery((Identity) oid);
            }

            if (!cld.isInterface())
            {
                this.dbAccess.executeDelete(query, cld);
            }

            // if class is an extent, we have to delete all extent classes too
            String lastUsedTable = cld.getFullTableName();
            if (cld.isExtent())
            {
                Iterator extents = getDescriptorRepository().getAllConcreteSubclassDescriptors(cld).iterator();

                while (extents.hasNext())
                {
                    ClassDescriptor extCld = (ClassDescriptor) extents.next();

                    // read same table only once
                    if (!extCld.getFullTableName().equals(lastUsedTable))
                    {
                        lastUsedTable = extCld.getFullTableName();
                        this.dbAccess.executeDelete(query, extCld);
                    }
                }
            }

        }
    }
1059011
public void clear() {
		Mutator<K> mutator = HFactory.createMutator(this.keyspace, this.keySerializer, new BatchSizeHint(1, this.mutateInterval));

		SliceCounterQuery<K, N> query = HFactory.createCounterSliceQuery(this.keyspace, this.keySerializer, this.nameSerializer).
						setColumnFamily(this.cf).
						setKey(this.rowKey);

		SliceCounterIterator<K, N> iterator =
						new SliceCounterIterator<K, N>(query, null, (N) null, false, this.count);

		while(iterator.hasNext()) {
			HCounterColumn<N> column = iterator.next();
			mutator.incrementCounter(this.rowKey, this.cf, column.getName(), column.getValue() * -1);
		}

		mutator.execute();
	}
537754
def delete(self, obj, matches=None, mt=None, lt=None, eq=None):
        '''
        
        '''
        deleted = False
        objects = list()
        for _obj in self.get(obj):
            if not self.__criteria(_obj, matches=matches, mt=mt, lt=lt, eq=eq):
                objects.append(_obj)
            else:
                deleted = True

        self.flush(obj._TABLE)
        self.create_table_from_object(obj())
        for _obj in objects:
            self.store(_obj)

        return deleted
1319181
public static <E> void removeKeys(Counter<E> counter, Collection<E> removeKeysCollection) {

    for (E key : removeKeysCollection)
      counter.remove(key);
  }
201239
@Override
  public <T> List<T> remove(Collection<? extends T> batchToRemove, String collectionName) {
    if (null == batchToRemove) {
      throw new InvalidJsonDbApiUsageException("Null Object batch cannot be removed from DB");
    }
    CollectionMetaData cmd = cmdMap.get(collectionName);
    cmd.getCollectionLock().writeLock().lock();
    try {
      @SuppressWarnings("unchecked")
      Map<Object, T> collection = (Map<Object, T>) collectionsRef.get().get(collectionName);
      if (null == collection) {
        throw new InvalidJsonDbApiUsageException("Collection by name '" + collectionName + "' not found. Create collection first.");
      }

      Set<Object> removeIds = new HashSet<Object>();

      for (T o : batchToRemove) {
        Object id = Util.getIdForEntity(o, cmd.getIdAnnotatedFieldGetterMethod());
        if (collection.containsKey(id)) {
          removeIds.add(id);
        }
      }

      if(removeIds.size() < 1) {
        return null;
      }

      JsonWriter jw;
      try {
        jw = new JsonWriter(dbConfig, cmd, collectionName, fileObjectsRef.get().get(collectionName));
      } catch (IOException ioe) {
        logger.error("Failed to obtain writer for " + collectionName, ioe);
        throw new JsonDBException("Failed to save " + collectionName, ioe);
      }
      boolean substractResult = jw.removeFromJsonFile(collection, removeIds);

      List<T> removedObjects = null;
      if(substractResult) {
        removedObjects = new ArrayList<T>();
        for (Object id : removeIds) {
          // Don't need to clone it, this object no more exists in the collection
          removedObjects.add(collection.remove(id));
        }
      }
      return removedObjects;
    } finally {
      cmd.getCollectionLock().writeLock().unlock();
    }
  }
1010685
public void deleteObjects(Collection objects)
    {
        for (Iterator iterator = objects.iterator(); iterator.hasNext();)
        {
            getDatabase().deletePersistent(iterator.next());
        }
    }
21233
protected synchronized void clear()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "clear"
                            );
        // All ManagedObjects are new sequence number up to initialSequenceNumber are reserved.
        sequenceNumber = initialSequenceNumber;
        allocationAllowed = true;

        inMemoryTokens = new WeakValueConcurrentHashMap(concurrency);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "clear"
                            );
    }
971675
@Override
    public void delete(Object entity, Object pKey)
    {
        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entity.getClass());
        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());
        AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(entityMetadata.getEntityClazz());

        DBObject query = new BasicDBObject();

        if (managedType.hasLobAttribute())
        {
            KunderaGridFS gfs = new KunderaGridFS(mongoDb, entityMetadata.getTableName());
            String id = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName();
            query.put("metadata." + id, pKey);
            gfs.remove(query);
        }

        else
        {
            if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType()))
            {
                MongoDBUtils.populateCompoundKey(query, entityMetadata, metaModel, pKey);
            }
            else
            {
                query.put("_id", MongoDBUtils.populateValue(pKey, pKey.getClass()));
            }
            // For secondary tables.
            List<String> secondaryTables = ((DefaultEntityAnnotationProcessor) managedType.getEntityAnnotation())
                    .getSecondaryTablesName();
            secondaryTables.add(entityMetadata.getTableName());

            for (String collectionName : secondaryTables)
            {
                KunderaCoreUtils.printQuery("Drop existing collection:" + query, showQuery);
                DBCollection dbCollection = mongoDb.getCollection(collectionName);
                dbCollection.remove(query, getWriteConcern(), encoder);
            }

            getIndexManager().remove(entityMetadata, entity, pKey);
        }
    }
485368
function collectionResultIterator (context, results) {
    // create new result object
    var result = new ImmutableCoreModelResult({
        query: this.query,
        results: results,
    })
    // execute iterator
    return result.each((record, num) => {
        // get result
        return this.applyModelViewCollection(context, num, record.raw)
        // merge result to context
        .then(ctx => {
            _.merge(context, ctx)
        })
    })
    // resolve with context
    .then(() => context)
}
902920
def delete(self):
        
        for related_collection_name in self.related_collections:
            related_collection = getattr(self, related_collection_name)
            related_collection.remove_instance()
        return super(RelatedModel, self).delete()
609206
void removeFromIndexes(TransactionContext transactionContext, Object key) {
      Stream<IndexedTypeIdentifier> typeIdentifiers = getKnownClasses().stream()
            .filter(searchFactoryHandler::hasIndex)
            .map(PojoIndexedTypeIdentifier::new);
      Set<Work> deleteWorks = typeIdentifiers
            .map(e -> searchWorkCreator.createEntityWork(keyToString(key), e, WorkType.DELETE))
            .collect(Collectors.toSet());
      performSearchWorks(deleteWorks, transactionContext);
   }
675314
public List<DynamoDBMapper.FailedBatch> batchDelete(Iterable<T> objectsToDelete) {
        return mapper.batchWrite((Iterable<T>)Collections.<T>emptyList(), objectsToDelete);
    }
315946
public void deleteNodeIndex(EntityMetadata entityMetadata, GraphDatabaseService graphDb, Node node)
    {
        if (!isNodeAutoIndexingEnabled(graphDb) && entityMetadata.isIndexable())
        {
            Index<Node> nodeIndex = graphDb.index().forNodes(entityMetadata.getIndexName());
            nodeIndex.remove(node);
        }
    }