How oracle index hint can be passed to ExpressionBuilder in eclipselink. We are using session.readAllObjects method - eclipselink

How oracle index hint can be passed to ExpressionBuilder in eclipselink. We are using session.readAllObjects method.
ExpressionBuilder doesn't support it. Is there any other way.

Somehow I tried below one. It worked.
We can use below ReadAllQuery class instead of session.readAllObjects(Class,Expression)
ReadAllQuery raq = new ReadAllQuery();
raq.setReferenceClass(MyClass.class);
raq.setSelectionCriteria(expBuilder.getExpression());
//Query hint in set as below
raq.setHintString("/*+ index(t0 INDEXNAME)*/");
session.executeQuery(raq);

Related

How to add allowDiskUse to mongooperation.find method in spring boot

The below query i want to add allowDiskUse true. I am able to add allowDiskUsage to aggregation query but not able to find a solution for find method
Query query = new Query().with(pageable).addCriteria(criteria).collation(collation);
mongoOperations.find(query, RuntimeApplication.class, RUNTIME_APP);
I want to know is that possible to add allowDiskUsage to find method or i need to change query to aggregation.
i just found in below query from internet. but i am not getting how to convert it into spring boot
db.collection.find(<match>).sort(<sort>).allowDiskUse()
What kind of spring-data version are you using? You should be able to add allowDiskUse to the Query object just like this:
val query = Query()
.with(Pageable.ofSize(1))
.addCriteria(Criteria())
.allowDiskUse(true)
And then afterwards use the query with find for instance with mongoTemplate.
Here is the documentation: https://javadoc.io/doc/org.springframework.data/spring-data-mongodb/latest/org/springframework/data/mongodb/core/query/Query.html

How to use the "defines" parameter of Microsoft.Hadoop.WebHCat.Protocol.WebHCatHttpClient.CreateHiveJob?

I guess defines allows passing parameters to the Hive query, but I haven't found any documentation or usage examples. How do I use these parameters in the query?
I am using defines parameter from powershell, but hopefully it will help you.
So first in PowerShell script I am writing something like following:
[HashTable] $defines
$defines = #{}
$defines.Add("someContainerUrl",${someContainerUrl})
Then I am using this new defines variable when I am calling the HDInsight:
$jobDef = New-AzureHDInsightHiveJobDefinition -Query $hiveQuery -JobName $jobName -Defines $defines -StatusFolder "/JobStatus/Hive"
$hiveJob = Start-AzureHDInsightJob –Cluster $clusterName –JobDefinition $jobDef
Then in my hive code, I can use this defines variable for example as following:
ADD FILES
${hiveconf:someContainerUrl}/SomeFile.exe;
I think this article might be of help to you as well:
http://blogs.msdn.com/b/bigdatasupport/archive/2014/02/13/how-to-pass-hadoop-configuration-values-for-a-job-via-hdinsight-powershell-and-net-sdk.aspx

Neo4j python binding: Querying node index for a set of values

I have a Neo4j database graphDb where nodes have a property 'label'. I have a Lucene index 'my_nodes' with key 'label' which indexes the values of node property 'label'. Now I want to retrieve nodes which have property 'label' equal to a value from a list of possible values labellist. To accomplish this, I wrote a Cypher query the following way:
cypherQ = """START n=node:my_nodes('"""
+' OR '.join(['label:'+str(i) for i in labellist]) + """')
RETURN n"""
result = graphDb.query(cypherQ)
That works fine, but I wonder whether there is a way to write a parameterized query anyhow?
I tried something like:
cypherQ = """START n=node:my_nodes('label:{params}')
RETURN n"""
result = graphDb.query(cypherQ, params = labellist)
But this surely does not work, though if there is one value in labellist it works. And the neo4j tutorial does not provide much material on this issue.
Once again I am using a python binding for Neo4j.
The parameter is working for the whole query part of the index, so this would be
cypherQ = """START n=node:my_nodes({queryParam})
RETURN n"""
and you construct the query in your client code and pass it into Cypher as one parameter.

From within a grails HQL, how would I use a (non-aggregate) Oracle function?

If I were retrieving the data I wanted from a plain sql query, the following would suffice:
select * from stvterm where stvterm_code > TT_STUDENT.STU_GENERAL.F_Get_Current_term()
I have a grails domain set up correctly for this table, and I can run the following code successfully:
def a = SaturnStvterm.findAll("from SaturnStvterm as s where id > 201797") as JSON
a.render(response)
return false
In other words, I can hardcode in the results from the Oracle function and have the HQL run correctly, but it chokes any way that I can figure to try it with the function. I have read through some of the documentation on Hibernate about using procs and functions, but I'm having trouble making much sense of it. Can anyone give me a hint as to the proper way to handle this?
Also, since I think it is probably relevant, there aren't any synonyms in place that would allow the function to be called without qualifying it as schema.package.function(). I'm sure that'll make things more difficult. This is all for Grails 1.3.7, though I could use a later version if needed.
To call a function in HQL, the SQL dialect must be aware of it. You can add your function at runtime in BootStrap.groovy like this:
import org.hibernate.dialect.function.SQLFunctionTemplate
import org.hibernate.Hibernate
def dialect = applicationContext.sessionFactory.dialect
def getCurrentTerm = new SQLFunctionTemplate(Hibernate.INTEGER, "TT_STUDENT.STU_GENERAL.F_Get_Current_term()")
dialect.registerFunction('F_Get_Current_term', getCurrentTerm)
Once registered, you should be able to call the function in your queries:
def a = SaturnStvterm.findAll("from SaturnStvterm as s where id > TT_STUDENT.STU_GENERAL.F_Get_Current_term()")

How to create secondary index in Cassandra Hector API programmatically

I have been trying to create indexing using below set of lines.
KeyspaceDefinition fromCluster = cluster.describeKeyspace(KEYSPACE);
ColumnFamilyDefinition cfDef = fromCluster.getCfDefs().get(0);
BasicColumnFamilyDefinition columnFamilyDefinition = newBasicColumnFamilyDefinition(cfDef);
BasicColumnDefinition columnDefinition = new BasicColumnDefinition();
columnDefinition.setName(StringSerializer.get().toByteBuffer("A_NO"));
columnDefinition.setIndexName("A_NO_idx");
columnDefinition.setIndexType(ColumnIndexType.KEYS);
columnDefinition.setValidationClass(ComparatorType.UTF8TYPE.getClassName());
columnFamilyDefinition.addColumnDefinition(columnDefinition);
But i am unable to do so. Actually i am storing the data in the columns dynamically as well as creating those columns dynamically and after that for better query purpose i am trying to put index on some particular columns. Any suggestion please how to do that.
Its eventually quite simple. You just have to create the secondary index while defining your columnfamily. In the above code, all the manipulation are done on the object index which has to be created while defining only. The steps for adding index are
List<ColumnDef> columns = new ArrayList<ColumnDef>();
columns.add(newIndexedColumnDef("columnName", "UTF8Type"));
List<ColumnDefinition> columnMetadata = ThriftColumnDef
.fromThriftList(columns);
cdefs.add(cf_def); //cf_def is your columnfamily definition
The helper method code is from KeyspaceCreationTest
public ColumnDef newIndexedColumnDef(String column_name, String comparer){
ColumnDef cd = new ColumnDef(se.toByteBuffer(column_name), comparer);
cd.setIndex_name(column_name);
cd.setIndex_type(IndexType.KEYS);
return cd;
}
References for comparer can be found here
I hope it will help you.