What is the default MAXDEPTH value in an Orient TRAVERSE statement? - orientdb

I'm assuming the MAXDEPTH in a TRAVERSE is -1 but the documentation doesn't actually specify it.
http://orientdb.com/docs/master/SQL-Traverse.html

The default MAXDEPTH is -1 (unlimited traversal)

Related

Flutter list.indexOf(element) always returns -1

i'm trying to get indexes of elements in a list using Flutter and Getx. The problem is that it is always returning -1 whatever element I pass into indexOf().
Here is my code:
var my_index = Get.find<ProductsController>()
.productsList
.indexOf(_cartList[index].product!);
print(my_index); ==> always retuning -1
Noting that _cartList and productsList have elements inside of them. Even when I pass an element manually it always returns -1.
Usually -1 is the standard message to tell that the element not exist in the list searched.
Maybe it is but the comparison can't be made (==) ? Are the types rigorously accurate? Do you use equatable or an equivalent (freezed, ...). If you are able to do it with a list of integer or string it is probably from there

Timelion expression for boolean fields

I am writing a Timelion expression where I want to plot only if the specified key is TRUE.
.es(index=xyz*, metric=count, timefield=evaluatedAt, split=APM.CREDIT_CARD.REQUESTED:1).label(regex='.* APM.CREDIT_CARD.REQUESTED:(.*) > .*', label='APM.CREDIT_CARD approved')
How can I add a filter where APM.CREDIT_CARD.REQUESTED is TRUE
Nvm found it, I can use lucene query. I used .q("APM.CREDIT_CARD.REQUESTED:true")

Mongoid limit parameter ignored

I tried to grab the latest N records with a unique value (first_name).
So far:
#users = User.all(:limit => 5, :sort => [:created_at, :desc]).distinct(:first_name)
almost works..But ignores the limit and sort order
Also:
#users = User.limit(5).desc(:created_at).distinct(:first_name)
Ignores both 'limit' and 'desc'
#users = User.limit(5)
Works..
What am I doing wrong?
Any help would be greatly appreciated!
I played with this for a little while and this is the best I could come up with.
Good luck.
#users = User.desc(:created_at).reduce([]) do |arr, user|
unless arr.length == 5 || arr.detect{ |u| u.first_name == user.first_name }
arr << user
end
arr
end
Have you tried using a pagination gem such as amatsuda / kaminari and limiting the results using page().per()?
Both distinct and count ignore the limit command in Mongoid. With count you can pass true (i.e. User.limit(5).count(true)) to force it to pay attention to the scope. Unfortunately there is no such trick for distinct as far as I'm aware (see docs/source here).
If you want to just grab the first 5 first_name's you can do this (not distinct):
User.desc(:created_at).limit(5).map(&:first_name)
This will respect the limit, but still load 5 full objects from the database (then discard the rest of the object to give you full name). If you actually need to run distinct, you're better off heading toward an aggregation framework solution.
I haven't tested, but this seems to be what you're looking for: https://stackoverflow.com/a/17568267/127311
I played with some result I found this.
User.limit(2).count => 10 #but in array I found only two results
User.limit(2).to_a.count => 2
May be limit gives the correct result, but count query gives wrong result.

drools rule get value from a map

How to get the perticular value in the drools when block.
I am looking for something like this but its not working:
I have inserted Hashmap into Working memory and trying to retrieve it in When
$expiry_date:HashMap(get("CREDIT_CARD_EXPIRATION_DATE"));
eval(ageInDays($expiry_date)>10) ;
I get below error
[42,37]: [ERR 101] Line 42:37 no viable alternative at input '"CREDIT_CARD_EXPIRATION_DATE"' in rule "Rule1" in pattern HashMap
For maps/lists/arrays, you can use [] syntax to access elements. Also, if you are using Drools 5.3+, evals are basically irrelevant now.
rule X
when
HashMap( ageInDays(this["CREDIT_CARD_EXPIRATION_DATE"]) > 10 )
then
...
end
With Drools 5.1/5.2, you could do:
rule X
when
HashMap( eval( ageInDays(this["CREDIT_CARD_EXPIRATION_DATE"]) > 10 ) )
then
...
end
Usually its better to insert more typed objects than just a hash map. Can you explain the information that are you trying to process and why do you choose to insert a hashmap instead of a typed object?
I'm pretty sure that you can do something like:
HashMap($expire: keys["CREDIT_CARD_EXPIRATION_DATE"] )
eval(ageInDays($expire) > 10)
I didn't test it but you should look in that direction if you can't insert more typed facts.
Cheers

XML::LibXML - detect if two Elements are the same?

I'm working with XML::LibXML in Perl.
Say I have two $element references gotten by different (opaque) XPath queries.
(How) can I determine, if the two $element (Node) refs are the same element in the document tree?
Comparing $el1 == $el2doesn't always work as far as I could tell.
It's in the XML::LibXML::Node documentation:
isSameNode
$bool = $node->isSameNode( $other_node );
returns TRUE (1) if the given nodes refer to the same node structure,
otherwise FALSE (0) is returned.