use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class LindenUtil method parseDynamicFieldSchema.
public static LindenFieldSchema parseDynamicFieldSchema(String name) {
LindenFieldSchema fieldSchema = new LindenFieldSchema();
// Linden dynamic field is always indexed and stored
fieldSchema.setStored(true);
fieldSchema.setIndexed(true);
fieldSchema.setDynamicSchema(true);
int idx = name.lastIndexOf(LindenSchemaConf.DYNAMIC_TYPE_SEPARATOR);
String tag = idx >= 0 ? name.substring(idx + 1) : "";
switch(tag.toLowerCase()) {
case LindenSchemaConf.INT:
fieldSchema.setName(name.substring(0, idx));
fieldSchema.setType(LindenType.INTEGER);
break;
case LindenSchemaConf.LONG:
fieldSchema.setName(name.substring(0, idx));
fieldSchema.setType(LindenType.LONG);
break;
case LindenSchemaConf.DOUBLE:
fieldSchema.setName(name.substring(0, idx));
fieldSchema.setType(LindenType.DOUBLE);
break;
case LindenSchemaConf.FLOAT:
fieldSchema.setName(name.substring(0, idx));
fieldSchema.setType(LindenType.FLOAT);
break;
case LindenSchemaConf.STRING:
fieldSchema.setName(name.substring(0, idx));
fieldSchema.setType(LindenType.STRING);
break;
case LindenSchemaConf.FACET:
fieldSchema.setName(name.substring(0, idx));
fieldSchema.setType(LindenType.FACET);
break;
default:
// default field type is STRING
fieldSchema.setName(name);
fieldSchema.setType(LindenType.STRING);
break;
}
return fieldSchema;
}
use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class BQLCompilerAnalyzer method getFieldNameAndType.
private Map.Entry<String, LindenType> getFieldNameAndType(String col) {
LindenType type = fieldTypeMap.get(col);
if (type != null) {
return new AbstractMap.SimpleEntry<>(col, type);
}
LindenFieldSchema fieldSchema = LindenUtil.parseDynamicFieldSchema(col);
return new AbstractMap.SimpleEntry<>(fieldSchema.getName(), fieldSchema.getType());
}
use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class TestHotSwapLindenCore method init.
public void init() throws Exception {
LindenSchema schema = new LindenSchema().setId("id");
schema.addToFields(new LindenFieldSchema().setName("title").setIndexed(true).setStored(true).setTokenized(true));
lindenConfig = new LindenConfig();
lindenConfig.setClusterUrl("127.0.0.1:2181/test");
lindenConfig.setSchema(schema);
String path = FilenameUtils.concat(TestMultiLindenCore.class.getResource("./").getPath(), "index/");
FileUtils.deleteQuietly(new File(path));
lindenConfig.setIndexDirectory(path);
lindenConfig.setLindenCoreMode(LindenConfig.LindenCoreMode.HOTSWAP);
}
use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class TestLindenAggregation method init.
@Override
public void init() throws Exception {
LindenSchema schema = new LindenSchema().setId("id");
schema.addToFields(new LindenFieldSchema().setName("intValue").setType(LindenType.INTEGER).setDocValues(true));
lindenConfig.setSchema(schema);
}
use of com.xiaomi.linden.thrift.common.LindenFieldSchema in project linden by XiaoMi.
the class TestLindenDynamicField method init.
@Override
public void init() {
schema = new LindenSchema().setId("id");
schema.addToFields(new LindenFieldSchema("name", LindenType.STRING).setIndexed(true).setTokenized(true).setStored(true));
schema.addToFields(new LindenFieldSchema("level", LindenType.STRING).setIndexed(true).setStored(true));
schema.addToFields(new LindenFieldSchema("log", LindenType.STRING).setIndexed(true).setTokenized(true).setStored(true));
schema.addToFields(new LindenFieldSchema("host", LindenType.STRING).setIndexed(true).setStored(true));
schema.addToFields(new LindenFieldSchema("shard", LindenType.INTEGER).setIndexed(true).setStored(true));
lindenConfig.setSchema(schema);
}
Aggregations