下面列出了怎么用org.apache.tinkerpop.gremlin.structure.util.empty.EmptyVertexProperty的API类实例代码及写法,或者点击链接到github查看源代码。
private List<Object> project(Map<String, String> fieldToTableMap, List<String> fields,
List<Map<String, ? extends Element>> results,
Map<String, TableDef> tableIdToTableDefMap) {
final List<Object> rows = new ArrayList<>(results.size());
Map<String, String> labelTableIdMap = new HashMap<>();
for (Map.Entry<String, TableDef> entry : tableIdToTableDefMap.entrySet()) {
labelTableIdMap.put(entry.getValue().label.toLowerCase(), entry.getKey());
}
for(Map<String, ? extends Element> result : results) {
final Object[] row = new Object[fields.size()];
int column = 0;
for(String field : fields) {
String tableId = fieldToTableMap.get(field);
String simpleFieldName = Character.isDigit(field.charAt(field.length()-1)) ?
field.substring(0, field.length()-1) : field;
simpleFieldName = Character.isDigit(field.charAt(simpleFieldName.length()-1)) ?
simpleFieldName.substring(0, simpleFieldName.length()-1) : simpleFieldName;
// check for primary & fks
final int keyIndex = simpleFieldName.toLowerCase().indexOf("_id");
Object val = null;
if(keyIndex > 0) {
// is it a pk or fk?
String key = simpleFieldName.substring(0, keyIndex);
String tableLabel = tableIdToTableDefMap.get(tableId).label;
if(tableLabel.toLowerCase().equals(key.toLowerCase())) {
val = result.get(tableId).id();
} else {
String fkTableId = labelTableIdMap.get(key.toLowerCase());
if(result.containsKey(fkTableId)) {
val = result.get(fkTableId).id();
}
}
}
final Property<Object> property = result.get(tableId).
property(tableIdToTableDefMap.get(tableId).getColumn(simpleFieldName.toLowerCase()).getPropertyName());
if(!(property instanceof EmptyProperty || property instanceof EmptyVertexProperty)) {
if(result.get(tableId).label().equals(tableIdToTableDefMap.get(tableId).label)) {
val = property.value();
} else {
val = null;
}
}
if(tableIdToTableDefMap.get(tableId).getColumn(field) != null && val != null) {
row[column++] = TableUtil.convertType(val, tableIdToTableDefMap.get(tableId).getColumn(field));
} else {
row[column++] = val;
}
}
rows.add(row);
}
return rows;
}
/**
* Constructs an empty {@code VertexProperty}.
*/
public static <V> VertexProperty<V> empty() {
return EmptyVertexProperty.instance();
}