protected static async Task PrecalculateAsync(Document document, IndexCreator create, CancellationToken cancellationToken)
        {
            if (!document.SupportsSyntaxTree)
            {
                return;
            }

            using (Logger.LogBlock(FunctionId.SyntaxTreeIndex_Precalculate, cancellationToken))
            {
                Debug.Assert(document.IsFromPrimaryBranch());

                var checksum = await GetChecksumAsync(document, cancellationToken).ConfigureAwait(false);

                // Check if we've already created and persisted the index for this document.
                if (await PrecalculatedAsync(document, checksum, cancellationToken).ConfigureAwait(false))
                {
                    return;
                }

                using (Logger.LogBlock(FunctionId.SyntaxTreeIndex_Precalculate_Create, cancellationToken))
                {
                    // If not, create and save the index.
                    var data = await CreateIndexAsync(document, checksum, create, cancellationToken).ConfigureAwait(false);

                    await data.SaveAsync(document, cancellationToken).ConfigureAwait(false);
                }
            }
        }
Example #2
0
        private void btnCreateIndex_Click(object sender, EventArgs e)
        {
            string sql = "SELECT VerseID, VerseText FROM Verse";

            using (SqlCeConnection conn = new SqlCeConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                conn.Open();
                var rdr = new SqlCeCommand(sql, conn).ExecuteReader();

                var context        = new TextFileAccessContext("Bible", IndexDir, new CultureInfo("en-US"));
                var textIndexSaver = new TextIndexSaver <int>(context);

                var wordBreaker = new DefaultWordBreaker(new WordBreakingInformationRetriever(context.Directory, context.Culture))
                {
                    DatabasePath = context.Directory
                };

                var textIndexFiller = new TextIndexFiller <int>(wordBreaker);
                var indexCreator    = new IndexCreator <int>(textIndexFiller);

                var index = indexCreator.CreateIndex(new BibleVersuses(rdr));

                textIndexSaver.SaveIndex(index);

                rdr.Close();
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _db = DbRule.GraphDatabaseAPI;
            if (WithIndex)
            {
                using (Org.Neo4j.Graphdb.Transaction tx = _db.beginTx())
                {
                    _db.schema().indexFor(_label).on(Keys[0]).create();

                    IndexCreator indexCreator = _db.schema().indexFor(_label);
                    foreach (string key in Keys)
                    {
                        indexCreator = indexCreator.On(key);
                    }
                    indexCreator.Create();
                    tx.Success();
                }

                using (Org.Neo4j.Graphdb.Transaction tx = _db.beginTx())
                {
                    _db.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
                    tx.Success();
                }
            }
        }
Example #4
0
        public void IndexCreation_multiChromosome()
        {
            var jsonStream = new BlockGZipStream(ResourceUtilities.GetReadStream(Resources.TopPath("cosmicv72.indels.json.gz")), CompressionMode.Decompress);

            var writeStream = new MemoryStream();

            using (var indexCreator = new IndexCreator(jsonStream, writeStream))
            {
                indexCreator.CreateIndex();
            }

            JasixIndex readBackIndex;
            var        readStream = new MemoryStream(writeStream.ToArray());

            readStream.Seek(0, SeekOrigin.Begin);

            using (readStream)
            {
                readBackIndex = new JasixIndex(readStream);
            }

            Assert.Equal(2268, readBackIndex.GetFirstVariantPosition("chr1", 9775924, 9775924));
            Assert.Equal(14035925971, readBackIndex.GetFirstVariantPosition("chr2", 16081096, 16081096));
            Assert.Equal(433156622693, readBackIndex.GetFirstVariantPosition("chr20", 36026164, 36026164));
            Assert.Equal(439602269527, readBackIndex.GetFirstVariantPosition("chrX", 66765044, 66765044));
        }
Example #5
0
 public CreateTableBuilder(DbConnection db, IGenerateDDL generator, TableSchema schema)
 {
     _db = db;
     _generator = generator;
     _table = schema;
     _columns = new ColumnsCreator(Table);
     _constraints = new ConstraintsCreator(Table.Constraints);
     _indexes = new IndexCreator(Table.Indexes);
 }
Example #6
0
        private static void Main(string[] args)
        {
            var docFileReader     = new DocFileReader("EnglishData");
            var indexCreator      = new IndexCreator(docFileReader);
            var hashInvertedIndex = new HashInvertedIndex(indexCreator.OrganizeDocsAndWords());
            var controller        = new Controller(new ConsoleView(), new Processor(hashInvertedIndex));

            controller.Run();
        }
Example #7
0
    public void SetUp()
    {
        IWindsorContainer container = new WindsorContainer().Install(
            new RavenInstaller(Array.Empty <Tenant>(), DocumentStoreMode.InMemory));

        Store = container.Resolve <IDocumentStore>();
        IndexCreator.CreateIndexes(Store);
        Session = Store.OpenSession();
        OnSetUp();
    }
        public void ParsingDeletionJsonLine()
        {
            const string jsonLine =
                "{\"chromosome\":\"chr1\",\"refAllele\":\"GT\",\"position\":2337967,\"altAlleles\":[\"G\"],\"cyt\r\nogeneticBand\":\"1p36.32\",\"variants\":[{\"altAllele\":\"C\",\"refAllele\":\"-\",\"begin\":2337968,\"chromosome\":\"chr1\",\"dbsnp\":[\"rs797044762\"],\"end\":2337967,\"variantType\":\"insertion\",\"vid\":\"1:2337968:2337967:C\",\"regulatoryRegions\":[{\"id\":\"ENSR00001576444\",\"consequence\":[\"regulatory_region_variant\"]}],\"transcripts\":{\"refSeq\":[{\"transcript\":\"XM_005244712.1\",\"bioType\":\"protein_coding\",\"geneId\":\"11079\",\"hgnc\":\"RER1\",\"consequence\":[\"downstream_gene_variant\"],\"proteinId\":\"XP_005244769.1\"},{\"transcript\":\"NM_007033.4\",\"bioType\":\"protein_coding\",\"geneId\":\"11079\",\"hgnc\":\"RER1\",\"consequence\":[\"downstream_gene_variant\"],\"isCanonical\":true,\"proteinId\":\"NP_008964.3\"},{\"transcript\":\"XM_005244713.1\",\"bioType\":\"protein_coding\",\"geneId\":\"11079\",\"hgnc\":\"RER1\",\"consequence\":[\"downstream_gene_variant\"],\"proteinId\":\"XP_005244770.1\"},{\"transcript\":\"NM_002617.3\",\"bioType\":\"protein_coding\",\"aminoAcids\":\"-/X\",\"cDnaPos\":\"936-937\",\"codons\":\"-/G\",\"cdsPos\":\"867-868\",\"exons\":\"5/6\",\"geneId\":\"5192\",\"hgnc\":\"PEX10\",\"consequence\":[\"frameshift_variant\"],\"hgvsc\":\"NM_002617.3:c.867_868insG\",\"hgvsp\":\"NP_002608.1:p.His290AlafsTer49\",\"proteinId\":\"NP_002608.1\",\"proteinPos\":\"289-290\"},{\"transcript\":\"NM_153818.1\",\"bioType\":\"protein_coding\",\"aminoAcids\":\"-/X\",\"cDnaPos\":\"996-997\",\"codons\":\"-/G\",\"cdsPos\":\"927-928\",\"exons\":\"5/6\",\"geneId\":\"5192\",\"hgnc\":\"PEX10\",\"consequence\":[\"frameshift_variant\"],\"hgvsc\":\"NM_153818.1:c.927_928insG\",\"hgvsp\":\"NP_722540.1:p.His310AlafsTer49\",\"isCanonical\":true,\"proteinId\":\"NP_722540.1\",\"proteinPos\":\"309-310\"}]}}]}";

            var chrPos = IndexCreator.GetChromPosition(jsonLine);

            Assert.Equal("chr1", chrPos.Item1);
            Assert.Equal(2337967, chrPos.Item2);
            Assert.Equal(2337968, chrPos.Item3);
        }
        public void ParseJsonBreakEnd()
        {
            const string jsonLine =
                "{\"chromosome\":\"2\",\"refAllele\":\"G\",\"position\":321681,\"quality\":6,\"filters\":[\"PASS\"],\"altAlleles\":[\"G]2:421681]\"],\"cytogeneticBand\":\"2p25.3\",\"oneKg\":[{\"chromosome\":\"2\",\"begin\":314969,\"end\":694521,\"variantType\":\"copy_number_gain\",\"variantFreqAll\":0.0008,\"variantFreqEas\":0.00397,\"id\":\"esv3589600\",\"sampleSize\":2504,\"sampleSizeAfr\":661,\"sampleSizeAmr\":347,\"sampleSizeEas\":504,\"sampleSizeEur\":503,\"sampleSizeSas\":489,\"observedGains\":2}],\"variants\":[{\"altAllele\":\"G]2:421681]\",\"refAllele\":\"G\",\"begin\":321681,\"chromosome\":\"2\",\"end\":321686,\"variantType\":\"translocation_breakend\",\"vid\":\"2:321681:+:2:421681:-\",\"overlappingGenes\":[\"AC079779.6\"]}]}";

            var chrPos = IndexCreator.GetChromPosition(jsonLine);

            Assert.Equal("2", chrPos.Item1);
            Assert.Equal(321681, chrPos.Item2);
            Assert.Equal(321681, chrPos.Item3);
        }
        public void ParseJsonStructuralVariant()
        {
            const string jsonLine =
                "{\"chromosome\":\"chr3\",\"refAllele\":\"A\",\"position\":62431401,\"svEnd\":62431801,\"altAlleles\":[\"<DEL>\"],\"cytogeneticBand\":\"3p14.2\",\"variants\":[{\"altAllele\":\"<DEL>\",\"refAllele\":\"A\",\"begin\":62431402,\"chromosome\":\"chr3\",\"end\":62431801,\"variantType\":\"unknown\",\"vid\":\"3:62431402:62431401\",\"globalAllele\":{\"globalMajorAllele\":\"C\",\"globalMajorAlleleFrequency\":0.9856,\"globalMinorAllele\":\"A\",\"globalMinorAlleleFrequency\":0.01438}}]}";

            var chrPos = IndexCreator.GetChromPosition(jsonLine);

            Assert.Equal("chr3", chrPos.Item1);
            Assert.Equal(62431401, chrPos.Item2);
            Assert.Equal(62431801, chrPos.Item3);
        }
        public static IIndex Provide(string name, DateTime startDate, DateTime endDate, string frequency)
        {
            var historicalData = ReadDataFromFile.ReadDataSeriesFromFile(
                DownloadedFile.ProvideHistoridalDataFile(name, startDate, endDate, frequency));

            var currentPrice = new DataPoint();     //currently not available
            var listOfStocks = new List <IStock>(); //currently not available

            var index = IndexCreator.CreateIndex(name, currentPrice, listOfStocks, historicalData);

            return(index);
        }
        private static void Main(string[] args)
        {
            var context            = new SearchContextFactory().CreateDbContext(args);
            var docFileReader      = new DocFileReader();
            var documentRepository = new DocumentRepository(context);
            var indexCreator       = new IndexCreator(docFileReader, documentRepository);

            indexCreator.OrganizeDocsAndWords("EnglishData");
            var controller = new Controller(new ConsoleView(), new Processor(documentRepository));

            controller.Run();
        }
Example #13
0
        public CreateTableBuilder(DbConnection db, IGenerateDDL generator, string tableName, IfTableExists option)
        {
            _db = db;
            _generator = generator;
            tableName.MustNotBeEmpty();
            _table = new TableSchema(tableName);
            _columns = new ColumnsCreator(Table);
            _constraints = new ConstraintsCreator(Table.Constraints);
            _indexes = new IndexCreator(Table.Indexes);

            Table.Name = tableName;
            Table.CreationOption = option;
        }
Example #14
0
        public FileItemsView()
        {
            InitializeComponent();
            BackButton.Command    = BackCommand;
            ForwardButton.Command = ForwardCommand;
            // Create search index
            var searchIndexCreator = new IndexCreator(Dispatcher);

            // searchIndexCreator.CreateSearchIndex();
            _imageLoader        = new ImageLoader(Dispatcher);
            Unloaded           += EndLoadingImage;
            FileItems.Focusable = true;
            FileItems.Focus();
            InitializeCommand();
        }
Example #15
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void shouldFailWithNonExistentProviderName(IndexCreator creator) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        internal virtual void ShouldFailWithNonExistentProviderName(IndexCreator creator)
        {
            // given
            SchemaWrite schemaWrite = SchemaWriteInNewTransaction();

            // when
            try
            {
                creator.Create(schemaWrite, forLabel(0, 0), "something-completely-different");
                fail("Should have failed");
            }
            catch (IndexProviderNotFoundException)
            {
                // then good
            }
        }
Example #16
0
 public static void Initialize()
 {
     ranker         = new Ranker.Ranker();
     indexer        = new Indexer.Indexer();
     urlFilter      = new UrlFilter();
     urlFrontier    = new UrlFrontier();
     indexCreator   = new IndexCreator();
     pageRetriever  = new PageRetriever();
     termContructor = new TermConstructor();
     tokenizer      = new Tokenizer();
     webCrawler     = new WebCrawler.WebCrawler();
     pageDB         = new PageDB();
     DPC            = new DuplicatePageChecker();
     DUC            = new DuplicateURLChecker();
     pageFetcher    = new PageFetcher();
     pageParser     = new PageParser();
 }
Example #17
0
 private void CreateIndex(params string[] propKeys)
 {
     using (Transaction tx = Db.beginTx())
     {
         IndexCreator indexCreator = Db.schema().indexFor(LABEL_ONE);
         foreach (string propKey in propKeys)
         {
             indexCreator = indexCreator.On(propKey);
         }
         indexCreator.Create();
         tx.Success();
     }
     using (Transaction tx = Db.beginTx())
     {
         Db.schema().awaitIndexesOnline(1, TimeUnit.MINUTES);
         tx.Success();
     }
 }
Example #18
0
        public void WhenIIndexThePeople()
        {
            var people = ScenarioContext.Current.Get<IEnumerable<Person>>();

            var mock = new Mock<IWordBreakingInformationRetriever>();
            mock.Setup(x => x.GetWordBreakingInformation())
                .Returns(new WordBreakingInformation{NoiseWords = new Dictionary<string, string>(),
                Substitutions = new Dictionary<string, string>(),
                Whitespace = new List<char>()});

            var indexCreator = new IndexCreator<int>(new TextIndexFiller<int>(new DefaultWordBreaker(mock.Object)));

            var phrases = people.Select(x => new Phrase<int> {Key = x.Key, Text = x.FirstName + " " + x.LastName});

            var index = indexCreator.CreateIndex(phrases);

            ScenarioContext.Current.Set(index);
        }
Example #19
0
 private void CreateIndex(params string[] keys)
 {
     using (Transaction tx = Db.beginTx())
     {
         IndexCreator indexCreator = Db.schema().indexFor(LABEL);
         foreach (string key in keys)
         {
             indexCreator = indexCreator.On(key);
         }
         indexCreator.Create();
         tx.Success();
     }
     using (Transaction tx = Db.beginTx())
     {
         Db.schema().awaitIndexesOnline(10, SECONDS);
         tx.Success();
     }
 }
Example #20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void shouldCreateWithSpecificExistingProviderName(IndexCreator creator) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        internal virtual void ShouldCreateWithSpecificExistingProviderName(IndexCreator creator)
        {
            int labelId = 0;

            foreach (GraphDatabaseSettings.SchemaIndex indexSetting in GraphDatabaseSettings.SchemaIndex.values())
            {
                // given
                SchemaWrite           schemaWrite = SchemaWriteInNewTransaction();
                string                provider    = indexSetting.providerName();
                LabelSchemaDescriptor descriptor  = forLabel(labelId++, 0);
                creator.Create(schemaWrite, descriptor, provider);

                // when
                Commit();

                // then
                assertEquals(provider, IndexingService.getIndexProxy(descriptor).Descriptor.providerDescriptor().name());
            }
        }
Example #21
0
        public void TestIndexCreation()
        {
            var readStream = new BlockGZipStream(ResourceUtilities.GetReadStream(Resources.TopPath("cosmicv72.indels.json.gz")), CompressionMode.Decompress);
            var tempFile   = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            using (var indexCreator = new IndexCreator(readStream, FileUtilities.GetCreateStream(tempFile)))
            {
                indexCreator.CreateIndex();
            }
            JasixIndex readBackIndex;

            using (var stream = FileUtilities.GetReadStream(tempFile))
            {
                readBackIndex = new JasixIndex(stream);
            }

            Assert.Equal(1591, readBackIndex.GetFirstVariantPosition("chr1", 9775924, 9775924));
            Assert.Equal(11500956299, readBackIndex.GetFirstVariantPosition("chr2", 16081096, 16081096));
            Assert.Equal(372100991296, readBackIndex.GetFirstVariantPosition("chr20", 36026164, 36026164));
            Assert.Equal(377682846863, readBackIndex.GetFirstVariantPosition("chrX", 66765044, 66765044));

            File.Delete(tempFile);
        }
Example #22
0
        public void WhenIIndexThePeople()
        {
            var people = ScenarioContext.Current.Get <IEnumerable <Person> >();

            var mock = new Mock <IWordBreakingInformationRetriever>();

            mock.Setup(x => x.GetWordBreakingInformation())
            .Returns(new WordBreakingInformation {
                NoiseWords    = new Dictionary <string, string>(),
                Substitutions = new Dictionary <string, string>(),
                Whitespace    = new List <char>()
            });

            var indexCreator = new IndexCreator <int>(new TextIndexFiller <int>(new DefaultWordBreaker(mock.Object)));

            var phrases = people.Select(x => new Phrase <int> {
                Key = x.Key, Text = x.FirstName + " " + x.LastName
            });

            var index = indexCreator.CreateIndex(phrases);

            ScenarioContext.Current.Set(index);
        }
        private static void Main(string[] args)
        {
            IConfiguration config        = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            var            directoryPath = config.GetValue <string>("DirectoryPath");

            var client       = new ElasticClientFactory(config).CreateElasticClient();
            var queryCreator = new QueryCreator();
            var searcher     = new Searcher(client, queryCreator, Index);

            var consoleView = new ConsoleView();
            var controller  = new Controller(consoleView, searcher);

            if (!IsIndexExisting(Index, client))
            {
                var indexCreator = new IndexCreator(client);
                indexCreator.CreateIndex(Index);
                var fileReader = new DocFileReader();
                var docCreator = new DocFactory(fileReader);
                var importer   = new Importer <Doc>(client);
                importer.Import(docCreator.GetAllDocuments(directoryPath), Index);
            }
            controller.Run();
        }
Example #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnIndexRuleForLabelAndVeryManyPropertiesComposite()
        public virtual void ShouldReturnIndexRuleForLabelAndVeryManyPropertiesComposite()
        {
            string[] props = "abcdefghijklmnopqrstuvwxyzABCDEFGHJILKMNOPQRSTUVWXYZ".Split("\\B", true);
            CreateSchema(Db =>
            {
                IndexCreator indexCreator = Db.schema().indexFor(Label.label(LABEL1));
                foreach (string prop in props)
                {
                    indexCreator = indexCreator.on(prop);
                }
                indexCreator.create();
            });

            StoreIndexDescriptor rule = _storage.indexGetForSchema(TestIndexDescriptorFactory.forLabel(LabelId(LABEL1), java.util.props.Select(this.propId).ToArray()));

            assertNotNull(rule);
            assertTrue(SchemaDescriptorPredicates.hasLabel(rule, LabelId(LABEL1)));
            foreach (string prop in props)
            {
                assertTrue(SchemaDescriptorPredicates.hasProperty(rule, PropId(prop)));
            }
            assertEquals(IndexDescriptor.Type.GENERAL, rule.Type());
        }
    public override Task Handle(HandlerContext <Command> context)
    {
        IndexCreator.CreateIndexes(CompositionRoot.DocumentStore);
        User admin = CompositionRoot.DocumentSession.Load <User>(User.AdminId);

        if (admin == null)
        {
            admin = new("", "", context.Payload.Email, context.Payload.Password)
            {
                Id = User.AdminId
            };
            admin.Initialize(t => context.PublishMessage(t));
            admin.Activate();
            CompositionRoot.DocumentSession.Store(admin);
        }
        else
        {
            admin.SetEmail(context.Payload.Email);
            admin.SetPassword(context.Payload.Password);
            admin.Activate();
        }

        return(Task.CompletedTask);
    }
Example #26
0
        private IHttpActionResult Handle(InitializeIndexesMessage message)
        {
            IndexCreator.CreateIndexes(DocumentStore);
            User admin = DocumentSession.Load <User>(Models.User.AdminId);

            if (admin == null)
            {
                admin = new User("", "", message.Email, message.Password)
                {
                    Id = Models.User.AdminId
                };
                admin.Initialize(PublishMessage);
                admin.Activate();
                DocumentSession.Store(admin);
            }
            else
            {
                admin.SetEmail(message.Email);
                admin.SetPassword(message.Password);
                admin.Activate();
            }

            return(Ok());
        }
Example #27
0
    public ActionResult ResetIndexesConfirmed()
    {
        IndexCreator.ResetIndexes(CompositionRoot.DocumentStore, CompositionRoot.EventStore);

        return(RedirectToAction("Raven"));
    }
Example #28
0
 public IndexCreatorTests()
 {
     _docFileReader = Substitute.For <IFileReader>();
     _sut           = new IndexCreator(_docFileReader);
 }
Example #29
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.util.stream.Stream<BuiltInProcedures.SchemaIndexInfo> createIndex(String indexSpecification, String providerName, String statusMessage, IndexCreator indexCreator) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        private Stream <BuiltInProcedures.SchemaIndexInfo> CreateIndex(string indexSpecification, string providerName, string statusMessage, IndexCreator indexCreator)
        {
            AssertProviderNameNotNull(providerName);
            IndexSpecifier index   = IndexSpecifier.ByPattern(indexSpecification);
            int            labelId = GetOrCreateLabelId(index.Label());

            int[] propertyKeyIds = GetOrCreatePropertyIds(index.Properties());
            try
            {
                SchemaWrite           schemaWrite           = _ktx.schemaWrite();
                LabelSchemaDescriptor labelSchemaDescriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyIds);
                indexCreator(schemaWrite, labelSchemaDescriptor, providerName);
                return(Stream.of(new BuiltInProcedures.SchemaIndexInfo(indexSpecification, providerName, statusMessage)));
            }
            catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException)
            {
                throw new ProcedureException(e.status(), e, e.Message);
            }
        }
 public IndexCreatorTest()
 {
     _docFileReader      = Substitute.For <IFileReader>();
     _documentRepository = new DocumentRepositoryForTest();
     _sut = new IndexCreator(_docFileReader, _documentRepository);
 }