Skip to content

Commit

Permalink
Closes #127
Browse files Browse the repository at this point in the history
  • Loading branch information
augustearth committed Dec 13, 2024
1 parent 70a1e6b commit 4b0b7af
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
18 changes: 18 additions & 0 deletions app/carnival-core/src/main/groovy/carnival/core/Carnival.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ abstract class Carnival implements GremlinTrait {



///////////////////////////////////////////////////////////////////////////
// ABSTRACT INTERFACE
///////////////////////////////////////////////////////////////////////////

/**
* Close this carnival.
*
*/
abstract void close()


/**
* Dispose of the resources of this carnival.
*
* */
abstract void dispose()


///////////////////////////////////////////////////////////////////////////
// INITIALIZATION
///////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class CarnivalJanusBerkeley extends Carnival {
/** The names of the indexes created */
Set<String> indexNames = new HashSet<String>()

/** */
boolean openedExisting = false


///////////////////////////////////////////////////////////////////////////
// FACTORY
Expand Down Expand Up @@ -149,6 +152,7 @@ class CarnivalJanusBerkeley extends Carnival {

if (graphDirExists) {

carnival.openedExisting = true
carnival.initPropModelNoMgmt()
carnival.initVertModelNoMgmt()
carnival.initEdgeModelNoMgmt()
Expand Down Expand Up @@ -755,6 +759,15 @@ class CarnivalJanusBerkeley extends Carnival {
}


/**
* Dispose of the resources of this Carnival.
*/
public void dispose() {
this.close()
CarnivalJanusBerkeley.clearGraph(this.config)
}



///////////////////////////////////////////////////////////////////////////
// CLASSES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ class CarnivalTinker extends Carnival {
graph.close()
}


/**
* Dispose of the resources of this Carnival.
*/
public void dispose() {
this.close()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CarnivalInitSpec extends Specification {

def g = graph.traversal()
try {
carnival.initialize(graph, g)
carnival.initModel(graph, g)
} finally {
if (g) g.close()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class CarnivalJanusBerkeleyFilesSpec extends Specification {
}

then:
carnival
!carnival.openedExisting
numVerts1

when:
Expand All @@ -130,6 +132,7 @@ class CarnivalJanusBerkeleyFilesSpec extends Specification {

then:
carnival
carnival.openedExisting
numVerts1 == numVerts2

cleanup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ class CarnivalModelSpec extends Specification {

expect:
carnival.checkModel().size() == 0
GraphModel.VX.DOG_CLASS.vertex == null

when:
GraphModel.VX.DOG_CLASS.vertex = null

int numVerts1
carnival.withGremlin { graph, g ->
numVerts1 = g.V().count().next()
Expand Down

0 comments on commit 4b0b7af

Please sign in to comment.