internal void fillcurfromnextbuf() { if (nextbufpos + 12 > nextbufend) { throw new Exception("Unaligned values (enumeration buffer)"); } currun = 1; cur.A = DistObjectBase.BytesToLong(nextbuf, nextbufpos); cur.B = DistObjectBase.BytesToInt(nextbuf, nextbufpos + 8); nextbufpos += 12; }
internal void fillcurfromnextbuf() { if (nextbufpos + 8 + 2 > nextbufend) { throw new Exception("Unaligned values (enumeration buffer)"); } currun = MySpace.DataMining.DistributedObjects.Entry.BytesToInt16(nextbuf, nextbufpos); cur.A = DistObjectBase.BytesToInt(nextbuf, nextbufpos + 2); cur.B = DistObjectBase.BytesToInt(nextbuf, nextbufpos + 2 + 4); nextbufpos += 8 + 2; }
// Returns -1 if no such key. public int Length(byte[] key) { if (!didopen) { throw new Exception("Must Open before writing to Hashtable"); } int slaveID = DetermineSlave(key); if (slaveID < 0 || slaveID >= dslaves.Count) { throw new Exception("Sub process missing: subProcessID needed: " + slaveID.ToString()); } SlaveInfo slave = dslaves[slaveID]; lock (slave) { // 'l' for get length slave.nstm.WriteByte((byte)'l'); XContent.SendXContent(slave.nstm, key); // Replies with tag '+' and xcontent length; or tag '-' if not exists. byte[] result = null; int len; int x = slave.nstm.ReadByte(); if ('+' == x) { result = XContent.ReceiveXBytes(slave.nstm, out len, buf); return(DistObjectBase.BytesToInt(result)); // Only reads first one. } else if ('-' == x) { //result = null; return(-1); } else { throw new Exception("Server returned invalid response for l (Length)"); } } }
public void SetFromArray(byte[] buf) { A = DistObjectBase.BytesToLong(buf, 0); B = DistObjectBase.BytesToInt(buf, 8); }
public void SetFromArray(byte[] buf, int offset) { A = DistObjectBase.BytesToLong(buf, offset + 0); B = DistObjectBase.BytesToInt(buf, offset + 8); }
protected override void ProcessCommand(NetworkStream nstm, char tag) { //string s; int len; switch (tag) { case 'e': // Batch 'get next' enumeration. { try { int ienumid = nstm.ReadByte(); if (ienumid >= 0) { byte enumid = (byte)ienumid; if (enumid >= this.enums.Length) { nstm.WriteByte((byte)'-'); } else { if (null == this.enums[enumid]) { this.enums[enumid] = new IntComboListPartEnumerator(this); } int offset = 0; if (null == buf || buf.Length < 40) { throw new Exception("Enumeration batch buffer too small!"); } //if (uniquecompression) // Compressed... { for (; ;) { if (!this.enums[enumid].MoveNext()) { break; } B8 b8 = this.enums[enumid].Current; int nrow = 1; while (this.enums[enumid].MoveNext()) { B8 b8next = this.enums[enumid].Current; if (b8.A != b8next.A || b8.B != b8next.B) //if (b8 != b8next) { this.enums[enumid].MoveBack(); // ! break; } nrow++; } if (nrow < mindupes) { continue; } if (nrow > Int16.MaxValue) { nrow = Int16.MaxValue; } // Using Big Endian! MySpace.DataMining.DistributedObjects.Entry.Int16ToBytes((Int16)nrow, buf, offset); b8.CopyToArray(buf, offset + 2); offset += 8 + 2; if (offset + 8 + 2 > buf.Length) { break; } } } if (offset > 0) { nstm.WriteByte((byte)'+'); XContent.SendXContent(nstm, buf, offset); } else { nstm.WriteByte((byte)'-'); } } } } catch { nstm.WriteByte((byte)'-'); throw; } } break; case 'n': // Reset next in enumeration.. { int ienumid = nstm.ReadByte(); if (ienumid >= 0) { byte enumid = (byte)ienumid; if (XLog.logging) { XLog.log("Starting enumeration (enumid:" + enumid.ToString() + ")"); } if (enumid < this.enums.Length && null != this.enums[enumid]) { //this.enums[enumid].Reset(); this.enums[enumid] = null; } } } break; case 's': { try { #if ENABLE_TIMING long start = 0; if (XLog.logging) { QueryPerformanceCounter(out start); } #endif int readbuflen = 1048576; if (null != DistributedObjectsSlave.xslave) { System.Xml.XmlNode xzblocks = DistributedObjectsSlave.xslave["zblocks"]; if (null != xzblocks) { { System.Xml.XmlAttribute xzbs = xzblocks.Attributes["readbuffersize"]; if (null != xzbs) { readbuflen = DistributedObjectsSlave.ParseCapacity(xzbs.Value); } } } } foreach (ZBlock zb in zblocks) { zb.LeaveAddMode(readbuflen); } foreach (ZBlock zb in zblocks) { zb.Sort(b8buffer, this.buf); } #if ENABLE_TIMING if (XLog.logging) { long stop; QueryPerformanceCounter(out stop); long freq; if (QueryPerformanceFrequency(out freq)) { long secs = (stop - start) / freq; if (secs > 10) { XLog.log("IntComboListPart sort seconds: " + secs.ToString()); } } } #endif } finally { nstm.WriteByte((byte)'+'); } } break; case 'p': // Batch push/publish... { buf = XContent.ReceiveXBytes(nstm, out len, buf); uint gbfree = (uint)(GetCurrentDiskFreeBytes() / 1073741824); #if DEBUG { string computer_name = System.Environment.GetEnvironmentVariable("COMPUTERNAME"); if (computer_name == "MAPDDRULE" || computer_name == "MAPDCMILLER" || computer_name == "MAPDCLOK") { gbfree = uint.MaxValue; } } #endif if (gbfree > 20) { int pcount = len / 8; // size of B8 int y = 0; for (int i = 0; i != pcount; i++) { TimedAdd(buf, y); y += 8; } } else { if (!nofreedisklog) { nofreedisklog = true; XLog.errorlog("Low free disk space; now dropping entries."); } } } break; case 'M': { buf = XContent.ReceiveXBytes(nstm, out len, buf); if (4 == len) { this.mindupes = DistObjectBase.BytesToInt(buf); } } break; default: base.ProcessCommand(nstm, tag); break; } }