本文整理汇总了Java中com.orientechnologies.orient.core.command.OCommandContext.setVariable方法的典型用法代码示例。如果您正苦于以下问题:Java OCommandContext.setVariable方法的具体用法?Java OCommandContext.setVariable怎么用?Java OCommandContext.setVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.command.OCommandContext
的用法示例。
在下文中一共展示了OCommandContext.setVariable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendLookupTime
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
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());
}
});
}
}
示例2: executeIndexQuery
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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;
}
示例3: evaluateRecord
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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 = factory.context().makePoint(lon, lat);
List<Number> right = (List<Number>) iRight;
double lat1 = right.get(0).doubleValue();
double lon1 = right.get(1).doubleValue();
Shape shape1 = factory.context().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 = factory.context().makeCircle(p.getX(), p.getY(),
DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM));
double docDistDEG = factory.context().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;
}
示例4: executeIndexQuery
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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), new OSpatialCompositeKey(
keyParams));
iContext.setVariable("$luceneIndex", true);
return cursor;
}
示例5: executeIndexQuery
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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), new OSpatialCompositeKey(keyParams));
iContext.setVariable("$luceneIndex", true);
return cursor;
}
示例6: amendCommand
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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()]);
}
}
示例7: sendTotalHits
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
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);
}
}
示例8: executeIndexQuery
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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;
}
示例9: evaluateRecord
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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;
}
示例10: executeIndexQuery
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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;
}
示例11: onJoinNotFound
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
@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);
}
示例12: createDefaultContext
import com.orientechnologies.orient.core.command.OCommandContext; //导入方法依赖的package包/类
protected static OCommandContext createDefaultContext() {
final OCommandContext context = new OBasicCommandContext();
context.setVariable("dumpEveryMs", 1000);
return context;
}