public void Store(WTree tree, BinaryWriter writer) { CountCompression.Serialize(writer, checked ((ulong)Count)); Debug.Assert(Count > 0); writer.Write((byte)this[0].Value.NodeType); for (int i = 0; i < Count; i++) { var kv = this[i]; FullKey fullkey = kv.Key; Branch branch = kv.Value; //lock (branch) //{ //} //write locator tree.SerializeLocator(writer, fullkey.Locator); fullkey.Locator.KeyPersist.Write(writer, fullkey.Key); //write branch info writer.Write(branch.NodeHandle); writer.Write((int)branch.NodeState); branch.Cache.Store(tree, writer); } }
public static void WriteResponse(BinaryWriter writer, byte[] tag) { writer.Write(tag != null); if (tag != null) { CountCompression.Serialize(writer, (ulong)tag.Length); writer.Write(tag, 0, tag.Length); } }
public static void WriteRequest(BinaryWriter writer, byte[] tag) { writer.Write((byte)RemoteHeapCommandCodes.SetTag); writer.Write(tag != null); if (tag != null) { CountCompression.Serialize(writer, (ulong)tag.Length); writer.Write(tag, 0, tag.Length); } }
private void StoreExampleSingleSlot(BinaryWriter writer, Func <int, IData> values, int count) { //String using (MemoryStream ms = new MemoryStream()) { ((IIndexerPersist <String>)Persists[0]).Store(new BinaryWriter(ms), (idx) => { return(((Data <string>)values(idx)).Slot0); }, count); CountCompression.Serialize(writer, checked ((ulong)ms.Length)); writer.Write(ms.GetBuffer(), 0, (int)ms.Length); } }
public static void WriteRequest(BinaryWriter writer, long handle, int index, int count, byte[] buffer) { writer.Write((byte)RemoteHeapCommandCodes.WriteCommand); CountCompression.Serialize(writer, (ulong)handle); CountCompression.Serialize(writer, (ulong)index); CountCompression.Serialize(writer, (ulong)count); CountCompression.Serialize(writer, (ulong)(count + index)); writer.Write(buffer, 0, index + count); }
public override void Store(Stream stream) { BinaryWriter writer = new BinaryWriter(stream); writer.Write(VERSION); CountCompression.Serialize(writer, checked ((ulong)Branch.NodeHandle)); writer.Write(HaveChildrenForMaintenance); Branches.Store(Branch.Tree, writer); IsModified = false; }
private void WriteVertical(BinaryWriter writer, IOrderedSet <IData, IData> data) { KeyValuePair <IData, IData>[] rows; bool isInternallyOrdered; lock (data) { isInternallyOrdered = data.IsInternallyOrdered; rows = new KeyValuePair <IData, IData> [data.Count]; int index = 0; foreach (var kv in data.InternalEnumerate()) { rows[index++] = kv; } CountCompression.Serialize(writer, checked ((ulong)rows.Length)); writer.Write(data.IsInternallyOrdered); } Action[] actions = new Action[2]; MemoryStream[] streams = new MemoryStream[2]; actions[0] = () => { streams[0] = new MemoryStream(); keyIndexerPersist.Store(new BinaryWriter(streams[0]), (idx) => { return(rows[idx].Key); }, rows.Length); }; actions[1] = () => { streams[1] = new MemoryStream(); recordIndexerPersist.Store(new BinaryWriter(streams[1]), (idx) => { return(rows[idx].Value); }, rows.Length); }; Parallel.Invoke(actions); foreach (var stream in streams) { using (stream) { CountCompression.Serialize(writer, checked ((ulong)stream.Length)); writer.Write(stream.GetBuffer(), 0, (int)stream.Length); } } }
public override void Store(Stream stream) { BinaryWriter writer = new BinaryWriter(stream); writer.Write(VERSION); CountCompression.Serialize(writer, checked ((ulong)Branch.NodeHandle)); CountCompression.Serialize(writer, checked ((ulong)Container.Count)); foreach (var kv in Container) { Branch.Tree.SerializeLocator(writer, kv.Key); kv.Key.OrderedSetPersist.Write(writer, kv.Value); } IsModified = false; }
public override void Store(Stream stream) { BinaryWriter writer = new BinaryWriter(stream); CountCompression.Serialize(writer, 1); //structure version CountCompression.Serialize(writer, checked ((ulong)Branch.NodeHandle)); CountCompression.Serialize(writer, checked ((ulong)Container.Count)); foreach (var kv in Container) { Branch.Tree.Serialize(writer, kv.Key); kv.Key.PersistDataContainer.Write(writer, kv.Value); } IsModified = false; }
private void InternalSerialize(BinaryWriter writer) { //StructureType writer.Write(checked ((byte)StructureType)); if (Object.ReferenceEquals(this, Locator.MIN)) { return; } //descriptor descriptor.Serialize(writer); //Items CountCompression.Serialize(writer, checked ((ulong)Path.Length)); for (int i = 0; i < Path.Length; i++) { writer.Write(Path[i]); } }
private void WriteStorageEngineGetEnumeratorCommand(BinaryWriter writer, ICommand command) { var cmd = (StorageEngineGetEnumeratorCommand)command; if (cmd.Descriptions == null) { writer.Write(true); } else { writer.Write(false); int listCount = cmd.Descriptions.Count; CountCompression.Serialize(writer, (ulong)listCount); for (int i = 0; i < listCount; i++) { SerializeDescriptor(writer, cmd.Descriptions[i]); } } }
private void StoreExample(BinaryWriter writer, Func <int, IData> values, int count) { Action[] actions = new Action[DataType.TypesCount]; MemoryStream[] streams = new MemoryStream[DataType.TypesCount]; //Int actions[0] = () => { streams[0] = new MemoryStream(); ((IIndexerPersist <Int32>)Persists[0]).Store(new BinaryWriter(streams[0]), (idx) => { return(((Data <int, string, double>)values(idx)).Slot0); }, count); }; //String actions[1] = () => { streams[1] = new MemoryStream(); ((IIndexerPersist <String>)Persists[1]).Store(new BinaryWriter(streams[1]), (idx) => { return(((Data <int, string, double>)values(idx)).Slot1); }, count); }; //Double actions[2] = () => { streams[2] = new MemoryStream(); ((IIndexerPersist <Double>)Persists[2]).Store(new BinaryWriter(streams[2]), (idx) => { return(((Data <int, string, double>)values(idx)).Slot2); }, count); }; Parallel.Invoke(actions); for (int i = 0; i < DataType.TypesCount; i++) { var stream = streams[i]; using (stream) { CountCompression.Serialize(writer, checked ((ulong)stream.Length)); writer.Write(stream.GetBuffer(), 0, (int)stream.Length); } } }
public void Write(BinaryWriter writer, IDataContainer item) { var set = (IOrderedSet <IData, IData>)item; var rows = new KeyValuePair <IData, IData> [set.Count]; bool isOrdered; set.InternalCopyTo(rows, out isOrdered); CountCompression.Serialize(writer, checked ((ulong)set.Count)); writer.Write(isOrdered); Action[] actions = new Action[2]; MemoryStream[] streams = new MemoryStream[2]; actions[0] = () => { streams[0] = new MemoryStream(); keyIndexerPersist.Store(new BinaryWriter(streams[0]), (idx) => { return(rows[idx].Key); }, rows.Length); }; actions[1] = () => { streams[1] = new MemoryStream(); recordIndexerPersist.Store(new BinaryWriter(streams[1]), (idx) => { return(rows[idx].Value); }, rows.Length); }; Parallel.Invoke(actions); foreach (var str in streams) { using (str) { CountCompression.Serialize(writer, checked ((ulong)str.Length)); writer.Write(str.GetBuffer(), 0, (int)str.Length); } } }
public void Store(BinaryWriter writer, Func <int, long> values, int count) { writer.Write(VERSION); long[] array = new long[count]; int index = factors.Length - 1; for (int i = 0; i < count; i++) { long value = values(i); array[i] = value; while (index >= 0) { if (value % factors[index] == 0) { break; } else { index--; } } } long factor = index >= 0 ? factors[index] : 1; DeltaCompression.Helper helper = new DeltaCompression.Helper(); for (int i = 0; i < count; i++) { array[i] /= factor; helper.Add(array[i]); } CountCompression.Serialize(writer, checked ((ulong)factor)); DeltaCompression.Compress(writer, array, 0, count, helper); }
public void Store(BinaryWriter writer, Func <int, long> values, int count) { List <long> list = new List <long>(count); int index = factors.Length - 1; for (int i = 0; i < count; i++) { long value = values(i); list.Add(value); while (index >= 0) { if (value % factors[index] == 0) { break; } else { index--; } } } long factor = index >= 0 ? factors[index] : 1; DeltaCompression.Helper helper = new DeltaCompression.Helper(); for (int i = 0; i < count; i++) { list[i] = list[i] / factor; helper.AddValue(list[i]); } CountCompression.Serialize(writer, checked ((ulong)factor)); DeltaCompression.CoreCompress(writer, list, helper); }
//public byte[] Tag //{ // get // { // //if (ForSerialize) // // return tag; // IDescriptor descriptor = GetDescriptor(this); // tag = descriptor.Tag; // return tag; // } // set // { // //this.ForSerialize = true; // //this.tag = value; // //IDescriptor descriptor = SetDescriptor(this); // //tag = descriptor.Tag; // //this.ForSerialize = false; // } //} #endregion public void Serialize(BinaryWriter writer) { CountCompression.Serialize(writer, (ulong)ID); writer.Write(Name); CountCompression.Serialize(writer, (ulong)StructureType); KeyDataType.Serialize(writer); RecordDataType.Serialize(writer); CountCompression.Serialize(writer, (ulong)CreateTime.Ticks); CountCompression.Serialize(writer, (ulong)ModifiedTime.Ticks); CountCompression.Serialize(writer, (ulong)AccessTime.Ticks); if (Tag == null) { CountCompression.Serialize(writer, 0); } else { CountCompression.Serialize(writer, (ulong)Tag.Length + 1); writer.Write(Tag); } }
private void SerializeDescriptor(BinaryWriter writer, IDescriptor description) { CountCompression.Serialize(writer, (ulong)description.ID); writer.Write(description.Name); CountCompression.Serialize(writer, (ulong)description.StructureType); description.KeyDataType.Serialize(writer); description.RecordDataType.Serialize(writer); CountCompression.Serialize(writer, (ulong)description.CreateTime.Ticks); CountCompression.Serialize(writer, (ulong)description.ModifiedTime.Ticks); CountCompression.Serialize(writer, (ulong)description.AccessTime.Ticks); if (description.Tag == null) { CountCompression.Serialize(writer, 0); } else { CountCompression.Serialize(writer, (ulong)description.Tag.Length + 1); writer.Write(description.Tag); } }
public void Store(BinaryWriter writer, Func <int, byte[]> values, int count) { writer.Write(VERSION); int index = 0; byte[] value; if (writer.BaseStream is MemoryStream) { writer.Write((byte)1); if (count == 0) { return; } int c = 1; long pos = writer.BaseStream.Position; writer.Write(count); //writer.Write(c); int length; value = values(index); if (value == null) { length = -1; writer.Write(length); } else { length = value.Length; writer.Write(length); writer.Write(value); } index++; while (index < count) { value = values(index); if (value == null) { if (length != -1) { break; } } else { if (length != value.Length) { break; } writer.Write(value); } index++; c++; } if (c < count) { var pos2 = writer.BaseStream.Position; writer.BaseStream.Seek(pos, SeekOrigin.Begin); writer.Write(c); writer.BaseStream.Seek(pos2, SeekOrigin.Begin); } else { return; } } else { writer.Write((byte)0); } for (int i = index; i < count; i++) { value = values(i); if (value == null) { CountCompression.Serialize(writer, 0); } else { CountCompression.Serialize(writer, (ulong)(value.Length + 1)); writer.Write(value); } } }
public static void WriteRequest(BinaryWriter writer, long handle) { writer.Write((byte)RemoteHeapCommandCodes.HandleExist); CountCompression.Serialize(writer, (ulong)handle); }
public static void WriteResponse(BinaryWriter writer, long size) { CountCompression.Serialize(writer, (ulong)size); }
private void InternalSerialize(BinaryWriter writer) { lock (SyncRoot) { writer.Write(VERSION); writer.Write(ID); if (ID == Locator.MIN.ID) { return; } writer.Write(IsDeleted); writer.Write(Name); writer.Write(checked ((byte)StructureType)); //data types KeyDataType.Serialize(writer); RecordDataType.Serialize(writer); //types if (!DataTypeUtils.IsAnonymousType(KeyType)) { writer.Write(KeyType.FullName); } else { writer.Write(""); } if (!DataTypeUtils.IsAnonymousType(RecordType)) { writer.Write(RecordType.FullName); } else { writer.Write(""); } //key & record members WriteMembers(writer, keyMembers); WriteMembers(writer, recordMembers); //times writer.Write(CreateTime.Ticks); writer.Write(ModifiedTime.Ticks); writer.Write(AccessTime.Ticks); //tag if (Tag == null) { writer.Write(false); } else { writer.Write(true); CountCompression.Serialize(writer, (ulong)Tag.Length); writer.Write(Tag); } } }
public static void WriteResponse(BinaryWriter writer, byte[] buffer) { CountCompression.Serialize(writer, (ulong)buffer.Length); writer.Write(buffer, 0, buffer.Length); }
private void WriteStorageEngineCountCommand(BinaryWriter writer, ICommand command) { var cmd = (StorageEngineCountCommand)command; CountCompression.Serialize(writer, (ulong)cmd.Count); }
public void Serialize(BinaryWriter writer) { CountCompression.Serialize(writer, checked ((ulong)Raw.Length)); writer.Write(Raw); }