Exemple #1
0
        /// <summary>
        ///     Constructs a BatchGraph wrapping the provided baseGraph, using the specified buffer size and expecting vertex ids of
        ///     the specified IdType. Supplying vertex ids which do not match this type will throw exceptions.
        /// </summary>
        /// <param name="graph">Graph to be wrapped</param>
        /// <param name="type"> Type of vertex id expected. This information is used to optimize the vertex cache memory footprint.</param>
        /// <param name="bufferSize">Defines the number of vertices and edges loaded before starting a new transaction. The larger this value,
        /// the more memory is required but the faster the loading process.</param>
        public BatchGraph(ITransactionalGraph graph, VertexIdType type, long bufferSize)
        {
            if (graph == null)
            {
                throw new ArgumentNullException(nameof(graph));
            }
            if (bufferSize <= 0)
            {
                throw new ArgumentException("bufferSize must be greater than zero");
            }

            _baseGraph           = graph;
            _bufferSize          = bufferSize;
            _vertexIdKey         = null;
            _edgeIdKey           = null;
            _cache               = type.GetVertexCache();
            _remainingBufferSize = _bufferSize;
        }
        public static IVertexCache GetVertexCache(this VertexIdType vertexIdType)
        {
            switch (vertexIdType)
            {
            case VertexIdType.Object:
                return(new ObjectIdVertexCache());

            case VertexIdType.Number:
                return(new LongIdVertexCache());

            case VertexIdType.String:
                return(new StringIdVertexCache());

            case VertexIdType.Url:
                return(new StringIdVertexCache(new UrlCompression()));

            default:
                throw new ArgumentException(string.Concat("Unrecognized ID type: ", vertexIdType));
            }
        }