indexing

How to schedule jobs without overlap using LINQ to Objects?

霸气de小男生 提交于 2019-12-18 12:45:12
问题 This is another resource-allocation problem. My goal is to run a query to assign the top-priority job for any time-slot to one of two CPU cores (just an example, so let's assume no interrupts or multi-tasking). Note: this is similar to my earlier post about partitioning, but focuses on overlapping times and assigning multiple items, not just the top-priority item. Here is our object: public class Job { public int Id; public int Priority; public DateTime Begin; public DateTime End; } The real

How do I create an index in PostgreSQL based on lowercase only?

杀马特。学长 韩版系。学妹 提交于 2019-12-18 12:45:00
问题 How would I set up an index based on lower case only? Even though the actual field contains both upper and lower case letters. Also, can I run a query and have only the lower case index value returned? 回答1: You can create the index and transform the field to upper- or lower-case. Then when you do your queries, you can do the same transform and it'll do the right thing. So: CREATE UNIQUE INDEX lower_case_username ON users ((lower(username))); Then query for the same thing: SELECT username FROM

How to find nearest value that is greater in numpy array?

送分小仙女□ 提交于 2019-12-18 12:35:19
问题 I would like to obtain the index of the nearest value in a numpy array which is greater than my search value. Example: findNearestAbove(np.array([0.,1.,1.4,2.]), 1.5) should return 3 (the index of 2.). I know that I can get the nearest index with np.abs(a-value).argmin() , and I found out that min(a[np.where(a-value >= 0.)[0]]) returns the desired array value. Hence, np.where(a == min(a[np.where(a-value >= 0.)[0]]))[0] would probably give me the desired index. However, this looks rather

SolrException: Internal Server Error

余生长醉 提交于 2019-12-18 12:26:47
问题 I am working on Solr in my application. I am using apache-solr-solrj-1.4.0.jar . When I try to call add(SolrInputDocument doc) from CommonsHttpSolrServer , I am getting the following exception: org.apache.solr.common.SolrException: Internal Server Error Internal Server Error at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:424) at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:243) at org.apache.solr

See existing indexes in MongoDB using mongoid

我只是一个虾纸丫 提交于 2019-12-18 12:24:05
问题 I'd like to see the existing indexes used by MongoDB. Can I do the equivalent of $ mongod > use my_db > db.system.indexes.find() using Mongoid? $ rails console > ? Would be convenient from my heroku apps using MongoHQ. Thanks! 回答1: You can get at the underlying indexes for a Mongoid model through its collection . > YourModel.collection.indexes This reaches down into the moped driver (in Mongoid 3). See http://mongoid.org/en/moped/docs/driver.html 来源: https://stackoverflow.com/questions

Smarty: How to reference to the associative array index

拟墨画扇 提交于 2019-12-18 11:50:02
问题 Array $imagelist: Array ( [additional] => Array ( [count] => 2 [image] => Array ( [nokia_e61_1.jpg] => Array ( [name_body] => nokia_e61_1 [name_ext] => jpg ) [nokia_e61_2.jpg] => Array ( [name_body] => nokia_e61_2 [name_ext] => jpg ) [nokia_e61_3.jpg] => Array ( [name_body] => nokia_e61_3 [name_ext] => jpg ) [nokia_e61_4.jpg] => Array ( [name_body] => nokia_e61_4 [name_ext] => jpg ) ) ) [main] => nokia_e61 ) The value nokia_e61_1.jpg is kept in {$getvars.imagename} . I wrote {$imagelist

Disable all non-clustered indexes

谁说我不能喝 提交于 2019-12-18 11:47:28
问题 I select a number of non-clustered indexes from my database with the following: SELECT sys.objects.name tableName, sys.indexes.name indexName FROM sys.indexes JOIN sys.objects ON sys.indexes.object_id = sys.objects.object_id WHERE sys.indexes.type_desc = 'NONCLUSTERED' AND sys.objects.type_desc = 'USER_TABLE' I'd like to run the following over each of the results: ALTER INDEX indexName ON tableName DISABLE How would I go about doing this? Is there a better way? EDIT I'm doing this for the

Accessing non-consecutive elements of a list or string in python

亡梦爱人 提交于 2019-12-18 11:45:29
问题 As far as I can tell, this is not officially not possible, but is there a "trick" to access arbitrary non-sequential elements of a list by slicing? For example: >>> L = range(0,101,10) >>> L [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] Now I want to be able to do a,b = L[2,5] so that a == 20 and b == 50 One way besides two statements would be something silly like: a,b = L[2:6:3][:2] But that doesn't scale at all to irregular intervals. Maybe with list comprehension using the indices I want?

Filtering multiple items in a multi-index Python Panda dataframe

杀马特。学长 韩版系。学妹 提交于 2019-12-18 11:42:01
问题 I have the following table: Note: Both NSRCODE and PBL_AWI are index's Note: the % Of area column would be filled out just have not done so yet. NSRCODE PBL_AWI Area % Of Area CM BONS 44705.492941 BTNN 253854.591990 FONG 41625.590370 FONS 16814.159680 Lake 57124.819333 River 1603.906642 SONS 583958.444751 STNN 45603.837177 clearcut 106139.013930 disturbed 127719.865675 lowland 118795.578059 upland 2701289.270193 LBH BFNN 289207.169650 BONS 9140084.716743 BTNI 33713.160390 BTNN 19748004.789040

PostgreSQL GIN index on array of uuid

走远了吗. 提交于 2019-12-18 11:26:26
问题 I would like to use a GIN index on uuid[] (to have efficient membership tests for arrays of uuids). However when I try it PostgreSQL gives me an error: mydb=> CREATE TABLE foo (val uuid[]); CREATE TABLE mydb=> CREATE INDEX foo_idx ON foo USING GIN(val); ERROR: data type uuid[] has no default operator class for access method "gin" HINT: You must specify an operator class for the index or define a default operator class for the data type. How can I add the necessary operator class so that it