g.V().has(label,"request_job").order().by("submit_time",incr).valueMap("submit_time")
==>[submit_time:[1330647978000]]
==>[submit_time:[1330652298000]]
When I use, order() query in Gremlin console, it is working fine. But when I try the same query in Java, I am not able to use "incr", it is showing that undefined symbol "incr".
How to use "incr" with order() in Java?
Kindly help me to resolve this problem.
It is defined in the enum Order (javadoc) which is automatically imported by the Gremlin Console. You should add the following import to your Java class:
import static org.apache.tinkerpop.gremlin.process.traversal.Order.*;
Related
In some code I'm looking at, there was this import statement.
import husaynhakeem.io.facedetector.models.FaceBounds
How do I find the code in this FaceBounds class? I have tried looking on the user's github but I have not been able to find the actual class. The only classes I find are Facing.kt, Orientation.kt and models.kt but not the Facebounds class. https://github.com/husaynhakeem/android-face-detector/tree/master/facedetector/src/main/java/husaynhakeem/io/facedetector/models
data class FaceBounds(val id: Int, val box: Rect)
It's in models.kt
I am trying to create a geoBoundingBoxQuery("pin.location") in Java for Elastic Search. Eclipse is not able to resolve imports for this method although the Elastic Search Java API documentation specifically suggests to use this method.
What class do I need to import which has this method?
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-geo-queries.html#java-query-dsl-geo-bounding-box-query
geoBoundingBoxQuery("pin.location") is defined as a static method in class org.elasticsearch.index.query.QueryBuilders, so you can use it this way:
QueryBuilder q = QueryBuilders.geoBoundingBoxQuery("pin.location");
Elasticsearch documentation is assuming you're using a static import like:
import static org.elasticsearch.index.query.QueryBuilders.geoBoundingBoxQuery;
so you don't need qualify the method with class name:
QueryBuilder q = geoBoundingBoxQuery("pin.location");
For anyone who is having the same issue, I have found the answer.
Its the version of Elastic search java API that I am using is the issue. The documentation is for version 2.1 whereas I am using an older version. For the older version, you need to do the following:
FilterBuilders.geoBoundingBoxFilter("pin.location")
I'm migrating my aplications to MongoDb 3.0.2. I have no problems with inserts, finds and deletes. But,Problems with the update. Specially with the eq().
In this sentence:
coll.updateOne(eq("_id", id), new Document("$set", new Document("name", name)));
The id variable is defined ObjectId. Eclipse gives me an error:
The method eq(String, ObjectId) is undefined for the
type SystemDAO (my java class).
What am I doing wrong? I followed the examples in the Mongo java driver documents.
you need to import the static method eq from the package com.mongodb.client.model.Filters.
add this infront of your class to your other imports:
import static com.mongodb.client.model.Filters.*;
In Eclipse it should give a quick-fix to import the right package if you do a mouse over on your error. But for static imports this does not work all the time.
I want to write some tests for my compiler but can't get past an error.
I'm following an example from 'Implementing DSL with Xtext and Xtend' by L. Bettini (great book btw). I've downloaded the code for the 'entities' DSL from https://github.com/LorenzoBettini/packtpub-xtext-book-examples and the tests in EntitiesGenerator.xtend work great.
If I write a test for the default DSL (MyDsl) using the same code, I've got an error:
org.eclipse.xtext.xbase.compiler.CompilationTestHelper cannot be resolved to a type.
or, if I add org.eclipse.xtext.xbase.junit (2.4.1) to the list of required plug-ins, I get
Discouraged access: The type CompilationTestHelper is not accessible due to restriction on required project org.xtext.example.myDsl.tests
I can allow access to it, but then get a runtime error anyway. If I try to add org.eclipse.xtext.xbase.lib as well, only org.eclipse.xtext.xbase.lib.source appears in the list. I don't know it that matters. In any case, adding it doesn't change anything.
What do I need to do to make it work?
I'm using Juno with Xtext 2.4.1., Java 1.7.
The content of the test class:
package org.xtext.example.myDsl.tests
import com.google.inject.Inject
import org.eclipse.xtext.junit4.InjectWith
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.xbase.compiler.CompilationTestHelper // error here
import org.xtext.example.myDsl.MyDslInjectorProvider
import org.junit.Test
import org.junit.runner.RunWith
#RunWith(typeof(XtextRunner))
#InjectWith(typeof(MyDslInjectorProvider))
class MyDslGeneratorTest {
#Inject extension CompilationTestHelper
#Test
def void testGeneratedCode() {
'''
Hello some1!
Hello some2!
'''.assertCompilesTo(
'''some content''')
}
}
Thank you in advance!
the xtext guys mark stuff that may be changed NOT as api. this is why you get this warning.
it should work anyway. (although it is meant to be used for xbase languages only)
P.S: you have to add a dependency to jdt.core too
I have connected JAVA application with MySql .When i wrote PreparedStatement ps = null ;
then two option for import package was showing .The two suggested package was :com.mysql.jdbc.PreparedStatement; and java.sql.PreparedStatement .And , when i import com.mysql.jdbc.PreparedStatement package they said for casting as shown below .
ps = (PreparedStatement) con.prepareStatement("INSERT INTO Authors(Name) VALUES(?)");
And when i used java.sql.PreparedStatement not need for casting in above sentence .
so, My question is : why two different import package are showing ? and why casting needed for com.mysql.jdbc.PreparedStatement package ?
why two different import package are showing ?
Because both classes were present in your compiletime classpath and your IDE were trying to be helpful.
and why casting needed for com.mysql.jdbc.PreparedStatement package ?
Because prepareStatement() is specified to return java.sql.PreparedStatement, not com.mysql.jdbc.PreparedStatement.
The java.sql.PreparedStatement is an interface and you should be using this all the time. The MySQL one is a concrete implementation and you should not be tight coupling your JDBC code to the MySQL specific implementation. Otherwise you'd have to make a lot of changes in your code if you ever want to switch the DB server (and thus also the JDBC driver) to a different vendor like PostgreSQL. If you're using the standard JDBC interfaces from java.sql package all the time, all you would need to change is only the JDBC URL and maybe also the username and password and some DB-specific SQL statements.
See also:
When should I use an interface in java?
In simplest terms, what is a factory?