예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void raceContestantsAndVerifyResults(org.neo4j.internal.kernel.api.schema.SchemaDescriptor newDescriptor, Runnable aliceWork, Runnable changeConfig, Runnable bobWork) throws Throwable
        private void RaceContestantsAndVerifyResults(SchemaDescriptor newDescriptor, ThreadStart aliceWork, ThreadStart changeConfig, ThreadStart bobWork)
        {
            _race.addContestants(_aliceThreads, aliceWork);
            _race.addContestant(changeConfig);
            _race.addContestants(_bobThreads, bobWork);
            _race.go();
            Await(IndexDescriptorFactory.forSchema(newDescriptor, "nodes", FulltextIndexProviderFactory.Descriptor));
            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction   ktx = KernelTransaction(tx);
                ScoreEntityIterator bob = FulltextAdapter.query(ktx, "nodes", "bob");
                IList <ScoreEntityIterator.ScoreEntry> list = bob.ToList();
                try
                {
                    assertEquals(_bobThreads * _nodesCreatedPerThread, list.Count);
                }
                catch (Exception e)
                {
                    StringBuilder sb = (new StringBuilder(e.Message)).Append(Environment.NewLine).Append("Nodes found in query for bob:");
                    foreach (ScoreEntityIterator.ScoreEntry entry in list)
                    {
                        sb.Append(Environment.NewLine).Append("\t").Append(Db.getNodeById(entry.EntityId()));
                    }
                    throw e;
                }
                ScoreEntityIterator alice = FulltextAdapter.query(ktx, "nodes", "alice");
                assertEquals(0, alice.Count());
            }
        }
예제 #2
0
        private IndexDescriptor IndexDescriptor(Label label, string propertyKey)
        {
            int labelId   = labelId(label);
            int propKeyId = PropertyKeyId(propertyKey);

            return(IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(labelId, propKeyId)));
        }
        private StoreIndexDescriptor[] CreateIndexRules(IDictionary <string, int> labelNameIdMap, int propertyId)
        {
            IndexProvider           lookup             = IndexProviderMap.lookup(SchemaIndex.providerName());
            IndexProviderDescriptor providerDescriptor = lookup.ProviderDescriptor;

//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            return(labelNameIdMap.Values.Select(index => IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(index, propertyId), providerDescriptor).withId(index)).ToArray(StoreIndexDescriptor[] ::new));
        }
