Permalink
Browse files

Merge pull request #598 from delving/12.07-no-versioning

No longer keeping old versions of sets around
  • Loading branch information...
2 parents 24bc032 + 3372be1 commit 460fafe4221bc9b9e5db8a9bd2dc4718e50206f8 @kiivihal kiivihal committed Jul 6, 2012
Showing with 10 additions and 6 deletions.
  1. +8 −1 app/controllers/SipCreatorEndPoint.scala
  2. +2 −5 web-core/app/core/storage/BaseXStorage.scala
@@ -521,9 +521,16 @@ object SipCreatorEndPoint extends ApplicationController {
}
def loadSourceData(dataSet: DataSet, source: InputStream): Long = {
- val collection = basexStorage.openCollection(dataSet.orgId, dataSet.spec).getOrElse {
+
+ // until we have a better concept on how to deal with per-collection versions, do not make use of them here, but drop the data instead
+ val mayCollection = basexStorage.openCollection(dataSet.orgId, dataSet.spec)
+ val collection = if(mayCollection.isDefined) {
+ basexStorage.deleteCollection(mayCollection.get)
+ basexStorage.createCollection(dataSet.orgId, dataSet.spec)
+ } else {
basexStorage.createCollection(dataSet.orgId, dataSet.spec)
}
+
val parser = new SimpleDataSetParser(source, dataSet)
def onRecordInserted(count: Long) {
@@ -64,12 +64,9 @@ class BaseXStorage(host: String, port: Int, ePort: Int, user: String, password:
def store(collection: Collection, records: Iterator[Record], namespaces: Map[String, String], onRecordInserted: Long => Unit): Long = {
var inserted: Long = 0
val start = System.currentTimeMillis()
+
withBulkSession(collection) {
session =>
- val versions: Map[String, Int] = (session.find("""for $i in /*:record let $id := $i/@id group by $id return <version id="{$id}">{count($i)}</version>""") map {
- v: Node =>
- ((v \ "@id").text -> v.text.toInt)
- }).toMap
val it = records.zipWithIndex
while(it.hasNext) {
@@ -79,7 +76,7 @@ class BaseXStorage(host: String, port: Int, ePort: Int, user: String, password:
// we add the record on a path of its own, which is useful because then we know how many distinct records are stored in a BaseX collection
// given that those path need to be valid file names, we do preemptive sanitization here
val sanitizedId = if(next._1.id.endsWith(".")) next._1.id + DEFAUL_BASEX_PATH_EXTENSION else next._1.id
- session.add(sanitizedId, buildRecord(next._1, versions.get(next._1.id).getOrElse(0), namespaces, next._2))
+ session.add(sanitizedId, buildRecord(next._1, 0, namespaces, next._2))
} catch {
case t =>
Logger("CultureHub").error(next._1.toString)

0 comments on commit 460fafe

Please sign in to comment.