Package org.neo4j.kernel.impl.nioneo.store

Examples of org.neo4j.kernel.impl.nioneo.store.IdGenerator


        }

        public Void execute( GraphDatabaseService db )
        {
            Config config = getConfig( db );
            IdGenerator generator = config.getIdGeneratorFactory().get( IdType.NODE );
            for ( int i = 0; i < count; i++ )
            {
                generator.nextId();
            }
            return null;
        }
View Full Code Here


            this.receiver = receiver;
        }
       
        public IdGenerator open( String fileName, int grabSize, IdType idType, long highestIdInUse )
        {
            IdGenerator localIdGenerator = localFactory.open( fileName, grabSize,
                    idType, highestIdInUse );
            SlaveIdGenerator generator = new SlaveIdGenerator( idType, highestIdInUse, broker,
                    receiver, localIdGenerator );
            generators.put( idType, generator );
            return generator;
View Full Code Here

        private final Map<IdType, IdGenerator> generators = new HashMap<IdType, IdGenerator>();
       
        public IdGenerator open( String fileName, int grabSize, IdType idType,
                long highestIdInUse )
        {
            IdGenerator generator = new IdGeneratorImpl( fileName, grabSize, idType.getMaxValue() );
            generators.put( idType, generator );
            return generator;
        }
View Full Code Here

        return result;
    }

    public Response<IdAllocation> allocateIds( IdType idType )
    {
        IdGenerator generator = graphDbConfig.getIdGeneratorFactory().get( idType );
        IdAllocation result = new IdAllocation( generator.nextIdBatch( ID_GRAB_SIZE ), generator.getHighId(),
                generator.getDefragCount() );
        return MasterUtil.packResponseWithoutTransactionStream( graphDb, SlaveContext.EMPTY, result );
    }
View Full Code Here

    public IdGenerator get( IdType idType )
    {
        if ( idType == IdType.NODE || idType == IdType.RELATIONSHIP || idType == IdType.PROPERTY ||
                idType == IdType.STRING_BLOCK || idType == IdType.ARRAY_BLOCK )
        {
            IdGenerator generator = generators.get( idType );
            if ( generator == null )
            {
                generator = new JumpingIdGenerator();
                generators.put( idType, generator );
            }
View Full Code Here

    @Test
    public void testIt() throws Exception
    {
        int sizePerJump = 1000;
        IdGeneratorFactory factory = new JumpingIdGeneratorFactory( sizePerJump );
        IdGenerator generator = factory.get( IdType.NODE );
        for ( int i = 0; i < sizePerJump/2; i++ )
        {
            assertEquals( (long)i, generator.nextId() );
        }
       
        for ( int i = 0; i < sizePerJump-1; i++ )
        {
            long expected = 0x100000000L-sizePerJump/2+i;
            if ( expected >= 0xFFFFFFFFL )
            {
                expected++;
            }
            assertEquals( expected, generator.nextId() );
        }

        for ( int i = 0; i < sizePerJump; i++ )
        {
            assertEquals( 0x200000000L-sizePerJump/2+i, generator.nextId() );
        }

        for ( int i = 0; i < sizePerJump; i++ )
        {
            assertEquals( 0x300000000L-sizePerJump/2+i, generator.nextId() );
        }
    }
View Full Code Here

    public void testOffsettedFileChannel() throws Exception
    {
        String fileName = "target/var/neostore.nodestore.db";
        deleteFileOrDirectory( fileName );
        FileSystemAbstraction offsettedFileSystem = new JumpingFileSystemAbstraction( 10 );
        IdGenerator idGenerator = new JumpingIdGeneratorFactory( 10 ).get( IdType.NODE );
        JumpingFileChannel channel = (JumpingFileChannel) offsettedFileSystem.open( fileName, "rw" );
       
        for ( int i = 0; i < 16; i++ )
        {
            writeSomethingLikeNodeRecord( channel, idGenerator.nextId(), i );
        }
       
        channel.close();
        channel = (JumpingFileChannel) offsettedFileSystem.open( fileName, "rw" );
        idGenerator = new JumpingIdGeneratorFactory( 10 ).get( IdType.NODE );
       
        for ( int i = 0; i < 16; i++ )
        {
            assertEquals( i, readSomethingLikeNodeRecord( channel, idGenerator.nextId() ) );
        }
       
        channel.close();
    }
View Full Code Here

TOP

Related Classes of org.neo4j.kernel.impl.nioneo.store.IdGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.