Class MemoryEstimations.Builder
- java.lang.Object
-
- org.neo4j.graphalgo.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.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
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
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, 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
-
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
-
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
-
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
-
build
public MemoryEstimation build()
-
-