示例数据:TinkerPop Modern (ID与我的结果不匹配,但您可以跳过ID)
目的: 查找在遍历限制内以某种方式(进出)连接到Marko的所有软件
查询1 :没有重复数据删除
select *
from
(SELECT ROUND(coalesce(SUM(c.ClaimNet), 0), 2) as net,
MAX(c.ClaimID) claimid, count(c.ClaimID) as claims,
MAX(h.TransactionDate) as TransactionDate,
'Resubmission' AS 'Claim Type'
FROM Claim c
LEFT OUTER JOIN ClaimHeader h on h.HeaderID = c.HeaderPKID
INNER JOIN Resubmission r ON r.ClaimID = c.ClaimPKID WHERE h.HeaderType=2
UNION ALL
SELECT ROUND(coalesce(SUM(c.ClaimNet), 0), 2) as net,
MAX(c.ClaimID), count(c.ClaimID) as claims,
MAX(h.TransactionDate) as TransactionDate,
'First Submission' AS 'Claim Type'
FROM Claim c
LEFT OUTER JOIN ClaimHeader h on h.HeaderID = c.HeaderPKID
WHERE ClaimPKID NOT IN
( SELECT ClaimID FROM Resubmission GROUP BY ClaimID ) AND HeaderType=2) claims
where claims.claims <> 0
查询1的结果:
g.V().hasLabel("Person").has("name", "Marko").as("from")
.repeat(both().as("to").simplePath().barrier())
.emit(loops().is(lt(4)).and().hasLabel("Software")) .path().as("p")
.select("from", "to").by("name").as("data") .select("p", "data")
查询2 :带重复数据删除
{'p': [v[10224], v[10220]], 'data': {'from': 'Marko', 'to': 'lop'}}
{'p': [v[10224], v[10226], v[10220]], 'data': {'from': 'Marko', 'to': 'lop'}}
{'p': [v[10224], v[10226], v[10222]], 'data': {'from': 'Marko', 'to': 'ripple'}}
{'p': [v[10224], v[10220], v[10226], v[10222]], 'data': {'from': 'Marko', 'to': 'ripple'}}
查询2的结果:
g.V().hasLabel("Person").has("name", "Marko").as("from")
.repeat(both().as("to").simplePath().barrier())
.emit(loops().is(lt(4)).and().hasLabel("Software"))
.dedup("from", "to")
.path().as("p")
.select("from", "to").by("name").as("data")
.select("p", "data")
问题:
答案 0 :(得分:1)
请注意,window.smoothScroll = function(target) {
var scrollContainer = target;
do { //find scroll container
scrollContainer = scrollContainer.parentNode;
if (!scrollContainer) return;
scrollContainer.scrollTop += 1;
} while (scrollContainer.scrollTop == 0);
var targetY = 0;
do { //find the top of target relatively to the container
if (target == scrollContainer) break;
targetY += target.offsetTop;
} while (target = target.offsetParent);
scroll = function(c, a, b, i) {
i++; if (i > 30) return;
c.scrollTop = a + (b - a) / 30 * i;
setTimeout(function(){ scroll(c, a, b, i); }, 20);
}
// start scrolling
scroll(scrollContainer, scrollContainer.scrollTop, targetY, 0);
}
遍历不是中断条件。您的遍历将继续,直到没有更简单的路径。此外,您应该emit()
内dedup()
,因为没有任何意义可以进一步遵循重复路径(基于repeat()
和from
顶点)。
to
这应该以最有效的方式做你想做的事。
g = TinkerFactory.createModern().traversal()
g.V().has("person","name","marko").as("from").
repeat(both().as("to").dedup("from","to")).
times(3).
emit(hasLabel("software")).
hasLabel("software").
project("p","data").
by(path()).
by(select(last, "from", "to").by("name"))