use of com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery in project orientdb by orientechnologies.
the class SQLAsynchQuerySpeedTest method cycle.
@Override
@SuppressWarnings("unchecked")
public void cycle() throws UnsupportedEncodingException {
System.out.println("1 -----------------------");
OrientTest.printRecords((List<? extends ORecord>) database.command(new OSQLAsynchQuery<ODocument>("select * from animal where column(0) < 5 or column(0) >= 3 and column(5) < 7", new OCommandResultListener() {
@Override
public boolean result(Object iRecord) {
OrientTest.printRecord(resultCount++, iRecord);
return true;
}
@Override
public void end() {
}
@Override
public Object getResult() {
return null;
}
})).execute());
}
use of com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery in project orientdb by orientechnologies.
the class OMatchStatement method parse.
// ------------------------------------------------------------------
// query parsing and optimization
// ------------------------------------------------------------------
/**
* this method parses the statement
*
* @param iRequest Command request implementation.
* @param <RET>
*
* @return
*/
@Override
public <RET extends OCommandExecutor> RET parse(OCommandRequest iRequest) {
final OCommandRequestText textRequest = (OCommandRequestText) iRequest;
if (iRequest instanceof OSQLSynchQuery) {
request = (OSQLSynchQuery<ODocument>) iRequest;
} else if (iRequest instanceof OSQLAsynchQuery) {
request = (OSQLAsynchQuery<ODocument>) iRequest;
} else {
// BUILD A QUERY OBJECT FROM THE COMMAND REQUEST
request = new OSQLSynchQuery<ODocument>(textRequest.getText());
if (textRequest.getResultListener() != null) {
request.setResultListener(textRequest.getResultListener());
}
}
String queryText = textRequest.getText();
// please, do not look at this... refactor this ASAP with new executor structure
final InputStream is = new ByteArrayInputStream(queryText.getBytes());
final OrientSql osql = new OrientSql(is);
try {
OMatchStatement result = (OMatchStatement) osql.parse();
this.matchExpressions = result.matchExpressions;
this.returnItems = result.returnItems;
this.returnAliases = result.returnAliases;
this.limit = result.limit;
} catch (ParseException e) {
OCommandSQLParsingException ex = new OCommandSQLParsingException(e, queryText);
OErrorCode.QUERY_PARSE_ERROR.throwException(ex.getMessage(), ex);
}
assignDefaultAliases(this.matchExpressions);
pattern = new Pattern();
for (OMatchExpression expr : this.matchExpressions) {
pattern.addExpression(expr);
}
Map<String, OWhereClause> aliasFilters = new LinkedHashMap<String, OWhereClause>();
Map<String, String> aliasClasses = new LinkedHashMap<String, String>();
Map<String, ORID> aliasRids = new LinkedHashMap<String, ORID>();
for (OMatchExpression expr : this.matchExpressions) {
addAliases(expr, aliasFilters, aliasClasses, aliasRids, context);
}
this.aliasFilters = aliasFilters;
this.aliasClasses = aliasClasses;
this.aliasRids = aliasRids;
rebindFilters(aliasFilters);
pattern.validate();
return (RET) this;
}
Aggregations