Esempio n. 1
0
        internal Collection(Scheme scheme, string name, bool justInCache)
        {
            //  예외문자 처리
            {
                string pattern = @"^[a-zA-Z0-9_]*$";
                if (System.Text.RegularExpressions.Regex.IsMatch(name, pattern) == false)
                {
                    throw new AegisException(RoseResult.InvalidArgument, $"Not allowed character contains on CollectionName({name}).");
                }
            }


            if (scheme.GetCollection(name, false) != null)
            {
                throw new AegisException(RoseResult.DuplicateName, "The same collection name exists.");
            }

            CachedObjects = new CachedObjects(this);
            IndexMap      = new IndexMap(this);
            _indexKeys    = new List <string>();

            ParentScheme = scheme;
            Name         = name;
            JustInCache  = justInCache;

            AfterObjectAdd += OnDataAdded;
        }
Esempio n. 2
0
        internal void AddData(string objectId, string data)
        {
            DataObject obj = DataObject.NewObject(objectId, data);

            CachedObjects.Add(objectId, JToken.Parse(data));
            AfterObjectAdd(this, obj);
        }
Esempio n. 3
0
        public void AddIndex(string index)
        {
            //  데이터 전체를 Scan하여 해당 Index를 갖고있는 객체를 모두 IndexMap에 추가
            using (WriterLock)
            {
                if (_indexKeys.Contains(index) == true)
                {
                    return;
                }

                _indexKeys.Add(index);


                var collectionData = CachedObjects.GetAllData();
                foreach (var data in collectionData.Values)
                {
                    if (data.ContainsKey(index) == true)
                    {
                        IndexMap.Add(index, data.ObjectId);
                    }
                }
            }

            Storage.StorageEngine.Engine.AddIndex(this, index);
        }
Esempio n. 4
0
 internal void RemoveData(List <DataObject> candidates)
 {
     using (WriterLock)
     {
         IndexMap.RemoveData(candidates);
         CachedObjects.Remove(candidates);
     }
 }
Esempio n. 5
0
        internal DataObject AddData(JToken data)
        {
            string     objectId = GenerateObjectId();
            DataObject obj      = DataObject.NewObject(objectId, data);

            CachedObjects.Add(objectId, data);
            AfterObjectAdd(this, obj);

            return(obj);
        }
Esempio n. 6
0
        internal Collection(Scheme scheme, string name, string jsonText, bool justInCache)
        {
            CachedObjects = new CachedObjects(this);
            IndexMap      = new IndexMap(this);
            _indexKeys    = new List <string>();

            ParentScheme = scheme;
            Name         = name;
            JustInCache  = justInCache;

            AfterObjectAdd += OnDataAdded;
        }
Esempio n. 7
0
        internal Dictionary <string, DataObject> GetObjects(string index)
        {
            List <string> objectIds;

            if (index != null && ContainsIndex(index) == true)
            {
                objectIds = IndexMap.GetChunk(index)?.GetAllObjectId();
                Logger.Debug("dbg Indexed scan {0}.", index);
            }
            else
            {
                objectIds = CachedObjects.GetAllObjectId();
                Logger.Debug("dbg Dirty scan {0}.", index);
            }


            return(objectIds.ToDictionary(v => v, v => CachedObjects.GetData(v)));
        }