Skip to content

Commit

Permalink
Moved dictionaries to own package and created a placeholder for a Hu-…
Browse files Browse the repository at this point in the history
…Tucker Front-Coding dictionary

#22
  • Loading branch information
pstutz committed Jul 26, 2015
1 parent 259b3c9 commit da0c296
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import scala.Option.option2Iterable
import scala.runtime.ScalaRunTime
import scala.util.hashing.MurmurHash3._
import scala.language.implicitConversions
import com.signalcollect.triplerush.dictionary.Dictionary

object EfficientIndexPattern {

Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/com/signalcollect/triplerush/TripleRush.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import com.signalcollect.triplerush.vertices.query.QueryPlanningVertex
import java.util.concurrent.atomic.AtomicReference
import com.signalcollect.triplerush.loading.FileLoader
import com.signalcollect.triplerush.optimizers.NoOptimizerCreator
import com.signalcollect.triplerush.dictionary.CompressedDictionary
import com.signalcollect.triplerush.dictionary.Dictionary

/**
* Global accessors for the console visualization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*
*/

package com.signalcollect.triplerush
package com.signalcollect.triplerush.dictionary

import java.util.concurrent.locks.ReentrantReadWriteLock

import com.signalcollect.triplerush.EfficientIndexPattern
import com.signalcollect.triplerush.util.CompositeLongIntHashMap
import com.signalcollect.util.IntLongHashMap

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

package com.signalcollect.triplerush
package com.signalcollect.triplerush.dictionary

import com.signalcollect.util.IntHashMap
import com.signalcollect.util.IntValueHashMap
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2015 iHealth Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.signalcollect.triplerush.dictionary

/**
* This paper suggests that a Hu-Tucker Front-Coding dictionary performs very well on URIs.
* http://www.dcc.uchile.cl/~gnavarro/ps/sea11.1.pdf
*/
class FrontCodingDictionary extends Dictionary {

def contains(s: String): Boolean = ???
def apply(s: String): Int = ???
def apply(id: Int): String = ???
def unsafeDecode(id: Int): String = ???
def unsafeGetEncoded(s: String): Int = ???
def decode(id: Int): Option[String] = ???
def clear(): Unit = ???

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import org.apache.jena.riot.lang.{ PipedRDFIterator, PipedTriplesStream }

import com.hp.hpl.jena.graph.{ Triple => JenaTriple }
import com.signalcollect.GraphEditor
import com.signalcollect.triplerush.{ Dictionary, EfficientIndexPattern, PlaceholderEdge }
import com.signalcollect.triplerush.{ EfficientIndexPattern, PlaceholderEdge }
import com.signalcollect.triplerush.dictionary.Dictionary
import com.signalcollect.triplerush.sparql.NodeConversion

case class FileLoader(filePath: String, dictionary: Dictionary) extends Iterator[GraphEditor[Long, Any] => Unit] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.signalcollect.triplerush.TriplePattern
import scala.annotation.tailrec
import com.signalcollect.triplerush.PredicateStats
import scala.collection.mutable.ArrayBuffer
import com.signalcollect.triplerush.Dictionary
import scala.collection.immutable.Map
import com.signalcollect.triplerush.TriplePattern

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
package com.signalcollect.triplerush.sparql

import com.hp.hpl.jena.graph.{ NodeFactory, Triple }
import com.signalcollect.triplerush.Dictionary
import com.hp.hpl.jena.graph.impl.LiteralLabelFactory
import com.hp.hpl.jena.datatypes.TypeMapper
import com.signalcollect.triplerush.dictionary.Dictionary

object TripleRushIterator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import com.hp.hpl.jena.sparql.engine.{ ExecutionContext, QueryIterator }
import com.hp.hpl.jena.sparql.engine.binding.{ Binding, BindingHashMap }
import com.hp.hpl.jena.sparql.engine.iterator.{ QueryIterConcat, QueryIterPlainWrapper }
import com.hp.hpl.jena.sparql.engine.main.StageGenerator
import com.signalcollect.triplerush.{ Dictionary, TriplePattern, TripleRush }
import com.signalcollect.triplerush.{ TriplePattern, TripleRush }
import com.signalcollect.triplerush.dictionary.Dictionary
import com.hp.hpl.jena.sparql.engine.iterator.QueryIterSingleton
import com.hp.hpl.jena.graph.Node_Blank

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

package com.signalcollect.triplerush
package com.signalcollect.triplerush.dictionary

import org.scalatest.FlatSpec

Expand Down Expand Up @@ -63,7 +63,7 @@ class CompressedDictionarySpec extends FlatSpec with TestAnnouncements {
val decoded = d(id)
assert(decoded == "simple#")
}

it should "correctly encode and decode a string with a hash at the beginning" in {
val d = new CompressedDictionary
val id = d("#simple")
Expand All @@ -73,7 +73,7 @@ class CompressedDictionarySpec extends FlatSpec with TestAnnouncements {
val decoded = d(id)
assert(decoded == "#simple")
}

it should "support adding entries in parallel" in {
val d = new CompressedDictionary
val stringEntries = (1 to 1000).map(s => s + "#" + s)
Expand All @@ -99,5 +99,5 @@ class CompressedDictionarySpec extends FlatSpec with TestAnnouncements {
assert(reverseMapped.map(_.toInt).min == 1001)
assert(highStringEntries.toSet == reverseMapped.toSet)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
*
*/

package com.signalcollect.triplerush
package com.signalcollect.triplerush.dictionary

import org.scalatest.FlatSpec

import com.signalcollect.util.TestAnnouncements

class DictonarySpec extends FlatSpec with TestAnnouncements {
Expand Down

0 comments on commit da0c296

Please sign in to comment.