Ejemplo n.º 1
0
 protected internal EntityImporter(BatchingNeoStores stores, Monitor monitor)
 {
     this._propertyStore = stores.PropertyStore;
     this._propertyKeyTokenRepository = stores.PropertyKeyRepository;
     this.Monitor = monitor;
     for (int i = 0; i < _propertyBlocks.Length; i++)
     {
         _propertyBlocks[i] = new PropertyBlock();
     }
     this._propertyRecord = _propertyStore.newRecord();
     this._propertyIds    = new BatchingIdGetter(_propertyStore);
     this._dynamicStringRecordAllocator = new StandardDynamicRecordAllocator(new BatchingIdGetter(_propertyStore.StringStore, _propertyStore.StringStore.RecordsPerPage), _propertyStore.StringStore.RecordDataSize);
     this._dynamicArrayRecordAllocator  = new StandardDynamicRecordAllocator(new BatchingIdGetter(_propertyStore.ArrayStore, _propertyStore.ArrayStore.RecordsPerPage), _propertyStore.StringStore.RecordDataSize);
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFlushNewTokens()
        public virtual void ShouldFlushNewTokens()
        {
            // given

            try (PageCache pageCache = Storage.pageCache(); NeoStores stores = new StoreFactory(Storage.directory().databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(Storage.fileSystem()), pageCache, Storage.fileSystem(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY)
                                                                               .openNeoStores(true, StoreType.PROPERTY_KEY_TOKEN, StoreType.PROPERTY_KEY_TOKEN_NAME))
                {
                    TokenStore <PropertyKeyTokenRecord> tokenStore = stores.PropertyKeyTokenStore;
                    int rounds         = 3;
                    int tokensPerRound = 4;
                    using (BatchingPropertyKeyTokenRepository repo = new BatchingPropertyKeyTokenRepository(tokenStore))
                    {
                        // when first creating some tokens
                        int expectedId     = 0;
                        int tokenNameAsInt = 0;
                        for (int round = 0; round < rounds; round++)
                        {
                            for (int i = 0; i < tokensPerRound; i++)
                            {
                                int tokenId = repo.GetOrCreateId((tokenNameAsInt++).ToString());
                                assertEquals(expectedId + i, tokenId);
                            }
                            assertEquals(expectedId, tokenStore.HighId);
                            repo.Flush();
                            assertEquals(expectedId + tokensPerRound, tokenStore.HighId);
                            expectedId += tokensPerRound;
                        }
                    }

                    IList <NamedToken> tokens = tokenStore.Tokens;
                    assertEquals(tokensPerRound * rounds, tokens.Count);
                    foreach (NamedToken token in tokens)
                    {
                        assertEquals(token.Id(), parseInt(token.Name()));
                    }
                }
        }
    }