//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateAndOpenStoreWithNoDataAndEmptyHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCreateAndOpenStoreWithNoDataAndEmptyHeader()
        {
            // given
            Format format = new Format(this);

            // when
            using (KeyValueStoreFile file = format.Create(NoHeaders(), NoData()))
            {
                // then
                assertTrue(file.Headers().fields().Count == 0);
                AssertEntries(0, file);
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected final void visitFile(java.io.File path, Visitor visitor) throws java.io.IOException
        protected internal void VisitFile(File path, Visitor visitor)
        {
            using (KeyValueStoreFile file = RotationStrategy.openStoreFile(path))
            {
                if (visitor is MetadataVisitor)
                {
                    (( MetadataVisitor )visitor).VisitMetadata(path, file.Headers(), file.EntryCount());
                }
                using (DataProvider provider = file.DataProvider())
                {
                    Transfer(provider, visitor);
                }
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateAndOpenStoreWithDataAndEmptyHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCreateAndOpenStoreWithDataAndEmptyHeader()
        {
            // given
            Format format = new Format(this);
            Data   data   = data(entry(new sbyte[] { ( sbyte )'o', ( sbyte )'n', ( sbyte )'e' }, new sbyte[] { ( sbyte )'a', ( sbyte )'l', ( sbyte )'p', ( sbyte )'h', ( sbyte )'a' }), entry(new sbyte[] { ( sbyte )'t', ( sbyte )'w', ( sbyte )'o' }, new sbyte[] { ( sbyte )'b', ( sbyte )'e', ( sbyte )'t', ( sbyte )'a' }), entry(new sbyte[] { ( sbyte )'z', ( sbyte )'e', ( sbyte )'d' }, new sbyte[] { ( sbyte )'o', ( sbyte )'m', ( sbyte )'e', ( sbyte )'g', ( sbyte )'a' }));

            // when
            using (KeyValueStoreFile file = format.Create(NoHeaders(), data))
            {
                // then
                assertTrue(file.Headers().fields().Count == 0);
                file.Scan(ExpectData(data));
                assertEquals("number of entries", 3, data.Index);
                AssertEntries(3, file);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateAndOpenStoreWithNoDataWithHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCreateAndOpenStoreWithNoDataWithHeader()
        {
            // given
            Format format = new Format(this, "abc", "xyz");
            IDictionary <string, sbyte[]> headers = new Dictionary <string, sbyte[]>();

            headers["abc"] = new sbyte[] { ( sbyte )'h', ( sbyte )'e', ( sbyte )'l', ( sbyte )'l', ( sbyte )'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            headers["xyz"] = new sbyte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ( sbyte )'w', ( sbyte )'o', ( sbyte )'r', ( sbyte )'l', ( sbyte )'d' };

            // when
            using (KeyValueStoreFile file = format.Create(headers, NoData()))
            {
                // then
                AssertDeepEquals(headers, file.Headers());
                AssertEntries(0, file);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateAndOpenEmptyStoreWithHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCreateAndOpenEmptyStoreWithHeader()
        {
            // given
            Format format = new Format(this, "foo", "bar");
            IDictionary <string, sbyte[]> headers = new Dictionary <string, sbyte[]>();

            headers["foo"] = new sbyte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ( sbyte )'f', ( sbyte )'o', ( sbyte )'o' };
            headers["bar"] = new sbyte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ( sbyte )'b', ( sbyte )'a', ( sbyte )'r' };

            // when
            format.CreateEmpty(headers);

            // then
            using (KeyValueStoreFile file = format.Open())
            {
                AssertDeepEquals(headers, file.Headers());
                AssertEntries(0, file);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateAndOpenStoreWithDataAndHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCreateAndOpenStoreWithDataAndHeader()
        {
            // given
            Format format = new Format(this, "abc", "xyz");
            IDictionary <string, sbyte[]> headers = new Dictionary <string, sbyte[]>();

            headers["abc"] = new sbyte[] { ( sbyte )'h', ( sbyte )'e', ( sbyte )'l', ( sbyte )'l', ( sbyte )'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            headers["xyz"] = new sbyte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ( sbyte )'w', ( sbyte )'o', ( sbyte )'r', ( sbyte )'l', ( sbyte )'d' };
            Data data = data(entry(new sbyte[] { ( sbyte )'o', ( sbyte )'n', ( sbyte )'e' }, new sbyte[] { ( sbyte )'a', ( sbyte )'l', ( sbyte )'p', ( sbyte )'h', ( sbyte )'a' }), entry(new sbyte[] { ( sbyte )'t', ( sbyte )'w', ( sbyte )'o' }, new sbyte[] { ( sbyte )'b', ( sbyte )'e', ( sbyte )'t', ( sbyte )'a' }), entry(new sbyte[] { ( sbyte )'z', ( sbyte )'e', ( sbyte )'d' }, new sbyte[] { ( sbyte )'o', ( sbyte )'m', ( sbyte )'e', ( sbyte )'g', ( sbyte )'a' }));

            // when
            using (KeyValueStoreFile file = format.Create(headers, data))
            {
                // then
                AssertDeepEquals(headers, file.Headers());
                file.Scan(ExpectData(data));
                assertEquals("number of entries", 3, data.Index);
                AssertEntries(3, file);
            }
        }
Пример #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public final org.neo4j.helpers.collection.Pair<java.io.File, KeyValueStoreFile> open() throws java.io.IOException
        public Pair <File, KeyValueStoreFile> Open()
        {
            KeyValueStoreFile result = null;
            File path = null;

            foreach (File candidatePath in CandidateFiles())
            {
                KeyValueStoreFile file;
                if (Fs.fileExists(candidatePath))
                {
                    try
                    {
                        file = _format.openStore(Fs, Pages, candidatePath);
                    }
                    catch (Exception e)
                    {
                        _monitor.failedToOpenStoreFile(candidatePath, e);
                        continue;
                    }
                    if (result == null || _format.compareHeaders(result.Headers(), file.Headers()) < 0)
                    {
                        if (result != null)
                        {
                            result.Dispose();
                        }
                        result = file;
                        path   = candidatePath;
                    }
                    else
                    {
                        file.Dispose();
                    }
                }
            }
            return(result == null ? null : Pair.of(path, result));
        }