public override long ramBytesUsed() { long sizeInBytes = 0; foreach (KeyValuePair <string, TermsReader> entry in fields.entrySet()) { sizeInBytes += (entry.Key.length() * RamUsageEstimator.NUM_BYTES_CHAR); sizeInBytes += entry.Value.ramBytesUsed(); } return(sizeInBytes); }
private void copyStrikes(SortedMap copy) { // Shallow copy is not good enough. We want a copy that deep // copies the MamdaOptionExpirationStrikes, but not the // contents of those strike sets. DateTime today = DateTime.Today; Set entries = copy.entrySet(); Iterator entryIter = entries.iterator(); while (entryIter.hasNext()) { MapEntry entry = (MapEntry)entryIter.next(); DateTime expireDate = (DateTime)entry.getKey(); // Need to uncomment the following when we have a newer playback file // to properly test with! // if (expireDate > today) { MamdaOptionExpirationStrikes strikes = (MamdaOptionExpirationStrikes)entry.getValue(); put(expireDate, new MamdaOptionExpirationStrikes(strikes)); } } }
public void readFromSortedMap(SortedMap <Integer, String> areaCodeMap) { SortedSet <String> descriptionsSet = new TreeSet <String>(); numOfEntries = areaCodeMap.size(); prefixSizeInBytes = getOptimalNumberOfBytesForValue(areaCodeMap.lastKey()); phoneNumberPrefixes = ByteBuffer.allocate(numOfEntries * prefixSizeInBytes); // Fill the phone number prefixes byte buffer, the set of possible lengths of prefixes and the // description set. int index = 0; foreach (Entry <Integer, String> entry in areaCodeMap.entrySet()) { int prefix = entry.getKey(); storeWordInBuffer(phoneNumberPrefixes, prefixSizeInBytes, index, prefix); possibleLengths.add((int)Math.log10(prefix) + 1); descriptionsSet.add(entry.getValue()); ++index; } createDescriptionPool(descriptionsSet, areaCodeMap); }
public override void readFromSortedMap(SortedMap<Integer, String> areaCodeMap) { SortedSet<String> descriptionsSet = new TreeSet<String>(); numOfEntries = areaCodeMap.size(); prefixSizeInBytes = getOptimalNumberOfBytesForValue(areaCodeMap.lastKey()); phoneNumberPrefixes = ByteBuffer.allocate(numOfEntries * prefixSizeInBytes); // Fill the phone number prefixes byte buffer, the set of possible lengths of prefixes and the // description set. int index = 0; foreach (Entry<Integer, String> entry in areaCodeMap.entrySet()) { int prefix = entry.getKey(); storeWordInBuffer(phoneNumberPrefixes, prefixSizeInBytes, index, prefix); possibleLengths.add((int) Math.log10(prefix) + 1); descriptionsSet.add(entry.getValue()); ++index; } createDescriptionPool(descriptionsSet, areaCodeMap); }