Пример #1
0
        public override Exceptional<IObject> Aggregate(AAttributeIndex attributeIndex, GraphDBType graphDBType, DBContext dbContext)
        {
            //if (graphDBType.IsAbstract)
            //{
            //    #region For abstract types, count all attribute idx of the subtypes

            //    UInt64 count = 0;

            //    foreach (var aSubType in dbContext.DBTypeManager.GetAllSubtypes(graphDBType, false))
            //    {
            //        if (!aSubType.IsAbstract)
            //        {
            //            count += aSubType.GetUUIDIndex(dbContext.DBTypeManager).GetValueCount();
            //        }
            //    }

            //    return new Exceptional<IObject>(new DBUInt64(count));

            //    #endregion
            //}
            //else
            //{
                #region Return the count of idx values

                var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(attributeIndex.IndexRelatedTypeUUID);

                return new Exceptional<IObject>(new DBUInt64(attributeIndex.GetValueCount()));

                #endregion
            //}
        }
Пример #2
0
        /// <summary>
        /// Count the index elements
        /// <seealso cref=" ABaseAggregate"/>
        /// </summary>
        public override Exceptional<FuncParameter> Aggregate(AAttributeIndex attributeIndex, GraphDBType graphDBType, DBContext dbContext)
        {
            //if (graphDBType.IsAbstract)
            //{
            //    #region For abstract types, count all attribute idx of the subtypes

            //    UInt64 count = 0;

            //    foreach (var aSubType in dbContext.DBTypeManager.GetAllSubtypes(graphDBType, false))
            //    {
            //        if (!aSubType.IsAbstract)
            //        {
            //            count += aSubType.GetUUIDIndex(dbContext.DBTypeManager).GetValueCount();
            //        }
            //    }

            //    return new Exceptional<IObject>(new DBUInt64(count));

            //    #endregion
            //}
            //else
            //{
            #region Return the count of idx values

            var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(attributeIndex.IndexRelatedTypeUUID);
            var count = attributeIndex.GetValueCount(dbContext, indexRelatedType);

            foreach (var type in dbContext.DBTypeManager.GetAllSubtypes(indexRelatedType, false))
            {
                var idx = type.GetAttributeIndex(dbContext, attributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs, attributeIndex.IndexEdition);
                if (idx.Success())
                {
                    count += idx.Value.GetValueCount(dbContext, type);
                }
            }

            return new Exceptional<FuncParameter>(new FuncParameter(new DBUInt64(count)));

            #endregion
            //}
        }