Ejemplo n.º 1
0
        public MongoIndexOutput(MongoDirectory indexDirectory, IOContext context, string indexFileName)
        {
            this.indexDirectory = indexDirectory;
            this.indexFileName  = indexFileName;

            cacheOutput = indexDirectory.CacheDirectory.CreateOutput(indexFileName, context);
        }
Ejemplo n.º 2
0
 public MongoIndexInput(MongoIndexInput source)
     : base("clone")
 {
     cacheInput     = (IndexInput)source.cacheInput.Clone();
     context        = source.context;
     indexDirectory = source.indexDirectory;
     indexFileName  = source.indexFileName;
 }
Ejemplo n.º 3
0
        public Task <LuceneDirectory> CreateDirectoryAsync(Guid schemaId)
        {
            var folderName = schemaId.ToString();

            var tempFolder    = Path.Combine(Path.GetTempPath(), "Indices", folderName);
            var tempDirectory = new DirectoryInfo(tempFolder);

            var directory = new MongoDirectory(bucket, folderName, tempDirectory);

            return(Task.FromResult <LuceneDirectory>(directory));
        }
Ejemplo n.º 4
0
        public MongoIndexInput(MongoDirectory indexDirectory, IOContext context, string indexFileName)
            : base(indexDirectory.GetFullName(indexFileName))
        {
            this.indexDirectory = indexDirectory;
            this.indexFileName  = indexFileName;

            this.context = context;

            try
            {
                var file = indexDirectory.FindFile(indexFileName);

                if (file != null)
                {
                    var fileInfo = new FileInfo(indexDirectory.GetFullPath(indexFileName));

                    var writtenTime = file.Metadata["WrittenTime"].ToUniversalTime();

                    if (!fileInfo.Exists || fileInfo.LastWriteTimeUtc < writtenTime)
                    {
                        using (var fs = new FileStream(fileInfo.FullName, FileMode.Create, FileAccess.Write))
                        {
                            var fullName = indexDirectory.GetFullName(indexFileName);

                            indexDirectory.Bucket.DownloadToStream(fullName, fs);
                        }
                    }
                }
            }
            catch (GridFSFileNotFoundException)
            {
                throw new FileNotFoundException();
            }

            cacheInput = indexDirectory.CacheDirectory.OpenInput(indexFileName, context);
        }