Improve TypedSimilarity algorithm and update test.

Add one optimization to disco/dimsum algorithms: doing the filtering before the large self-join.
Update test to use TypedTsv.