static public void Test() { BitVector S1 = 0b0011_0010; BitVector S2 = 0b0100_0011; Debug.Assert(SetOp.Union(S1, S2) == 0b0111_0011); Debug.Assert(SetOp.Union(S1, S2) == SetOp.Union(S2, S1)); Debug.Assert(SetOp.Intersect(S1, S2) == 0b0000_0010); Debug.Assert(SetOp.Intersect(S1, S2) == SetOp.Intersect(S2, S1)); Debug.Assert(SetOp.Substract(S1, S2) == 0b0011_0000); Debug.Assert(SetOp.Substract(S2, S1) == 0b0100_0001); Debug.Assert(SetOp.CountSetBits(S1) == 3); Debug.Assert(SetOp.MinTableIndex(S1) == 1); Debug.Assert(SetOp.MinTableIndex(S2) == 0); Debug.Assert(SetOp.OrderBeforeSet(3) == 15); var l = SetOp.TablesAscending(S2).ToList(); Debug.Assert(l.SequenceEqual(new List <int>() { 0, 1, 6 })); l = SetOp.TablesDescending(S2).ToList(); Debug.Assert(l.SequenceEqual(new List <int>() { 6, 1, 0 })); }
IEnumerable <BitVector> enumerateCsgRecursive(JoinGraph graph, BitVector S, BitVector X) { // N = neighbour(S) \ X BitVector N = SetOp.Substract(graph.NeighboursExcluding(S), X); // Console.WriteLine("N: " + BitHelper.ToString(N)); // for all non-empty S' subsetof(N), emit (S union S') if (N != SetOp.EmptySet) { VancePartition partitioner = new VancePartition(N); foreach (var S_prime in partitioner.Next(true)) { yield return(SetOp.Union(S, S_prime)); } // for all non-empty S' subsetof(N), recursively invoke (graph, (S union S'), (X union N)) partitioner = new VancePartition(N); foreach (var S_prime in partitioner.Next(true)) { foreach (var v in enumerateCsgRecursive(graph, SetOp.Union(S, S_prime), SetOp.Union(X, N))) { yield return(v); } } } }
IEnumerable <BitVector> enumerateCmp(JoinGraph graph, BitVector S1) { int ntables = graph.vertices_.Count; Debug.Assert(S1 != SetOp.EmptySet); // min(S1) := min({i|v_i \in S1}) int minS1 = SetOp.MinTableIndex(S1); // B_i(W) := {vj |v_j \in W, j <= i} // X = union (B_min(S1), S) BitVector BminS1 = SetOp.OrderBeforeSet(minS1); BitVector X = SetOp.Union(BminS1, S1); // N = neighbour(S1) \ X BitVector N = SetOp.Substract(graph.NeighboursExcluding(S1), X); // for all(vi 2 N by descending i) foreach (int vi in SetOp.TablesDescending(N)) { // emit {v_i} BitVector VI = SetOp.SingletonSet(vi); yield return(VI); // recursively invoke enumerateCmp(graph, {v_i}, X union (B_i intersect N)) BitVector Bi = SetOp.OrderBeforeSet(vi); BitVector BiN = SetOp.Intersect(Bi, N); foreach (var csg in enumerateCsgRecursive(graph, VI, SetOp.Union(X, BiN))) { yield return(csg); } } }
internal CsgCmpPair(JoinGraph graph, BitVector S1, BitVector S2) { S1_ = S1; S2_ = S2; S_ = SetOp.Union(S1, S2); Verify(graph); }