예제 #1
0
        public FullTextIndex(StorageEnvironmentOptions options, IAnalyzer analyzer)
        {
            Analyzer           = analyzer;
            Conventions        = new IndexingConventions();
            BufferPool         = new BufferPool();
            StorageEnvironment = new StorageEnvironment(options);

            using (var tx = StorageEnvironment.NewTransaction(TransactionFlags.ReadWrite))
            {
                StorageEnvironment.CreateTree(tx, "@terms", keysPrefixing: true);
                StorageEnvironment.CreateTree(tx, "deletes", keysPrefixing: true);
                var docs = StorageEnvironment.CreateTree(tx, "docs", keysPrefixing: true);

                var metadata = StorageEnvironment.CreateTree(tx, "$metadata");
                var idVal    = metadata.Read("id");
                if (idVal == null)
                {
                    Id = Guid.NewGuid();
                    metadata.Add("id", Id.ToByteArray());
                }
                else
                {
                    int _;
                    Id = new Guid(idVal.Reader.ReadBytes(16, out _));
                }
                using (var it = docs.Iterate())
                {
                    _lastDocumentId = it.Seek(Slice.AfterAllKeys) == false ?
                                      0 :
                                      it.CurrentKey.CreateReader().ReadBigEndianInt64();
                }
                tx.Commit();
            }
        }
예제 #2
0
        public FullTextIndex(StorageEnvironmentOptions options, IAnalyzer analyzer)
        {
            Analyzer = analyzer;
            Conventions = new IndexingConventions();
            BufferPool = new BufferPool();
            StorageEnvironment = new StorageEnvironment(options);

            using (var tx = StorageEnvironment.NewTransaction(TransactionFlags.ReadWrite))
            {
                ReadMetadata(tx);
                ReadLastDocumentId(tx);
                ReadFields(tx);

                tx.Commit();
            }
        }
예제 #3
0
        public FullTextIndex(StorageEnvironmentOptions options, IAnalyzer analyzer)
        {
            Analyzer = analyzer;
            Conventions = new IndexingConventions();
            BufferPool = new BufferPool();
            StorageEnvironment = new StorageEnvironment(options);

            using (var tx = StorageEnvironment.NewTransaction(TransactionFlags.ReadWrite))
            {
                StorageEnvironment.CreateTree(tx, "TermPositions");
                ReadMetadata(tx);
                ReadLastDocumentId(tx);
                ReadFields(tx);

                tx.Commit();
            }
        }