use of com.baidu.hugegraph.structure.HugeIndex.IdWithExpiredTime in project incubator-hugegraph by apache.
the class TextSerializer method readElementIds.
private static IdWithExpiredTime[] readElementIds(String str) {
Object[] values = JsonUtil.fromJson(str, Object[].class);
IdWithExpiredTime[] ids = new IdWithExpiredTime[values.length];
for (int i = 0; i < values.length; i++) {
Object idValue;
long expiredTime;
if (values[i] instanceof Map) {
@SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) values[i];
idValue = map.get(HugeKeys.ID.string());
expiredTime = ((Number) map.get(HugeKeys.EXPIRED_TIME.string())).longValue();
} else {
idValue = values[i];
expiredTime = 0L;
}
Id id;
if (idValue instanceof Number) {
id = IdGenerator.of(((Number) idValue).longValue());
} else {
assert idValue instanceof String;
id = IdGenerator.of(idValue.toString());
}
ids[i] = new IdWithExpiredTime(id, expiredTime);
}
return ids;
}
use of com.baidu.hugegraph.structure.HugeIndex.IdWithExpiredTime in project incubator-hugegraph by apache.
the class TextSerializer method readIndex.
@Override
public HugeIndex readIndex(HugeGraph graph, ConditionQuery query, BackendEntry backendEntry) {
E.checkNotNull(graph, "serializer graph");
if (backendEntry == null) {
return null;
}
TextBackendEntry entry = this.convertEntry(backendEntry);
String indexValues = entry.column(formatSyspropName(HugeKeys.FIELD_VALUES));
String indexLabelId = entry.column(formatSyspropName(HugeKeys.INDEX_LABEL_ID));
String elemIds = entry.column(formatSyspropName(HugeKeys.ELEMENT_IDS));
IndexLabel indexLabel = IndexLabel.label(graph, readId(indexLabelId));
HugeIndex index = new HugeIndex(graph, indexLabel);
index.fieldValues(JsonUtil.fromJson(indexValues, Object.class));
for (IdWithExpiredTime elemId : readElementIds(elemIds)) {
long expiredTime = elemId.expiredTime();
Id id;
if (indexLabel.queryType().isEdge()) {
id = EdgeId.parse(elemId.id().asString());
} else {
id = elemId.id();
}
index.elementIds(id, expiredTime);
}
// Memory backend might return empty BackendEntry
return index;
}
Aggregations