Esempio n. 1
0
        private long Merge(string srcIxFileName)
        {
            Log.InfoFormat("merging branch {0} with trunk {1}", _ixFilesToProcess[1], _ixFilesToProcess[0]);

            var  ix = IxInfo.Load(srcIxFileName);
            var  documentFileName = Path.Combine(_directory, ix.VersionId + ".rdoc");
            long version;

            using (var documentStream = new RDocStream(documentFileName, ix.PrimaryKeyFieldName))
            {
                using (var upsert = new UpsertTransaction(
                           _directory,
                           _analyzer,
                           ix.Compression,
                           documentStream))
                {
                    version = upsert.Write();
                    upsert.Commit();
                }

                Log.InfoFormat("{0} merged with {1} creating a segmented index", srcIxFileName, _ixFilesToProcess[0]);
            }
            Util.RemoveAll(srcIxFileName);
            return(version);
        }
Esempio n. 2
0
        private long Merge(string srcIxFileName)
        {
            Log.InfoFormat("merging branch {0} with trunk {1}", _ixFilesToProcess[1], _ixFilesToProcess[0]);

            var  ix           = BatchInfo.Load(srcIxFileName);
            var  dataFileName = Path.Combine(_directory, ix.VersionId + ".rdb");
            long version;

            using (var stream = new FileStream(dataFileName, FileMode.Open))
                using (var documentStream = new DtblStream(stream, ix))
                {
                    // TODO: instead of rewriting, copy the segments from the branch file into the main data file.
                    using (var upsert = new UpsertTransaction(
                               _directory,
                               _analyzer,
                               ix.Compression,
                               documentStream))
                    {
                        version = upsert.Write();
                        upsert.Commit();
                    }

                    Log.InfoFormat("{0} merged with {1} creating a segmented index", srcIxFileName, _ixFilesToProcess[0]);
                }
            Util.RemoveAll(srcIxFileName);
            return(version);
        }
Esempio n. 3
0
        private long Truncate(string srcIxFileName)
        {
            Log.InfoFormat("truncating {0}", srcIxFileName);

            var  srcIx             = IxInfo.Load(srcIxFileName);
            var  documentFileName  = Path.Combine(_directory, srcIx.VersionId + ".rdoc");
            var  docAddressFn      = Path.Combine(_directory, srcIx.VersionId + ".da");
            var  docHashesFileName = Path.Combine(_directory, string.Format("{0}.{1}", srcIx.VersionId, "pk"));
            long version;

            using (var documentStream = new RDocStream(documentFileName, srcIx.PrimaryKeyFieldName))
            {
                Util.TryAquireWriteLock(_directory);

                using (var upsert = new UpsertTransaction(
                           _directory,
                           _analyzer,
                           srcIx.Compression,
                           documentStream))
                {
                    version = upsert.Write();
                    upsert.Commit();
                }

                Util.ReleaseFileLock(_directory);

                Log.InfoFormat("ix {0} fully truncated", _ixFilesToProcess[0]);
            }
            Util.RemoveAll(srcIxFileName);
            return(version);
        }
Esempio n. 4
0
        private long Truncate(string srcIxFileName)
        {
            Log.InfoFormat("truncating {0}", srcIxFileName);

            var  srcIx        = BatchInfo.Load(srcIxFileName);
            var  dataFileName = Path.Combine(_directory, srcIx.VersionId + ".rdb");
            long version;

            using (var stream = new FileStream(dataFileName, FileMode.Open))
                using (var documentStream = new DtblStream(stream, srcIx))
                {
                    using (var upsert = new UpsertTransaction(
                               _directory,
                               _analyzer,
                               srcIx.Compression,
                               documentStream))
                    {
                        version = upsert.Write();
                        upsert.Commit();
                    }

                    Log.InfoFormat("ix {0} fully truncated", _ixFilesToProcess[0]);
                }
            Util.RemoveAll(srcIxFileName);
            return(version);
        }