///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Creates the index.
        /// </summary>
        /// <exception cref="NotImplementedException">
        ///  Thrown when the requested operation is unimplemented.
        /// </exception>
        /// <param name="metaclass">
        ///  .
        /// </param>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <param name="unique">
        ///  true to unique.
        /// </param>
        /// <param name="propertyNames">
        ///  List of names of the properties.
        /// </param>
        /// <returns>
        ///  The new index.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public IIndex CreateIndex(ISchemaElement metaclass, string name, bool unique, params string[] propertyNames)
        {
            DebugContract.Requires(metaclass);
            DebugContract.RequiresNotEmpty(name);

            return(_indexManager.CreateIndex(metaclass, name, unique, propertyNames));
        }
Example #2
0
        private void Initialize(string domainModelName, int memoryStoreVacuumIntervalInSeconds, ITransactionManager transactionManager, IHyperstoreTrace trace, IStatistics stat)
        {
            DebugContract.RequiresNotEmpty(domainModelName);
            DebugContract.Requires(transactionManager);

            _trace = trace ?? new EmptyHyperstoreTrace();
            _transactionManager = transactionManager;
            if (memoryStoreVacuumIntervalInSeconds < 0)
            {
                memoryStoreVacuumIntervalInSeconds = defaultInterval;
            }

            _jobScheduler  = new JobScheduler(Vacuum, TimeSpan.FromSeconds(memoryStoreVacuumIntervalInSeconds));
            _involvedSlots = PlatformServices.Current.CreateConcurrentQueue <SlotList>();

            if (stat == null)
            {
                stat = EmptyStatistics.DefaultInstance;
            }

            _vaccumCounter = VACUUM_EVICTIONS_THROTTLE;

            _statAddValue      = stat.RegisterCounter("MemoryStore", String.Format("#AddValue {0}", domainModelName), domainModelName, StatisticCounterType.Value);
            _statGeIGraphNode  = stat.RegisterCounter("MemoryStore", String.Format("#GeIGraphNode {0}", domainModelName), domainModelName, StatisticCounterType.Value);
            _statUpdateValue   = stat.RegisterCounter("MemoryStore", String.Format("#UpdateValue {0}", domainModelName), domainModelName, StatisticCounterType.Value);
            _statRemoveValue   = stat.RegisterCounter("MemoryStore", String.Format("#RemoveValue {0}", domainModelName), domainModelName, StatisticCounterType.Value);
            _statVaccumCount   = stat.RegisterCounter("MemoryStore", String.Format("#Vaccum{0}", domainModelName), domainModelName, StatisticCounterType.Value);
            _statVaccumAverage = stat.RegisterCounter("MemoryStore", String.Format("VaccumAvgTimes{0}", domainModelName), domainModelName, StatisticCounterType.Average);
            _statVaccumSkipped = stat.RegisterCounter("MemoryStore", String.Format("#VaccumSkipped{0}", domainModelName), domainModelName, StatisticCounterType.Value);
        }
Example #3
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Gets the metadata.
        /// </summary>
        /// <exception cref="MetadataNotFoundException">
        ///  Thrown when a Metadata Not Found error condition occurs.
        /// </exception>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <param name="throwErrorIfNotExists">
        ///  (Optional) true to throw error if not exists.
        /// </param>
        /// <returns>
        ///  The schema information.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        ISchemaInfo ISchema.GetSchemaInfo(string name, bool throwErrorIfNotExists)
        {
            DebugContract.RequiresNotEmpty(name);

            ISchemaInfo metaClass;

            if (_metadatasByName.TryGetValue(name, out metaClass))
            {
                return(metaClass);
            }

            metaClass = _metadatas.Values.FirstOrDefault(m => m.Name == name);
            if (metaClass != null)
            {
                lock (_metadatasByName)
                {
                    if (!_metadatasByName.ContainsKey(name))
                    {
                        _metadatasByName.Add(name, metaClass);
                    }
                }
                return(metaClass);
            }

            if (throwErrorIfNotExists)
            {
                throw new MetadataNotFoundException(name);
            }

            return(null);
        }
        private IndexDefinition GetIndexDefinition(string indexName)
        {
            DebugContract.RequiresNotEmpty(indexName);

            IndexDefinition def;

            _indexByNames.TryGetValue(indexName, out def);
            return(def);
        }
Example #5
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Constructor.
        /// </summary>
        /// <param name="graph">
        ///  The graph.
        /// </param>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <param name="unique">
        ///  true to unique.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        public BTreeIndex(IHyperGraph graph, string name, bool unique)
        {
            DebugContract.Requires(graph);
            DebugContract.RequiresNotEmpty(name);

            _graph  = new WeakReference(graph);
            Name    = name;
            _unique = unique;
        }
