コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private <R extends org.neo4j.kernel.impl.store.record.AbstractBaseRecord> void verifyWriteAndRead(System.Func<RecordFormat<R>> formatSupplier, System.Func<org.neo4j.kernel.impl.store.format.RecordGenerators_Generator<R>> generatorSupplier, System.Func<RecordKey<R>> keySupplier, boolean assertPostReadOffset) throws java.io.IOException
        private void VerifyWriteAndRead <R>(System.Func <RecordFormat <R> > formatSupplier, System.Func <RecordGenerators_Generator <R> > generatorSupplier, System.Func <RecordKey <R> > keySupplier, bool assertPostReadOffset) where R : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord
        {
            // GIVEN
            using (PagedFile storeFile = _pageCache.map(new File("store-" + Name.MethodName), _pageSize, CREATE))
            {
                RecordFormat <R> format = formatSupplier();
                RecordKey <R>    key    = keySupplier();
                RecordGenerators_Generator <R> generator = generatorSupplier();
                int recordSize = format.GetRecordSize(new IntStoreHeader(DATA_SIZE));
                BatchingIdSequence idSequence = new BatchingIdSequence(_random.nextBoolean() ? IdSureToBeOnTheNextPage(_pageSize, recordSize) : 10);

                // WHEN
                long time    = currentTimeMillis();
                long endTime = time + TEST_TIME;
                long i       = 0;
                for ( ; i < TEST_ITERATIONS && currentTimeMillis() < endTime; i++)
                {
                    R written = generator.Get(recordSize, format, i % 5);
                    R read    = format.NewRecord();
                    try
                    {
                        WriteRecord(written, format, storeFile, recordSize, idSequence);
                        ReadAndVerifyRecord(written, read, format, key, storeFile, recordSize, assertPostReadOffset);
                        idSequence.Reset();
                    }
                    catch (Exception t)
                    {
                        Exceptions.setMessage(t, t.Message + " : written:" + written + ", read:" + read + ", seed:" + _random.seed() + ", iteration:" + i);
                        throw t;
                    }
                }
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private DataFactory generateData(Header.Factory factory, org.apache.commons.lang3.mutable.MutableLong start, long count, long nodeCount, String headerString, String fileName, org.neo4j.unsafe.impl.batchimport.input.Groups groups) throws java.io.IOException
        private DataFactory GenerateData(Header.Factory factory, MutableLong start, long count, long nodeCount, string headerString, string fileName, Groups groups)
        {
            File   file   = Directory.file(fileName);
            Header header = factory.Create(charSeeker(wrap(headerString), COMMAS, false), COMMAS, IdType.Integer, groups);
            Distribution <string>    distribution    = new Distribution <string>(new string[] { "Token" });
            Deserialization <string> deserialization = new StringDeserialization(COMMAS);

            using (PrintWriter @out = new PrintWriter(new StreamWriter(file)), RandomEntityDataGenerator generator = new RandomEntityDataGenerator(nodeCount, count, toIntExact(count), Random.seed(), start.longValue(), header, distribution, distribution, 0, 0), InputChunk chunk = generator.NewChunk(), InputEntity entity = new InputEntity())
            {
                @out.println(headerString);
                while (generator.Next(chunk))
                {
                    while (chunk.Next(entity))
                    {
                        @out.println(convert(entity, deserialization, header));
                    }
                }
            }
            start.add(count);
            return(DataFactories.Data(InputEntityDecorators.NO_DECORATOR, Charsets.UTF_8, file));
        }