The Wayback Machine - https://web.archive.org/web/20200905062428/https://github.com/JanusGraph/janusgraph/issues/1984
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Data type of auto-created property key is inferred, not fixed Object.class #1984

Open
li-boxuan opened this issue Feb 25, 2020 · 0 comments

Comments

@li-boxuan
Copy link
Contributor

@li-boxuan li-boxuan commented Feb 25, 2020

The doc on https://docs.janusgraph.org/basics/schema/#automatic-schema-maker says automatically created property key has data type Object.class

By default, implicitly created edge labels have multiplicity MULTI and implicitly created property keys have cardinality SINGLE and data type Object.class.

However, my testing shows that Default Schema Maker automatically infers the type of property key, and only uses data type Object.class when the given value is not of any native JanusGraph Data Type (Integer, String, etc.). See the relevant code snippet:

public PropertyKey makePropertyKey(PropertyKeyMaker factory, Object value) {
String name = factory.getName();
Class actualClass = determineClass(value);
if (factory.cardinalityIsSet()) {
return factory.dataType(actualClass).make();
}
return factory.cardinality(defaultPropertyCardinality(name)).dataType(actualClass).make();

protected Class determineClass(Object value) {
if (value instanceof String) {
return String.class;
} else if (value instanceof Character) {
return Character.class;
} else if (value instanceof Boolean) {
return Boolean.class;
} else if (value instanceof Byte) {
return Byte.class;
} else if (value instanceof Short) {
return Short.class;
} else if (value instanceof Integer) {
return Integer.class;
} else if (value instanceof Long) {
return Long.class;
} else if (value instanceof Float) {
return Float.class;
} else if (value instanceof Double) {
return Double.class;
} else if (value instanceof Date) {
return Date.class;
} else if (value instanceof Geoshape) {
return Geoshape.class;
} else if (value instanceof UUID) {
return UUID.class;
} else {
return Object.class;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.