key-value

What is the difference between a map and a dictionary?

蹲街弑〆低调 提交于 2019-11-28 15:07:22
I know a map is a data structure that maps keys to values. Isn't a dictionary the same? What is the difference between a map and a dictionary 1 ? 1. I am not asking for how they are defined in language X or Y (which seems to be what generally people are asking here on SO), I want to know what is their difference in theory. Two terms for the same thing: "Map" is used by Java, C++ "Dictionary" is used by .Net, Python "Associative array" is used by PHP "Map" is the correct mathematical term, but it is avoided because it has a separate meaning in functional programming . Some languages use still

Custom HashMap Code Issue

爷,独闯天下 提交于 2019-11-28 14:19:50
I have following code, where I used HashMap (using two parallel arrays) for storing key-value pairs (key can have multiple values). Now, I have to store and load it for future use that's why I store and load it by using File Channel. Issue with this code is: I can store nearly 120 millions of key-value pairs in my 8 GB server (actually, I can allocate nearly 5 gb out of 8 gb for my JVM, and those two parallel arrays takes nearly 2.5 gb, other memory are used for various processing of my code). But, I have to store nearly 600/700 millions of key-value pairs. Can anybdoy help me how to modify

Need a MySQL query for selecting from a table storing key value pairs

泪湿孤枕 提交于 2019-11-28 12:35:57
I need to store few items and its properties in form of a key value pairs in the database (mySQL). I am planning to do it as following. I'll use two tables items and item_properties . items itemId | itemName ------------------- 1923 | AC 1235 | Fridge 8273 | Heater item_properties itemId | property | value -------------------------------- 1923 | effect | cooling 1923 | consumption | efficient 1923 | type | split 1235 | effect | cooling 1235 | volume | 20 liters 8273 | effect | heating 8273 | consumption | efficient 8273 | heatMethod | coil Now, if I have to select items whose 'effect' is

Create XML with variable element names from a data table with values and names

夙愿已清 提交于 2019-11-28 11:58:44
问题 I wasn't able to find a relevant post, so I decided to ask. I have the following table in my SQL Server database: ID attname value --------------------------------- 22405543 blktradind N 22405543 brkref IRVTGB2X 22405543 buyamt 104650.2000 22405543 buycurref USD 22405543 Buy53ref 22405543 Buy56ref 22405543 Buy57ref IRVTBEBB How can I convert this table by using FOR XML variations to a dynamic XML result based on the "attname" that each message has? For the excerpt above, the desired result

Need to convert json key-value pairs to standard array

依然范特西╮ 提交于 2019-11-28 10:32:55
I'm interperting a json string into a variable using jquery's parseJSON() function. The problem is, it's turning my data into an object instead of a 2d array. Eg, myData = $.parse(JSON(data)); myData.name// = "Bob" The problem is, "name" is not supposed to be a key (assuming that is the correct term). Instead, it should be: myData[0] // = "name" myData[1] // = "Bob" How would I convert this? Or is there a different method than using a for loop to walk through the index of an array (but still be able to access both key and value as a string, as you would in a 2d array). EDIT: This is some json

How to assign multiple values to a JavaScript object?

一个人想着一个人 提交于 2019-11-28 08:55:03
问题 Say that I have an object with key/value pair as the following: var someVar = { color: "white", font_size: "30px", font_weight: "normal" ...some more variables and functions }; Is there a way to do a multiple assignment to those keys instead of having to do something like this: someVar.color = "blue"; someVar.font_size = "30px"; ... 回答1: You could loop through another object: var thingsToAdd = { color: "blue", font_size: "30px" }; for (var x in thingsToAdd) someVar[x] = thingsToAdd[x]; Or,

What's the difference between std::multimap<key, value> and std::map<key, std::set<value> >

空扰寡人 提交于 2019-11-28 04:48:30
I found that they have one key and multiple values which is unique. The multimap stores pairs of (key, value) where both key and value can appear several times. The map<key, set<value>> will only store each value once for a specific key. To do that, it will have to be able to compare the values, not just the keys. It depends on your application if the values that compare equal are equivalent, or if you wish to store them separately anyway. Perhaps they contain fields that are different but do not take part in the comparison for the set. A std::map is an associative container, that allows you

Is there a business proven cloud store / Key=>Value Database? (Open Source) [closed]

无人久伴 提交于 2019-11-28 03:06:35
I have been looking for cloud computing / storage solutions for a long time (inspired by the Google Bigtable). But I can't find a easy-to-use, business-ready solution. I'm searching a simple, fault tolerant, distributed Key=>Value DB like SimpleDB from Amazon. I've seen things like: The CouchDB Project : Simple and distributed, fault-tolerant Database. But it understands only JSON. No XML connectors etc. Eucalyptus : Nice Amazon EC2 interfaces. Open Standards & XML. But less distributed and less fault-tolerant? There are also a lot of open tickets with XEN/VMWare issues. Cloudstore / Kosmosfs

What is difference between const and non const key?

一笑奈何 提交于 2019-11-27 20:25:55
问题 What is the difference between the following two lines? map<int, float> map_data; map<const int, float> map_data; 回答1: int and const int are two distinct types. std::map<int, float> and std::map<const int, float> are, similarly, different types. The difference between std::map<const int, float> and std::map<int, float> is, to a degree, analogous to the difference between, say, std::map<int, float> and std::map<std::string, float> ; you get a fresh map type for each. In the non- const case,

Storing Directory Hierarchy in a Key-Value Data store

自作多情 提交于 2019-11-27 19:49:21
问题 What is a clean/efficient method for storing the directory Hierarchy/tree in a Key-Value database (in my case MongoDB but any of them)? For example a tree structure - Cars + Audi + BMW - M5 + Ford - Color + Red - Apple - Cherry + Purple - Funny The method I am using now, each object links to it's parent { dir: "red" parent-dir: "color" } This makes it very efficient/fast to insert and reorder any aspect of the tree (for example if I want to move Red and all it's children to the Cars directory