Esempio n. 1
0
        public void TestWithCells()
        {
            var k1 = new Key("b", "cf");
            var k2 = new Key("b", "cf", "2");

            Assert.IsTrue(k1 < k2);

            var scanSpec = ScanSpecBuilder
                           .Create()
                           .WithColumns()
                           .WithCells("x", "cf", "cq")
                           .WithCells(k2, k1)
                           .WithCells(new[] { k1, k2 })
                           .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(5, scanSpec.CellCount);
            Assert.IsTrue(scanSpec.Cells.SequenceEqual(new[] { new Key("x", "cf", "cq"), k2, k1, k1, k2 }));

            scanSpec = ScanSpecBuilder
                       .CreateOrdered()
                       .WithColumns()
                       .WithCells("x", "cf", "cq")
                       .WithCells(k2, k1)
                       .WithCells(new[] { k1, k2 })
                       .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(3, scanSpec.CellCount);
            Assert.IsTrue(scanSpec.Cells.SequenceEqual(new[] { k1, k2, new Key("x", "cf", "cq") }));
        }
Esempio n. 2
0
        public void TestWithRows()
        {
            var scanSpec = ScanSpecBuilder
                           .Create()
                           .WithColumns()
                           .WithRows("a")
                           .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(1, scanSpec.RowCount);
            Assert.IsTrue(scanSpec.Rows.SequenceEqual(new[] { "a" }));

            scanSpec = ScanSpecBuilder
                       .Create()
                       .WithColumns()
                       .WithRows("x", "a")
                       .WithRows("b", "a", "z")
                       .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(5, scanSpec.RowCount);
            Assert.IsTrue(scanSpec.Rows.SequenceEqual(new[] { "x", "a", "b", "a", "z" }));

            scanSpec = ScanSpecBuilder
                       .Create()
                       .WithColumns()
                       .WithRows("x", "a")
                       .WithRows(new[] { "b", "a", "z" })
                       .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(5, scanSpec.RowCount);
            Assert.IsTrue(scanSpec.Rows.SequenceEqual(new[] { "x", "a", "b", "a", "z" }));

            scanSpec = ScanSpecBuilder
                       .CreateOrdered()
                       .WithColumns()
                       .WithRows("x", "a")
                       .WithRows("b", "a", "z")
                       .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(4, scanSpec.RowCount);
            Assert.IsTrue(scanSpec.Rows.SequenceEqual(new[] { "a", "b", "x", "z" }));

            scanSpec = ScanSpecBuilder
                       .CreateOrdered()
                       .WithColumns()
                       .WithRows("x", "a")
                       .WithRows(new[] { "b", "a", "z" })
                       .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(4, scanSpec.RowCount);
            Assert.IsTrue(scanSpec.Rows.SequenceEqual(new[] { "a", "b", "x", "z" }));
        }
Esempio n. 3
0
        public void TestWithColumnPredicates()
        {
            var cp1 = new ColumnPredicate("x", MatchKind.ValueExact, Encoding.UTF8.GetBytes("xyz"));
            var cp2 = new ColumnPredicate("a", MatchKind.ValueExact, Encoding.UTF8.GetBytes("xyz"));

            Assert.IsTrue(cp2 < cp1);

            var scanSpec = ScanSpecBuilder
                           .Create()
                           .WithColumns()
                           .WithColumnPredicates(cp1)
                           .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(1, scanSpec.ColumnPredicateCount);
            Assert.IsTrue(scanSpec.ColumnPredicates.SequenceEqual(new[] { cp1 }));

            scanSpec = ScanSpecBuilder
                       .Create()
                       .WithColumns()
                       .WithColumnPredicates(cp1, cp2)
                       .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(2, scanSpec.ColumnPredicateCount);
            Assert.IsTrue(scanSpec.ColumnPredicates.SequenceEqual(new[] { cp1, cp2 }));

            scanSpec = ScanSpecBuilder
                       .CreateOrdered()
                       .WithColumns()
                       .WithColumnPredicates(cp1, cp2)
                       .WithColumnPredicates(new ColumnPredicate("a", MatchKind.ValueExact, Encoding.UTF8.GetBytes("xyz")), cp1)
                       .Build();

            Assert.IsNotNull(scanSpec);
            Assert.AreEqual(2, scanSpec.ColumnPredicateCount);
            Assert.IsTrue(scanSpec.ColumnPredicates.SequenceEqual(new[] { cp1, cp2 }));
        }