use of org.umlg.sqlg.structure.PropertyType in project sqlg by pietermartin.
the class GlobalUniqueIndex method createGlobalUniqueIndex.
@SuppressWarnings("OptionalGetWithoutIsPresent")
static GlobalUniqueIndex createGlobalUniqueIndex(SqlgGraph sqlgGraph, Topology topology, String globalUniqueIndexName, Set<PropertyColumn> properties) {
// all PropertyColumns must be for the same PropertyType
PropertyType propertyType = properties.iterator().next().getPropertyType();
Map<String, PropertyType> valueColumn = new HashMap<>();
valueColumn.put(GLOBAL_UNIQUE_INDEX_RECORD_ID, PropertyType.STRING);
valueColumn.put(GLOBAL_UNIQUE_INDEX_PROPERTY_NAME, PropertyType.STRING);
valueColumn.put(GLOBAL_UNIQUE_INDEX_VALUE, propertyType);
VertexLabel vertexLabel = topology.getGlobalUniqueIndexSchema().ensureVertexLabelExist(globalUniqueIndexName, valueColumn);
PropertyColumn valuePropertyColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_VALUE).get();
PropertyColumn recordIdColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_RECORD_ID).get();
PropertyColumn propertyColumn = vertexLabel.getProperty(GLOBAL_UNIQUE_INDEX_PROPERTY_NAME).get();
vertexLabel.ensureIndexExists(IndexType.UNIQUE, Collections.singletonList(valuePropertyColumn));
vertexLabel.ensureIndexExists(IndexType.UNIQUE, Arrays.asList(recordIdColumn, propertyColumn));
GlobalUniqueIndex globalUniqueIndex = new GlobalUniqueIndex(topology, globalUniqueIndexName, properties);
topology.getGlobalUniqueIndexSchema().globalUniqueIndexes.put(globalUniqueIndex.getName(), globalUniqueIndex);
TopologyManager.addGlobalUniqueIndex(sqlgGraph, globalUniqueIndexName, properties);
globalUniqueIndex.committed = false;
return globalUniqueIndex;
}
use of org.umlg.sqlg.structure.PropertyType in project sqlg by pietermartin.
the class SQLServerBaseCacheBulkRecord method addValues.
protected void addValues(List<Object> values) {
for (String column : this.columns) {
PropertyType propertyType;
if (this.propertyColumns != null) {
propertyType = this.propertyColumns.get(column).getPropertyType();
} else {
propertyType = this.properties.get(column);
}
Object value = getValue(column);
switch(propertyType) {
case BOOLEAN:
values.add(value);
break;
case BYTE:
case SHORT:
case INTEGER:
case LONG:
case FLOAT:
case DOUBLE:
case JSON:
case STRING:
values.add(value);
break;
case LOCALDATE:
values.add(value.toString());
break;
case LOCALDATETIME:
Timestamp timestamp = Timestamp.valueOf((LocalDateTime) value);
values.add(timestamp.toString());
break;
case LOCALTIME:
values.add(value.toString());
break;
case ZONEDDATETIME:
values.add(((ZonedDateTime) value).toLocalDateTime());
TimeZone tz = TimeZone.getTimeZone(((ZonedDateTime) value).getZone());
values.add(tz.getID());
break;
case PERIOD:
Period period = (Period) value;
values.add(period.getYears());
values.add(period.getMonths());
values.add(period.getDays());
break;
case DURATION:
Duration duration = (Duration) value;
values.add(duration.getSeconds());
values.add(duration.getNano());
break;
case byte_ARRAY:
values.add(value);
break;
case BYTE_ARRAY:
byte[] byteArray = SqlgUtil.convertObjectArrayToBytePrimitiveArray((Object[]) value);
values.add(byteArray);
break;
default:
throw SqlgExceptions.invalidPropertyType(propertyType);
}
}
}
use of org.umlg.sqlg.structure.PropertyType in project sqlg by pietermartin.
the class H2Dialect method putJsonMetaObject.
@Override
public void putJsonMetaObject(ObjectMapper mapper, ArrayNode metaNodeArray, String columnName, int sqlType, Object o) {
switch(sqlType) {
case Types.ARRAY:
try {
ObjectNode metaNode = mapper.createObjectNode();
metaNode.put("name", columnName);
metaNodeArray.add(metaNode);
java.sql.Array sqlA = (java.sql.Array) o;
Object a = sqlA.getArray();
if (Array.getLength(a) > 0) {
PropertyType pt = PropertyType.from(Array.get(a, 0));
switch(pt) {
case BOOLEAN:
metaNode.put("type", PropertyType.boolean_ARRAY.name());
break;
case SHORT:
metaNode.put("type", PropertyType.short_ARRAY.name());
break;
case INTEGER:
metaNode.put("type", PropertyType.int_ARRAY.name());
break;
case LONG:
metaNode.put("type", PropertyType.long_ARRAY.name());
break;
case FLOAT:
metaNode.put("type", PropertyType.float_ARRAY.name());
break;
case DOUBLE:
metaNode.put("type", PropertyType.double_ARRAY.name());
break;
case STRING:
metaNode.put("type", PropertyType.STRING_ARRAY.name());
break;
default:
throw new IllegalStateException("Unknown array sqlType " + sqlType);
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
break;
default:
super.putJsonMetaObject(mapper, metaNodeArray, columnName, sqlType, o);
}
}
Aggregations