OverflowDbDriver

class OverflowDbDriver: IDriver, Any

Driver to create an OverflowDB database file from Plume's domain classes.

Fields

Name Description
var storageLocation: String

Where the database will be serialize/deserialize and overflow to disk.

var overflow: Boolean

Specifies if OverflowDb should write to disk when memory is constrained.

var heapPercentageThreshold: Int

Percentage of the heap from when overflowing should begin to occur. Default is 80%.

var serializationStatsEnabled: Boolean

If specified, OverflowDB will measure and report serialization/deserialization timing averages.

Methods

storageLocation

fun storageLocation(value: String): OverflowDbDriver

Set the storage location.

Parameters

Name Description
value: String

the storage location to overflow to e.g. /tmp/cpg.bin

ReturnValue

Name Description
OverflowDbDriver

overflow

fun overflow(value: Boolean): OverflowDbDriver

Set whether the database overflows or not.

Parameters

Name Description
value: Boolean

true to overflow, false to remain in memory.

ReturnValue

Name Description
OverflowDbDriver

heapPercentageThreshold

fun heapPercentageThreshold(value: Int): OverflowDbDriver

Set the percentage threshold before overflowing.

Parameters

Name Description
value: Int

the percentage of the heap space.

ReturnValue

Name Description
OverflowDbDriver

serializationStatsEnabled

fun serializationStatsEnabled(value: Boolean): OverflowDbDriver

To set if serialization/deserialization timing averages should be reported.

Parameters

Name Description
value: Boolean

true to report averages, false to not.

ReturnValue

Name Description
OverflowDbDriver

connect

fun connect(): OverflowDbDriver

ReturnValue

Name Description
OverflowDbDriver

addVertex

fun addVertex(v: NewNodeBuilder)

Inserts a vertex in the graph database.

Parameters

Name Description
v: NewNodeBuilder

the NewNodeBuilder to insert.

ReturnValue

Name Description
Unit

exists

fun exists(v: NewNodeBuilder): Boolean

Checks if the given NewNodeBuilder exists in the database.

Parameters

Name Description
v: NewNodeBuilder

the NewNodeBuilder to check existence of.

ReturnValue

Name Description
Boolean

true if the vertex exists, false if otherwise.

exists

fun exists(src: NewNodeBuilder, tgt: NewNodeBuilder, edge: String): Boolean

Checks if there exists a directed edge of the given label between two NewNodeBuilder vertices.

Parameters

Name Description
src: NewNodeBuilder

the source NewNodeBuilder.

tgt: NewNodeBuilder

the target NewNodeBuilder.

edge: String

the edge label.

ReturnValue

Name Description
Boolean

true if the edge exists, false if otherwise.

addEdge

fun addEdge(src: NewNodeBuilder, tgt: NewNodeBuilder, edge: String)

Creates an edge with the given label between two NewNodeBuilder vertices in the graph database. If the given vertices are not already present in the database, they are created. If the edge already exists it wil not be recreated.

Parameters

Name Description
src: NewNodeBuilder

the source NewNodeBuilder.

tgt: NewNodeBuilder

the target NewNodeBuilder.

edge: String

the edge label.

ReturnValue

Name Description
Unit

clearGraph

fun clearGraph(): IDriver

Clears the graph of all vertices and edges.

ReturnValue

Name Description
IDriver

itself as so to be chained in method calls.

getWholeGraph

fun getWholeGraph(): Graph

Returns the whole CPG as a Graph object. Depending on the size of the CPG, this may be very memory intensive and usually a bad idea to call.

ReturnValue

Name Description
Graph

The whole CPG in the graph database.

getMethod

fun getMethod(fullName: String, includeBody: Boolean): Graph

Given the full signature of a method, returns the subgraph of the method body.

Parameters

Name Description
fullName: String

The fully qualified name with signature e.g. interprocedural.basic.Basic4.f:int(int,int)

includeBody: Boolean

True if the body should be included, false if only method head should be included.

ReturnValue

Name Description
Graph

The Graph containing the method graph.

getMethodNames

fun getMethodNames(): List<String>

Obtains all method full names in the CPG. These can be used in IDriver.getMethod.

ReturnValue

Name Description
List<String>

A list of all method full names.

getProgramStructure

fun getProgramStructure(): Graph

Obtains all program structure related vertices. These are NAMESPACE_BLOCK, FILE, and TYPE_DECL vertices.

ReturnValue

Name Description
Graph

The Graph containing the program structure related sub-graphs.

getProgramTypeData

fun getProgramTypeData(): Graph

Obtains all the type references, declarations, and arguments of a program to their children and referenced vertices.

ReturnValue

Name Description
Graph

The Graph containing the type data of the CPG.

getNeighbours

fun getNeighbours(v: NewNodeBuilder): Graph

Given a vertex, returns a Graph representation of neighbouring vertices.

Parameters

Name Description
v: NewNodeBuilder

The source vertex.

ReturnValue

Name Description
Graph

The Graph representation of the source vertex and its neighbouring vertices.

deleteVertex

fun deleteVertex(id: Long, label: String?)

Given a vertex, will remove it from the graph if present.

Parameters

Name Description
id: Long

The id to remove.

label: String?

The label, if known.

ReturnValue

Name Description
Unit

deleteEdge

fun deleteEdge(src: NewNodeBuilder, tgt: NewNodeBuilder, edge: String)

Given two vertices and an edge label.

Parameters

Name Description
src: NewNodeBuilder

Outgoing vertex.

tgt: NewNodeBuilder

Incoming vertex.

edge: String

The edge label of the edge to remove.

ReturnValue

Name Description
Unit

deleteMethod

fun deleteMethod(fullName: String)

Given the full signature of a method, removes the method and its body from the graph.

Parameters

Name Description
fullName: String

The fully qualified name with signature e.g. interprocedural.basic.Basic4.f:int(int,int)

ReturnValue

Name Description
Unit

updateVertexProperty

fun updateVertexProperty(id: Long, label: String?, key: String, value: Any)

Updates a vertex's property if the node exists.

Parameters

Name Description
id: Long

The ID of the vertex to update.

label: String?

The label of the node, if known.

key: String

The key of the property to update.

value: Any

The updated value.

ReturnValue

Name Description
Unit

getMetaData

fun getMetaData(): NewMetaDataBuilder?

Obtains the graph meta data information, if found.

ReturnValue

Name Description
NewMetaDataBuilder?

A NewMetaDataBuilder containing the meta data information, false if no information found.

getVerticesByProperty

fun getVerticesByProperty(propertyKey: String, propertyValue: Any, label: String?): List<NewNodeBuilder>

Attempts to get vertex by it's fullname property.

Parameters

Name Description
propertyKey: String

The key to match with.

propertyValue: Any

The value to match with.

label: String?

An optional vertex label if known to further filter results by.

ReturnValue

Name Description
List<NewNodeBuilder>

A list of all vertices which match the predicates.

getPropertyFromVertices

fun <T : Any> getPropertyFromVertices(propertyKey: String, label: String?): List<T>

Get a list of the results from a given property in vertices.

Parameters

Name Description
propertyKey: String

The property to retrieve.

label: String?

An optional vertex label if known to further filter results by.

ReturnValue

Name Description
List<T>

A list of the values from the given key using the specified type.

close

fun close()

ReturnValue

Name Description
Unit