예제 #1
0
파일: CsvInput.cs 프로젝트: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long[] sample(Iterable<DataFactory> dataFactories, Header.Factory headerFactory, System.Func<org.neo4j.values.storable.Value[], int> valueSizeCalculator, System.Func<org.neo4j.unsafe.impl.batchimport.input.InputEntity, int> additionalCalculator) throws java.io.IOException
        private long[] Sample(IEnumerable <DataFactory> dataFactories, Header.Factory headerFactory, System.Func <Value[], int> valueSizeCalculator, System.Func <InputEntity, int> additionalCalculator)
        {
            long[] estimates = new long[4];               // [entity count, property count, property size, labels (for nodes only)]
            using (CsvInputChunkProxy chunk = new CsvInputChunkProxy())
            {
                // One group of input files
                int groupId = 0;
                foreach (DataFactory dataFactory in dataFactories)                           // one input group
                {
                    groupId++;
                    Header header = null;
                    Data   data   = dataFactory.Create(_config);
                    RawIterator <CharReadable, IOException> sources = data.Stream();
                    while (sources.HasNext())
                    {
                        using (CharReadable source = sources.Next())
                        {
                            if (header == null)
                            {
                                // Extract the header from the first file in this group
                                header = extractHeader(source, headerFactory, _idType, _config, _groups);
                            }
                            using (CsvInputIterator iterator = new CsvInputIterator(source, data.Decorator(), header, _config, _idType, EMPTY, extractors(_config), groupId), InputEntity entity = new InputEntity())
                            {
                                int entities     = 0;
                                int properties   = 0;
                                int propertySize = 0;
                                int additional   = 0;
                                while (iterator.Position() < _estimateSampleSize && iterator.Next(chunk))
                                {
                                    for ( ; chunk.Next(entity); entities++)
                                    {
                                        properties   += entity.PropertyCount();
                                        propertySize += calculatePropertySize(entity, valueSizeCalculator);
                                        additional   += additionalCalculator(entity);
                                    }
                                }
                                if (entities > 0)
                                {
                                    long entityCountInSource = ( long )((( double )source.Length() / iterator.Position()) * entities);
                                    estimates[0] += entityCountInSource;
                                    estimates[1] += ( long )((( double )properties / entities) * entityCountInSource);
                                    estimates[2] += ( long )((( double )propertySize / entities) * entityCountInSource);
                                    estimates[3] += ( long )((( double )additional / entities) * entityCountInSource);
                                }
                            }
                        }
                    }
                }
            }
            return(estimates);
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public boolean next(CsvInputChunkProxy proxy) throws java.io.IOException
        public virtual bool Next(CsvInputChunkProxy proxy)
        {
            proxy.EnsureInstantiated(_realInputChunkSupplier, _groupId);
            return(proxy.FillFrom(_chunker));
        }