27 Kasım 2014 Perşembe

a lucene tip

Retrieving large resultsets with lucene may degrade performance as in here: http://stackoverflow.com/questions/9868419/how-to-get-total-count-in-hibernate-full-text-search 
You can choose to show the first top k results, or you can paginate lucene as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// can get the resultsize easily, so you know how many pages would be..
Integer resultSize = jpaQuery.getResultSize(); 
// I use 1000 as max results, but it depends.. just try to find the optimum.
Integer pageCount = resultSize / MAX_RESULTS + 1;
List<Object[]> rawQueryResultList = new ArrayList<>();
for(int page = 0; page < pageCount; page++) {  
 jpaQuery.setFirstResult(page * MAX_RESULTS);
 jpaQuery.setMaxResults(MAX_RESULTS);
  
 rawQueryResultList.addAll(jpaQuery.getResultList());
}

12 Haziran 2014 Perşembe

book: learning cypher

Cypher is the query language for Neo4j graph databases. In fact, in my thesis about user profiling, i use cypher and  i am plannig to write a post about cypher after publishing my system for evaluation..
http://www.neo4j.org/learn/cypher  provides good information about cypher.
Moreover, i am planning to review the book on http://bit.ly/QZ5Alw ..
i recommend to try graph databases and cypher if you are dealing with connected-data problems.. 

10 Haziran 2014 Salı

bitbucket - checkout by date

At work, we decided to upgrade the system and we did not tag the old version in bitbucket (since we were planning to upgrade definitely).. However, due to some extra work and time restriction the team could not able to achieve the goal and we decided to return back to an old version by date. To do this,
- open SourceTree
- open git with Terminal icon and run the command  git checkout 'master@{2014-04-01}'


- create a branch for the detached head.

https://answers.atlassian.com/questions/245850/how-to-run-a-git-command-as-a-custom-action
http://stackoverflow.com/questions/6990484/git-checkout-by-date
https://answers.atlassian.com/questions/263451/branches-for-commit-git

19 Mayıs 2014 Pazartesi

intro. to developing a Facebook app

In order to evaluate my thesis work, i have to prepare a website with a Connect with Facebook button. I am using Spring social api for Facebook functionality.
You have to enter your mobile phone and get a confirmation code to create a Facebook app from https://developers.facebook.com/ Apps tab. Unfortunately, this was a bit problematic for me, i waited more than an hour to get a confirmation code with sms. After creating a Facebook app, you obtain an app id and app secret. They are important for your application to run successfully. Moreover, in development mode, do not enter any app domain, but add your localhost address as a canvas url as explained in http://stackoverflow.com/questions/4532721/facebook-development-in-localhost.
Now, with the help of the app id and app secret, you are able to write your application..

Edit:
Facebook changed policy this month. The default Graph Api version is 1.0 for Facebook apps created before this month and 2.0 for apps created in this month. The facebook issues are summarized in http://www.nextscripts.com/known-issues/facebook-issues/

25 Ocak 2014 Cumartesi

the error: "org.neo4j.graphdb.NotInTransactionException"

The error message is somehing like this:

2014-01-25 16:37:43 ERROR HPAggregateProfile:141 - GRAMY_ERR:
org.neo4j.graphdb.NotInTransactionException
at org.neo4j.kernel.impl.index.IndexConnectionBroker.acquireResourceConnection(IndexConnectionBroker.java:49)
at org.neo4j.index.impl.lucene.LuceneIndex.getConnection(LuceneIndex.java:85)
at org.neo4j.index.impl.lucene.LuceneIndex.add(LuceneIndex.java:138)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.add(AbstractIndexingTypeRepresentationStrategy.java:124)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.addToTypesIndex(AbstractIndexingTypeRepresentationStrategy.java:116)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.writeTypeTo(AbstractIndexingTypeRepresentationStrategy.java:59)
at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.writeTypeTo(TRSTypeAliasAccessor.java:46)
at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.writeTypeTo(TRSTypeAliasAccessor.java:26)

The solution is using transactions explicitly..
http://stackoverflow.com/questions/11485090/org-neo4j-graphdb-notintransactionexception

@Autowired
private GraphDatabaseService graphDb;

@Transactional
public void addRelation() {
  Transaction tx = graphDb.beginTx();
  ...
  tx.success(); //or tx.failure();
  tx.finish();
}

18 Ocak 2014 Cumartesi

the error:"Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.xsd)"

The error message is:

Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.xsd).

A related link:  http://stackoverflow.com/questions/7267341/validation-error-of-spring-beans-schema-inside-application-context
In summary, the error may be resolved by doing the following:
" It was caused by some cached files. After removing those items (Preferences -> General -> Network Connections -> Cache) everything worked as expected. "
However, in my condition it was not helpful :( Another cause is using different versions together as stated:
"This error may have appeared because you had a mix of 2.5 xsd and 3.0 xsd in your applicationContext.xml. "
When i removed the version info from every element in xsi:schemaLocation, the project compiled successfully..