Cleaned up the DeepZipper source file. #44

Closed
wants to merge 2 commits into
from

Projects

None yet

3 participants

@ncreep
ncreep commented Sep 16, 2011
  • Minor method refactorings on DeepZipper.
  • Took out PathCreator and BasicMergeStrategy into separate files.
@ncreep ncreep Cleaned up the DeepZipper source file.
- Minor method refactorings on DeepZipper.
- Took out PathCreator and BasicMergeStrategy into separate files.
1d50ad4
@djspiewak
Owner

This doesn't appear to compile for me. Am I missing something?

@ncreep
ncreep commented Sep 17, 2011

Works on my machine.
What compilation errors do you get?

@djspiewak
Owner
[info] Set current project to default-0f5d91 (in build file:/Users/daniel/Development/Scala/anti-xml/project/plugins/)
[info] Set current project to default-46d821 (in build file:/Users/daniel/Development/Scala/anti-xml/)
[info] Compiling 2 Scala sources to /Users/daniel/Development/Scala/anti-xml/target/scala-2.9.1.final/classes...
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:471: not found: value PathCreator
[error]   import PathCreator._
[error]          ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/BasicNodeMergeStrategy.scala:12: diverging implicit expansion for type Ordering[com.codecommit.antixml.DeepZipper.Time]
[error] starting with method Tuple9 in object Ordering
[error]     val max @ (newestNode, maxUpTime) = alternatives.maxBy(_._2) // by time
[error]                                                           ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/BasicNodeMergeStrategy.scala:40: diverging implicit expansion for type Ordering[Option[com.codecommit.antixml.DeepZipper.Time]]
[error] starting with method Option in object Ordering
[error]     def maxBy(f: Elem => Any) = alternatives.maxBy { et =>
[error]                                                    ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/BasicNodeMergeStrategy.scala:47: value _2 is not a member of Nothing
[error]     val (maxNonChild, nonChildTime) = nonChildFuncs.map(maxBy(_)).maxBy(_._2) // by time
[error]                                                                           ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/BasicNodeMergeStrategy.scala:47: diverging implicit expansion for type Ordering[B]
[error] starting with method Tuple9 in object Ordering
[error]     val (maxNonChild, nonChildTime) = nonChildFuncs.map(maxBy(_)).maxBy(_._2) // by time
[error]                                                                        ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/BasicNodeMergeStrategy.scala:50: value copy is not a member of Any
[error]     (maxNonChild.copy(children = maxChild.children), nonChildTime.max(childTime))
[error]                  ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/BasicNodeMergeStrategy.scala:50: value max is not a member of Any
[error]     (maxNonChild.copy(children = maxChild.children), nonChildTime.max(childTime))
[error]                                                                   ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:75: type mismatch;
[error]  found   : com.codecommit.antixml.DeepZipper.Time
[error]  required: ?{val +(x$1: ?>: Int(1) <: Any): ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method byte2short in object Predef of type (x: Byte)Short
[error]  and method byte2int in object Predef of type (x: Byte)Int
[error]  are possible conversion functions from com.codecommit.antixml.DeepZipper.Time to ?{val +(x$1: ?>: Int(1) <: Any): ?}
[error]       val time = self.time + 1
[error]                       ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:142: type mismatch;
[error]  found   : time.type (with underlying type com.codecommit.antixml.DeepZipper.Time)
[error]  required: ?{val +(x$1: ?>: Int(1) <: Any): ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method byte2short in object Predef of type (x: Byte)Short
[error]  and method byte2int in object Predef of type (x: Byte)Int
[error]  are possible conversion functions from time.type to ?{val +(x$1: ?>: Int(1) <: Any): ?}
[error]         val newTime = time + 1
[error]                       ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:164: type mismatch;
[error]  found   : com.codecommit.antixml.DeepZipper.EmptiesSet
[error]  required: ?{val ++(x$1: ?>: scala.collection.immutable.Set[(com.codecommit.antixml.DeepZipper.FullLoc, com.codecommit.antixml.DeepZipper.Time)] <: Any): ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method zipped2ToTraversable in object Predef of type [El1, El2](zz: (_$1, _$2)#Zipped[_, El1, _, El2])Traversable[(El1, El2)]
[error]  and method zipped3ToTraversable in object Predef of type [El1, El2, El3](zz: (_$5, _$6, _$7)#Zipped[_, El1, _, El2, _, El3])Traversable[(El1, El2, El3)]
[error]  are possible conversion functions from com.codecommit.antixml.DeepZipper.EmptiesSet to ?{val ++(x$1: ?>: scala.collection.immutable.Set[(com.codecommit.antixml.DeepZipper.FullLoc, com.codecommit.antixml.DeepZipper.Time)] <: Any): ?}
[error]     val builder = cbfwdz(self.parent, contexts, emptiesSet ++ newEmpties)
[error]                                                 ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:209: diverging implicit expansion for type Ordering[com.codecommit.antixml.DeepZipper.Time]
[error] starting with method Tuple9 in object Ordering
[error]               (n +: nodes, times.max) // appending extras
[error]                                  ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:223: type mismatch;
[error]  found   : com.codecommit.antixml.DeepZipper.EmptiesSet
[error]  required: ?{val map: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method zipped2ToTraversable in object Predef of type [El1, El2](zz: (_$1, _$2)#Zipped[_, El1, _, El2])Traversable[(El1, El2)]
[error]  and method zipped3ToTraversable in object Predef of type [El1, El2, El3](zz: (_$5, _$6, _$7)#Zipped[_, El1, _, El2, _, El3])Traversable[(El1, El2, El3)]
[error]  are possible conversion functions from com.codecommit.antixml.DeepZipper.EmptiesSet to ?{val map: ?}
[error]     val res = emptiesSet.map { lt =>
[error]               ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:237: type mismatch;
[error]  found   : x$21.parentsList.type (with underlying type com.codecommit.antixml.DeepZipper.ParentsList)
[error]  required: ?{val length: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method refArrayOps in object Predef of type [T <: AnyRef](xs: Array[T])scala.collection.mutable.ArrayOps[T]
[error]  and method intArrayOps in object Predef of type (xs: Array[Int])scala.collection.mutable.ArrayOps[Int]
[error]  are possible conversion functions from x$21.parentsList.type to ?{val length: ?}
[error]       val byDepthContexts = fullContext.groupBy(_.parentsList.length) withDefaultValue Vector()
[error]                                                   ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:238: type mismatch;
[error]  found   : x$22._1.parentsList.type (with underlying type com.codecommit.antixml.DeepZipper.ParentsList)
[error]  required: ?{val length: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method refArrayOps in object Predef of type [T <: AnyRef](xs: Array[T])scala.collection.mutable.ArrayOps[T]
[error]  and method intArrayOps in object Predef of type (xs: Array[Int])scala.collection.mutable.ArrayOps[Int]
[error]  are possible conversion functions from x$22._1.parentsList.type to ?{val length: ?}
[error]       val byDepthTransforms = transforms.groupBy(_._1.parentsList.length) withDefaultValue Map()
[error]                                                       ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:310: type mismatch;
[error]  found   : parents.type (with underlying type com.codecommit.antixml.DeepZipper.ParentsList)
[error]  required: ?{val isEmpty: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method zipped2ToTraversable in object Predef of type [El1, El2](zz: (_$1, _$2)#Zipped[_, El1, _, El2])Traversable[(El1, El2)]
[error]  and method zipped3ToTraversable in object Predef of type [El1, El2, El3](zz: (_$5, _$6, _$7)#Zipped[_, El1, _, El2, _, El3])Traversable[(El1, El2, El3)]
[error]  are possible conversion functions from parents.type to ?{val isEmpty: ?}
[error]     assert(!parents.isEmpty, "Cannot merge under an empty parent.")
[error]             ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:312: type mismatch;
[error]  found   : parents.type (with underlying type com.codecommit.antixml.DeepZipper.ParentsList)
[error]  required: ?{val head: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method zipped2ToTraversable in object Predef of type [El1, El2](zz: (_$1, _$2)#Zipped[_, El1, _, El2])Traversable[(El1, El2)]
[error]  and method zipped3ToTraversable in object Predef of type [El1, El2, El3](zz: (_$5, _$6, _$7)#Zipped[_, El1, _, El2, _, El3])Traversable[(El1, El2, El3)]
[error]  are possible conversion functions from parents.type to ?{val head: ?}
[error]     val directParentLoc = parents.head
[error]                           ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:314: type mismatch;
[error]  found   : parents.type (with underlying type com.codecommit.antixml.DeepZipper.ParentsList)
[error]  required: ?{val tail: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method zipped2ToTraversable in object Predef of type [El1, El2](zz: (_$1, _$2)#Zipped[_, El1, _, El2])Traversable[(El1, El2)]
[error]  and method zipped3ToTraversable in object Predef of type [El1, El2, El3](zz: (_$5, _$6, _$7)#Zipped[_, El1, _, El2, _, El3])Traversable[(El1, El2, El3)]
[error]  are possible conversion functions from parents.type to ?{val tail: ?}
[error]     val grandParents = parents.tail
[error]                        ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:319: type mismatch;
[error]  found   : scala.collection.immutable.Iterable[com.codecommit.antixml.DeepZipper.FullContext[Any]]
[error]  required: scala.collection.Iterable[DeepZipper.this.FullContext]
[error]     val mergedChildren = mergeOriginalWithContext(oldChildren, uniques)
[error]                                                                ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:336: diverging implicit expansion for type Ordering[com.codecommit.antixml.DeepZipper.Time]
[error] starting with method Tuple9 in object Ordering
[error]     val maxTimeByContext = toOpt(uniques) map (_.maxBy(_.updateTime).updateTime)
[error]                                                       ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:339: value ++ is not a member of Any
[error]     val newUpdateTime = (times ++ maxTimeByContext).max // both cannot be empty otherwise we wouldn't be merging 
[error]                                ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:340: value flatten is not a member of Any
[error]     val newChildren = Group.fromSeq(nodes.flatten)
[error]                                           ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:382: type mismatch;
[error]  found   : com.codecommit.antixml.Node => Seq[com.codecommit.antixml.Node]
[error]  required: Any => ?
[error]       val fullMap = contextMap andThen transformMap
[error]                                        ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:576: too many arguments for constructor Object: ()java.lang.Object
[error]         new Group[A](group.toVectorCase) with DeepZipper[A] {
[error]             ^
[error] /Users/daniel/Development/Scala/anti-xml/src/main/scala/com/codecommit/antixml/DeepZipper.scala:600: too many arguments for constructor Object: ()java.lang.Object
[error]     new Group[A](vals) with DeepZipper[A] {
[error]         ^
[error] 24 errors found
[error] {file:/Users/daniel/Development/Scala/anti-xml/}default-46d821/compile: Compilation failed
[error] Total time: 11 s, completed Sep 18, 2011 3:04:05 PM
@ncreep
ncreep commented Sep 18, 2011

Scala compilation errors are way too scary...

Anyways, could it be that you're trying to compile the new PathCreator and BasicNodeMergeStrategy files while still retaining their old definitions inside the DeepZipper companion object?

@josharnold52

I ran into the same problem trying to compile. I don't actually see the PathCreator file at all. Is it possible it hasn't been added to your repo yet?

@ncreep
ncreep commented Sep 19, 2011

And of course you're right, my bad, sorry...

@djspiewak
Owner

I've started the process of integrating this fully back into Group. You can find the work in my djspiewak:zipper-replacement branch. I've already been able to delete Zipper, so we're off to a good start!

The main stuff that still needs to be done:

  • General cleanup of DeepZipper (largely subjective issues, not really necessary before we merge into master)
  • Bloom filters
  • Memory optimization restoration
  • Misc documentation fixes (I probably reference Zipper explicitly in various places in the documentation)

I suspect the last two will be fairly straightforward, and the first is merely a matter of doing it. So, we're in really good shape! I'll continue working towards the goal of landing this in master asap.

@djspiewak
Owner

I'm going to close this pull request, not because we're not going to merge it, but because it's a longer and more involved integration process that's currently happening in a branch. Once that integration process is done (basically, performance is the remaining hang-up), we'll merge that branch over into master.

@djspiewak djspiewak closed this Sep 23, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment