Questions tagged [lookup]

Look up is related to indexes and hash tables. It is the action of accessing fastly to an item in a large collection thanks to a index (a so-called lookup table).

In computer science, a lookup table is an array that replaces runtime computation with a simpler array indexing operation. The savings in terms of processing time can be significant, since retrieving a value from memory is often faster than undergoing an 'expensive' computation or input/output operation.

The tables may be precalculated and stored in static program storage, calculated (or "pre-fetched") as part of a program's initialization phase (memoization), or even stored in hardware in application-specific platforms. Lookup tables are also used extensively to validate input values by matching against a list of valid (or invalid) items in an array and, in some programming languages, may include pointer functions (or offsets to labels) to process the matching input.

3604 questions
65
votes
4 answers

Mongodb Join on _id field from String to ObjectId

I have two collections User { "_id" : ObjectId("584aac38686860d502929b8b"), "name" : "John" } Role { "_id" : ObjectId("584aaca6686860d502929b8d"), "role" : "Admin", "userId" : "584aac38686860d502929b8b" } I want to join these…
Kavya Mugali
  • 1,008
  • 2
  • 10
  • 17
64
votes
8 answers

Replace values in a dataframe based on lookup table

I am having some trouble replacing values in a dataframe. I would like to replace values based on a separate table. Below is an example of what I am trying to do. I have a table where every row is a customer and every column is an animal they…
jbunk
  • 643
  • 1
  • 6
  • 4
63
votes
9 answers

Lookup Tables Best Practices: DB Tables... or Enumerations

If we have to store the available positions at a company (i.e. Manager, Team Lead, ... etc). What are the best practices for storing it? I have two opinions with comments... "sure, welcoming yours" Storing it as DB table with columns ID and Name,…
Bishoy Moussa
63
votes
5 answers

How can I see if a Perl hash already has a certain key?

I have a Perl script that is counting the number of occurrences of various strings in a text file. I want to be able to check if a certain string is not yet a key in the hash. Is there a better way of doing this altogether? Here is what I am…
user105574
61
votes
15 answers

How to get the Country according to a certain IP?

Does anyone know any simple way to retrieve the country from a given IP Address, preferably in ISO_3166-1 format?
DylanJ
  • 2,373
  • 3
  • 25
  • 24
56
votes
2 answers

Getting keys from a Lookup

How do I get the collection of keys from a Lookup<> I created through the .ToLookup() method? I have a lookup which maps int-values to groups of instances of a custom class. I need a collection of all the int keys that the lookup contains. Any way…
magnattic
  • 12,638
  • 13
  • 62
  • 115
52
votes
5 answers

What is a practical way to model lookup tables in Domain Driven Design (DDD)?

I'm just learning DDD (Eric Evans book is open in front of me) and I've come across a problem that I can't find an answer for. What do you do in DDD when you're just trying to get a simple list of lookup records? Ex. EmployeeID: 123 EmployeeName:…
John
  • 3,332
  • 5
  • 33
  • 55
41
votes
2 answers

Should I use a C# Dictionary if I only need fast lookup of keys, and values are irrelevant?

I am in need of a data type that is able to insert entries and then be able to quickly determine if an entry has already been inserted. A Dictionary seems to suit this need (see example). However, I have no use for the dictionary's values. Should I…
reformed
  • 4,505
  • 11
  • 62
  • 88
37
votes
2 answers

What is the fastest way to do Array Table Lookup with an Integer Index?

I have a video processing application that moves a lot of data. To speed things up, I have made a lookup table, as many calculations in essence only need to be calculated one time and can be reused. However I'm at the point where all the lookups…
RobotRock
  • 4,211
  • 6
  • 46
  • 86
37
votes
4 answers

Tensorflow Dictionary lookup with String tensor

Is there any way to perform a dictionary lookup based on a String tensor in Tensorflow? In plain Python, I'd do something like value = dictionary[key] . Now I'd like to do the same thing at Tensorflow runtime, when I have my key as a String tensor.…
mackcmillion
  • 830
  • 2
  • 10
  • 16
35
votes
6 answers

Java hashmaps without the value?

Let's say I want to put words in a data structure and I want to have constant time lookups to see if the word is in this data structure. All I want to do is to see if the word exists. Would I use a HashMap (containsKey()) for this? HashMaps use…
jbu
  • 15,831
  • 29
  • 82
  • 105
34
votes
2 answers

Is the Set.has() method O(1) and Array.indexOf O(n)?

I have seen in an answer that the Set.has() method is O(1) and Array.indexOf() is O(n). var a = [1, 2, 3, 4, 5]; a.indexOf(5); s = new Set(a); s.has(5); //Is this O(1)? Is Set.has() really O(1) ?
Charlie
  • 22,886
  • 11
  • 59
  • 90
34
votes
9 answers

A dictionary object that uses ranges of values for keys

I have need of a sort of specialized dictionary. My use case is this: The user wants to specify ranges of values (the range could be a single point as well) and assign a value to a particular range. We then want to perform a lookup using a single…
Jeffrey Cameron
  • 9,975
  • 10
  • 45
  • 77
33
votes
2 answers

$project in $lookup mongodb

I have a query, that use $lookup to "join" two models, after this i use $project to select olny the fields that i need, but my $project brings an arrray of objects (user_detail) that contains more data that i need. I want only two fields…
Matheus Barem
  • 1,497
  • 2
  • 20
  • 37
30
votes
1 answer

If Mongo $lookup is a left outer join, then how come it excludes non-matching documents?

The title says it all. How come if a document does not result in any matching outer document according to its matching field, then how come it's not included in the pipeline's result set? I'm testing out the new aggregators in Mongo 3.2 and I've…
Sun Lee
  • 879
  • 2
  • 8
  • 17