// //ICollection<KeyValuePair<K,V>> // public void CopyTo(KeyValuePair <K, V>[] array, int index) { array = new KeyValuePair <K, V> [_count]; for (int i = 0; i < _count; i++) { array.SetValue(new KeyValuePair <K, V>(_keys[i], _values[i]), i); } }
// //ICollection<KeyValuePair<K,V>> // public void CopyTo(KeyValuePair <K, V>[] array, int index) { array = new KeyValuePair <K, V> [countField]; for (int i = 0; i < countField; i++) { array.SetValue(new KeyValuePair <K, V>(keysField[i], valFieldues[i]), i); } }
public async Task<IList<Torrent>> GetTorrents(Filter filter = Filter.All, string category = null) { await CheckAuthentification(); var keyValuePairs = new KeyValuePair<string, string>[2]; keyValuePairs.SetValue(new KeyValuePair<string, string>("filter", filter.ToString().ToLower()), 0); if (category != null) { keyValuePairs.SetValue(new KeyValuePair<string, string>("category", category), 1); } HttpContent content = new FormUrlEncodedContent(keyValuePairs); var uri = new Uri("/query/torrents?" + await content.ReadAsStringAsync(), UriKind.Relative); var response = await _httpClient.GetAsync(uri); var jsonStr = await response.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject<IList<Torrent>>(jsonStr); }
public async Task <IList <Torrent> > GetTorrents(Filter filter = Filter.All, string category = null) { await CheckAuthentification(); var keyValuePairs = new KeyValuePair <string, string> [2]; keyValuePairs.SetValue(new KeyValuePair <string, string>("filter", filter.ToString().ToLower()), 0); if (category != null) { keyValuePairs.SetValue(new KeyValuePair <string, string>("category", category), 1); } HttpContent content = new FormUrlEncodedContent(keyValuePairs); var uri = new Uri("/query/torrents?" + await content.ReadAsStringAsync(), UriKind.Relative); var response = await _httpClient.GetAsync(uri); var jsonStr = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <IList <Torrent> >(jsonStr)); }
/// <summary> /// Parse an KeyValuePair /// </summary> /// <returns>Parsed KeyValuePair</returns> public KeyValuePair ParseKeyValuePair() { KeyValuePair keyValuePair = new KeyValuePair(); //Get key CurrentToken = TokenStream.NextToken(); keyValuePair.SetKey(CurrentToken.GetValue().ToString()); //Skip : NextToken(":", "key : value", ':'); //Get value keyValuePair.SetValue(ParseExpression()); return(keyValuePair); }
/// <summary>choose local node of localMachine as the target.</summary> /// <remarks> /// choose local node of localMachine as the target. /// if localMachine is not available, choose a node on the same nodegroup or /// rack instead. /// </remarks> /// <returns>the chosen node</returns> /// <exception cref="Org.Apache.Hadoop.Hdfs.Server.Blockmanagement.BlockPlacementPolicy.NotEnoughReplicasException /// "/> protected internal override DatanodeStorageInfo ChooseLocalStorage(Node localMachine , ICollection <Node> excludedNodes, long blocksize, int maxNodesPerRack, IList <DatanodeStorageInfo > results, bool avoidStaleNodes, EnumMap <StorageType, int> storageTypes, bool fallbackToLocalRack ) { // if no local machine, randomly choose one node if (localMachine == null) { return(ChooseRandom(NodeBase.Root, excludedNodes, blocksize, maxNodesPerRack, results , avoidStaleNodes, storageTypes)); } // otherwise try local machine first if (localMachine is DatanodeDescriptor) { DatanodeDescriptor localDataNode = (DatanodeDescriptor)localMachine; if (excludedNodes.AddItem(localMachine)) { // was not in the excluded list for (IEnumerator <KeyValuePair <StorageType, int> > iter = storageTypes.GetEnumerator (); iter.HasNext();) { KeyValuePair <StorageType, int> entry = iter.Next(); foreach (DatanodeStorageInfo localStorage in DFSUtil.Shuffle(localDataNode.GetStorageInfos ())) { StorageType type = entry.Key; if (AddIfIsGoodTarget(localStorage, excludedNodes, blocksize, maxNodesPerRack, false , results, avoidStaleNodes, type) >= 0) { int num = entry.Value; if (num == 1) { iter.Remove(); } else { entry.SetValue(num - 1); } return(localStorage); } } } } } // try a node on local node group DatanodeStorageInfo chosenStorage = ChooseLocalNodeGroup((NetworkTopologyWithNodeGroup )clusterMap, localMachine, excludedNodes, blocksize, maxNodesPerRack, results, avoidStaleNodes , storageTypes); if (chosenStorage != null) { return(chosenStorage); } if (!fallbackToLocalRack) { return(null); } // try a node on local rack return(ChooseLocalRack(localMachine, excludedNodes, blocksize, maxNodesPerRack, results , avoidStaleNodes, storageTypes)); }
/// <summary> /// Parse an KeyValuePair /// </summary> /// <returns>Parsed KeyValuePair</returns> public KeyValuePair ParseKeyValuePair() { KeyValuePair keyValuePair = new KeyValuePair(); //Get key CurrentToken = TokenStream.NextToken(); keyValuePair.SetKey(CurrentToken.GetValue().ToString()); //Skip : NextToken(":", "key : value", ':'); //Get value keyValuePair.SetValue(ParseExpression()); return keyValuePair; }