Java Code Examples for com.orientechnologies.orient.core.command.OCommandContext#setVariable()
The following examples show how to use
com.orientechnologies.orient.core.command.OCommandContext#setVariable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OLuceneIndexManagerAbstract.java From orientdb-lucene with Apache License 2.0 | 6 votes |
public void sendLookupTime(OCommandContext context, final TopDocs docs, final Integer limit, long startFetching) { if (context != null) { final long finalTime = System.currentTimeMillis() - startFetching; context.setVariable((indexName + ".lookupTime").replace(".", "_"), new HashMap<String, Object>() { { put("limit", limit); put("totalTime", finalTime); put("totalHits", docs.totalHits); put("returnedHits", docs.scoreDocs.length); put("maxScore", docs.getMaxScore()); } }); } }
Example 2
Source File: OLuceneWithinOperator.java From orientdb-lucene with Apache License 2.0 | 6 votes |
@Override public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) { OIndexDefinition definition = index.getDefinition(); int idxSize = definition.getFields().size(); int paramsSize = keyParams.size(); OIndexCursor cursor; Object indexResult = index.get(new OSpatialCompositeKey(keyParams).setOperation(SpatialOperation.IsWithin)); if (indexResult == null || indexResult instanceof OIdentifiable) cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, new OSpatialCompositeKey(keyParams)); else cursor = new OIndexCursorCollectionValue(((Collection<OIdentifiable>) indexResult).iterator(), new OSpatialCompositeKey( keyParams)); iContext.setVariable("$luceneIndex", true); return cursor; }
Example 3
Source File: VarParamExtension.java From guice-persist-orient with MIT License | 5 votes |
@Override public void amendCommand(final OCommandRequest query, final CommandMethodDescriptor descriptor, final Object instance, final Object... arguments) { @SuppressWarnings("unchecked") final Map<String, Integer> vars = (Map<String, Integer>) descriptor.extDescriptors.get(KEY); final OCommandContext context = query.getContext(); for (Map.Entry<String, Integer> entry : vars.entrySet()) { context.setVariable(entry.getKey(), arguments[entry.getValue()]); } }
Example 4
Source File: OLuceneIndexManagerAbstract.java From orientdb-lucene with Apache License 2.0 | 5 votes |
public void sendTotalHits(OCommandContext context, TopDocs docs) { if (context != null) { if (context.getVariable("totalHits") == null) { context.setVariable("totalHits", docs.totalHits); } else { context.setVariable("totalHits", null); } context.setVariable((indexName + ".totalHits").replace(".", "_"), docs.totalHits); } }
Example 5
Source File: OLuceneTextOperator.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@Override public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) { OIndexCursor cursor; Object indexResult = index.get(new OFullTextCompositeKey(keyParams).setContext(iContext)); if (indexResult == null || indexResult instanceof OIdentifiable) cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, new OFullTextCompositeKey(keyParams)); else cursor = new OIndexCursorCollectionValue(((Collection<OIdentifiable>) indexResult).iterator(), new OFullTextCompositeKey( keyParams)); iContext.setVariable("$luceneIndex", true); return cursor; }
Example 6
Source File: OLuceneNearOperator.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@Override public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft, Object iRight, OCommandContext iContext) { List<Number> left = (List<Number>) iLeft; double lat = left.get(0).doubleValue(); double lon = left.get(1).doubleValue(); Shape shape = SpatialContext.GEO.makePoint(lon, lat); List<Number> right = (List<Number>) iRight; double lat1 = right.get(0).doubleValue(); double lon1 = right.get(1).doubleValue(); Shape shape1 = SpatialContext.GEO.makePoint(lon1, lat1); Map map = (Map) right.get(2); double distance = 0; Number n = (Number) map.get("maxDistance"); if (n != null) { distance = n.doubleValue(); } Point p = (Point) shape1; Circle circle = SpatialContext.GEO.makeCircle(p.getX(), p.getY(), DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM)); double docDistDEG = SpatialContext.GEO.getDistCalc().distance((Point) shape, p); final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM); iContext.setVariable("distance", docDistInKM); return shape.relate(circle) == SpatialRelation.WITHIN; }
Example 7
Source File: OLuceneNearOperator.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@Override public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) { OIndexCursor cursor; OIndexDefinition definition = index.getDefinition(); int idxSize = definition.getFields().size(); int paramsSize = keyParams.size(); double distance = 0; Object spatial = iContext.getVariable("spatial"); if (spatial != null) { if (spatial instanceof Number) { distance = ((Double) OType.convert(spatial, Double.class)).doubleValue(); } else if (spatial instanceof Map) { Map<String, Object> params = (Map<String, Object>) spatial; Object dst = params.get("maxDistance"); if (dst != null && dst instanceof Number) { distance = ((Double) OType.convert(dst, Double.class)).doubleValue(); } } } Object indexResult = index.get(new OSpatialCompositeKey(keyParams).setMaxDistance(distance).setContext(iContext)); if (indexResult == null || indexResult instanceof OIdentifiable) cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, new OSpatialCompositeKey(keyParams)); else cursor = new OIndexCursorCollectionValue(((Collection<OIdentifiable>) indexResult).iterator(), new OSpatialCompositeKey( keyParams)); iContext.setVariable("$luceneIndex", true); return cursor; }
Example 8
Source File: OrienteerETLProcessor.java From Orienteer with Apache License 2.0 | 5 votes |
public static OrienteerETLProcessor parseConfigRecord(OETLTaskSession taskSession,String config){ final OCommandContext context = createDefaultContext(); ODocument configuration = new ODocument().fromJSON("{}"); configuration.merge(new ODocument().fromJSON(config, "noMap"), true, true); // configuration = ; ODocument cfgGlobal = configuration.field("config"); if (cfgGlobal != null) { for (String f : cfgGlobal.fieldNames()) { context.setVariable(f, cfgGlobal.field(f)); } } return (OrienteerETLProcessor) new OrienteerETLProcessor(taskSession).parse(configuration, context); }
Example 9
Source File: ODefaultImporterListener.java From orientdb-etl with Apache License 2.0 | 4 votes |
@Override public void onJoinNotFound(final ODatabaseDocumentTx db, final OCommandContext iContext, final OIndex<?> iIndex, final Object iKey) { iContext.setVariable("joinNotFound", ((Integer) iContext.getVariable("joinNotFound", 0)) + 1); OLogManager.instance().warn(this, " + %d line: join record not found in index '%s' for key='%s'", iContext.getVariable("currentLine"), iIndex, iKey); }
Example 10
Source File: OETLProcessor.java From orientdb-etl with Apache License 2.0 | 4 votes |
protected static OCommandContext createDefaultContext() { final OCommandContext context = new OBasicCommandContext(); context.setVariable("dumpEveryMs", 1000); return context; }