예제 #4
0
        private void GivenIndex(string label, string propKey)
        {
            int labelId = Token(label, _labels).Value;
            int propId  = Token(propKey, _propKeys).Value;

            IndexReference index = IndexDescriptorFactory.forSchema(forLabel(labelId, propId), EMPTY.ProviderDescriptor);

            _indexes.Add(index);
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setUp()
        internal virtual void SetUp()
        {
            File folder = _testDir.directory("folder");
            PartitionedIndexStorage indexStorage = new PartitionedIndexStorage(_dirFactory, _fileSystem, folder);

            IndexDescriptor descriptor = IndexDescriptorFactory.forSchema(_labelSchemaDescriptor);

            _index = LuceneSchemaIndexBuilder.create(descriptor, Config.defaults()).withIndexStorage(indexStorage).build();
        }
예제 #6
0
        private void GivenUniqueConstraint(string label, string propKey)
        {
            int labelId = Token(label, _labels).Value;
            int propId  = Token(propKey, _propKeys).Value;

            IndexReference index = IndexDescriptorFactory.uniqueForSchema(forLabel(labelId, propId), EMPTY.ProviderDescriptor);

            _uniqueIndexes.Add(index);
            _constraints.Add(ConstraintDescriptorFactory.uniqueForLabel(labelId, propId));
        }
예제 #7
0
파일: Commands.cs 프로젝트: Neo4Net/Neo4Net
        public static SchemaRuleCommand CreateIndexRule(IndexProviderDescriptor provider, long id, LabelSchemaDescriptor descriptor)
        {
            SchemaRule    rule   = IndexDescriptorFactory.forSchema(descriptor, provider).withId(id);
            DynamicRecord record = new DynamicRecord(id);

            record.InUse = true;
            record.SetCreated();
            record.Data = SchemaRuleSerialization.serialize(rule);
            return(new SchemaRuleCommand(Collections.emptyList(), singletonList(record), rule));
        }
예제 #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.storageengine.api.schema.IndexDescriptor indexDescriptor(org.neo4j.graphdb.Label label, String propertyKey, boolean constraint) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException, org.neo4j.internal.kernel.api.exceptions.schema.IllegalTokenNameException, org.neo4j.internal.kernel.api.exceptions.schema.TooManyLabelsException
        private IndexDescriptor IndexDescriptor(Label label, string propertyKey, bool constraint)
        {
            using (Transaction tx = _kernel.beginTransaction(@implicit, AUTH_DISABLED))
            {
                int labelId                 = tx.TokenWrite().labelGetOrCreateForName(label.Name());
                int propertyKeyId           = tx.TokenWrite().propertyKeyGetOrCreateForName(propertyKey);
                SchemaDescriptor schema     = SchemaDescriptorFactory.forLabel(labelId, propertyKeyId);
                IndexDescriptor  descriptor = constraint ? IndexDescriptorFactory.uniqueForSchema(schema, PROVIDER_DESCRIPTOR) : IndexDescriptorFactory.forSchema(schema, PROVIDER_DESCRIPTOR);
                tx.Success();
                return(descriptor);
            }
        }
        // === INDEX RULES ===

        private static StoreIndexDescriptor ReadIndexRule(long id, bool constraintIndex, int label, ByteBuffer serialized)
        {
            IndexProviderDescriptor providerDescriptor = ReadIndexProviderDescriptor(serialized);

            int[] propertyKeyIds                       = ReadIndexPropertyKeys(serialized);
            LabelSchemaDescriptor schema               = SchemaDescriptorFactory.forLabel(label, propertyKeyIds);
            Optional <string>     name                 = null;
            IndexDescriptor       descriptor           = constraintIndex ? IndexDescriptorFactory.uniqueForSchema(schema, name, providerDescriptor) : IndexDescriptorFactory.forSchema(schema, name, providerDescriptor);
            StoreIndexDescriptor  storeIndexDescriptor = constraintIndex ? descriptor.WithIds(id, ReadOwningConstraint(serialized)) : descriptor.WithId(id);

            return(storeIndexDescriptor);
        }
예제 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void before() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void Before()
        {
            _directory = new RAMDirectory();
            DirectoryFactory directoryFactory = new Org.Neo4j.Kernel.Api.Impl.Index.storage.DirectoryFactory_Single(new Org.Neo4j.Kernel.Api.Impl.Index.storage.DirectoryFactory_UncloseableDirectory(_directory));

            _provider       = new LuceneIndexProvider(_fs, directoryFactory, defaultDirectoryStructure(_testDir.directory("folder")), IndexProvider.Monitor_Fields.EMPTY, Config.defaults(), OperationalMode.single);
            _indexStoreView = mock(typeof(IndexStoreView));
            IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.defaults());

            _index          = IndexDescriptorFactory.forSchema(forLabel(42, PROPERTY_KEY_ID), _provider.ProviderDescriptor).withId(0);
            _indexPopulator = _provider.getPopulator(_index, samplingConfig, heapBufferFactory(1024));
            _indexPopulator.create();
        }
예제 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void removeSchemaWithRepeatedRelType()
        public virtual void RemoveSchemaWithRepeatedRelType()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final SchemaCache cache = newSchemaCache();
            SchemaCache cache = NewSchemaCache();

            const int id = 1;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int[] repeatedRelTypes = {0, 1, 0};
            int[] repeatedRelTypes = new int[] { 0, 1, 0 };
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.api.schema.MultiTokenSchemaDescriptor schema = org.neo4j.kernel.api.schema.SchemaDescriptorFactory.multiToken(repeatedRelTypes, org.neo4j.storageengine.api.EntityType.RELATIONSHIP, 1);
            MultiTokenSchemaDescriptor schema = SchemaDescriptorFactory.multiToken(repeatedRelTypes, EntityType.RELATIONSHIP, 1);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.schema.StoreIndexDescriptor storeIndexDescriptor = org.neo4j.storageengine.api.schema.IndexDescriptorFactory.forSchema(schema).withId(id);
            StoreIndexDescriptor storeIndexDescriptor = IndexDescriptorFactory.forSchema(schema).withId(id);

            cache.AddSchemaRule(storeIndexDescriptor);
            cache.RemoveSchemaRule(id);
        }
