本文整理汇总了C#中Aerospike.Client.AerospikeClient.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# AerospikeClient.Execute方法的具体用法?C# AerospikeClient.Execute怎么用?C# AerospikeClient.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aerospike.Client.AerospikeClient
的用法示例。
在下文中一共展示了AerospikeClient.Execute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PurgeDay
public static void PurgeDay(string date, AerospikeClient client)
{
Console.WriteLine ("Purgin data for {0}", date);
Stopwatch stopwatch = new Stopwatch ();
stopwatch.Start ();
Statement statement = new Statement ();
statement.Namespace = ns;
statement.SetName = seqSet;
//statement.SetFilters (Filter.Equal (dayBinName, date));
ExecuteTask task = client.Execute (null, statement, "utility", "purge",
Value.Get(dayBinName),
Value.Get(date));
while (!task.IsDone())
Thread.Sleep (100);
stopwatch.Stop ();
Console.WriteLine ("Purge completed {0} ms", stopwatch.ElapsedMilliseconds);
}
示例2: RunQueryExecute
private void RunQueryExecute(AerospikeClient client, Arguments args, string indexName, string binName1, string binName2)
{
int begin = 3;
int end = 9;
console.Info("For ns={0} set={1} index={2} bin={3} >= {4} <= {5}", args.ns, args.set, indexName, binName1, begin, end);
console.Info("Even integers: add 100 to existing " + binName1);
console.Info("Multiple of 5: delete " + binName2 + " bin");
console.Info("Multiple of 9: delete record");
Statement stmt = new Statement();
stmt.SetNamespace(args.ns);
stmt.SetSetName(args.set);
stmt.SetFilters(Filter.Range(binName1, begin, end));
ExecuteTask task = client.Execute(args.writePolicy, stmt, "record_example", "processRecord", Value.Get(binName1), Value.Get(binName2), Value.Get(100));
task.Wait();
}
示例3: WriteWithValidation
private void WriteWithValidation(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "udfkey4");
string binName = "udfbin4";
// Lua function writeWithValidation accepts number between 1 and 10.
// Write record with valid value.
console.Info("Write with valid value.");
client.Execute(args.writePolicy, key, "record_example", "writeWithValidation", Value.Get(binName), Value.Get(4));
// Write record with invalid value.
console.Info("Write with invalid value.");
try
{
client.Execute(args.writePolicy, key, "record_example", "writeWithValidation", Value.Get(binName), Value.Get(11));
console.Error("UDF should not have succeeded!");
}
catch (Exception)
{
console.Info("Success. UDF resulted in exception as expected.");
}
}
示例4: ServerSideExists
private void ServerSideExists(AerospikeClient client, WritePolicy policy, Key key, Bin bin, int search, bool expected)
{
long lexists = (long)client.Execute(policy, key, "record_example", "valueExists", Value.Get(bin.name), Value.Get(search));
bool exists = (lexists != 0);
if (expected && exists)
{
console.Info("Value found as expected.");
return;
}
if (!expected && !exists)
{
console.Info("Value not found as expected.");
return;
}
console.Error("Data mismatch. Expected " + expected + " Received " + exists);
}
示例5: WriteUsingUdf
private void WriteUsingUdf(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "udfkey1");
Bin bin = new Bin(args.GetBinName("udfbin1"), "string value");
client.Execute(args.writePolicy, key, "record_example", "writeBin", Value.Get(bin.name), bin.value);
Record record = client.Get(args.policy, key, bin.name);
string expected = bin.value.ToString();
string received = (string)record.GetValue(bin.name);
if (received != null && received.Equals(expected))
{
console.Info("Data matched: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, bin.name, received);
}
else
{
console.Error("Data mismatch: Expected {0}. Received {1}.", expected, received);
}
}
示例6: WriteListMapUsingUdf
private void WriteListMapUsingUdf(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "udfkey5");
List<object> inner = new List<object>();
inner.Add("string2");
inner.Add(8L);
Dictionary<object, object> innerMap = new Dictionary<object, object>();
innerMap["a"] = 1L;
innerMap[2L] = "b";
innerMap["list"] = inner;
List<object> list = new List<object>();
list.Add("string1");
list.Add(4L);
list.Add(inner);
list.Add(innerMap);
string binName = args.GetBinName("udfbin5");
client.Execute(args.writePolicy, key, "record_example", "writeBin", Value.Get(binName), Value.Get(list));
object received = client.Execute(args.writePolicy, key, "record_example", "readBin", Value.Get(binName));
string receivedString = Util.ListToString((List<object>)received);
string expectedString = Util.ListToString(list);
if (receivedString.Equals(expectedString))
{
console.Info("UDF data matched: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, binName, received);
}
else
{
console.Error("UDF data mismatch");
console.Error("Expected " + list);
console.Error("Received " + received);
}
}
示例7: WriteIfNotExists
private void WriteIfNotExists(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "udfkey3");
string binName = "udfbin3";
// Delete record if it already exists.
client.Delete(args.writePolicy, key);
// Write record only if not already exists. This should succeed.
client.Execute(args.writePolicy, key, "record_example", "writeUnique", Value.Get(binName), Value.Get("first"));
// Verify record written.
Record record = client.Get(args.policy, key, binName);
string expected = "first";
string received = (string)record.GetValue(binName);
if (received != null && received.Equals(expected))
{
console.Info("Record written: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, binName, received);
}
else
{
console.Error("Data mismatch: Expected {0}. Received {1}.", expected, received);
}
// Write record second time. This should fail.
console.Info("Attempt second write.");
client.Execute(args.writePolicy, key, "record_example", "writeUnique", Value.Get(binName), Value.Get("second"));
// Verify record not written.
record = client.Get(args.policy, key, binName);
received = (string)record.GetValue(binName);
if (received != null && received.Equals(expected))
{
console.Info("Success. Record remained unchanged: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, binName, received);
}
else
{
console.Error("Data mismatch: Expected {0}. Received {1}.", expected, received);
}
}
示例8: WriteIfGenerationNotChanged
private void WriteIfGenerationNotChanged(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "udfkey2");
Bin bin = new Bin(args.GetBinName("udfbin2"), "string value");
// Seed record.
client.Put(args.writePolicy, key, bin);
// Get record generation.
long gen = (long)client.Execute(args.writePolicy, key, "record_example", "getGeneration");
// Write record if generation has not changed.
client.Execute(args.writePolicy, key, "record_example", "writeIfGenerationNotChanged", Value.Get(bin.name), bin.value, Value.Get(gen));
console.Info("Record written.");
}
示例9: WriteBlobUsingUdf
private void WriteBlobUsingUdf(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "udfkey6");
string binName = args.GetBinName("udfbin6");
byte[] blob;
// Create packed blob using standard C# tools.
using (MemoryStream ms = new MemoryStream())
{
Formatter.Default.Serialize(ms, 9845);
Formatter.Default.Serialize(ms, "Hello world.");
blob = ms.ToArray();
}
client.Execute(args.writePolicy, key, "record_example", "writeBin", Value.Get(binName), Value.Get(blob));
byte[] received = (byte[])client.Execute(args.writePolicy, key, "record_example", "readBin", Value.Get(binName));
string receivedString = Util.BytesToString(received);
string expectedString = Util.BytesToString(blob);
if (receivedString.Equals(expectedString))
{
console.Info("Blob data matched: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, binName, receivedString);
}
else
{
throw new Exception(string.Format("Mismatch: expected={0} received={1}", expectedString, receivedString));
}
}