w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
RavenDB polymorphic Index
What are you trying to do? If the end result is to query all Principals, then load the entire User or AppInstance, why not just go straight for querying all Users or all AppInstances? Raven won't store base classes; it will only store the most derived type (User or AppInstance, in your case). So you'll have a collection of Users and a collection of AppInstances. If you really need to query both at once, you can use Multi Map indexes. You can also change the entity name and store both in a single Principal collection. But it's difficult to recommend a solution without knowing what you're trying to do. Explain what you're trying to do and we'll tell you the proper way to get there.

Categories : C#

alphanumeric sorting in Go
According to the reference, you can simply sort on the property you require: From the doc: // Order alphabetically by last name: q := datastore.NewQuery("Person").Order("LastName") So in your example, you could have something along the lines of: func queryAll(r *http.Request) ([]string, error) { c := appengine.NewContext(r) res := make([]string, 0, 0) t := datastore.NewQuery("YourStructure").Order("Sequence").Run(c) for { var s YourStructure if _, err := t.Next(&s); err == datastore.Done { // Done iterating return res, nil } else if err != nil { // An error happened return nil, err } res = append(res, s.Name) } panic("unreachable") }

Categories : Google App Engine

sorting an alphanumeric column in sql
DECLARE @t table(id varchar(50)) INSERT @t values ('10') INSERT @t values('100') INSERT @t values('700-6 0110B512') INSERT @t values('700-6 0110B513') INSERT @t values('700-8 0110B512') INSERT @t values('700-9 0110B512') SELECT * FROM @t ORDER BY cast(left(id, 3) as int), stuff(id, 1, 6, ''), substring(id, 5,1)

Categories : SQL

sorting alphanumeric multiple columns
I hope this is what you need. echo -e "ccc1 4 cccY 1 cccY 5 cccX 2 cccX 10 ccc10 4 ccc1 10 ccc2 5" | sort -t $' ' -k 1.4,1 --version-sort -k 2n I believe the main problem in your command is with numeric sort in first key, because there are numbers mixed with chars.

Categories : Shell

Alphanumeric sorting/ordering from database
If the string always starts with a single alpha/numeric prefix then you can use SELECT no from my_table order by substring(no,1,1), substring(no,2)+0 fiddle here In PHP you can sort once it's in a multidimensional array by using usort returning the results of a strnatcasecmp call on the fields. usort($records, function($a, $b){return strnatcasecmp($a["fieldname"], $b["fieldname"]);});

Categories : PHP

RavenDB Query on Inner property serialize with [JsonProperty]
This appears to be a bug in the query provider for DocumentSession.Query<> where it will not honor the Newtonsoft attributes on documents. However if you use the Lucene query provider it will perform as expected: [Test] public void Test() { using (var session = DocumentStore.OpenSession()) { session.Store(new Parent {Inner = new Child {Num = 1}}); session.SaveChanges(); } using (var session = DocumentStore.OpenSession()) { var list = session.Advanced.LuceneQuery<Parent>() .WhereEquals(x => x.Inner.Num, 1) .ToList(); Assert.That(list.Count, Is.EqualTo(1)); } }

Categories : C#

Sorting alphanumeric keys of a dictionary in python
import re def key_func(s): return [int(x) if x.isdigit() else x for x in re.findall(r'D+|d+', s)] sorted_keys = sorted(d, key=key_func) Example: >>> d = {'01IB0610': 'foo', '01IB062': 'bar', '01IB0604': 'baz'} >>> sorted(d, key=key_func) ['01IB062', '01IB0604', '01IB0610']

Categories : Python

Is there an android equivalent of iOS alphanumeric index overlay control?
Please try IndexScroller if you are looking for something like this: If you are looking for an example on how to use it, please check IndexableListView

Categories : Android

