Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleBigNumberOfLabelsAndRelationshipTypes()
        public virtual void ShouldHandleBigNumberOfLabelsAndRelationshipTypes()
        {
            /*
             * This test ensures that the RelationshipCountsProcessor does not attempt to allocate a negative amount
             * of memory when trying to get an array to store the relationship counts. This could happen when the labels
             * and relationship types were enough in number to overflow an integer used to hold a product of those values.
             * Here we ask the Processor to do that calculation and ensure that the number passed to the NumberArrayFactory
             * is positive.
             */
            // Given

            /*
             * A large but not impossibly large number of labels and relationship types. These values are the simplest
             * i could find in a reasonable amount of time that would result in an overflow. Given that the calculation
             * involves squaring the labelCount, 22 bits are more than enough for an integer to overflow. However, the
             * actual issue involves adding a product of relTypeCount and some other things, which makes hard to predict
             * which values will make it go negative. These worked. Given that with these values the integer overflows
             * some times over, it certainly works with much smaller numbers, but they don't come out of a nice simple bit
             * shifting.
             */
            int relTypeCount = 1 << 8;
            int labelCount   = 1 << 22;
            NumberArrayFactory numberArrayFactory = mock(typeof(NumberArrayFactory));

            // When
            new RelationshipCountsProcessor(_nodeLabelCache, labelCount, relTypeCount, _countsUpdater, numberArrayFactory);

            // Then
            verify(numberArrayFactory, times(2)).newLongArray(longThat(new IsNonNegativeLong(this)), anyLong());
        }
 public RelationshipGroupDefragmenter(Configuration config, ExecutionMonitor executionMonitor, Monitor monitor, NumberArrayFactory numberArrayFactory)
 {
     this._config             = config;
     this._executionMonitor   = executionMonitor;
     this._monitor            = monitor;
     this._numberArrayFactory = numberArrayFactory;
 }
Exemplo n.º 3
0
 public CountsComputer(long lastCommittedTransactionId, NodeStore nodes, RelationshipStore relationships, int highLabelId, int highRelationshipTypeId, NumberArrayFactory numberArrayFactory, ProgressReporter progressMonitor)
 {
     this._lastCommittedTransactionId = lastCommittedTransactionId;
     this._nodes                  = nodes;
     this._relationships          = relationships;
     this._highLabelId            = highLabelId;
     this._highRelationshipTypeId = highRelationshipTypeId;
     this._numberArrayFactory     = numberArrayFactory;
     this._progressMonitor        = progressMonitor;
 }
Exemplo n.º 4
0
 public override IdMapper IdMapper(NumberArrayFactory numberArrayFactory)
 {
     return(IdMappers.actual());
 }
Exemplo n.º 5
0
        public RelationshipCountsStage(Configuration config, NodeLabelsCache cache, RelationshipStore relationshipStore, int highLabelId, int highRelationshipTypeId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, NumberArrayFactory cacheFactory, ProgressReporter progressReporter) : base(NAME, null, config, RECYCLE_BATCHES)
        {
            Add(new BatchFeedStep(Control(), config, allIn(relationshipStore, config), relationshipStore.RecordSize));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: add(new org.neo4j.unsafe.impl.batchimport.staging.ReadRecordsStep<>(control(), config, false, relationshipStore));
            Add(new ReadRecordsStep <object>(Control(), config, false, relationshipStore));
            Add(new ProcessRelationshipCountsDataStep(Control(), cache, config, highLabelId, highRelationshipTypeId, countsUpdater, cacheFactory, progressReporter));
        }
Exemplo n.º 6
0
 public abstract [email protected] idMapper([email protected] numberArrayFactory, [email protected] groups);
Exemplo n.º 7
0
 private CountsComputer(long lastCommittedTransactionId, NodeStore nodes, RelationshipStore relationships, int highLabelId, int highRelationshipTypeId, NumberArrayFactory numberArrayFactory) : this(lastCommittedTransactionId, nodes, relationships, highLabelId, highRelationshipTypeId, numberArrayFactory, SilentProgressReporter.INSTANCE)
 {
 }
Exemplo n.º 8
0
 internal CountsComputer(NeoStores stores, PageCache pageCache, DatabaseLayout databaseLayout) : this(stores.MetaDataStore.LastCommittedTransactionId, stores.NodeStore, stores.RelationshipStore, ( int )stores.LabelTokenStore.HighId, ( int )stores.RelationshipTypeTokenStore.HighId, NumberArrayFactory.auto(pageCache, databaseLayout.DatabaseDirectory(), true, [email protected]_Fields.NoMonitor))
 {
 }
Exemplo n.º 9
0
 public IdMapper idMapper(NumberArrayFactory numberArrayFactory)
 {
     return(_idMapper);
 }
Exemplo n.º 10
0
        public RelationshipCountsProcessor(NodeLabelsCache nodeLabelCache, int highLabelId, int highRelationshipTypeId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, NumberArrayFactory cacheFactory)
        {
            this._nodeLabelCache = nodeLabelCache;
            this._client         = nodeLabelCache.NewClient();
            this._countsUpdater  = countsUpdater;

            // Make room for high id + 1 since we need that extra slot for the ANY counts
            this._anyLabel            = highLabelId;
            this._anyRelationshipType = highRelationshipTypeId;
            this._itemsPerType        = _anyLabel + 1;
            this._itemsPerLabel       = _anyRelationshipType + 1;
            this._labelsCounts        = cacheFactory.NewLongArray(SideSize() * SIDES, 0);
            this._wildcardCounts      = cacheFactory.NewLongArray(_anyRelationshipType + 1, 0);
        }