예제 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPopulateRelatonshipIndexWithASmallDataset() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPopulateRelatonshipIndexWithASmallDataset()
        {
            // GIVEN
            string value = "Philip J.Fry";
            long   node1 = CreateNode(map(_name, value), _first);
            long   node2 = CreateNode(map(_name, value), _second);
            long   node3 = CreateNode(map(_age, 31), _first);
            long   node4 = CreateNode(map(_age, 35, _name, value), _first);

            long rel1 = CreateRelationship(map(_name, value), _likes, node1, node3);

            CreateRelationship(map(_name, value), _knows, node3, node1);
            CreateRelationship(map(_age, 31), _likes, node2, node1);
            long rel4 = CreateRelationship(map(_age, 35, _name, value), _likes, node4, node4);

            IndexDescriptor    descriptor = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forRelType(0, 0));
            IndexPopulator     populator  = spy(IndexPopulator(descriptor));
            IndexPopulationJob job        = NewIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.RELATIONSHIP, descriptor);

            // WHEN
            job.Run();

            // THEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update1 = add(rel1, descriptor, org.neo4j.values.storable.Values.of(value));
            IndexEntryUpdate <object> update1 = add(rel1, descriptor, Values.of(value));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update2 = add(rel4, descriptor, org.neo4j.values.storable.Values.of(value));
            IndexEntryUpdate <object> update2 = add(rel4, descriptor, Values.of(value));

            verify(populator).create();
            verify(populator).includeSample(update1);
            verify(populator).includeSample(update2);
            verify(populator, times(2)).add(anyCollection());
            verify(populator).sampleResult();
            verify(populator).close(true);
        }
예제 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPopulateIndexWithOneRelationship() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPopulateIndexWithOneRelationship()
        {
            // GIVEN
            string             value        = "Taylor";
            long               nodeId       = CreateNode(map(_name, value), _first);
            long               relationship = CreateRelationship(map(_name, _age), _likes, nodeId, nodeId);
            IndexDescriptor    descriptor   = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forRelType(0, 0));
            IndexPopulator     populator    = spy(IndexPopulator(descriptor));
            IndexPopulationJob job          = NewIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.RELATIONSHIP, descriptor);

            // WHEN
            job.Run();

            // THEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update = org.neo4j.kernel.api.index.IndexEntryUpdate.add(relationship, descriptor, org.neo4j.values.storable.Values.of(age));
            IndexEntryUpdate <object> update = IndexEntryUpdate.add(relationship, descriptor, Values.of(_age));

            verify(populator).create();
            verify(populator).includeSample(update);
            verify(populator, times(2)).add(any(typeof(System.Collections.ICollection)));
            verify(populator).sampleResult();
            verify(populator).close(true);
        }
예제 #14
0
 private StoreIndexDescriptor UniqueIndexRule(long ruleId, long owningConstraint, IndexProviderDescriptor descriptor, int labelId, params int[] propertyIds)
 {
     return(IndexDescriptorFactory.uniqueForSchema(forLabel(labelId, propertyIds), descriptor).withIds(ruleId, owningConstraint));
 }
예제 #15
0
            internal virtual object Parameter(Type type)
            {
                if (type == typeof(RecordType))
                {
                    return(RecordType.STRING_PROPERTY);
                }
                if (type == typeof(RecordCheck))
                {
                    return(MockChecker());
                }
                if (type == typeof(NodeRecord))
                {
                    return(new NodeRecord(0, false, 1, 2));
                }
                if (type == typeof(RelationshipRecord))
                {
                    return(new RelationshipRecord(0, 1, 2, 3));
                }
                if (type == typeof(PropertyRecord))
                {
                    return(new PropertyRecord(0));
                }
                if (type == typeof(PropertyKeyTokenRecord))
                {
                    return(new PropertyKeyTokenRecord(0));
                }
                if (type == typeof(PropertyBlock))
                {
                    return(new PropertyBlock());
                }
                if (type == typeof(RelationshipTypeTokenRecord))
                {
                    return(new RelationshipTypeTokenRecord(0));
                }
                if (type == typeof(LabelTokenRecord))
                {
                    return(new LabelTokenRecord(0));
                }
                if (type == typeof(DynamicRecord))
                {
                    return(new DynamicRecord(0));
                }
                if (type == typeof(NeoStoreRecord))
                {
                    return(new NeoStoreRecord());
                }
                if (type == typeof(LabelScanDocument))
                {
                    return(new LabelScanDocument(new NodeLabelRange(0, new long[][] {})));
                }
                if (type == typeof(IndexEntry))
                {
                    return(new IndexEntry(IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)).withId(1L), idTokenNameLookup, 0));
                }
                if (type == typeof(CountsEntry))
                {
                    return(new CountsEntry(nodeKey(7), 42));
                }
                if (type == typeof(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind))
                {
                    return(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.IndexRule);
                }
                if (type == typeof(StoreIndexDescriptor))
                {
                    return(IndexDescriptorFactory.forSchema(forLabel(2, 3), IndexProviderDescriptor.UNDECIDED).withId(1));
                }
                if (type == typeof(SchemaRule))
                {
                    return(SimpleSchemaRule());
                }
                if (type == typeof(RelationshipGroupRecord))
                {
                    return(new RelationshipGroupRecord(0, 1));
                }
                if (type == typeof(long))
                {
                    return(12L);
                }
                if (type == typeof(object))
                {
                    return("object");
                }
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                throw new System.ArgumentException(format("Don't know how to provide parameter of type %s", type.FullName));
            }
