Class MemoryEstimations.Builder

  • Enclosing class:
    MemoryEstimations

    public static final class MemoryEstimations.Builder
    extends java.lang.Object
    • Method Detail

      • startField

        public MemoryEstimations.Builder startField​(java.lang.String name,
                                                    java.lang.Class<?> type)
        Starts the construction of new sub-components. The returned builder is used to construct the sub-component. After construction, endField() must be called to return to the parent builder.
        Parameters:
        name - description of the sub-component
        type - type to estimate fields for
        Returns:
        a builder for the sub-component
      • startField

        public MemoryEstimations.Builder startField​(java.lang.String name)
        Starts the construction of new sub-components. The returned builder is used to construct the sub-component. After construction, endField() must be called to return to the parent builder.
        Parameters:
        name - description of the sub-component
        Returns:
        a builder for the sub-component
      • endField

        public MemoryEstimations.Builder endField()
        Ends the construction of a sub-component and returns the parent builder.
        Returns:
        parent builder
        Throws:
        java.lang.IllegalArgumentException - if this is the root builder
      • add

        public MemoryEstimations.Builder add​(java.lang.String description,
                                             MemoryEstimation estimation)
        Adds a MemoryEstimation as a sub-component to the builder. Uses the given description as sub-component name.
        Parameters:
        description - description of the sub-component
        estimation - new sub-component
        Returns:
        this builder
      • field

        public MemoryEstimations.Builder field​(java.lang.String description,
                                               java.lang.Class<?> type)
        Adds the memory consumption of the given class as a sub-component to this builder. This is shorthand syntax for:
         
         builder.startField(name, type);
         builder.endField();
         
         
        or
         
         builder.add(name, MemoryEstimations.of(type);
         
         
        Parameters:
        description - description of the sub-component
        type - class type
        Returns:
        this builder
      • fixed

        public MemoryEstimations.Builder fixed​(java.lang.String description,
                                               long bytes)
        Adds a fixed amount of memory consumption in bytes to the builder.
        Parameters:
        description - description of the sub-component
        bytes - memory consumption in bytes
        Returns:
        this builder
      • fixed

        public MemoryEstimations.Builder fixed​(java.lang.String description,
                                               MemoryRange range)
        Adds a fixed memory range to the builder.
        Parameters:
        description - description of the sub-component
        range - memory range
        Returns:
        this builder
      • perNodeVector

        public MemoryEstimations.Builder perNodeVector​(java.lang.String description,
                                                       long sizeOfVector,
                                                       java.util.function.LongUnaryOperator fn)
        Adds a new sub-component to the builder. The memory consumption (in bytes) is being computed by the supplied function. The input to that function is the number of nodes times within the graph times the vector size.
        Parameters:
        description - description of the sub-component
        sizeOfVector - number elements in each node vector
        fn - function to compute memory consumption in bytes
        Returns:
        this builder
      • perNode

        public MemoryEstimations.Builder perNode​(java.lang.String description,
                                                 MemoryEstimation estimation)
        Adds a MemoryEstimation as a sub-component to the builder. The given memory estimation is multiplied by the number of nodes in the graph.
        Parameters:
        description - description of the sub-component
        estimation - new sub-component
        Returns:
        this builder
      • perNode

        public MemoryEstimations.Builder perNode​(java.lang.String description,
                                                 java.util.function.LongUnaryOperator fn)
        Adds a new sub-component to the builder. The memory consumption (in bytes) is being computed by the supplied function. The input to that function is the number of nodes within the graph.
        Parameters:
        description - description of the sub-component
        fn - function to compute memory consumption in bytes
        Returns:
        this builder
      • rangePerNode

        public MemoryEstimations.Builder rangePerNode​(java.lang.String description,
                                                      java.util.function.LongFunction<MemoryRange> fn)
        Adds a new sub-component to the builder. The memory consumption is being computed by the supplied function. The input to that function is the number of nodes within the graph.
        Parameters:
        description - description of the sub-component
        fn - function to compute memory consumption
        Returns:
        this builder
      • perGraphDimension

        public MemoryEstimations.Builder perGraphDimension​(java.lang.String description,
                                                           java.util.function.BiFunction<GraphDimensions,​java.lang.Integer,​MemoryRange> fn)
        Adds a new sub-component to the builder. The memory consumption (in bytes) is being computed by the supplied function. The input to that function are the GraphDimensions of the graph.
        Parameters:
        description - description of the sub-component
        fn - function to compute memory consumption in bytes
        Returns:
        this builder
      • rangePerGraphDimension

        public MemoryEstimations.Builder rangePerGraphDimension​(java.lang.String description,
                                                                java.util.function.BiFunction<GraphDimensions,​java.lang.Integer,​MemoryRange> fn)
        Adds a new sub-component to the builder. The memory consumption is being computed by the supplied function. The input to that function are the GraphDimensions of the graph.
        Parameters:
        description - description of the sub-component
        fn - function to compute memory consumption
        Returns:
        this builder
      • perThread

        public MemoryEstimations.Builder perThread​(java.lang.String description,
                                                   long bytes)
        Adds a new sub-component to the builder. The memory consumption is being computed by multiplying the given bytes with the number of threads.
        Parameters:
        description - description of the sub-component
        bytes - memory consumption in bytes
        Returns:
        this builder
      • perThread

        public MemoryEstimations.Builder perThread​(java.lang.String description,
                                                   java.util.function.IntToLongFunction fn)
        Adds a new sub-component to the builder. The memory consumption (in bytes) is being computed by the supplied function. The input to that function is the number of available threads.
        Parameters:
        description - description of the sub-component
        fn - function to compute memory consumption in bytes
        Returns:
        this builder
      • perThread

        public MemoryEstimations.Builder perThread​(java.lang.String description,
                                                   MemoryEstimation estimation)
        Adds a MemoryEstimation as a sub-component to the builder. The given memory estimation is multiplied by the number of available threads.
        Parameters:
        description - description of the sub-component
        estimation - new sub-component
        Returns:
        this builder
      • max

        public MemoryEstimations.Builder max​(java.util.List<MemoryEstimation> components)
        Adds the biggest of several MemoryEstimation as a sub-component to the builder. Handy for when you do not not know ahead of time which one is going to result in the largest memory usage high-water mark
      • max

        public MemoryEstimations.Builder max​(java.lang.String description,
                                             java.util.List<MemoryEstimation> components)
        Adds the biggest of several MemoryEstimation as a sub-component to the builder. Handy for when you do not not know ahead of time which one is going to result in the largest memory usage high-water mark