Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void snapshotForPartitionedIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void SnapshotForPartitionedIndex()
        {
            // Given
            using (LuceneIndexAccessor indexAccessor = CreateDefaultIndexAccessor())
            {
                GenerateUpdates(indexAccessor, 32);
                indexAccessor.Force(Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited);

                // When & Then
                IList <string> singlePartitionFileTemplates = Arrays.asList(".cfe", ".cfs", ".si", "segments_1");
                using (ResourceIterator <File> snapshotIterator = indexAccessor.SnapshotFiles())
                {
                    IList <string> indexFileNames = AsFileInsidePartitionNames(snapshotIterator);

                    assertTrue(indexFileNames.Count >= (singlePartitionFileTemplates.Count * 4), "Expect files from 4 partitions");
                    IDictionary <string, int> templateMatches = CountTemplateMatches(singlePartitionFileTemplates, indexFileNames);

                    foreach (string fileTemplate in singlePartitionFileTemplates)
                    {
                        int?matches = templateMatches[fileTemplate];
                        assertTrue(matches >= 4, "Expect to see at least 4 matches for template: " + fileTemplate);
                    }
                }
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldRemoveAndAddEntries() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldRemoveAndAddEntries()
        {
            // given
            PartitionedIndexStorage indexStorage = IndexStorage;

            LuceneIndexAccessor accessor = CreateAccessor(indexStorage);

            // when
            UpdateAndCommit(accessor, asList(Add(1L, "value1")));
            UpdateAndCommit(accessor, asList(Add(2L, "value2")));
            UpdateAndCommit(accessor, asList(Add(3L, "value3")));
            UpdateAndCommit(accessor, asList(Add(4L, "value4")));
            UpdateAndCommit(accessor, asList(Remove(1L, "value1")));
            UpdateAndCommit(accessor, asList(Remove(2L, "value2")));
            UpdateAndCommit(accessor, asList(Remove(3L, "value3")));
            UpdateAndCommit(accessor, asList(Add(1L, "value1")));
            UpdateAndCommit(accessor, asList(Add(3L, "value3b")));
            accessor.Dispose();

            // then
            assertEquals(asList(1L), GetAllNodes(indexStorage, "value1"));
            assertEquals(emptyList(), GetAllNodes(indexStorage, "value2"));
            assertEquals(emptyList(), GetAllNodes(indexStorage, "value3"));
            assertEquals(asList(3L), GetAllNodes(indexStorage, "value3b"));
            assertEquals(asList(4L), GetAllNodes(indexStorage, "value4"));
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void snapshotForIndexWithNoCommits() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void SnapshotForIndexWithNoCommits()
        {
            // Given
            // A completely un-used index
            using (LuceneIndexAccessor indexAccessor = CreateDefaultIndexAccessor(), ResourceIterator <File> snapshotIterator = indexAccessor.SnapshotFiles())
            {
                assertThat(AsUniqueSetOfNames(snapshotIterator), equalTo(emptySet()));
            }
        }
Exemple #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void generateUpdates(LuceneIndexAccessor indexAccessor, int nodesToUpdate) throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        private void GenerateUpdates(LuceneIndexAccessor indexAccessor, int nodesToUpdate)
        {
            using (IndexUpdater updater = indexAccessor.NewUpdater(IndexUpdateMode.ONLINE))
            {
                for (int nodeId = 0; nodeId < nodesToUpdate; nodeId++)
                {
                    updater.Process(Add(nodeId, nodeId));
                }
            }
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldUpdateUniqueEntries() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldUpdateUniqueEntries()
        {
            // given
            PartitionedIndexStorage indexStorage = IndexStorage;

            LuceneIndexAccessor accessor = CreateAccessor(indexStorage);

            // when
            UpdateAndCommit(accessor, asList(Add(1L, "value1")));
            UpdateAndCommit(accessor, asList(Change(1L, "value1", "value2")));
            accessor.Dispose();

            // then
            assertEquals(asList(1L), GetAllNodes(indexStorage, "value2"));
            assertEquals(emptyList(), GetAllNodes(indexStorage, "value1"));
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldConsiderWholeTransactionForValidatingUniqueness() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldConsiderWholeTransactionForValidatingUniqueness()
        {
            // given
            PartitionedIndexStorage indexStorage = IndexStorage;

            LuceneIndexAccessor accessor = CreateAccessor(indexStorage);

            // when
            UpdateAndCommit(accessor, asList(Add(1L, "value1")));
            UpdateAndCommit(accessor, asList(Add(2L, "value2")));
            UpdateAndCommit(accessor, asList(Change(1L, "value1", "value2"), Change(2L, "value2", "value1")));
            accessor.Dispose();

            // then
            assertEquals(asList(2L), GetAllNodes(indexStorage, "value1"));
            assertEquals(asList(1L), GetAllNodes(indexStorage, "value2"));
        }
Exemple #7
0
 protected internal LuceneSchemaIndexUpdater(LuceneIndexAccessor outerInstance, bool idempotent, bool refresh) : base(outerInstance, idempotent, refresh)
 {
     this._outerInstance = outerInstance;
 }
Exemple #8
0
//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()
        {
            _accessor = new LuceneIndexAccessor(_schemaIndex, _schemaIndexDescriptor);
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Before()
        {
            _dirFactory = new Org.Neo4j.Kernel.Api.Impl.Index.storage.DirectoryFactory_InMemoryDirectoryFactory();
            _accessor   = AccessorFactory.apply(_dirFactory);
        }