public static ReadCommand ReadResponse(BinaryReader reader) { return(new ReadCommand() { Buffer = reader.ReadBytes((int)CountCompression.Deserialize(reader)) }); }
public static DataBaseSizeCommand ReadResponse(BinaryReader reader) { return(new DataBaseSizeCommand() { DataBaseSize = (long)CountCompression.Deserialize(reader) }); }
public static GetTagCommand ReadResponse(BinaryReader reader) { return(new GetTagCommand() { Tag = reader.ReadBoolean() ? reader.ReadBytes((int)CountCompression.Deserialize(reader)) : null }); }
public override void Load(Stream stream) { BinaryReader reader = new BinaryReader(stream); if (reader.ReadByte() != VERSION) { throw new Exception("Invalid LeafNode version."); } long id = (long)CountCompression.Deserialize(reader); if (id != Branch.NodeHandle) { throw new Exception("Wtree logical error."); } int count = (int)CountCompression.Deserialize(reader); for (int i = 0; i < count; i++) { Locator path = Branch.Tree.DeserializeLocator(reader); IOrderedSet <IData, IData> data = path.OrderedSetPersist.Read(reader); Container[path] = data; RecordCount += data.Count; } IsModified = false; }
public static ObtainHandleCommand ReadResponse(BinaryReader reader) { return(new ObtainHandleCommand() { Handle = (long)CountCompression.Deserialize(reader) }); }
public void Load(WTree tree, BinaryReader reader) { int count = (int)CountCompression.Deserialize(reader); Capacity = count; NodeType nodeType = (NodeType)reader.ReadByte(); for (int i = 0; i < count; i++) { //read fullKey var locator = tree.DeserializeLocator(reader); var key = locator.KeyPersist.Read(reader); var fullKey = new FullKey(locator, key); //read branch info long nodeID = reader.ReadInt64(); NodeState nodeState = (NodeState)reader.ReadInt32(); Branch branch = new Branch(tree, nodeType, nodeID); branch.NodeState = nodeState; branch.Cache.Load(tree, reader); Add(new KeyValuePair <FullKey, Branch>(fullKey, branch)); } }
public override void Load(Stream stream) { BinaryReader reader = new BinaryReader(stream); int version = (int)CountCompression.Deserialize(reader); switch (version) { case 1: { long id = (long)CountCompression.Deserialize(reader); if (id != Branch.NodeHandle) { throw new Exception("Wtree logical error."); } HaveChildrenForMaintenance = reader.ReadBoolean(); Branches.Load(Branch.Tree, reader); RebuildOptimizator(); } break; default: throw new NotSupportedException(string.Format("Inernal node version {0}", version)); } IsModified = false; }
public override void Load(Stream stream) { BinaryReader reader = new BinaryReader(stream); int version = (int)CountCompression.Deserialize(reader); switch (version) { case 1: { long id = (long)CountCompression.Deserialize(reader); if (id != Branch.NodeHandle) { throw new Exception("Wtree logical error."); } int count = (int)CountCompression.Deserialize(reader); for (int i = 0; i < count; i++) { ILocator path = Branch.Tree.Deserialize(reader); IDataContainer data = path.PersistDataContainer.Read(reader); Container[path] = data; FillPercentage += data.FillPercentage; } } break; default: throw new NotSupportedException(string.Format("Leaf node version {0}", version)); } IsModified = false; }
public static HandleExistCommand ReadRequest(BinaryReader reader) { return(new HandleExistCommand() { Handle = (long)CountCompression.Deserialize(reader) }); }
private void LoadExampleSingleSlot(BinaryReader reader, Action <int, IData> values, int count) { byte[] buffer = reader.ReadBytes((int)CountCompression.Deserialize(reader)); //String using (MemoryStream ms = new MemoryStream(buffer)) ((IIndexerPersist <string>)Persists[0]).Load(new BinaryReader(ms), (idx, value) => { values(idx, new Data <string>(value)); }, count); }
public static Locator Deserialize(BinaryReader reader) { if (reader.ReadByte() != VERSION) { throw new Exception("Invalid Locator version."); } long id = reader.ReadInt64(); if (id == Locator.MIN.ID) { return(Locator.MIN); } bool isDeleted = reader.ReadBoolean(); string name = reader.ReadString(); int structureType = reader.ReadByte(); //data types DataType keyDataType = DataType.Deserialize(reader); DataType recordDataType = DataType.Deserialize(reader); //types string sKeyType = reader.ReadString(); Type keyType = (sKeyType != "") ? TypeCache.GetType(sKeyType) : DataTypeUtils.BuildType(keyDataType); string sRecordType = reader.ReadString(); Type recordType = (sRecordType != "") ? TypeCache.GetType(sRecordType) : DataTypeUtils.BuildType(recordDataType); //key & record members var keyMembers = ReadMembers(reader); var recordMembers = ReadMembers(reader); //create time DateTime createTime = new DateTime(reader.ReadInt64()); DateTime modifiedTime = new DateTime(reader.ReadInt64()); DateTime accessTime = new DateTime(reader.ReadInt64()); //tag byte[] tag = reader.ReadBoolean() ? reader.ReadBytes((int)CountCompression.Deserialize(reader)) : null; var locator = new Locator(id, name, structureType, keyDataType, recordDataType, keyType, recordType); locator.IsDeleted = isDeleted; locator.keyMembers = keyMembers; locator.recordMembers = recordMembers; locator.CreateTime = createTime; locator.ModifiedTime = modifiedTime; locator.AccessTime = accessTime; locator.Tag = tag; return(locator); }
public void Load(BinaryReader reader, Action <int, byte[]> values, int count) { if (reader.ReadByte() != VERSION) { throw new Exception("Invalid ByteArrayIndexerPersist version."); } int index = 0; byte format = reader.ReadByte(); if (format == 1) { if (count == 0) { return; } int c = reader.ReadInt32(); int length = reader.ReadInt32(); if (length < 0) { for (int i = 0; i < c; i++) { values(index++, null); } } else { for (int i = 0; i < c; i++) { values(index++, reader.ReadBytes(length)); } } if (index == count) { return; } } for (int i = index; i < count; i++) { int length = (int)CountCompression.Deserialize(reader); if (length == 0) { values(i, null); } else { values(i, reader.ReadBytes(length - 1)); } } }
public void Load(BinaryReader reader, Action <int, long> values, int count) { long factor = (long)CountCompression.Deserialize(reader); List <long> rawValues = (List <long>)DeltaCompression.CoreDecompress(reader); for (int i = 0; i < count; i++) { values(i, factor * rawValues[i]); } }
public void Load(BinaryReader reader, Action <int, long> values, int count) { if (reader.ReadByte() != VERSION) { throw new Exception("Invalid Int64IndexerPersist version."); } long factor = (long)CountCompression.Deserialize(reader); DeltaCompression.Decompress(reader, (idx, val) => values(idx, factor * val), count); }
public IDataContainer Read(BinaryReader reader) { int count = (int)CountCompression.Deserialize(reader); bool isOrdered = reader.ReadBoolean(); IData[] keys = new IData[count]; IData[] records = new IData[count]; Action[] actions = new Action[2]; byte[][] buffers = new byte[2][]; for (int i = 0; i < buffers.Length; i++) { buffers[i] = reader.ReadBytes((int)CountCompression.Deserialize(reader)); } actions[0] = () => { using (MemoryStream ms = new MemoryStream(buffers[0])) keyIndexerPersist.Load(new BinaryReader(ms), (idx, value) => { keys[idx] = value; }, count); }; actions[1] = () => { using (MemoryStream ms = new MemoryStream(buffers[1])) recordIndexerPersist.Load(new BinaryReader(ms), (idx, value) => { records[idx] = value; }, count); }; Parallel.Invoke(actions); var data = Locator.CreateDataContainer(); var set = (IOrderedSet <IData, IData>)data; if (!isOrdered) { for (int i = 0; i < count; i++) { set.Add(keys[i], records[i]); } } else { KeyValuePair <IData, IData>[] orderedArray = new KeyValuePair <IData, IData> [count]; for (int i = 0; i < orderedArray.Length; i++) { orderedArray[i] = new KeyValuePair <IData, IData>(keys[i], records[i]); } set.AddOrdered(orderedArray, 0, orderedArray.Length); } return(data); }
public static WriteCommand ReadRequest(BinaryReader reader) { return(new WriteCommand() { Handle = (long)CountCompression.Deserialize(reader), Index = (int)CountCompression.Deserialize(reader), Count = (int)CountCompression.Deserialize(reader), Buffer = reader.ReadBytes((int)CountCompression.Deserialize(reader)) }); }
private StorageEngineGetEnumeratorCommand ReadStorageEngineGetEnumeratorCommand(BinaryReader reader) { bool isListNull = reader.ReadBoolean(); List <IDescriptor> descriptions = new List <IDescriptor>(); if (!isListNull) { int listCount = (int)CountCompression.Deserialize(reader); for (int i = 0; i < listCount; i++) { descriptions.Add((Descriptor)DeserializeDescriptor(reader)); } } return(new StorageEngineGetEnumeratorCommand(descriptions)); }
private void LoadExample(BinaryReader reader, Action <int, IData> values, int count) { Data <int, string, double>[] array = new Data <int, string, double> [count]; for (int i = 0; i < count; i++) { var data = new Data <int, string, double>(); array[i] = data; values(i, data); } Action[] actions = new Action[DataType.TypesCount]; byte[][] buffers = new byte[DataType.TypesCount][]; for (int i = 0; i < DataType.TypesCount; i++) { buffers[i] = reader.ReadBytes((int)CountCompression.Deserialize(reader)); } //Int32 actions[0] = () => { using (MemoryStream ms = new MemoryStream(buffers[0])) ((IIndexerPersist <Int32>)Persists[0]).Load(new BinaryReader(ms), (idx, value) => { array[idx].Slot0 = value; }, count); }; //String actions[1] = () => { using (MemoryStream ms = new MemoryStream(buffers[1])) ((IIndexerPersist <String>)Persists[0]).Load(new BinaryReader(ms), (idx, value) => { array[idx].Slot1 = value; }, count); }; //Double actions[2] = () => { using (MemoryStream ms = new MemoryStream(buffers[2])) ((IIndexerPersist <Double>)Persists[0]).Load(new BinaryReader(ms), (idx, value) => { array[idx].Slot2 = value; }, count); }; Parallel.Invoke(actions); }
public static Locator Deserialize(BinaryReader reader) { //StructureType int structureType = reader.ReadByte(); if (structureType == Locator.MIN.StructureType) { return(Locator.MIN); } //descriptor var descriptor = StructureDescriptor.Deserialize(reader); //Items string[] items = new string[CountCompression.Deserialize(reader)]; for (int i = 0; i < items.Length; i++) { items[i] = reader.ReadString(); } return(new Locator(structureType, descriptor, items)); }
private IOrderedSet <IData, IData> ReadVertical(BinaryReader reader) { int count = (int)CountCompression.Deserialize(reader); bool isOrdered = reader.ReadBoolean(); KeyValuePair <IData, IData>[] array = new KeyValuePair <IData, IData> [count]; Action[] actions = new Action[2]; byte[][] buffers = new byte[2][]; for (int i = 0; i < buffers.Length; i++) { buffers[i] = reader.ReadBytes((int)CountCompression.Deserialize(reader)); } actions[0] = () => { using (MemoryStream ms = new MemoryStream(buffers[0])) keyIndexerPersist.Load(new BinaryReader(ms), (idx, value) => { helper.SetKey(ref array[idx], value); }, count); }; actions[1] = () => { using (MemoryStream ms = new MemoryStream(buffers[1])) recordIndexerPersist.Load(new BinaryReader(ms), (idx, value) => { helper.SetValue(ref array[idx], value); }, count); }; var task = Task.Factory.StartNew(actions[1]); actions[0](); task.Wait(); var data = orderedSetFactory.Create(); data.LoadFrom(array, count, isOrdered); return(data); }
public override void Load(Stream stream) { BinaryReader reader = new BinaryReader(stream); if (reader.ReadByte() != VERSION) { throw new Exception("Invalid InternalNode version."); } long id = (long)CountCompression.Deserialize(reader); if (id != Branch.NodeHandle) { throw new Exception("Wtree logical error."); } HaveChildrenForMaintenance = reader.ReadBoolean(); Branches.Load(Branch.Tree, reader); RebuildOptimizator(); IsModified = false; }
private IDescriptor DeserializeDescriptor(BinaryReader reader) { long id = (long)CountCompression.Deserialize(reader); string name = reader.ReadString(); int structureType = (int)CountCompression.Deserialize(reader); var keyDataType = DataType.Deserialize(reader); var recordDataType = DataType.Deserialize(reader); var keyType = DataTypeUtils.BuildType(keyDataType); var recordType = DataTypeUtils.BuildType(recordDataType); var createTime = new DateTime((long)CountCompression.Deserialize(reader)); var modifiedTime = new DateTime((long)CountCompression.Deserialize(reader)); var accessTime = new DateTime((long)CountCompression.Deserialize(reader)); var tagLength = (int)CountCompression.Deserialize(reader) - 1; byte[] tag = tagLength >= 0 ? reader.ReadBytes(tagLength) : null; return(new Descriptor(id, name, structureType, keyDataType, recordDataType, keyType, recordType, createTime, modifiedTime, accessTime, tag)); }
public static StructureDescriptor Deserialize(BinaryReader reader) { byte[] raw = reader.ReadBytes((int)CountCompression.Deserialize(reader)); return(new StructureDescriptor(raw)); }
private StorageEngineCountCommand ReadStorageEngineCountCommand(BinaryReader reader) { return(new StorageEngineCountCommand((int)CountCompression.Deserialize(reader))); }