Ejemplo n.º 1
0
        static Func <Triple, IEnumerable <INode> > GetKeyMapper(TripleIndexType type)
        {
            switch (type)
            {
            case TripleIndexType.Object:
                return(KeyMapperO);

            case TripleIndexType.Predicate:
                return(KeyMapperP);

            case TripleIndexType.PredicateObject:
                return(KeyMapperPO);

            case TripleIndexType.Subject:
                return(KeyMapperS);

            case TripleIndexType.SubjectObject:
                return(KeyMapperOS);

            case TripleIndexType.SubjectPredicate:
                return(KeyMapperSP);

            default:
                throw new ArgumentException("Not an index type supported by the TripleTrie");
            }
        }
Ejemplo n.º 2
0
 public MappingPair(INode x, INode y, TripleIndexType type)
 {
     this._x    = x;
     this._y    = y;
     this._type = type;
     this._hash = Tools.CombineHashCodes(x, y);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new Triple Pattern.
        /// </summary>
        /// <param name="subj">Subject Pattern.</param>
        /// <param name="pred">Predicate Pattern.</param>
        /// <param name="obj">Object Pattern.</param>
        public TriplePattern(PatternItem subj, PatternItem pred, PatternItem obj)
        {
            _subj = subj;
            if (pred is BlankNodePattern)
            {
                throw new RdfParseException("Cannot use a Triple Pattern with a Blank Node Predicate in a SPARQL Query");
            }
            _pred = pred;
            _obj  = obj;

            // Decide on the Index Type
            if (_subj is NodeMatchPattern)
            {
                if (Options.FullTripleIndexing)
                {
                    if (_pred is NodeMatchPattern)
                    {
                        _indexType = TripleIndexType.SubjectPredicate;
                    }
                    else if (_obj is NodeMatchPattern)
                    {
                        _indexType = TripleIndexType.SubjectObject;
                    }
                    else
                    {
                        _indexType = TripleIndexType.Subject;
                    }
                }
                else
                {
                    _indexType = TripleIndexType.Subject;
                }
            }
            else if (_pred is NodeMatchPattern)
            {
                if (Options.FullTripleIndexing)
                {
                    if (_obj is NodeMatchPattern)
                    {
                        _indexType = TripleIndexType.PredicateObject;
                    }
                    else
                    {
                        _indexType = TripleIndexType.Predicate;
                    }
                }
                else
                {
                    _indexType = TripleIndexType.Predicate;
                }
            }
            else if (_obj is NodeMatchPattern)
            {
                _indexType = TripleIndexType.Object;
            }

            // Determine variables used
            if (_subj.VariableName != null)
            {
                _vars.Add(_subj.VariableName);
            }
            if (_pred.VariableName != null)
            {
                if (!_vars.Contains(_pred.VariableName))
                {
                    _vars.Add(_pred.VariableName);
                }
                else
                {
                    _pred.Repeated = true;
                }
            }
            if (_obj.VariableName != null)
            {
                if (!_vars.Contains(_obj.VariableName))
                {
                    _vars.Add(_obj.VariableName);
                }
                else
                {
                    Object.Repeated = true;
                }
            }
            _vars.Sort();
            if (_vars.Count == 0)
            {
                _indexType = TripleIndexType.NoVariables;
            }
        }
Ejemplo n.º 4
0
 public MappingPair(INode x, INode y, TripleIndexType type)
 {
     this._x = x;
     this._y = y;
     this._type = type;
     this._hash = Tools.CombineHashCodes(x, y);
 }
Ejemplo n.º 5
0
 public TripleTrie(TripleIndexType type)
     : base(GetKeyMapper(type))
 {
 }