Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement index usage to traverse supernodes (pattern matching)
- Loading branch information
1 parent
eece189
commit 4229da9
Showing
7 changed files
with
320 additions
and
43 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
core/src/main/java/com/orientechnologies/orient/core/sql/functions/OSQLFunctionFiltered.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* | ||
* * Copyright 2015 Orient Technologies LTD (info(at)orientdb.com) | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* * | ||
* * For more information: http://www.orientdb.com | ||
* | ||
*/ | ||
|
||
package com.orientechnologies.orient.core.sql.functions; | ||
|
||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.db.record.OIdentifiable; | ||
|
||
/** | ||
* @author Luigi Dell'Aquila | ||
*/ | ||
public interface OSQLFunctionFiltered extends OSQLFunction { | ||
|
||
/** | ||
* Process a record. | ||
* | ||
* | ||
* @param iThis | ||
* @param iCurrentRecord | ||
* : current record | ||
* @param iCurrentResult | ||
* TODO | ||
* @param iParams | ||
* : function parameters, number is ensured to be within minParams and maxParams. | ||
* @param iPossibleResults | ||
* : a set of possible results (the function will return, as a result, only items contained in this collection) | ||
* @param iContext | ||
* : object calling this function | ||
* @return function result, can be null. Special cases : can be null if function aggregate results, can be null if function filter | ||
* results : this mean result is excluded | ||
*/ | ||
public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, | ||
Iterable<OIdentifiable> iPossibleResults, OCommandContext iContext); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
.../main/java/com/orientechnologies/orient/graph/sql/functions/OSQLFunctionMoveFiltered.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* | ||
* * Copyright 2015 Orient Technologies LTD (info(at)orientdb.com) | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* * | ||
* * For more information: http://www.orientdb.com | ||
* | ||
*/ | ||
package com.orientechnologies.orient.graph.sql.functions; | ||
|
||
import com.orientechnologies.common.collection.OMultiValue; | ||
import com.orientechnologies.common.io.OIOUtils; | ||
import com.orientechnologies.common.types.OModifiableBoolean; | ||
import com.orientechnologies.common.util.OCallable; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; | ||
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal; | ||
import com.orientechnologies.orient.core.db.record.OIdentifiable; | ||
import com.orientechnologies.orient.core.sql.OSQLEngine; | ||
import com.orientechnologies.orient.core.sql.functions.OSQLFunctionFiltered; | ||
import com.orientechnologies.orient.graph.sql.OGraphCommandExecutorSQLFactory; | ||
import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph; | ||
|
||
/** | ||
* @author Luigi Dell'Aquila | ||
*/ | ||
public abstract class OSQLFunctionMoveFiltered extends OSQLFunctionMove implements OSQLFunctionFiltered{ | ||
|
||
public OSQLFunctionMoveFiltered() { | ||
super(NAME, 1, 2); | ||
} | ||
|
||
public OSQLFunctionMoveFiltered(final String iName, final int iMin, final int iMax) { | ||
super(iName, iMin, iMax); | ||
} | ||
|
||
|
||
@Override public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParameters, | ||
final Iterable<OIdentifiable> iPossibleResults, OCommandContext iContext) { | ||
final OModifiableBoolean shutdownFlag = new OModifiableBoolean(); | ||
ODatabaseDocumentInternal curDb = ODatabaseRecordThreadLocal.INSTANCE.get(); | ||
final OrientBaseGraph graph = OGraphCommandExecutorSQLFactory.getAnyGraph(shutdownFlag); | ||
try { | ||
final String[] labels; | ||
if (iParameters != null && iParameters.length > 0 && iParameters[0] != null) | ||
labels = OMultiValue.array(iParameters, String.class, new OCallable<Object, Object>() { | ||
|
||
@Override | ||
public Object call(final Object iArgument) { | ||
return OIOUtils.getStringContent(iArgument); | ||
} | ||
}); | ||
else | ||
labels = null; | ||
|
||
return OSQLEngine.foreachRecord(new OCallable<Object, OIdentifiable>() { | ||
@Override | ||
public Object call(final OIdentifiable iArgument) { | ||
return move(graph, iArgument, labels, iPossibleResults); | ||
} | ||
}, iThis, iContext); | ||
} finally { | ||
if (shutdownFlag.getValue()) | ||
graph.shutdown(false); | ||
ODatabaseRecordThreadLocal.INSTANCE.set(curDb); | ||
} | ||
} | ||
|
||
protected abstract Object move(OrientBaseGraph graph, OIdentifiable iArgument, String[] labels, | ||
Iterable<OIdentifiable> iPossibleResults); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.