public void SingleUpsert() { UpsertWorker(); var session = fht.NewSession(); int iv = 10; Console.WriteLine(sizeof(int) + ":" + sizeof(long) + ":" + sizeof(short) + ":" + sizeof(byte)); Assert.AreEqual(iv, 10); Assert.AreEqual(sizeof(int), 4); Assert.AreEqual(sizeof(long), 8); Assert.AreEqual(sizeof(short), 2); Assert.AreEqual(sizeof(byte), 1); Key key = new Key { key = -1231 }; LargeValue value = new LargeValue(8); session.Upsert(ref key, ref value, Empty.Default, 1); LargeValue value1 = new LargeValue(13212, 64); session.Upsert(ref key, ref value1, Empty.Default, 1); Input input = default(Input); LargeOutput output = new LargeOutput(); session.Read(ref key, ref input, ref output, Empty.Default, 1); for (int i = 0; i < 64; i += sizeof(long)) { long v = BitConverter.ToInt64(output.value.value, i); Assert.AreEqual(v, 13212); } DeleteWorker(ref session); session.Dispose(); }
public LargeValue(long content, int size) { value = new byte[size]; for (int i = 0; i < size; i += sizeof(long)) { Array.Copy(LargeValue.longToByte(content), 0, value, i, sizeof(long)); } }
void InitWorker() { var session = fht.NewSession(); Key key = new Key { key = 0 }; LargeValue value = new LargeValue((long)0, 64); session.Upsert(ref key, ref value, Empty.Default, 1); session.Dispose(); }
void UpsertWorker() { while (!begin) { Thread.Yield(); } var session = fht.NewSession(); Key key = new Key { key = 0 }; for (int i = 0; i < UpdateCount; i++) { //Console.WriteLine(i + ":" + key); LargeValue value = new LargeValue((long)i, 64); session.Upsert(ref key, ref value, Empty.Default, 1); Interlocked.Increment(ref tick); } session.Dispose(); }