![]() ![]() * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. ![]() * * Neither the name of Redis nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. Salvatore Sanfilippo * All rights reserved. * * zipmap compression table is very similar to ziplist, Does the memory operations efficiency higher * - * * Copyright (c) 2009-2010. * * Given that many times Redis Hashes are used to represent objects composed * of few fields, This is a very big win in terms of used memory. * * The Redis Hash type uses this data structure for hashes composed of a small * number of elements, to switch to a hash table once a given number of * elements is reached. * This file implements a data structure mapping strings to other strings * implementing an O(n) lookup data structure designed to be very memory * efficient. * String -> String Map data structure optimized for size. Several variables zmlen, len, and free are involved. Now I’m going to show you the structure of zipmap, which is really just a super long string. Where ziplist saves a list, ZipMap saves key-value pairs, attached by key:value :value. But in general, the advantages must outweigh the disadvantages, or the designer wouldn’t have done it. The same problem is complicated pointer movement and character position movement. Ziplist compressed list and ZipMap both use dynamic byte allocation to represent lengths, such as saving a lot of space with fixed byte representation. If you’ve looked at the ziplist compressed list analysis I analyzed earlier, I don’t find it particularly difficult to understand this.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |