Beispiel #1
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));
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParseHeaderFromFirstLineOfFirstInputFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParseHeaderFromFirstLineOfFirstInputFile()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.csv.reader.CharReadable firstSource = wrap("id:ID\tname:String\tbirth_date:long");
            CharReadable firstSource = wrap("id:ID\tname:String\tbirth_date:long");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.csv.reader.CharReadable secondSource = wrap("0\tThe node\t123456789");
            CharReadable secondSource = wrap("0\tThe node\t123456789");
            DataFactory  dataFactory  = DataFactories.Data(value => value, () => new MultiReadable(Readables.iterator(IOFunctions.identity(), firstSource, secondSource)));

            Header.Factory headerFactory = defaultFormatNodeFileHeader();
            Extractors     extractors    = new Extractors(';');

            // WHEN
            CharSeeker seeker = CharSeekers.charSeeker(new MultiReadable(dataFactory.Create(_tabs).stream()), _tabs, false);
            Header     header = headerFactory.Create(seeker, _tabs, IdType.Actual, _groups);

            // THEN
            assertArrayEquals(array(Entry("id", Type.Id, extractors.Long_()), Entry("name", Type.Property, extractors.String()), Entry("birth_date", Type.Property, extractors.Long_())), header.Entries());
            seeker.Dispose();
        }