private async Task MarkFreeSpaceAsync(SqoTypeInfo ti) { ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust); int nrRecords = ti.Header.numberOfRecords; List <FieldSqoInfo> existingDynamicFields = new List <FieldSqoInfo>(); foreach (FieldSqoInfo ai in ti.Fields) { IByteTransformer byteTrans = ByteTransformerFactory.GetByteTransformer(null, null, ai, ti); if (byteTrans is ArrayByteTranformer || byteTrans is DictionaryByteTransformer) { existingDynamicFields.Add(ai); } } if (existingDynamicFields.Count > 0) { for (int i = 0; i < nrRecords; i++) { int oid = i + 1; foreach (FieldSqoInfo ai in existingDynamicFields) { ATuple <int, int> arrayInfo = await this.GetArrayMetaOfFieldAsync(ti, oid, ai).ConfigureAwait(false); if (arrayInfo.Name > 0) { await rawSerializer.MarkRawInfoAsFreeAsync(arrayInfo.Name).ConfigureAwait(false);//this helps Shrink method to detect unused rawdata blocks. } } } } }
public List <Tile> Run(Tile start, Tile end) { List <ATuple> open = new List <ATuple>(); Dictionary <Point, double> costSoFar = new Dictionary <Point, double>(); open.Add(new ATuple() { tile = start, parent = null, heuristique_remaining = heuristique(start.Position, end.Position), real_cost_to_get_here = 0 }); while (true) { open.Sort((atuple1, atuple2) => atuple1.f().CompareTo(atuple2.f())); if (open.Count == 0) { // TODO return(null); } var current_tuple = open[0]; open.Remove(current_tuple); if (current_tuple.tile.Position.Equals(end.Position)) { return(ConstructPath(current_tuple)); } foreach (var neighbor in GetNeighbors(current_tuple.tile, end)) { ATuple next = new ATuple() { tile = neighbor, parent = current_tuple, real_cost_to_get_here = current_tuple.real_cost_to_get_here + GetCostToWalkUponTile(neighbor), heuristique_remaining = heuristique(neighbor.Position, end.Position) }; //if (neighbor_value_in_open == null) if (!costSoFar.ContainsKey(neighbor.Position)) { open.Add(next); costSoFar[neighbor.Position] = next.f(); } else if (costSoFar[neighbor.Position] > next.f()) { var neighbor_value_in_open = open.Find(atuple => atuple.tile.Position.Equals(neighbor.Position)); open.Remove(neighbor_value_in_open); open.Add(next); } } } }
public List <Tile> ConstructPath(ATuple final) { List <Tile> tiles = new List <Tile>(); ATuple current = final; while (current.parent != null) { tiles.Add(current.tile); current = current.parent; } tiles.Add(current.tile); tiles.Reverse(); return(tiles); }
internal async Task SaveObjectPartiallyByFieldsAsync(object obj, SqoTypeInfo ti, string[] fields) { foreach (string fieldName in fields) { ATuple <int, object> val = MetaExtractor.GetPartialObjectInfo(obj, ti, fieldName, metaCache); object objOfProp = val.Value; int oid = val.Name; if (oid == 0) { throw new Sqo.Exceptions.SiaqodbException("Only updates are allowed through this method."); } await this.SaveValueAsync(oid, fieldName, ti, objOfProp).ConfigureAwait(false); } }
private void MarkObjectAsDelete(ObjectSerializer serializer, int oid, SqoTypeInfo ti) { foreach (FieldSqoInfo ai in ti.Fields) { IByteTransformer byteTrans = ByteTransformerFactory.GetByteTransformer(null, null, ai, ti); if (byteTrans is ArrayByteTranformer || byteTrans is DictionaryByteTransformer) { ATuple <int, int> arrayInfo = this.GetArrayMetaOfField(ti, oid, ai); if (arrayInfo.Name > 0) { rawSerializer.MarkRawInfoAsFree(arrayInfo.Name);//this helps Shrink method to detect unused rawdata blocks. } } } serializer.MarkObjectAsDelete(oid, ti); }
public async Task <byte[]> GetBytesAsync(object obj) { ATuple <int, int> arrayMeta = null; if (parentOID > 0)//means already exists the rawOID { arrayMeta = await serializer.GetArrayMetaOfFieldAsync(ti, parentOID, fi).ConfigureAwait(false); } if (fi.AttributeTypeId == (MetaExtractor.ArrayTypeIDExtra + MetaExtractor.textID)) { return(await rawSerializer.SerializeArrayAsync(obj, fi.AttributeType, fi.Header.Length, fi.Header.RealLength, ti.Header.version, arrayMeta, this.serializer, true).ConfigureAwait(false)); } else { return(await rawSerializer.SerializeArrayAsync(obj, fi.AttributeType, fi.Header.Length, fi.Header.RealLength, ti.Header.version, arrayMeta, this.serializer, false).ConfigureAwait(false)); } }
public byte[] GetBytes(object obj) { ATuple <int, int> arrayMeta = null; if (parentOID > 0)//means already exists the rawOID { arrayMeta = serializer.GetArrayMetaOfField(ti, parentOID, fi); } if (fi.AttributeTypeId == (MetaExtractor.ArrayTypeIDExtra + MetaExtractor.textID)) { return(rawSerializer.SerializeArray(obj, fi.AttributeType, fi.Header.Length, fi.Header.RealLength, ti.Header.version, arrayMeta, this.serializer, true)); } else { return(rawSerializer.SerializeArray(obj, fi.AttributeType, fi.Header.Length, fi.Header.RealLength, ti.Header.version, arrayMeta, this.serializer, false)); } }
private async Task MarkObjectAsDeleteAsync(ObjectSerializer serializer, int oid, SqoTypeInfo ti) { foreach (FieldSqoInfo ai in ti.Fields) { IByteTransformer byteTrans = ByteTransformerFactory.GetByteTransformer(null, null, ai, ti); if (byteTrans is ArrayByteTranformer || byteTrans is DictionaryByteTransformer) { ATuple <int, int> arrayInfo = await this.GetArrayMetaOfFieldAsync(ti, oid, ai).ConfigureAwait(false); if (arrayInfo.Name > 0) { await rawSerializer.MarkRawInfoAsFreeAsync(arrayInfo.Name).ConfigureAwait(false);//this helps Shrink method to detect unused rawdata blocks. } } } await serializer.MarkObjectAsDeleteAsync(oid, ti).ConfigureAwait(false); }
internal async Task SaveObjectPartiallyAsync(object obj, SqoTypeInfo ti, string[] properties) { foreach (string path in properties) { string[] arrayPath = path.Split('.'); PropertyInfo property; Type type = ti.Type; object objOfProp = obj; SqoTypeInfo tiOfProp = ti; int oid = -1; string backingField = null; foreach (var include in arrayPath) { if ((property = type.GetProperty(include)) == null) { throw new Sqo.Exceptions.SiaqodbException("Property:" + include + " does not belong to Type:" + type.FullName); } backingField = ExternalMetaHelper.GetBackingField(property); tiOfProp = this.GetSqoTypeInfoSoft(type); ATuple <int, object> val = MetaExtractor.GetPartialObjectInfo(objOfProp, tiOfProp, backingField, metaCache); objOfProp = val.Value; oid = val.Name; if (oid == 0) { throw new Sqo.Exceptions.SiaqodbException("Only updates are allowed through this method."); } type = property.PropertyType; } object oldPropVal = await indexManager.GetValueForFutureUpdateIndexAsync(oid, backingField, tiOfProp); await this.SaveValueAsync(oid, backingField, tiOfProp, objOfProp).ConfigureAwait(false); await indexManager.UpdateIndexesAsync(oid, backingField, tiOfProp, oldPropVal, objOfProp); } }