Ejemplo n.º 1
0
        public IndexChunk GetChunk(string indexName)
        {
            IndexChunk chunk = null;

            using (_lock.ReaderLock)
                _indexes.TryGetValue(indexName, out chunk);

            return(chunk);
        }
Ejemplo n.º 2
0
        public void Add(string indexName, string objectId)
        {
            //  objectId를 Chunk에 추가
            IndexChunk chunk;

            using (_lock.ReaderLock)
                _indexes.TryGetValue(indexName, out chunk);

            if (chunk == null)
            {
                //  Double lock checking
                using (_lock.WriterLock)
                {
                    _indexes.TryGetValue(indexName, out chunk);
                    if (chunk == null)
                    {
                        chunk = new IndexChunk();
                        _indexes.Add(indexName, chunk);
                    }
                }
            }

            chunk.Add(objectId);


            //  objectId에 연관된 Chunk로 추가
            using (_lock.WriterLock)
            {
                List <IndexChunk> chunkList;
                _chunkListByObjectId.TryGetValue(objectId, out chunkList);
                if (chunkList == null)
                {
                    chunkList = new List <IndexChunk>();
                    _chunkListByObjectId.Add(objectId, chunkList);
                }

                if (chunkList.Contains(chunk) == false)
                {
                    chunkList.Add(chunk);
                }
            }
        }