use of com.orientechnologies.orient.core.iterator.ORecordIteratorClusters in project orientdb by orientechnologies.
the class OCommandExecutorSQLResultsetAbstract method searchInClusters.
protected void searchInClusters() {
final ODatabaseDocumentInternal database = getDatabase();
final Set<Integer> clusterIds = new HashSet<Integer>();
for (String clusterName : parsedTarget.getTargetClusters().keySet()) {
if (clusterName == null || clusterName.length() == 0)
throw new OCommandExecutionException("No cluster or schema class selected in query");
database.checkSecurity(ORule.ResourceGeneric.CLUSTER, ORole.PERMISSION_READ, clusterName.toLowerCase());
if (Character.isDigit(clusterName.charAt(0))) {
// GET THE CLUSTER NUMBER
for (int clusterId : OStringSerializerHelper.splitIntArray(clusterName)) {
if (clusterId == -1)
throw new OCommandExecutionException("Cluster '" + clusterName + "' not found");
clusterIds.add(clusterId);
}
} else {
// GET THE CLUSTER NUMBER BY THE CLASS NAME
final int clusterId = database.getClusterIdByName(clusterName.toLowerCase());
if (clusterId == -1)
throw new OCommandExecutionException("Cluster '" + clusterName + "' not found");
clusterIds.add(clusterId);
}
}
// CREATE CLUSTER AS ARRAY OF INT
final int[] clIds = new int[clusterIds.size()];
int i = 0;
for (int c : clusterIds) clIds[i++] = c;
final ORID[] range = getRange();
target = new ORecordIteratorClusters<ORecord>(database, database, clIds).setRange(range[0], range[1]);
}
use of com.orientechnologies.orient.core.iterator.ORecordIteratorClusters in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelect method fetchFromTarget.
private boolean fetchFromTarget(final Iterator<? extends OIdentifiable> iTarget) {
fetchLimit = getQueryFetchLimit();
final long startFetching = System.currentTimeMillis();
final int[] clusterIds = iTarget instanceof ORecordIteratorClusters ? ((ORecordIteratorClusters) iTarget).getClusterIds() : null;
parallel = (parallel || OGlobalConfiguration.QUERY_PARALLEL_AUTO.getValueAsBoolean()) && canRunParallel(clusterIds, iTarget);
try {
if (parallel)
return parallelExec(iTarget);
boolean prefetchRecords = false;
if (canScanStorageCluster(clusterIds)) {
prefetchRecords = true;
}
final ODatabaseDocumentInternal database = getDatabase();
database.setPrefetchRecords(prefetchRecords);
try {
// WORK WITH ITERATOR
return serialIterator(iTarget);
} finally {
database.setPrefetchRecords(false);
}
} finally {
context.setVariable("fetchingFromTargetElapsed", (System.currentTimeMillis() - startFetching));
}
}
Aggregations