Package org.neo4j.gds.core.utils.mem
Class MemoryEstimations.Builder
- java.lang.Object
-
- org.neo4j.gds.core.utils.mem.MemoryEstimations.Builder
-
- Enclosing class:
- MemoryEstimations
public static final class MemoryEstimations.Builder extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MemoryEstimations.Builder
add(java.lang.String description, MemoryEstimation estimation)
Adds aMemoryEstimation
as a sub-component to the builder.MemoryEstimations.Builder
add(MemoryEstimation estimation)
Adds aMemoryEstimation
as a sub-component to the builder.MemoryEstimations.Builder
addComponentsOf(MemoryEstimation estimation)
MemoryEstimation
build()
MemoryEstimations.Builder
endField()
Ends the construction of a sub-component and returns the parent builder.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.MemoryEstimations.Builder
fixed(java.lang.String description, long bytes)
Adds a fixed amount of memory consumption in bytes to the builder.MemoryEstimations.Builder
fixed(java.lang.String description, MemoryRange range)
Adds a fixed memory range to the builder.MemoryEstimations.Builder
max(java.lang.String description, java.util.List<MemoryEstimation> components)
Adds the biggest of severalMemoryEstimation
as a sub-component to the builder.MemoryEstimations.Builder
max(java.util.List<MemoryEstimation> components)
Adds the biggest of severalMemoryEstimation
as a sub-component to the builder.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.MemoryEstimations.Builder
perNode(java.lang.String description, java.util.function.LongUnaryOperator fn)
Adds a new sub-component to the builder.MemoryEstimations.Builder
perNode(java.lang.String description, MemoryEstimation estimation)
Adds aMemoryEstimation
as a sub-component to the builder.MemoryEstimations.Builder
perNodeVector(java.lang.String description, long sizeOfVector, java.util.function.LongUnaryOperator fn)
Adds a new sub-component to the builder.MemoryEstimations.Builder
perThread(java.lang.String description, long bytes)
Adds a new sub-component to the builder.MemoryEstimations.Builder
perThread(java.lang.String description, java.util.function.IntToLongFunction fn)
Adds a new sub-component to the builder.MemoryEstimations.Builder
perThread(java.lang.String description, MemoryEstimation estimation)
Adds aMemoryEstimation
as a sub-component to the builder.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.MemoryEstimations.Builder
rangePerNode(java.lang.String description, java.util.function.LongFunction<MemoryRange> fn)
Adds a new sub-component to the builder.MemoryEstimations.Builder
startField(java.lang.String name)
Starts the construction of new sub-components.MemoryEstimations.Builder
startField(java.lang.String name, java.lang.Class<?> type)
Starts the construction of new sub-components.
-
-
-
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-componenttype
- 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(MemoryEstimation estimation)
Adds aMemoryEstimation
as a sub-component to the builder. UsesMemoryEstimation.description()
as sub-component name.- Parameters:
estimation
- new sub-component- Returns:
- this builder
-
addComponentsOf
public MemoryEstimations.Builder addComponentsOf(MemoryEstimation estimation)
-
add
public MemoryEstimations.Builder add(java.lang.String description, MemoryEstimation estimation)
Adds aMemoryEstimation
as a sub-component to the builder. Uses the givendescription
as sub-component name.- Parameters:
description
- description of the sub-componentestimation
- 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();
builder.add(name, MemoryEstimations.of(type);
- Parameters:
description
- description of the sub-componenttype
- 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-componentbytes
- 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-componentrange
- 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-componentsizeOfVector
- number elements in each node vectorfn
- function to compute memory consumption in bytes- Returns:
- this builder
-
perNode
public MemoryEstimations.Builder perNode(java.lang.String description, MemoryEstimation estimation)
Adds aMemoryEstimation
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-componentestimation
- 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-componentfn
- 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-componentfn
- 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 theGraphDimensions
of the graph.- Parameters:
description
- description of the sub-componentfn
- 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 theGraphDimensions
of the graph.- Parameters:
description
- description of the sub-componentfn
- 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-componentbytes
- 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-componentfn
- function to compute memory consumption in bytes- Returns:
- this builder
-
perThread
public MemoryEstimations.Builder perThread(java.lang.String description, MemoryEstimation estimation)
Adds aMemoryEstimation
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-componentestimation
- new sub-component- Returns:
- this builder
-
max
public MemoryEstimations.Builder max(java.util.List<MemoryEstimation> components)
Adds the biggest of severalMemoryEstimation
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 severalMemoryEstimation
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
-
build
public MemoryEstimation build()
-
-