Skip to content

Instantly share code, notes, and snippets.

@lrhazi
Created November 22, 2012 00:43
Show Gist options
  • Save lrhazi/4128735 to your computer and use it in GitHub Desktop.
Save lrhazi/4128735 to your computer and use it in GitHub Desktop.
Objectivity test1
import com.objy.db._
import com.objy.db.app._
import scala.collection.mutable.ListBuffer
/*
1768 export PATH=/opt/object/linux86_64/bin:$PATH
1769 oocheckls
1774 sudo mkdir -p /var/object/data
1775 sudo chown ml623 /var/object/data
1776 oonewfd -pagesize 65536 -fdfilepath /var/object/data/skynet.fdb -lockserver $(hostname) /var/object/data/skynet.boot
*/
object SkyNet {
val bootfile = "/var/object/data/skynet.boot"
val fdfilepath = "/var/object/data/skynet.fdb"
val dbname = "skynet.1"
val dbname_file = "/var/object/data/"+dbname+".DB"
val num_containers = 10
class User extends ooObj {
private var _id: Long = _
// Getter
def id = {
fetch()
_id
}
// Setter
def id_= (value:Long):Unit = {
markModified()
_id = id
}
}
def main(args: Array[String]){
println("Here we go...")
val connection = Connection.open(bootfile, oo.openReadWrite)
connection.setThreadPolicy(oo.THREAD_POLICY_UNRESTRICTED)
val session = new Session("Main")
session.begin()
val fd = session.getFD()
if (fd.hasDB(dbname)) {
printf("Deleting existing database %s\n",dbname)
fd.lookupDB(dbname).delete()
}
printf("Creating database %s\n",dbname)
val database = fd.newDB(dbname, 0, 0, null, dbname_file, 1)
printf("Creating %d containers within new database...\n",num_containers)
val containers = new ListBuffer[ooContObj]
for(i <- 1 to num_containers) {
val c = new ooContObj
containers += c
database.addContainer(c, 0, i.toString(), 997, 20)
}
session.commit()
session.setMrowMode(oo.NO_MROW)
session.setOpenMode(oo.openReadWrite)
session.setThreadPolicy(oo.THREAD_POLICY_UNRESTRICTED)
session.begin()
var created_objects = 0
val full_startTime = System.nanoTime()
for (i <- containers.indices) {
val startTime = System.nanoTime()
containers(i).cluster(new User)
val endTime = System.nanoTime()
created_objects +=1
}
//Thread.sleep(1000)
session.commit()
session.leave()
printf("Created %d objects. Elapsed time: %1.2f s\n",created_objects,(System.nanoTime - full_startTime)/1e9)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment