Beispiel #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);
        }
Beispiel #2
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);
        }