Exemplo n.º 1
0
 /// <summary>
 /// Get the shard id corresponding to an indexKey
 /// </summary>
 /// <param name="aIndexKey">An IndexKey</param>
 /// <returns>The shard id</returns>
 private int GetIndexShardID(IndexKey aIndexKey)
 {
     //stupid... might be solved by constant hashing or sth like that
     return Math.Abs(aIndexKey.GetHashCode()) % AttributeIdxShards;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Get the shard id corresponding to an indexKey
 /// </summary>
 /// <param name="aIndexKey">An IndexKey</param>
 /// <returns>The shard id</returns>
 public int GetIndexShardID(IndexKey aIndexKey, UInt16 shardCount)
 {
     //stupid... might be solved by constant hashing or sth like that
     return Math.Abs(aIndexKey.GetHashCode()) % shardCount;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Instantiates a new IndexKey on the base of another one. Additionally a AADBBaseObject is added.
        /// </summary>
        /// <param name="myStartingIndexKey">The base of the new IndexKey</param>
        /// <param name="myAttributeUUID">AttributeUUID corresponding to the ADBBaseObject</param>
        /// <param name="myIndexKeyPayload">The ADBBaseObject that is going to be added</param>
        /// <param name="myIndexDefinition">The corresponding IndexKeyDefinition</param>
        public IndexKey(IndexKey myStartingIndexKey, AttributeUUID myAttributeUUID, ADBBaseObject myIndexKeyPayload, IndexKeyDefinition myIndexDefinition)
        {
            _hashCode = myStartingIndexKey.GetHashCode();

            _indexKeyValues.AddRange(myStartingIndexKey.IndexKeyValues);

            if (!myIndexDefinition.IndexKeyAttributeUUIDs.Contains(myAttributeUUID))
            {
                throw new GraphDBException(new Error_IndexKeyCreationError(myAttributeUUID, myIndexKeyPayload, myIndexDefinition));
            }
            else
            {
                AddAAKey(myAttributeUUID, myIndexKeyPayload);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Instantiates a new IndexKey on the base of another one. Additionally a AADBBaseObject is added.
        /// </summary>
        /// <param name="myStartingIndexKey">The base of the new IndexKey</param>
        /// <param name="myAttributeUUID">AttributeUUID corresponding to the ADBBaseObject</param>
        /// <param name="myIndexKeyPayload">The ADBBaseObject that is going to be added</param>
        /// <param name="myIndexDefinition">The corresponding IndexKeyDefinition</param>
        public IndexKey(IndexKey myStartingIndexKey, AttributeUUID myAttributeUUID, ADBBaseObject myIndexKeyPayload, IndexKeyDefinition myIndexDefinition)
        {
            _hashCode = myStartingIndexKey.GetHashCode();

            #region IEstimable

            _estimatedSize = GetBaseSize();

            foreach (var aADBBaseObject in myStartingIndexKey.IndexKeyValues)
            {
                _indexKeyValues.Add(aADBBaseObject);
                _estimatedSize += aADBBaseObject.GetEstimatedSize();
            }

            #endregion

            if (!myIndexDefinition.IndexKeyAttributeUUIDs.Contains(myAttributeUUID))
            {
                throw new GraphDBException(new Error_IndexKeyCreationError(myAttributeUUID, myIndexKeyPayload, myIndexDefinition));
            }
            else
            {
                AddAAKey(myAttributeUUID, myIndexKeyPayload);
            }
        }