protected override IEnumerable <long> GetValues(ISonesIndex myIndex, IComparable myIComparable) { if (myIndex is ISonesRangeIndex) { //use the range funtionality foreach (var aVertexID in ((ISonesRangeIndex)myIndex).GreaterThan(myIComparable, true)) { yield return(aVertexID); } } else { //stupid, but works foreach (var aVertexIDSet in myIndex.Keys().Where(key => key.CompareTo(myIComparable) >= 0).Select(key => myIndex[key])) { foreach (var aVertexID in aVertexIDSet) { yield return(aVertexID); } } } yield break; }
protected override IEnumerable<long> GetValues(ISonesIndex myIndex, IComparable myIComparable) { if (myIndex is ISonesRangeIndex) { //use the range funtionality foreach (var aVertexID in ((ISonesRangeIndex)myIndex).LowerThan(myIComparable, true)) { yield return aVertexID; } } else { //stupid, but works foreach (var aVertexIDSet in myIndex.Keys().Where(key => key.CompareTo(myIComparable) <= 0).Select(key => myIndex[key])) { foreach (var aVertexID in aVertexIDSet) { yield return aVertexID; } } } yield break; }
protected override IEnumerable <long> GetValues(ISonesIndex myIndex, IComparable myIComparable) { ICloseableEnumerable <long> values; myIndex.TryGetValues(myIComparable, out values); return(values); }
protected override IEnumerable<long> GetValues(ISonesIndex myIndex, IComparable myIComparable) { ICloseableEnumerable<long> values; myIndex.TryGetValues(myIComparable, out values); return values; }
protected override IEnumerable <long> GetValues(ISonesIndex myIndex, IComparable myIComparable) { foreach (var aVertexIDSet in myIndex.Keys().Where(key => key.CompareTo(myIComparable) != 0).Select(key => myIndex[key])) { foreach (var aVertexID in aVertexIDSet) { yield return(aVertexID); } } yield break; }
protected override IEnumerable<long> GetValues(ISonesIndex myIndex, IComparable myIComparable) { foreach (var aVertexIDSet in myIndex.Keys().Where(key => key.CompareTo(myIComparable) != 0).Select(key => myIndex[key])) { foreach (var aVertexID in aVertexIDSet) { yield return aVertexID; } } yield break; }
protected override IEnumerable <long> GetValues(ISonesIndex myIndex, IComparable myIComparable) { var regexpression = new Regex((String)myIComparable); List <long> ids = new List <long>(); foreach (var key in myIndex.Keys()) { if (regexpression.IsMatch((String)key)) { ids.AddRange(myIndex[key]); } } return(ids); }
/// <summary> /// Extract the values corresponding to the range /// </summary> /// <param name="myIndex">The interesting index</param> /// <param name="myConstant">The inderesting range</param> /// <returns>An enumerable of vertexIDs</returns> private IEnumerable <long> GetValues(ISonesIndex myIndex, RangeLiteralExpression myConstant) { if (myIndex is ISonesRangeIndex) { //use the range funtionality foreach (var aVertexID in ((ISonesRangeIndex)myIndex) .Between(myConstant.Lower, myConstant.Upper, myConstant.IncludeBorders, myConstant.IncludeBorders)) { yield return(aVertexID); } } else { //stupid, but works if (myConstant.IncludeBorders) { foreach (var aVertexIDSet in myIndex.Keys() .Where(key => (key.CompareTo(myConstant.Lower) >= 0) && (key.CompareTo(myConstant.Upper) <= 0)) .Select(key => myIndex[key])) { foreach (var aVertexID in aVertexIDSet) { yield return(aVertexID); } } } else { foreach (var aVertexIDSet in myIndex.Keys() .Where(key => (key.CompareTo(myConstant.Lower) > 0) && (key.CompareTo(myConstant.Upper) < 0)) .Select(key => myIndex[key])) { foreach (var aVertexID in aVertexIDSet) { yield return(aVertexID); } } } } yield break; }
/// <summary> /// Executes the query plan recursivly /// </summary> /// <param name="myVertexType">The starting vertex type</param> /// <returns>An enumeration of vertices</returns> private IEnumerable <IVertex> Execute_private(IVertexType myVertexType) { #region current type ISonesIndex idx = null; if (_expressionIndex != null) { idx = _indexManager.GetIndex(_expressionIndex, _securityToken, _transactionToken); } else { idx = GetBestMatchingIdx(_indexManager.GetIndices(_property.Property, _securityToken, _transactionToken)); } foreach (var aVertex in GetValues(idx, _constant) .Select(aId => _vertexStore.GetVertex( _securityToken, _transactionToken, aId, myVertexType.ID, VertexEditionFilter, VertexRevisionFilter))) { yield return(aVertex); } #endregion #region child types foreach (var aChildVertexType in myVertexType.GetDescendantVertexTypes()) { foreach (var aVertex in Execute_private(aChildVertexType)) { yield return(aVertex); } } #endregion yield break; }
private static bool GetIsPersistentIndex(ISonesIndex myIndex) { return myIndex is ISonesPersistentIndex; }
/// <summary> /// Extract the values corresponding to the range /// </summary> /// <param name="myIndex">The interesting index</param> /// <param name="myConstant">The inderesting range</param> /// <returns>An enumerable of vertexIDs</returns> private IEnumerable<long> GetValues(ISonesIndex myIndex, RangeLiteralExpression myConstant) { if (myIndex is ISonesRangeIndex) { //use the range funtionality foreach (var aVertexID in ((ISonesRangeIndex)myIndex) .Between(myConstant.Lower, myConstant.Upper, myConstant.IncludeBorders, myConstant.IncludeBorders)) { yield return aVertexID; } } else { //stupid, but works if (myConstant.IncludeBorders) { foreach (var aVertexIDSet in myIndex.Keys() .Where(key => (key.CompareTo(myConstant.Lower) >= 0) && (key.CompareTo(myConstant.Upper) <= 0)) .Select(key => myIndex[key])) { foreach (var aVertexID in aVertexIDSet) { yield return aVertexID; } } } else { foreach (var aVertexIDSet in myIndex.Keys() .Where(key => (key.CompareTo(myConstant.Lower) > 0) && (key.CompareTo(myConstant.Upper) < 0)) .Select(key => myIndex[key])) { foreach (var aVertexID in aVertexIDSet) { yield return aVertexID; } } } } yield break; }
public void Load(Int64 myTransaction, SecurityToken mySecurity) { var maxID = Int64.MinValue; var vertices = _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, (long)BaseTypes.Index); foreach (var indexVertex in vertices) { var def = _baseStorageManager.CreateIndexDefinition(indexVertex); var vertexType = def.VertexType; var indexID = def.ID; maxID = Math.Max(maxID, def.ID); var typeClass = def.IndexTypeName ?? GetBestMatchingIndexName(def.IsRange, def.IsVersioned); var parameter = (_indexPluginParameter.ContainsKey(typeClass)) ? _indexPluginParameter[typeClass].PluginParameter : new Dictionary<string, object>(); var options = (indexVertex.GetAllUnstructuredProperties() == null) ? null : indexVertex.GetAllUnstructuredProperties().Select(_ => new KeyValuePair<String, object>(_.PropertyName, _.Property)); // add propertyIDs for indexing parameter.Add(IndexConstants.PROPERTY_IDS_OPTIONS_KEY, def.IndexedProperties.Select(propDef => propDef.ID).ToList()); parameter = FillOptions(parameter, options); // HACK: manually inject eventuall existing PersistenceLocation (btk, 23.09.2011) #region Hack if (_applicationSettings.Get<PersistenceLocation>() != null) { // if not already, initialize if (parameter == null) parameter = new Dictionary<string, object>(); if (!parameter.ContainsKey("Path")) // only add when not already in there... parameter.Add("Path", _applicationSettings.Get<PersistenceLocation>()); } #endregion var index = _pluginManager.GetAndInitializePlugin<ISonesIndex>(typeClass, parameter, indexID); _indices.Add(indexID, index); if (def.Name == "IndexDotName") _ownIndex = index; } _idManager.GetVertexTypeUniqeID((long)BaseTypes.Index).SetToMaxID(maxID); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.BaseType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.VertexType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.EdgeType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.Index, myTransaction, mySecurity), myTransaction, mySecurity, true); }
private static bool GetIsRangeValue(ISonesIndex myIndex) { return(myIndex is ISonesRangeIndex); }
private static bool GetIsPersistentIndex(ISonesIndex myIndex) { return(myIndex is ISonesPersistentIndex); }
public void Load(Int64 myTransaction, SecurityToken mySecurity) { var maxID = Int64.MinValue; var vertices = _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, (long)BaseTypes.Index); foreach (var indexVertex in vertices) { var def = _baseStorageManager.CreateIndexDefinition(indexVertex); var vertexType = def.VertexType; var indexID = def.ID; maxID = Math.Max(maxID, def.ID); var typeClass = def.IndexTypeName ?? GetBestMatchingIndexName(def.IsRange, def.IsVersioned); var parameter = (_indexPluginParameter.ContainsKey(typeClass)) ? _indexPluginParameter[typeClass].PluginParameter : new Dictionary <string, object>(); var options = (indexVertex.GetAllUnstructuredProperties() == null) ? null : indexVertex.GetAllUnstructuredProperties().Select(_ => new KeyValuePair <String, object>(_.PropertyName, _.Property)); // add propertyIDs for indexing parameter.Add(IndexConstants.PROPERTY_IDS_OPTIONS_KEY, def.IndexedProperties.Select(propDef => propDef.ID).ToList()); parameter = FillOptions(parameter, options); // HACK: manually inject eventuall existing PersistenceLocation (btk, 23.09.2011) #region Hack if (_applicationSettings.Get <PersistenceLocation>() != null) { // if not already, initialize if (parameter == null) { parameter = new Dictionary <string, object>(); } if (!parameter.ContainsKey("Path")) // only add when not already in there... { parameter.Add("Path", _applicationSettings.Get <PersistenceLocation>()); } } #endregion var index = _pluginManager.GetAndInitializePlugin <ISonesIndex>(typeClass, parameter, indexID); _indices.Add(indexID, index); if (def.Name == "IndexDotName") { _ownIndex = index; } } _idManager.GetVertexTypeUniqeID((long)BaseTypes.Index).SetToMaxID(maxID); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.BaseType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.VertexType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.EdgeType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.Index, myTransaction, mySecurity), myTransaction, mySecurity, true); }
private static bool GetIsVersionedValue(ISonesIndex myIndex) { return(myIndex is ISonesVersionedIndex); }
protected override IEnumerable<long> GetValues(ISonesIndex myIndex, IComparable myIComparable) { var regexpression = new Regex((String)myIComparable); List<long> ids = new List<long>(); foreach (var key in myIndex.Keys()) { if (regexpression.IsMatch((String)key)) { ids.AddRange(myIndex[key]); } } return ids; }
/// <summary> /// Gets the values from an index corresponding to a value /// </summary> /// <param name="myIndex">The interesting index</param> /// <param name="myIComparable">The interesting key</param> /// <returns>An enumerable of VertexIDs</returns> protected abstract IEnumerable<long> GetValues(ISonesIndex myIndex, IComparable myIComparable);
/// <summary> /// Executes the query plan recursivly /// </summary> /// <param name="myVertexType">The starting vertex type</param> /// <returns>An enumeration of vertices</returns> protected IEnumerable <IVertex> Execute_protected(IVertexType myVertexType) { #region current type List <IVertex> vertices = new List <IVertex>(); if (!myVertexType.IsAbstract) { #region loading the index ISonesIndex idx = null; //an index name is specified in an expression, try to get the index // //NOTE: if the specified index couldn't be found, null will be returnd // to use another index, the call of GetBestMatchingIndex could be added here if (_expressionIndex != null) { idx = _indexManager.GetIndex(_expressionIndex, _securityToken, _transactionToken); } //no index name is specified, get the best matching index else { idx = GetBestMatchingIdx(_indexManager.GetIndices(myVertexType, _property.Property, _securityToken, _transactionToken)); } //no index could be found if (idx == null) { throw new IndexDoesNotExistException( _expressionIndex == null ? "no index found" : _expressionIndex, "default"); } #endregion #region get the index results //index is a ISonesFulltextIndex, //so we make a query and get a ISonesFulltextResult if (idx is ISonesFulltextIndex) { var value = (idx as ISonesFulltextIndex).Query(_constant.Value.ToString()); if (value != null) { //read out the ISonesFulltextResultEntries //create TemporalVertices which store vertices.AddRange(value.Entries .OrderByDescending(entry => entry.Score) .Select(entry => CreateTemporalVertex( GetVertex(entry.VertexID, myVertexType), entry))); } } else { //read out the values var values = GetValues(idx, _constant.Value); if (values != null) { foreach (var aVertexID in values) { vertices.Add(GetVertex(aVertexID, myVertexType)); } } } #endregion } #endregion #region child types foreach (var aChildVertexType in myVertexType.ChildrenVertexTypes) { vertices.AddRange(Execute_protected(aChildVertexType)); } #endregion return(vertices); }
private static bool GetIsRangeValue(ISonesIndex myIndex) { return myIndex is ISonesRangeIndex; }
public void Load(Int64 myTransaction, SecurityToken mySecurity) { var maxID = Int64.MinValue; var vertices = _vertexStore.GetVerticesByTypeID(mySecurity, myTransaction, (long)BaseTypes.Index); foreach (var indexVertex in vertices) { var def = _baseStorageManager.CreateIndexDefinition(indexVertex); var vertexType = def.VertexType; var indexID = def.ID; maxID = Math.Max(maxID, def.ID); var typeClass = def.IndexTypeName ?? GetBestMatchingIndexName(def.IsRange, def.IsVersioned); var parameter = (_indexPluginParameter.ContainsKey(typeClass)) ? _indexPluginParameter[typeClass].PluginParameter : new Dictionary<string, object>(); var options = (indexVertex.GetAllUnstructuredProperties() == null) ? null : indexVertex.GetAllUnstructuredProperties().Select(_ => new KeyValuePair<String, object>(_.Item1, _.Item2)); // add propertyIDs for indexing parameter.Add(IndexConstants.PROPERTY_IDS_OPTIONS_KEY, def.IndexedProperties.Select(propDef => propDef.ID).ToList()); parameter = FillOptions(parameter, options); var index = _pluginManager.GetAndInitializePlugin<ISonesIndex>(typeClass, parameter, indexID); _indices.Add(indexID, index); if (def.Name == "IndexDotName") _ownIndex = index; } _idManager.GetVertexTypeUniqeID((long)BaseTypes.Index).SetToMaxID(maxID); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.BaseType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.VertexType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.EdgeType, myTransaction, mySecurity), myTransaction, mySecurity, true); RebuildIndices(_vertexTypeManager.ExecuteManager.GetType((long)BaseTypes.Index, myTransaction, mySecurity), myTransaction, mySecurity, true); }
private static bool GetIsVersionedValue(ISonesIndex myIndex) { return myIndex is ISonesVersionedIndex; }
/// <summary> /// Gets the values from an index corresponding to a value /// </summary> /// <param name="myIndex">The interesting index</param> /// <param name="myIComparable">The interesting key</param> /// <returns>An enumerable of VertexIDs</returns> protected abstract IEnumerable <long> GetValues(ISonesIndex myIndex, IComparable myIComparable);