Ejemplo n.º 1
0
        public void T03_PipeStages()
        {
            // setup the pipe...
            PipeStagePartition p =
                new PipeStagePartition("username",
                    new PipeStagePartition("tablename",
                        new PipeStageEnd()
                    )
                );

            // setup the HDF context
            PipeHdfContext ctx = new PipeHdfContext();
            ctx.setQualifier("username", "jeske");

            {
                bool err = false;
                // process the HDF context, should be an error because "table" doesn't exist..
                try {
                    p.generateRowFromContext(ctx);
                } catch (PipeGenerateException) {
                    err = true;
                }
                Assert.AreEqual(true, err, "error on pipe element not in context");
            }

            // add the "tablename" key
            ctx.setQualifier("tablename", "foo");

            // process the HDF context, should be an error because "table" doesn't exist..
            PipeRowQualifier newrow = p.generateRowFromContext(ctx);

            // test the key produced
            Assert.AreEqual("/=jeske/=foo", newrow.ToString());
        }
Ejemplo n.º 2
0
        public void T01_PipeHdfContext()
        {
            PipeHdfContext ctx2 = new PipeHdfContext();
            ctx2.setQualifier("blah", "1");

            PipeHdfContext ctx = new PipeHdfContext();
            ctx.setQualifier("foo", "bar");
            ctx.setQualifier("baz", "blah");
            ctx.setSubtree("baz", ctx2);

            Assert.AreEqual(new QualifierExact("bar"), ctx.getQualifier("foo", "deffoo"));
            Assert.AreEqual(new QualifierExact("blah"), ctx.getQualifier("baz", "defblah"));
            Assert.AreEqual(new QualifierExact("def not present"), ctx.getQualifier("notpresent", "def not present"));

            Assert.AreEqual(ctx2, ctx.getSubtree("baz"));
        }
Ejemplo n.º 3
0
        public void T04_PipeMux()
        {
            // setup the pipe...
            PipeStagePartition p =
                new PipeStagePartition("username",
                    new PipeStagePartition("table",
                        new PipeStageEnd()
                    )
                );

            Dictionary<QualifierExact, PipeStage> mux_map = new Dictionary<QualifierExact, PipeStage>();
            mux_map.Add(new QualifierExact("path_a"),
                new PipeStagePartition("suba", new PipeStageEnd()));
            mux_map.Add(new QualifierExact("path_b"),
                new PipeStagePartition("subb", new PipeStageEnd()));

            PipeStageMux mux = new PipeStageMux("select_sub", mux_map);

            PipeHdfContext ctx = new PipeHdfContext();
            ctx.setQualifier("suba", "suba-keypart");
            ctx.setQualifier("subb", "subb-keypart");
            // test missing muxkey with no default
            {
                bool err = false;
                try {
                    PipeRowQualifier builder = mux.generateRowFromContext(ctx);
                }
                catch (PipeGenerateException) {
                    err = true;
                }
                Assert.AreEqual(err, true, "non-default muxkey should throw exception");
            }

            // test mux defaults
            {
                PipeStageMux defmux = new PipeStageMux("select_sub", mux_map, new QualifierExact("path_a"));
                PipeRowQualifier builder = defmux.generateRowFromContext(ctx);
                Assert.AreEqual("/=path_a/=suba-keypart", builder.ToString());
            }

            // test suba
            {
                ctx.setQualifier("select_sub", "path_a");
                PipeRowQualifier builder = mux.generateRowFromContext(ctx);
                Assert.AreEqual("/=path_a/=suba-keypart", builder.ToString());
            }

            // test subb
            {
                ctx.setQualifier("select_sub", "path_b");
                PipeRowQualifier builder = mux.generateRowFromContext(ctx);
                Assert.AreEqual("/=path_b/=subb-keypart", builder.ToString());
            }
        }
Ejemplo n.º 4
0
 internal override void _generateContextFromRow(PipeRow row, PipeHdfContext ctr)
 {
     // TODO
 }
Ejemplo n.º 5
0
 internal override void _generateRowQualifierFromContext(PipeHdfContext ctx, PipeRowQualifier rob)
 {
     QualifierBase qual = ctx.getQualifier(this.context_key);
     if (qual != null) {
         rob.appendKeyPart(qual);
     } else {
         throw new PipeGenerateException(this, "missing context: " + this.context_key);
     }
     this.next_stage._generateRowQualifierFromContext(ctx, rob);
 }
Ejemplo n.º 6
0
 internal override void _generateRowQualifierFromContext(PipeHdfContext ctx, PipeRowQualifier rob)
 {
 }
Ejemplo n.º 7
0
        internal override void _generateRowQualifierFromContext(PipeHdfContext ctx, PipeRowQualifier rob)
        {
            // TODO typecheck this cast and throw a useful execption
            QualifierExact mux_key = (QualifierExact) ctx.getQualifier(this.context_key, this.default_muxvalue);

            if (mux_key != null) {
                rob.appendKeyPart(mux_key);
                {
                    PipeStage next_stage;
                    try {
                        next_stage = this.mux_map[mux_key];
                    }
                    catch (KeyNotFoundException) {
                        throw new PipeGenerateException(this, "missing mux_map entry for: " +
                            this.context_key + " : " + mux_key);
                    }
                    next_stage._generateRowQualifierFromContext(ctx, rob);
                }
            } else {
                throw new PipeGenerateException(this, "missing mux context: " + this.context_key);
            }
        }
Ejemplo n.º 8
0
 internal abstract void _generateRowQualifierFromContext(PipeHdfContext ctx, PipeRowQualifier rowb);
Ejemplo n.º 9
0
 //------
 internal abstract void _generateContextFromRow(PipeRow row, PipeHdfContext ctx);
Ejemplo n.º 10
0
 public PipeRowQualifier generateRowFromContext(PipeHdfContext ctx)
 {
     // generate our own rowparts
     PipeRowQualifier builder = new PipeRowQualifier();
     this._generateRowQualifierFromContext(ctx, builder);
     return builder;
 }
Ejemplo n.º 11
0
 public PipeHdfContext generateContextFromRow(PipeRow row)
 {
     PipeHdfContext ctx = new PipeHdfContext();
     this._generateContextFromRow(row, ctx);
     return ctx;
 }
Ejemplo n.º 12
0
 public void setSubtree(string key, PipeHdfContext subtree)
 {
     if (subtrees == null) {
         subtrees = new Dictionary<string, PipeHdfContext>();
     }
     subtrees[key] = subtree;
 }