Esempio n. 1
0
        private IList <IndexEntryUpdate <SchemaDescriptorSupplier> > GenerateSomeUpdates(int count)
        {
            IList <IndexEntryUpdate <SchemaDescriptorSupplier> > updates = new List <IndexEntryUpdate <SchemaDescriptorSupplier> >();

            for (int i = 0; i < count; i++)
            {
                long entityId = Random.nextLong(10_000_000);
                switch (Random.among(UpdateMode.MODES))
                {
                case ADDED:
                    updates.Add(IndexEntryUpdate.add(entityId, _descriptor, Random.nextValue()));
                    break;

                case REMOVED:
                    updates.Add(IndexEntryUpdate.remove(entityId, _descriptor, Random.nextValue()));
                    break;

                case CHANGED:
                    updates.Add(IndexEntryUpdate.change(entityId, _descriptor, Random.nextValue(), Random.nextValue()));
                    break;

                default:
                    throw new System.ArgumentException();
                }
            }
            return(updates);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCountDistinctValues() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCountDistinctValues()
        {
            // given
            LuceneIndexWriter writer = _index.IndexWriter;
            int expectedCount        = 10_000;

            for (int i = 0; i < expectedCount; i++)
            {
                Value value = Random.nextValue();
                writer.AddDocument(documentRepresentingProperties(i, value));
            }
            _index.maybeRefreshBlocking();

            // when/then
            GatheringNodeValueClient client           = new GatheringNodeValueClient();
            NodePropertyAccessor     propertyAccessor = mock(typeof(NodePropertyAccessor));

            using (IndexReader reader = _index.IndexReader)
            {
                reader.DistinctValues(client, propertyAccessor, true);
                int actualCount = 0;
                while (client.Progressor.next())
                {
                    actualCount += ( int )client.Reference;
                }
                assertEquals(expectedCount, actualCount);
            }
            verifyNoMoreInteractions(propertyAccessor);
        }
Esempio n. 3
0
		 private Value[] GenerateValueTuple( int slots )
		 {
			  Value[] tuple = new Value[slots];
			  for ( int j = 0; j < slots; j++ )
			  {
					tuple[j] = Random.nextValue();
			  }
			  return tuple;
		 }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupMultipleSchemaIndexes() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupMultipleSchemaIndexes()
        {
            // given
            ExecutorService      executorService = Executors.newSingleThreadExecutor();
            AtomicBoolean        end             = new AtomicBoolean();
            int                  backupPort      = PortAuthority.allocatePort();
            GraphDatabaseService db = GetEmbeddedTestDataBaseService(backupPort);

            try
            {
                int           numberOfIndexedLabels = 10;
                IList <Label> indexedLabels         = CreateIndexes(db, numberOfIndexedLabels);

                // start thread that continuously writes to indexes
                executorService.submit(() =>
                {
                    while (!end.get())
                    {
                        using (Transaction tx = Db.beginTx())
                        {
                            Db.createNode(indexedLabels[_random.Next(numberOfIndexedLabels)]).setProperty("prop", _random.nextValue());
                            tx.success();
                        }
                    }
                });
                executorService.shutdown();

                // create backup
                OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort).full(_backupDatabasePath.Path);
                assertTrue("Should be consistent", backup.Consistent);
                end.set(true);
                executorService.awaitTermination(1, TimeUnit.MINUTES);
            }
            finally
            {
                Db.shutdown();
            }
        }