public static List <BatchNode> GenerateList(Cluster cluster, BatchPolicy policy, Key[] keys) { Node[] nodes = cluster.Nodes; if (nodes.Length == 0) { throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Command failed because cluster is empty."); } int nodeCount = nodes.Length; int keysPerNode = keys.Length / nodeCount + 10; // Split keys by server node. List <BatchNode> batchNodes = new List <BatchNode>(nodeCount + 1); for (int i = 0; i < keys.Length; i++) { Key key = keys[i]; Partition partition = new Partition(key); BatchNode batchNode; Node node = cluster.GetReadNode(partition, policy.replica); batchNode = FindBatchNode(batchNodes, node); if (batchNode == null) { batchNodes.Add(new BatchNode(node, keysPerNode, key.ns, i)); } else { batchNode.AddKey(key.ns, i); } } return(batchNodes); }
public static List <BatchNode> GenerateList(Cluster cluster, BatchPolicy policy, List <BatchRead> records) { Node[] nodes = cluster.Nodes; if (nodes.Length == 0) { throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Command failed because cluster is empty."); } // Create initial key capacity for each node as average + 25%. int max = records.Count; int keysPerNode = max / nodes.Length; keysPerNode += (int)((uint)keysPerNode >> 2); // The minimum key capacity is 10. if (keysPerNode < 10) { keysPerNode = 10; } // Split keys by server node. List <BatchNode> batchNodes = new List <BatchNode>(nodes.Length); for (int i = 0; i < max; i++) { Partition partition = new Partition(records[i].key); Node node = cluster.GetReadNode(partition, policy.replica); BatchNode batchNode = FindBatchNode(batchNodes, node); if (batchNode == null) { batchNodes.Add(new BatchNode(node, keysPerNode, i)); } else { batchNode.AddKey(i); } } return(batchNodes); }
protected internal override Node GetNode() { return(cluster.GetReadNode(partition, policy.replica)); }
public static List<BatchNode> GenerateList(Cluster cluster, BatchPolicy policy, Key[] keys) { Node[] nodes = cluster.Nodes; if (nodes.Length == 0) { throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Command failed because cluster is empty."); } // Create initial key capacity for each node as average + 25%. int keysPerNode = keys.Length / nodes.Length; keysPerNode += (int)((uint)keysPerNode >> 2); // The minimum key capacity is 10. if (keysPerNode < 10) { keysPerNode = 10; } // Split keys by server node. List<BatchNode> batchNodes = new List<BatchNode>(nodes.Length); for (int i = 0; i < keys.Length; i++) { Partition partition = new Partition(keys[i]); Node node = cluster.GetReadNode(partition, policy.replica); BatchNode batchNode = FindBatchNode(batchNodes, node); if (batchNode == null) { batchNodes.Add(new BatchNode(node, keysPerNode, i)); } else { batchNode.AddKey(i); } } return batchNodes; }