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 testOffsetFileChannel() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestOffsetFileChannel()
        {
            using (JumpingFileSystemAbstraction offsetFileSystem = new JumpingFileSystemAbstraction(10))
            {
                File fileName = new File("target/var/neostore.nodestore.db");
                offsetFileSystem.DeleteFile(fileName);
                offsetFileSystem.Mkdirs(fileName.ParentFile);
                IdGenerator idGenerator = (new JumpingIdGeneratorFactory(10)).Get(IdType.NODE);

                using (JumpingFileChannel channel = ( JumpingFileChannel )offsetFileSystem.Open(fileName, OpenMode.READ_WRITE))
                {
                    for (int i = 0; i < 16; i++)
                    {
                        WriteSomethingLikeNodeRecord(channel, idGenerator.NextId(), i);
                    }
                }
                using (JumpingFileChannel channel = ( JumpingFileChannel )offsetFileSystem.Open(fileName, OpenMode.READ_WRITE))
                {
                    idGenerator = (new JumpingIdGeneratorFactory(10)).Get(IdType.NODE);

                    for (int i = 0; i < 16; i++)
                    {
                        assertEquals(i, ReadSomethingLikeNodeRecord(channel, idGenerator.NextId()));
                    }
                }
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeSomethingLikeNodeRecord(org.neo4j.kernel.impl.core.JumpingFileSystemAbstraction.JumpingFileChannel channel, long id, int justAByte) throws java.io.IOException
        private void WriteSomethingLikeNodeRecord(JumpingFileChannel channel, long id, int justAByte)
        {
            channel.Position(id * RECORD_SIZE);
            ByteBuffer buffer = ByteBuffer.allocate(RECORD_SIZE);

            buffer.putLong(4321);
            buffer.put(( sbyte )justAByte);
            buffer.flip();
            channel.Write(buffer);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private byte readSomethingLikeNodeRecord(org.neo4j.kernel.impl.core.JumpingFileSystemAbstraction.JumpingFileChannel channel, long id) throws java.io.IOException
        private sbyte ReadSomethingLikeNodeRecord(JumpingFileChannel channel, long id)
        {
            ByteBuffer buffer = ByteBuffer.allocate(RECORD_SIZE);

            channel.Position(id * RECORD_SIZE);
            channel.Read(buffer);
            buffer.flip();
            buffer.Long;
            return(buffer.get());
        }