Get first alphanumeric or special character in string from start index
You'll need to define what exactly a special character is. If it's a non-consecutive set (according to ASCII ordering, see http://www.asciitable.com/) then you'll need to define a new allowed character set and check against that set. Something like this should work: public const string allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,"; public int RetrieveIndex(string input, int startIndex) { for (var x = startIndex; x < input.length; x++) { if (allowed.IndexOf(input[x])==-1) { return x; } } return -1; } However, if it is a consecutive set as defined by the ASCII standard: Just figure out which range is considered acceptable or special and check against that by converting the character to an integer a

Categories : C#

Insert a space between a non-alphanumeric and alphanumeric char except specific char (Python)
Just build a custom alpha-numeric pattern for your purpose: accents = [u'u064b', u'u064c', u'u064d', u'u064e', u'u064f', u'u0650', u'u0651', u'u0652'] alnum = r'([w%s]+)' % re.escape(''.join(accents)) pattern = re.compile(alnum, re.UNICODE) To find all tokens: >>> test_str = "...foo" + ''.join(accents) + "...bar" >>> test_str '...fooًٌٍَُِّْ...bar' >>> pattern.findall(test_str) ['fooًٌٍَُِّْ', 'bar'] >>> len(_) 2 Now to put a space between tokens and the rest: >>> ' '.join(filter(None, pattern.split(test_str))) '... fooًٌٍَُِّْ ... bar' >>> len(_.split()) 4

Categories : Python

How to obtain the index permutation after the sorting
Why not put some satellite data? Instead of sorting the numbers, just sort pairs of numbers and their indices. Since the sorting is first done on the first element of the pair, this shouldn't disrupt a stable sorting algorithm. For unstable algorithms, this will change it to a stable one. But note that if you try sorting this way it generates the index while sorting, not after. Also, since knowing the permutation index would lead to a O(n) sorting algorithm, so you cannot do it faster than O(nlogn).

Categories : C++

Multi-Index Sorting in Pandas
A hack would be to change the order of the levels: In [11]: g Out[11]: Sales Manufacturer Product Name Product Launch Date Apple iPad 2010-04-03 30 iPod 2001-10-23 34 Samsung Galaxy 2009-04-27 24 Galaxy Tab 2010-09-02 22 In [12]: g.index = g.index.swaplevel(1, 2) Sortlevel, which (as you've found) sorts the MultiIndex levels in order: In [13]: g = g.sortlevel() And swap back: In [14]: g.index = g.index.swaplevel(1, 2) In [15]: g Out[15]: Sales Manufacturer Product Name Product Launch Date Apple iPod 2001-10-23 34 iPad 2010-04-03

Categories : Python

Unique index in C++ map with custom sorting
how can I find an item only by the unique_id? the problem with this question is that the list contains Foo classes and ordered by priority. this makes it problematic to search for items by unique_id. what i'm suggesting is to create a new std::map std::map <int, foo> uniqueId_To_FooClass; and when adding to bla a new item, add it to uniqueId_To_FooClass. that way you can find a foo class by unique_id I would more like to store the priority in the value (not as the key), but I don't know how I can sort by value then. Is a std::map the right class/template for that? As far as I can remember, std::map will give you the iterator that will go through the items sorted by the key. Only way to go through the sorted items by the value, and still use the map, is to rewrite whole

Categories : C++

How to get Tuple property by property index in c#?
I'd probably go with if/else or switch, but if you want to avoid that (e.g. so you can use it with any Tuple), you can use reflection: Comparison<Tuple<T1, T2, T3>> tupleComparison = (x, y) => { var prop = typeof(Tuple<T1, T2, T3>).GetProperty("Item" + sortedColumn); var xItem = prop.GetValue(x); var yItem = prop.GetValue(y); return // something to compare xItem and yItem };

Categories : C#

Postgresql Sorting a Joined Table with an index
You need to rethink your approach. Where to begin? This is a clear example, basically of the limits, performance-wise, of the sort of functional approach you are taking to SQL. Functions are largely planner opaque, and you are forcing two different lookups on data_table for every row retrieved because the stored procedure's plans cannot be folded together. Now, far worse, you are indexing one table based on data in another. This might work for append-only workloads (inserts allowed but no updates) but it will not work if data_table can ever have updates applied. If the data in data_table ever changes, you will have the index return wrong results. In these cases, you are almost always better off writing in the join as explicit, and letting the planner figure out the best way to retri

Categories : Postgresql

2 dimensional array sorting using column index
The below code should work String[][] theArray = new String[][]{{"Enter values","Enter values"}, {more values, more values}}; Comparator<String[]> comparator= new Comparator<String[]>() { Arrays.sort(theArray, new Comparator<String[]>(){ @Override public int compare(String[] o1, String[] o2) { return o1[0].compareTo(02[0]); } }); Arrays.sort(theArray, comparator); Casting should always try to be avoided. Although it should work to use your approach (object and cast to string) so you probably have some other error in your code. Anyway, it's better to explicit tell the compiler that you are sorting Strings if you know that this is what you will be sorting.

Categories : Java

Sorting 2 dimensional arrays in Java - skipping the first index
A trivial way would be: int firstBurst = jobs[0][2]; jobs[0][2] = Integer.MIN_VALUE; Arrays.sort(jobs, new Comparator<int[]>(){ public int compare(int[] a, int[] b) { // don't use subtraction, this can lead to underflows return a[2] < b[2] ? -1 : (a[2] == b[2] ? 0 : 1); } }); jobs[0][2] = firstBurst; Simply set the burst of the first item to Integer.MIN_VALUE (the integer equivalent of minus infinity). That way, it guaranteed that the first item is the smallest, so after sorting it will still be the first element. After sorting, reset the burst of the first item to its original value. EDIT By checking the documentation to verify that Arrays.sort is stable, I accidentally found the simplest version to solve this problem: use Arrays.sort(T[] a,

Categories : Java

Mongo DB sorting exception - too much data for sort() with no index
Try creating a compound index instead of two indexes. db.collection.ensureIndex( { 'loc':'2d','lastActiveTime':-1 } ) You can also suggest the query which index to use: db.collection.find(...).hint('myIndexName')

Categories : Mongodb

sorting custom objects from array into dictionary by property
You need to iterate the array and build your dictionary. If the key isn't already there, create the array and add it to the dictionary, then add the new item to it. You could alternately use predicates to filter the array into sub-arrays and build the dictionary like that but it's a similar amount of code (for a few options) and doesn't support automatic future expansion when you have another value for the key you're organising on.

Categories : IOS

breezejs: inlineCount is incorrect when sorting by navigation property
Ok, this is fixed in the current bits on GitHub. ( You can just retrieve the Breeze.WebApi.dll and you should be good to go). We will include this fix in our next full release version (v 1.4.1) out probably sometime next week. and thanks for finding it :)

Categories : Javascript

Array sorting objects by property error with strings
You may have to convert your values to integer before using it - function sortByProperty(property) { return function (a,b) { var x = parseInt(a[property]); var y = parseInt(b[property]) /* Split over two lines for readability */ return (x < y) ? -1 : (x > y) ? 1 : 0; } }

Categories : Javascript

Sorting Array list of equal length Arrays based on index
I would suggest you to do two specific things: Take in consideration the data-set you would need to sort, that usually helps in sorting faster. (as mentioned in the comment, if its limited range do a counting sort) Start using multi-threading (actually called worker threads). YES JAVASCRIPT DOEST SUPPORT IT NOW. So do a merge sort and start showing results partially. For more details on how to use multi-threading, refer worker threads. One good tutorial I can think of is http://ejohn.org/blog/web-workers/

Categories : Javascript

Array index as property
You can prove it’s an enumerable property pretty easily. As you said, it shows up in a for in loop. That’s the definition of “enumerable”. If you want another way, though: var a = ['hello']; Object.getOwnPropertyDescriptor(a, '0') // {value: 1, writable: true, enumerable: true, configurable: true} And yes, they’re like any other object property, except for that they change an array’s length if one past the end is created. That’s the only different thing about arrays. var a = []; a[0] = 5; a.length // 1

Categories : Javascript

Determine which index of an array property is being set using c#
You can create a custom collection with overriden indexer operator, where you would do your custom logic. But creating a setter method SetItemActivation(int,bool) seems to be a cleaner solution.

Categories : C#

How to access JSON property by it's index
From the docs: mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] ) If you use json_decode(file_get_contents($data), true) it will return an array. After that, you can do something like this to access the array by the index not the key. $keys = array_keys($json); echo $json[$keys[2]];

Categories : PHP

settings the "index" property of an elasticsearch object
No, you can't specify the entire "object" as not indexed. However you can use dynamic_templates (http://www.elasticsearch.org/guide/reference/mapping/root-object-type/) to do this: { "my_type":{ "properties":{ "name":{ "type":"string", "store":"yes", "index":"not_analyzed" } }, "dynamic_templates":[ { "stored_json_object_template":{ "path_match":"some_json_object.*", "mapping":{ "store":"yes", "index":"no" } } } ] } } This tells the mapper to map all properties for "some_json_object" as stored strings. Update Removed type from mapping in order to match all property types (match_path

Categories : Elasticsearch

On touching uppermost div selects contents of div under it - z-index property
Surely because "Uses of inheritance" is the only link element (other than "What is java"), it will be selected - there's nothing else to select! Try setting the display of that element to "none" when it is hidden.

Categories : Javascript

RavenDB OrderBy
If you are using an index you need to set the sortoptions for the Order property. From http://ravendb.net/docs/client-api/querying/static-indexes/customizing-results-order Numerical values, on the other hand, are stored as text and therefore require the user to specify explicitly what is the number type used so a correct sorting mechanism is enforced. This is quite easily done, by declaring the required sorting setup in SortOptions in the index definition: Sort(x => x.Order, SortOptions.Int); The index outlined above will allow sorting by value on the user's age (1, 2, 3, 11, etc). If we wouldn't specify this option, it would have been sorted lexically (1, 11, 2, 3, etc). The default SortOptions value is String. Appropriate values available for all numeric types (Byte, Doub

Categories : C#

How to check if a schema index already exists for a node's property in neo4j?
why don't you check the Indexes for a Label before trying to create it and getting a (correct) exception? http://api.neo4j.org/2.0.0-M03/org/neo4j/graphdb/schema/Schema.html#getIndexes(org.neo4j.graphdb.Label)

Categories : Java

How to find datakey value of gridview on selected index changed property?
you can set DataKeyNames as forumId like below <asp:GridView ID="GridView1" runat="server" DataKeyNames = "forumId" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"> Since you haven't give any data key names in current solution GridView1.SelectedValue will not contain the value you expected

Categories : C#

Bulk insert in RavenDB
You should probably not be upserting one record at a time. RavenDB has a bulk insert feature that will make things much easier and faster. See http://ravendb.net/docs/2.0/client-api/advanced/bulk-inserts

Categories : C#

Ravendb Array intersect
The Array intersection is not allowed, but you can write your query as follows: var colors = session.Query<Color>() .Where(c => c.colorArray.Any(x => x == "r") && c.colorArray.Any(x => x == "e") && c.colorArray.Any(x => x == "d")); Please note that in order for this to work, you need to use strings, not chars. The colorArray property in your Color class needs to be defined as: public string[] colorArray { get; set; } The reason is that if you use char[], then the query will check for the numeric values (ASCII codes) rather then the string values (ex: 'r' will be interpreted by the query engine as 114, 'e' to 101 and 'd' to 100). Now, to take this

Categories : Arrays

Nservicebus 4 with azure and RavenDB
You have 2 options: Use RavenHQ and assign the connection string, see http://support.nservicebus.com/customer/portal/articles/859362-using-ravendb-in-nservicebus-%E2%80%93-connecting Use SqlServer as persistence

Categories : Azure

Load all documents from RavenDB
I figured it out: I have to wait for non staled results. So if I change my Query out with this: session.Query<Model.Category>().Customize(cr => cr.WaitForNonStaleResults()).ToList(); it works just fine.

Categories : C#

RavenDB domain error
Connecting locally, are you using http://localhost:[port]? I've had problems using the domain name locally. Try running your application locally and connect to the RavenDB via locahost address.

Categories : Windows

Error in selecting value from RavenDB
If you try to instanciate var ctrl = new Activation(); and do ctrl.validate(x); it won't work as OnActionExecuting didn't run. That function is called automatically by the MVC framework when serving a request, not when manually testing. Since MVC instantiates a new controller on each requests anyway, you should move the RavenSession initialization to the constructor since you do not seem to use any info in the request context: public class RavenBaseController : Controller { public IDocumentSession RavenSession { get; protected set; } public RavenBaseController() { RavenSession = MvcApplication.Store.OpenSession("ravendbtesting"); } protected override void OnActionExecuted(ActionExecutedContext filterContext) { if (filterContext.IsChildAction) retu

Categories : C#

OrderBy on a Sub Collection using RavenDB
result.OrderBy(x => x.Field.Name) will return a collection as LINQ will not change the collection on which it is called rather it returns a new collection which has the required result. So do result = result.OrderBy(x => x.Field.Name);

Categories : C#

RavenDB indices chains
Yes. You can now do this. Enable the Scripted Index Results bundle Write your first index, for example - a map/reduce index. Write a script that writes the result back to another document. Write a new index against those documents. As changes to the original documents are indexed, the resulting changes get written to new documents, which then get indexed. Repeat if desired, just be careful not to create an endless loop. This is a new feature for RavenDB 2.5. Oren describes it in this video at 21:36.

Categories : C#

Uncaught TypeError: Cannot read property 'checked' of null index.html:24
Your javascript code is executing before the DOM elements are ready on the page. You need to execute the code that is trying to get the inputs after the DOM is ready. (function () { if (window.addEventListener) { window.addEventListener('DOMContentLoaded', domReady, false); } else { window.attachEvent('onload', domReady); } } ()); function domReady() { var add = document.getElementById('addition').checked; var subs = document.getElementById('substraction').checked; var multi = document.getElementById('multiplication').checked; var div = document.getElementById('division').checked; var result = 0; var x = parseInt(document.getElementById('firstNumber').value); var y = parseInt(document.getElementById('secondNumber').value); }

Categories : Javascript

Where should I place business logic when using RavenDB
There's two main parts to consider here. Firstly, as you have already noted, if you go by the word of the more fanatical RavenDB fans it is some mythical beast which is exempt from the otherwise commonly accepted laws of good application design and should be allowed to permeate throughout your application at will. It depends on the situation of course but to put it simply, if you would structure your application a certain way with something like SQL Server, do the same with RavenDB. If you would have a DAL layer, ORM, repository pattern or whatever with a SQL Server back-end, do the same with RavenDB. If you don't mind leaky abstractions, or the project is small enough to not warrant abstracting your data access at all, code accordingly. The main difference with RavenDB is that you're g

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.