Example #6
0
        internal ConstraintContext(ISessionContext sessionContext, string category, ConstraintKind kind)
        {
            DebugContract.Requires(sessionContext);
            DebugContract.RequiresNotEmpty(category);

            this._sessionContext = sessionContext;
            this._messages       = _sessionContext.Result;
            this._category       = category;
            this.ConstraintKind  = kind;
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Constructor.
        /// </summary>
        /// <param name="services">
        ///  The services.
        /// </param>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <param name="extensionName">
        ///  Name of the extension.
        /// </param>
        /// <param name="extendeDomainModel">
        ///  The extende domain model.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        public DomainScope(IServicesContainer services, string name, string extensionName, IDomainModel extendeDomainModel)
            : base(services, name)
        {
            DebugContract.Requires(services);
            DebugContract.RequiresNotEmpty(name);
            DebugContract.Requires(extendeDomainModel);
            DebugContract.RequiresNotEmpty(extensionName);

            ExtensionName       = extensionName;
            ExtendedDomainModel = extendeDomainModel;
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Constructor.
        /// </summary>
        /// <param name="domainModel">
        ///  The domain model.
        /// </param>
        /// <param name="id">
        ///  The identifier.
        /// </param>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <param name="metadata">
        ///  The metadata.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        public PrimitiveMetaProperty(PrimitivesSchema domainModel, Identity id, string name, ISchemaValueObject metadata)
            : base(domainModel, typeof(SchemaProperty), domainModel.SchemaEntitySchema, name: name, id: id)
        {
            DebugContract.Requires(domainModel, "domainModel");
            DebugContract.RequiresNotEmpty(name);
            DebugContract.Requires(metadata, "metadata");
            DebugContract.Requires(id, "id");

            _metadata = metadata;
            ((PrimitivesSchema)domainModel).RegisterMetadata(this);
        }
            ///-------------------------------------------------------------------------------------------------
            /// <summary>
            ///  Specialised constructor for use only by derived classes.
            /// </summary>
            /// <param name="metaclass">
            ///  The metaclass.
            /// </param>
            /// <param name="indexName">
            ///  The name of the index.
            /// </param>
            /// <param name="id">
            ///  The identifier.
            /// </param>
            /// <param name="key">
            ///  The key.
            /// </param>
            ///-------------------------------------------------------------------------------------------------
            protected IndexAction(ISchemaElement metaclass, string indexName, Identity id, object key)
            {
                DebugContract.Requires(metaclass);
                DebugContract.Requires(id);
                DebugContract.RequiresNotEmpty(indexName);

                SchemaElement = metaclass;
                Id            = id;
                Key           = key;
                IndexName     = indexName;
            }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Ensureses the metadata exists.
        /// </summary>
        /// <param name="domainModel">
        ///  The domain model.
        /// </param>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <returns>
        ///  An ISchemaElement.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        protected override ISchemaElement EnsuresSchemaExists(IDomainModel domainModel, string name)
        {
            DebugContract.Requires(domainModel);
            DebugContract.RequiresNotEmpty(name);

            //if (ReflectionHelper.IsGenericType(GetType(), typeof (SchemaEntity<>)))
            //{
            //    // Optimisation
            //    return PrimitivesSchema.SchemaEntitySchema;
            //}

            return(base.EnsuresSchemaExists(domainModel, name));
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Resolve type.
        /// </summary>
        /// <param name="assemblyQualifiedTypeName">
        ///  Name of the assembly qualified type.
        /// </param>
        /// <returns>
        ///  A Type.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        protected override Type ResolveType(string assemblyQualifiedTypeName)
        {
            DebugContract.RequiresNotEmpty(assemblyQualifiedTypeName);

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            try
            {
                return(Type.GetType(assemblyQualifiedTypeName));
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
            }
        }
Example #12
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Ensureses the metadata exists.
        /// </summary>
        /// <param name="domainModel">
        ///  The domain model.
        /// </param>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <returns>
        ///  An ISchemaElement.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        protected override ISchemaElement EnsuresSchemaExists(IDomainModel domainModel, string name)
        {
            DebugContract.Requires(domainModel);
            DebugContract.RequiresNotEmpty(name);

            var type = GetType();

            if (type == typeof(SchemaEntity)) // Evite boucle infinie
            {
                return(domainModel.Store.PrimitivesSchema.SchemaEntitySchema);
            }

            return(base.EnsuresSchemaExists(domainModel, name));
        }
        internal void RemoveFromIndex(ISchemaElement metaclass, string indexName, Identity id, object key)
        {
            DebugContract.Requires(metaclass);
            DebugContract.RequiresNotEmpty(indexName);
            DebugContract.Requires(id);

            var def = GetIndexDefinition(indexName);

            if (def == null)
            {
                return;
            }

            def.Index.Remove(id, key);
        }
Example #14
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Constructor.
        /// </summary>
        /// <param name="graph">
        ///  The graph.
        /// </param>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <param name="metaClass">
        ///  The meta class.
        /// </param>
        /// <param name="unique">
        ///  true to unique.
        /// </param>
        /// <param name="propertyNames">
        ///  A list of names of the properties.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        public IndexDefinition(IHyperGraph graph, string name, ISchemaElement metaClass, bool unique, params string[] propertyNames)
        {
            DebugContract.Requires(graph);
            DebugContract.RequiresNotEmpty(name);
            DebugContract.Requires(metaClass);

            if (propertyNames.Length > 0)
            {
                PropertyNames = new string[propertyNames.Length];
                for (var i = 0; i < propertyNames.Length; i++)
                {
                    PropertyNames[i] = propertyNames[i];
                }
            }
            MetaClass = metaClass;
            Index     = new BTreeIndex(graph, name, unique);
        }
        internal IEnumerable <Identity> GetPendingIndexFor(string name, object key)
        {
            DebugContract.RequiresNotEmpty(name);

            var set = new HashSet <Identity>();

            foreach (var result in _indexActions.Where(a => a.IndexName == name))
            {
                if (result is RemoveFromIndexAction)
                {
                    set.Remove(result.Id);
                }
                else if (Equals(result.Key, key))
                {
                    set.Add(result.Id);
                }
            }
            return(set);
        }
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  Query if 'name' is name equals.
 /// </summary>
 /// <param name="name">
 ///  Domain name - Extensions shares the domain name.
 /// </param>
 /// <returns>
 ///  true if name equals, false if not.
 /// </returns>
 ///-------------------------------------------------------------------------------------------------
 public bool IsNameEquals(string name)
 {
     DebugContract.RequiresNotEmpty(name);
     return(String.Compare(Name, name, StringComparison.OrdinalIgnoreCase) == 0);
 }
        //   [DebuggerStepThrough]

        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Gets domain model.
        /// </summary>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <returns>
        ///  The domain model.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public T GetActiveScope(string name)
        {
            DebugContract.RequiresNotEmpty(name, "name");
            return(GetActiveScopes()
                   .FirstOrDefault(d => String.Compare(d.Name, name, StringComparison.CurrentCultureIgnoreCase) == 0));
        }
        protected virtual Type ResolveType(string assemblyQualifiedTypeName)
        {
            DebugContract.RequiresNotEmpty(assemblyQualifiedTypeName);

            return(Type.GetType(assemblyQualifiedTypeName));
        }
Example #19
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Drops the index.
        /// </summary>
        /// <exception cref="NotImplementedException">
        ///  Thrown when the requested operation is unimplemented.
        /// </exception>
        /// <param name="name">
        ///  The name.
        /// </param>
        ///-------------------------------------------------------------------------------------------------
        public void DropIndex(string name)
        {
            DebugContract.RequiresNotEmpty(name);

            _indexManager.DropIndex(name);
        }
Example #20
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Retourne un index.
        /// </summary>
        /// <param name="name">
        ///  The name.
        /// </param>
        /// <returns>
        ///  The index.
        /// </returns>
        ///-------------------------------------------------------------------------------------------------
        public IIndex GetIndex(string name)
        {
            DebugContract.RequiresNotEmpty(name);

            return(_indexManager.GetIndex(name));
        }
Example #21
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>
 ///  Gets the meta relationship.
 /// </summary>
 /// <param name="name">
 ///  The name.
 /// </param>
 /// <param name="throwErrorIfNotExists">
 ///  (Optional) true to throw error if not exists.
 /// </param>
 /// <returns>
 ///  The schema relationship.
 /// </returns>
 ///-------------------------------------------------------------------------------------------------
 ISchemaRelationship ISchema.GetSchemaRelationship(string name, bool throwErrorIfNotExists)
 {
     DebugContract.RequiresNotEmpty(name, "name");
     return(((ISchema)this).GetSchemaInfo(name, throwErrorIfNotExists) as ISchemaRelationship);
 }