Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
net_instaweb::SharedDynamicStringMap Class Reference

#include "shared_dynamic_string_map.h"

Public Member Functions

 SharedDynamicStringMap (size_t number_of_strings, size_t average_string_length, AbstractSharedMem *shm_runtime, const GoogleString &filename_prefix, const GoogleString &filename_suffix)
 
bool InitSegment (bool parent, MessageHandler *message_handler)
 
int IncrementElement (const StringPiece &string)
 
int LookupElement (const StringPiece &string) const
 
void GetKeys (StringSet *strings)
 Dumps table's strings into StringSet.
 
int GetNumberInserted () const
 Retrieve the number of strings inserted into the table.
 
void GlobalCleanup (MessageHandler *message_handler)
 Destroy shared memory segment and other relevant clean-up.
 
void Dump (Writer *writer, MessageHandler *message_handler)
 

Detailed Description

A shared memory string to int dictionary/map, no deletion. Currently the map is designed to fill with number_of_strings strings of average length average_string_length. Once the map is full it ignores attempts to add additional information.

Todo:
TODO(jhoch): make map dynamically sized

Constructor & Destructor Documentation

net_instaweb::SharedDynamicStringMap::SharedDynamicStringMap ( size_t  number_of_strings,
size_t  average_string_length,
AbstractSharedMem shm_runtime,
const GoogleString filename_prefix,
const GoogleString filename_suffix 
)

Number of strings will be rounded up to a power of 2. Average string length should include terminating null character. Map will be able to hold exactly number_of_strings * average_string_length chars worth of string data.

Member Function Documentation

void net_instaweb::SharedDynamicStringMap::Dump ( Writer writer,
MessageHandler message_handler 
)

Iterates through the string data that is present at the time of calling and dumps out each string with its associated value. The value produced for a given string is going to be the value present whenever that string is dumped.

int net_instaweb::SharedDynamicStringMap::IncrementElement ( const StringPiece &  string)

Increments value corresponding to given string by 1. Adds the string to the map with initial value 1 if the string is not present. Returns the new value corresponding to the element. If the map is full it does nothing and returns 0.

bool net_instaweb::SharedDynamicStringMap::InitSegment ( bool  parent,
MessageHandler message_handler 
)

Initialize the shared memory segment. This method should complete before any other methods are executed. parent = true means invoked in root process, initialize the shared memory = false means invoked in child process – attach to existing segment

int net_instaweb::SharedDynamicStringMap::LookupElement ( const StringPiece &  string) const

Retrieve the value corresponding to the string (returns 0 if the string is not in the map)


The documentation for this class was generated from the following file: