1
在Gremlin-Groovy中,給定TinkerVertex對象,什麼是最快/最快速的方式來檢索與其屬性中的鍵對應的值,如果返回默認值if它不存在(如null
)?獲取與TinkerVertex的屬性中的鍵對應的值
這是我當前如何做它:
def eval(vertex, field) {
prop = vertex.property(field)
prop.isPresent() ? prop.value() : null
}
當頂點不具備所需的字段vertex.property(field).value()
產生異常,所以我必須補充一點情況。
即使它有點矮,這個操作一直都在進行,它讓我感到我還沒有找到更多的「gremlinish」解決方案。