本文整理汇总了C#中Aerospike.Client.Bin类的典型用法代码示例。如果您正苦于以下问题:C# Bin类的具体用法?C# Bin怎么用?C# Bin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bin类属于Aerospike.Client命名空间,在下文中一共展示了Bin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ListComplex
public void ListComplex()
{
Key key = new Key(args.ns, args.set, "listkey2");
client.Delete(null, key);
string geopoint = "{ \"type\": \"Point\", \"coordinates\": [0.00, 0.00] }";
byte[] blob = new byte[] {3, 52, 125};
List<object> list = new List<object>();
list.Add("string1");
list.Add(2);
list.Add(blob);
list.Add(Value.GetAsGeoJSON(geopoint));
Bin bin = new Bin(args.GetBinName("listbin2"), list);
client.Put(null, key, bin);
Record record = client.Get(null, key, bin.name);
IList receivedList = (IList)record.GetValue(bin.name);
Assert.AreEqual(4, receivedList.Count);
Assert.AreEqual("string1", receivedList[0]);
// Server convert numbers to long, so must expect long.
Assert.AreEqual(2L, receivedList[1]);
CollectionAssert.AreEqual(blob, (byte[])receivedList[2]);
Assert.AreEqual(Value.GetAsGeoJSON(geopoint), (Value)receivedList[3]);
}
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:27,代码来源:TestListMap.cs
示例2: Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
// Establish connection the server
try
{
AerospikeClient client = new AerospikeClient("45.55.231.46", 3000);
// Create key
Aerospike.Client.Key key = new Aerospike.Client.Key("test", "myset", "mykey");
// Create Bins
Bin bin1 = new Bin("name", "John");
Bin bin2 = new Bin("age", 25);
// Write record
client.Put(null, key, bin1, bin2);
// Read record
Record record = client.Get(null, key);
Record userRecord = client.Get(null, key);
Console.WriteLine("Info:");
Console.WriteLine("Name: " + userRecord.GetValue("name"));
Console.WriteLine("Age: " + userRecord.GetValue("age"));
// Close connection
client.Close();
}
catch (AerospikeException.Connection conError)
{
Console.Write(conError);
}
}
开发者ID:bohregard,项目名称:SampleCsAeroSpike,代码行数:33,代码来源:MainWindow.xaml.cs
示例3: RunPutGet
private void RunPutGet(AsyncClient client, Arguments args, Key key, Bin bin)
{
console.Info("Put: namespace={0} set={1} key={2} value={3}",
key.ns, key.setName, key.userKey, bin.value);
client.Put(args.writePolicy, new WriteHandler(this, client, args.writePolicy, key, bin), key, bin);
}
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:7,代码来源:AsyncPutGet.cs
示例4: InsertByKey
public void InsertByKey()
{
int i = 0;
for (int x = 1; x <= TestQueryEngine.RECORD_COUNT; x++)
{
String keyString = "selector-test:" + x;
Bin name = new Bin("name", "name:" + x);
Bin age = new Bin("age", ages[i]);
Bin colour = new Bin("color", colours[i]);
Bin animal = new Bin("animal", animals[i]);
List<Bin> bins = new List<Bin>() { name, age, colour, animal };
Key key = new Key(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, keyString);
this.client.Delete(null, key);
KeyQualifier kq = new KeyQualifier(Value.Get(keyString));
Statement stmt = new Statement();
stmt.Namespace = TestQueryEngine.NAMESPACE;
stmt.SetName = TestQueryEngine.SET_NAME;
queryEngine.Insert(stmt, kq, bins);
Record record = this.client.Get(null, key);
Assert.NotNull(record);
i++;
if (i == 5)
i = 0;
}
}
开发者ID:helipilot50,项目名称:aerospike-helper,代码行数:30,代码来源:InserterTests.cs
示例5: RunExample
/// <summary>
/// Demonstrate multiple operations on a single record in one call.
/// </summary>
public override void RunExample(AerospikeClient client, Arguments args)
{
// Write initial record.
Key key = new Key(args.ns, args.set, "opkey");
Bin bin1 = new Bin("optintbin", 7);
Bin bin2 = new Bin("optstringbin", "string value");
console.Info("Put: namespace={0} set={1} key={2} binname1={3} binvalue1={4} binname1={5} binvalue1={6}",
key.ns, key.setName, key.userKey, bin1.name, bin1.value, bin2.name, bin2.value);
client.Put(args.writePolicy, key, bin1, bin2);
// Add integer, write new string and read record.
Bin bin3 = new Bin(bin1.name, 4);
Bin bin4 = new Bin(bin2.name, "new string");
console.Info("Add: " + bin3.value);
console.Info("Write: " + bin4.value);
console.Info("Read:");
Record record = client.Operate(args.writePolicy, key, Operation.Add(bin3), Operation.Put(bin4), Operation.Get());
if (record == null)
{
throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}",
key.ns, key.setName, key.userKey));
}
ValidateBin(key, record, bin3.name, 11L, record.GetValue(bin3.name));
ValidateBin(key, record, bin4.name, bin4.value.ToString(), record.GetValue(bin4.name));
}
开发者ID:alanprot,项目名称:aerospike-client-csharp,代码行数:30,代码来源:Operate.cs
示例6: Prepare
public static void Prepare(TestContext testContext)
{
Assembly assembly = Assembly.GetExecutingAssembly();
RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.record_example.lua", "record_example.lua", Language.LUA);
rtask.Wait();
Policy policy = new Policy();
policy.timeout = 0; // Do not timeout on index create.
IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.STRING, IndexCollectionType.MAPKEYS);
task.Wait();
for (int i = 1; i <= size; i++)
{
Key key = new Key(args.ns, args.set, keyPrefix + i);
Dictionary<string, string> map = new Dictionary<string, string>();
map[mapKeyPrefix + 1] = mapValuePrefix + i;
if (i % 2 == 0)
{
map[mapKeyPrefix + 2] = mapValuePrefix + i;
}
if (i % 3 == 0)
{
map[mapKeyPrefix + 3] = mapValuePrefix + i;
}
Bin bin = new Bin(binName, map);
client.Put(null, key, bin);
}
}
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:30,代码来源:TestQueryCollection.cs
示例7: PutGet
public void PutGet()
{
Key key = new Key(args.ns, args.set, "putgetkey");
Record record;
if (args.singleBin)
{
Bin bin = new Bin("", "value");
client.Put(null, key, bin);
record = client.Get(null, key);
AssertBinEqual(key, record, bin);
}
else {
Bin bin1 = new Bin("bin1", "value1");
Bin bin2 = new Bin("bin2", "value2");
client.Put(null, key, bin1, bin2);
record = client.Get(null, key);
AssertBinEqual(key, record, bin1);
AssertBinEqual(key, record, bin2);
}
record = client.GetHeader(null, key);
AssertRecordFound(key, record);
// Generation should be greater than zero. Make sure it's populated.
if (record.generation == 0)
{
Assert.Fail("Invalid record header: generation=" + record.generation + " expiration=" + record.expiration);
}
}
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:32,代码来源:TestPutGet.cs
示例8: TestArray
/// <summary>
/// Write array of integers using standard C# serializer.
/// </summary>
public virtual void TestArray(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "serialarraykey");
// Delete record if it already exists.
client.Delete(args.writePolicy, key);
console.Info("Initialize array");
int[] array = new int[10000];
for (int i = 0; i < 10000; i++)
{
array[i] = i * i;
}
Bin bin = new Bin(args.GetBinName("serialbin"), (object)array);
// Do a test that pushes this complex object through the serializer
console.Info("Write array using serializer.");
client.Put(args.writePolicy, key, bin);
console.Info("Read array using serializer.");
Record record = client.Get(args.policy, key, bin.name);
if (record == null)
{
throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}",
key.ns, key.setName, key.userKey));
}
int[] received;
try
{
received = (int[])record.GetValue(bin.name);
}
catch (Exception)
{
throw new Exception(string.Format("Failed to parse returned value: namespace={0} set={1} key={2} bin={3}",
key.ns, key.setName, key.userKey, bin.name));
}
if (received.Length != 10000)
{
throw new Exception(string.Format("Array length mismatch: Expected={0:D} Received={1:D}",
10000, received.Length));
}
for (int i = 0; i < 10000; i++)
{
if (received[i] != i * i)
{
throw new Exception(string.Format("Mismatch: index={0:D} expected={1:D} received={2:D}",
i, i * i, received[i]));
}
}
console.Info("Read array successful.");
}
开发者ID:alanprot,项目名称:aerospike-client-csharp,代码行数:63,代码来源:Serialize.cs
示例9: Replace
public void Replace()
{
Key key = new Key(args.ns, args.set, "replacekey");
Bin bin1 = new Bin("bin1", "value1");
Bin bin2 = new Bin("bin2", "value2");
Bin bin3 = new Bin("bin3", "value3");
client.Put(null, key, bin1, bin2);
WritePolicy policy = new WritePolicy();
policy.recordExistsAction = RecordExistsAction.REPLACE;
client.Put(policy, key, bin3);
Record record = client.Get(null, key);
AssertRecordFound(key, record);
if (record.GetValue(bin1.name) != null)
{
Assert.Fail(bin1.name + " found when it should have been deleted.");
}
if (record.GetValue(bin2.name) != null)
{
Assert.Fail(bin2.name + " found when it should have been deleted.");
}
AssertBinEqual(key, record, bin3);
}
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:27,代码来源:TestReplace.cs
示例10: add
private void add()
{
// C# Add Example
Key userKey = new Key("test", "users", "user1234");
Bin bin1 = new Bin("count", 2);
Bin bin2 = new Bin("count", 3);
client.Add(null, userKey, bin2);
}
开发者ID:rmondragon,项目名称:student-workbook,代码行数:8,代码来源:UtilityService.cs
示例11: AsyncPutGet
public void AsyncPutGet()
{
Key key = new Key(args.ns, args.set, "putgetkey1");
Bin bin = new Bin(binName, "value1");
client.Put(null, new WriteHandler(this, client, key, bin), key, bin);
WaitTillComplete();
}
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:8,代码来源:TestAsyncPutGet.cs
示例12: RunExample
/// <summary>
/// Add integer values.
/// </summary>
public override void RunExample(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "addkey");
string binName = args.GetBinName("addbin");
// Delete record if it already exists.
client.Delete(args.writePolicy, key);
// Perform some adds and check results.
Bin bin = new Bin(binName, 10);
console.Info("Initial add will create record. Initial value is " + bin.value + '.');
client.Add(args.writePolicy, key, bin);
bin = new Bin(binName, 5);
console.Info("Add " + bin.value + " to existing record.");
client.Add(args.writePolicy, key, bin);
Record record = client.Get(args.policy, key, bin.name);
if (record == null)
{
throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}",
key.ns, key.setName, key.userKey));
}
// The value received from the server is an unsigned byte stream.
// Convert to an integer before comparing with expected.
int received = record.GetInt(bin.name);
int expected = 15;
if (received == expected)
{
console.Info("Add successful: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, bin.name, received);
}
else
{
console.Error("Add mismatch: Expected {0}. Received {1}.", expected, received);
}
// Demonstrate add and get combined.
bin = new Bin(binName, 30);
console.Info("Add " + bin.value + " to existing record.");
record = client.Operate(args.writePolicy, key, Operation.Add(bin), Operation.Get(bin.name));
expected = 45;
received = record.GetInt(bin.name);
if (received == expected)
{
console.Info("Add successful: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, bin.name, received);
}
else
{
console.Error("Add mismatch: Expected {0}. Received {1}.", expected, received);
}
}
开发者ID:alanprot,项目名称:aerospike-client-csharp,代码行数:61,代码来源:Add.cs
示例13: AsyncUDF
public void AsyncUDF()
{
Key key = new Key(args.ns, args.set, "audfkey1");
Bin bin = new Bin(binName, binValue);
// Write bin
client.Execute(null, new WriteHandler(this, key), key, "record_example", "writeBin", Value.Get(bin.name), bin.value);
WaitTillComplete();
}
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:9,代码来源:TestAsyncUDF.cs
示例14: AddSingleValue
private static void AddSingleValue(AerospikeClient client,
WritePolicy writePolicy)
{
var newKey = new Key("test", "myAddSet", "myAddKey");
var counter = new Bin("mybin", 1);
client.Add(writePolicy, newKey, counter);
Console.WriteLine("Wrote this additional value (or bin): " + newKey);
Console.WriteLine("");
}
开发者ID:jamesrcounts,项目名称:areospike-client-demo-net,代码行数:9,代码来源:Program.cs
示例15: RunExample
/// <summary>
/// Drop a bin from a record.
/// </summary>
public override void RunExample(AerospikeClient client, Arguments args)
{
if (args.singleBin)
{
console.Info("Delete bin is not applicable to single bin servers.");
return;
}
console.Info("Write multi-bin record.");
Key key = new Key(args.ns, args.set, "delbinkey");
string binName1 = args.GetBinName("bin1");
string binName2 = args.GetBinName("bin2");
Bin bin1 = new Bin(binName1, "value1");
Bin bin2 = new Bin(binName2, "value2");
client.Put(args.writePolicy, key, bin1, bin2);
console.Info("Delete one bin in the record.");
bin1 = Bin.AsNull(binName1); // Set bin value to null to drop bin.
client.Put(args.writePolicy, key, bin1);
console.Info("Read record.");
Record record = client.Get(args.policy, key, bin1.name, bin2.name, "bin3");
if (record == null)
{
throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}",
key.ns, key.setName, key.userKey));
}
foreach (KeyValuePair<string, object> entry in record.bins)
{
console.Info("Received: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, entry.Key, entry.Value);
}
bool valid = true;
if (record.GetValue("bin1") != null)
{
console.Error("bin1 still exists.");
valid = false;
}
object v2 = record.GetValue("bin2");
if (v2 == null || !v2.Equals("value2"))
{
console.Error("bin2 value mismatch.");
valid = false;
}
if (valid)
{
console.Info("Bin delete successful");
}
}
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:59,代码来源:DeleteBin.cs
示例16: WriteRecords
public static void WriteRecords(TestContext testContext)
{
for (int i = 1; i <= size; i++)
{
Key key = new Key(args.ns, args.set, keyPrefix + i);
Bin bin = new Bin(binName, valuePrefix + i);
client.Put(null, key, bin);
}
}
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:10,代码来源:TestBatch.cs
示例17: RunExample
/// <summary>
/// Asynchronously write and read a bin using alternate methods.
/// </summary>
public override void RunExample(AsyncClient client, Arguments args)
{
completed = false;
Key key = new Key(args.ns, args.set, "putgetkey");
Bin bin = new Bin(args.GetBinName("putgetbin"), "value");
RunPutGet(client, args, key, bin);
WaitTillComplete();
RunPutGetWithTask(client, args, key, bin);
}
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:14,代码来源:AsyncPutGet.cs
示例18: AssertBinEqual
public static void AssertBinEqual(Key key, Record record, Bin bin)
{
AssertRecordFound(key, record);
object received = record.GetValue(bin.name);
object expected = bin.value.Object;
if (received == null || !received.Equals(expected))
{
Assert.Fail("Data mismatch: Expected " + expected + ". Received " + received);
}
}
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:12,代码来源:TestSync.cs
示例19: AsyncQuery
public void AsyncQuery()
{
WriteHandler handler = new WriteHandler(this);
for (int i = 1; i <= size; i++)
{
Key key = new Key(args.ns, args.set, keyPrefix + i);
Bin bin = new Bin(binName, i);
client.Put(null, handler, key, bin);
}
WaitTillComplete();
}
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:12,代码来源:TestAsyncQuery.cs
示例20: RunExample
/// <summary>
/// Demonstrate touch command.
/// </summary>
public override void RunExample(AerospikeClient client, Arguments args)
{
Key key = new Key(args.ns, args.set, "touchkey");
Bin bin = new Bin(args.GetBinName("touchbin"), "touchvalue");
console.Info("Create record with 2 second expiration.");
WritePolicy writePolicy = new WritePolicy();
writePolicy.expiration = 2;
client.Put(writePolicy, key, bin);
console.Info("Touch same record with 5 second expiration.");
writePolicy.expiration = 5;
Record record = client.Operate(writePolicy, key, Operation.Touch(), Operation.GetHeader());
if (record == null)
{
throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2} bin={3} value={4}",
key.ns, key.setName, key.userKey, bin.name, null));
}
if (record.expiration == 0)
{
throw new Exception(string.Format("Failed to get record expiration: namespace={0} set={1} key={2}",
key.ns, key.setName, key.userKey));
}
console.Info("Sleep 3 seconds.");
Thread.Sleep(3000);
record = client.Get(args.policy, key, bin.name);
if (record == null)
{
throw new Exception(string.Format("Failed to get: namespace={0} set={1} key={2}",
key.ns, key.setName, key.userKey));
}
console.Info("Success. Record still exists.");
console.Info("Sleep 4 seconds.");
Thread.Sleep(4000);
record = client.Get(args.policy, key, bin.name);
if (record == null)
{
console.Info("Success. Record expired as expected.");
}
else
{
console.Error("Found record when it should have expired.");
}
}
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:55,代码来源:Touch.cs
注:本文中的Aerospike.Client.Bin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论