public static String formatKey(HugeKeys key) { return key.name(); }
private static String table(Directions direction) { assert direction == Directions.OUT || direction == Directions.IN; return TABLE_PREFIX + "_" + direction.string(); }
private <V> V convSingleValue(V value) { if (this.dataType().isNumber()) { @SuppressWarnings("unchecked") V number = (V) this.dataType().valueToNumber(value); return number; } else if (this.dataType().isDate()) { @SuppressWarnings("unchecked") V date = (V) this.dataType().valueToDate(value); return date; } else if (this.dataType().isUUID()) { @SuppressWarnings("unchecked") V uuid = (V) this.dataType().valueToUUID(value); return uuid; } return value; }
public static final HugeKeys parseKey(String name) { return HugeKeys.valueOf(name.toUpperCase()); }
public String column(HugeKeys column) { return this.columns.get(column.string()); }
@Override public BackendEntry writePropertyKey(PropertyKey propertyKey) { TableBackendEntry entry = newBackendEntry(propertyKey); entry.column(HugeKeys.ID, propertyKey.id().asLong()); entry.column(HugeKeys.NAME, propertyKey.name()); entry.column(HugeKeys.DATA_TYPE, propertyKey.dataType().code()); entry.column(HugeKeys.CARDINALITY, propertyKey.cardinality().code()); entry.column(HugeKeys.PROPERTIES, this.toLongSet(propertyKey.properties())); this.writeUserdata(propertyKey, entry); entry.column(HugeKeys.STATUS, propertyKey.status().code()); return entry; }
public EdgeId switchDirection() { Directions direction = this.direction.opposite(); return new EdgeId(this.otherVertexId, direction, this.edgeLabelId, this.sortValues, this.ownerVertexId, this.directed); }
/** * Check type of the value valid * @param value the property value to be checked data type * @return true if the value is or can convert to the data type, * otherwise false */ public <V> boolean checkDataType(V value) { if (value instanceof Number) { return this.dataType().valueToNumber(value) != null; } return this.dataType().clazz().isInstance(value); }
private <T extends SerialEnum> T readEnum(HugeKeys key, Class<T> clazz) { byte[] value = column(key); E.checkState(value.length == 1, "The length of column '%s' must be 1, but is '%s'", key, value.length); return SerialEnum.fromCode(clazz, value[0]); }
public Id indexField() { E.checkState(this.indexType == IndexType.RANGE || this.indexType == IndexType.SEARCH, "Can't call indexField() for %s index label", this.indexType.string()); E.checkState(this.indexFields.size() == 1, "There should be only one field in %s index label, " + "but got: %s", this.indexType.string(), this.indexFields); return this.indexFields.get(0); }
public <V> UUID valueToUUID(V value) { if (value instanceof UUID) { return (UUID) value; } if (this.isUUID() && value instanceof String) { return java.util.UUID.fromString((String) value); } return null; } }
@Override public HugeType type() { return this.indexLabel.indexType().type(); }
private void writeEnum(HugeKeys key, SerialEnum value) { this.entry.column(formatColumnName(key), new byte[]{value.code()}); }
public static HugeKeys parseKey(String name) { return HugeKeys.valueOf(name.toUpperCase()); }
public void column(HugeKeys column, String value) { this.columns.put(column.string(), value); }
public static final String formatKey(HugeKeys key) { return key.name(); }
public static String table(Directions direction) { assert direction == Directions.OUT || direction == Directions.IN; return TABLE_PREFIX + "_" + direction.string(); }
@Override public String toString() { return String.format("{label=%s<%s>, fieldValues=%s, elementIds=%s}", this.indexLabel.name(), this.indexLabel.indexType().string(), this.fieldValues, this.elementIds); }
private String formatSyspropName(HugeKeys col) { return this.formatSyspropName(col.string()); }