示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void main(String[] arguments) throws java.io.IOException
        public static void Main(string[] arguments)
        {
            Args          args                  = Args.parse(arguments);
            long          nodeCount             = Settings.parseLongWithUnit(args.Get("nodes", null));
            long          relationshipCount     = Settings.parseLongWithUnit(args.Get("relationships", null));
            int           labelCount            = args.GetNumber("labels", 4).intValue();
            int           relationshipTypeCount = args.GetNumber("relationship-types", 4).intValue();
            File          dir        = new File(args.Get(ImportTool.Options.StoreDir.key()));
            long          randomSeed = args.GetNumber("random-seed", currentTimeMillis()).longValue();
            Configuration config     = Configuration.COMMAS;

            Extractors extractors = new Extractors(config.ArrayDelimiter());
            IdType     idType     = IdType.valueOf(args.Get("id-type", IdType.INTEGER.name()));

            Groups groups             = new Groups();
            Header nodeHeader         = ParseNodeHeader(args, idType, extractors, groups);
            Header relationshipHeader = ParseRelationshipHeader(args, idType, extractors, groups);

            Config dbConfig;
            string dbConfigFileName = args.Get(ImportTool.Options.DatabaseConfig.key(), null);

            if (!string.ReferenceEquals(dbConfigFileName, null))
            {
                dbConfig = (new Config.Builder()).withFile(new File(dbConfigFileName)).build();
            }
            else
            {
                dbConfig = Config.defaults();
            }

            bool highIo = args.GetBoolean(ImportTool.Options.HighIo.key());

            LogProvider logging         = NullLogProvider.Instance;
            long        pageCacheMemory = args.GetNumber("pagecache-memory", [email protected]_Fields.MaxPageCacheMemory).longValue();

            [email protected] importConfig = new ConfigurationAnonymousInnerClass(args, highIo, pageCacheMemory);

            float factorBadNodeData         = args.GetNumber("factor-bad-node-data", 0).floatValue();
            float factorBadRelationshipData = args.GetNumber("factor-bad-relationship-data", 0).floatValue();

            Input input = new DataGeneratorInput(nodeCount, relationshipCount, idType, Collector.EMPTY, randomSeed, 0, nodeHeader, relationshipHeader, labelCount, relationshipTypeCount, factorBadNodeData, factorBadRelationshipData);

            using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), Lifespan life = new Lifespan())
            {
                BatchImporter consumer;
                if (args.GetBoolean("to-csv"))
                {
                    consumer = new CsvOutput(dir, nodeHeader, relationshipHeader, config);
                }
                else
                {
                    Console.WriteLine("Seed " + randomSeed);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.scheduler.JobScheduler jobScheduler = life.add(createScheduler());
                    JobScheduler jobScheduler = life.Add(createScheduler());
                    consumer = BatchImporterFactory.withHighestPriority().instantiate(DatabaseLayout.of(dir), fileSystem, null, importConfig, new SimpleLogService(logging, logging), defaultVisible(jobScheduler), EMPTY, dbConfig, RecordFormatSelector.selectForConfig(dbConfig, logging), NO_MONITOR, jobScheduler);
                    ImportTool.PrintOverview(dir, Collections.emptyList(), Collections.emptyList(), importConfig, System.out);
                }
                consumer.DoImport(input);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: CsvImporter(org.neo4j.helpers.Args args, org.neo4j.kernel.configuration.Config databaseConfig, org.neo4j.commandline.admin.OutsideWorld outsideWorld) throws org.neo4j.commandline.admin.IncorrectUsage
        internal CsvImporter(Args args, Config databaseConfig, OutsideWorld outsideWorld)
        {
            this._args              = args;
            this._outsideWorld      = outsideWorld;
            _nodesFiles             = extractInputFiles(args, "nodes", outsideWorld.ErrorStream());
            _relationshipsFiles     = extractInputFiles(args, "relationships", outsideWorld.ErrorStream());
            _reportFileName         = args.InterpretOption("report-file", withDefault(ImportCommand.DEFAULT_REPORT_FILE_NAME), s => s);
            _ignoreExtraColumns     = args.GetBoolean("ignore-extra-columns", false).Value;
            _ignoreDuplicateNodes   = args.GetBoolean("ignore-duplicate-nodes", false).Value;
            _ignoreBadRelationships = args.GetBoolean("ignore-missing-nodes", false).Value;
            try
            {
                validateInputFiles(_nodesFiles, _relationshipsFiles);
            }
            catch (System.ArgumentException e)
            {
                throw new IncorrectUsage(e.Message);
            }

            _idType              = args.InterpretOption("id-type", withDefault(IdType.STRING), from => IdType.valueOf(from.ToUpper()));
            _inputEncoding       = Charset.forName(args.Get("input-encoding", defaultCharset().name()));
            _highIO              = args.GetBoolean("high-io", null, true);    // intentionally left as null if not specified
            this._databaseConfig = databaseConfig;
        }