예제 #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPopulateIndexWithASmallDataset() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPopulateIndexWithASmallDataset()
        {
            // GIVEN
            string value = "Mattias";
            long   node1 = CreateNode(map(_name, value), _first);

            CreateNode(map(_name, value), _second);
            CreateNode(map(_age, 31), _first);
            long                  node4      = CreateNode(map(_age, 35, _name, value), _first);
            IndexPopulator        populator  = spy(IndexPopulator(false));
            LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 0);
            IndexPopulationJob    job        = NewIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.NODE, IndexDescriptorFactory.forSchema(descriptor));

            // WHEN
            job.Run();

            // THEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update1 = add(node1, descriptor, org.neo4j.values.storable.Values.of(value));
            IndexEntryUpdate <object> update1 = add(node1, descriptor, Values.of(value));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update2 = add(node4, descriptor, org.neo4j.values.storable.Values.of(value));
            IndexEntryUpdate <object> update2 = add(node4, descriptor, Values.of(value));

            verify(populator).create();
            verify(populator).includeSample(update1);
            verify(populator).includeSample(update2);
            verify(populator, times(2)).add(anyCollection());
            verify(populator).sampleResult();
            verify(populator).close(true);
        }
예제 #17
0
 private void InitializeInstanceFields()
 {
     _indexDescriptor = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 42)).withId(_indexId);
 }
예제 #18
0
        private KernelTransactionImplementation CreateTransaction()
        {
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));

            try
            {
                TransactionHeaderInformation        headerInformation        = new TransactionHeaderInformation(-1, -1, new sbyte[0]);
                TransactionHeaderInformationFactory headerInformationFactory = mock(typeof(TransactionHeaderInformationFactory));
                when(headerInformationFactory.Create()).thenReturn(headerInformation);
                StorageEngine storageEngine = mock(typeof(StorageEngine));
                StorageReader storageReader = mock(typeof(StorageReader));
                when(storageEngine.NewReader()).thenReturn(storageReader);

                SimpleStatementLocks locks = new SimpleStatementLocks(mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client)));
                when(transaction.StatementLocks()).thenReturn(locks);
                when(transaction.TokenRead()).thenReturn(_tokenRead);
                when(transaction.SchemaRead()).thenReturn(_schemaRead);
                when(transaction.SchemaWrite()).thenReturn(_schemaWrite);
                TransactionState transactionState = mock(typeof(TransactionState));
                when(transaction.TxState()).thenReturn(transactionState);
                when(transaction.IndexUniqueCreate(any(typeof(SchemaDescriptor)), any(typeof(string)))).thenAnswer(i => IndexDescriptorFactory.uniqueForSchema(i.getArgument(0)));
            }
            catch (InvalidTransactionTypeKernelException)
            {
                fail("Expected write transaction");
            }
            catch (SchemaKernelException e)
            {
                throw new Exception(e);
            }
            return(transaction);
        }
예제 #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            _index = LuceneSchemaIndexBuilder.create(IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)), Config.defaults()).withFileSystem(Fs).withIndexRootFolder(Directory.directory()).build();
            _index.create();
            _index.open();
        }
예제 #20
0
 private StoreIndexDescriptor Descriptor(long indexId)
 {
     return(IndexDescriptorFactory.forSchema(forLabel(LABEL_ID, PROP_ID), PROVIDER_DESCRIPTOR).withId(indexId));
 }
예제 #21
0
 private StoreIndexDescriptor IndexRule(long ruleId, IndexProviderDescriptor descriptor, int labelId, params int[] propertyIds)
 {
     return(IndexDescriptorFactory.forSchema(forLabel(labelId, propertyIds), descriptor).withId(ruleId));
 }
예제 #22
0
 private StoreIndexDescriptor DescriptorUnique()
 {
     return(IndexDescriptorFactory.uniqueForSchema(forLabel(LABEL_ID, PROP_ID), PROVIDER_DESCRIPTOR).withId(INDEX_ID));
 }