本文整理汇总了Java中com.orientechnologies.orient.core.metadata.schema.OClass.createIndex方法的典型用法代码示例。如果您正苦于以下问题:Java OClass.createIndex方法的具体用法?Java OClass.createIndex怎么用?Java OClass.createIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.metadata.schema.OClass
的用法示例。
在下文中一共展示了OClass.createIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupTypesAndIndices
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
/**
* Setup some indices. This is highly orientdb specific and may not be easy so setup using blueprint API.
*/
private void setupTypesAndIndices() {
try (Tx tx = graph.tx()) {
OrientGraph g = ((OrientGraph) ((DelegatingFramedOrientGraph) tx.getGraph()).getBaseGraph());
ODatabaseDocument rawDb = g.getRawDatabase();
OClass e = rawDb.createEdgeClass("HAS_MEMBER");
e.createProperty("in", OType.LINK);
e.createProperty("out", OType.LINK);
e.createIndex("e.has_member", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "out", "in");
OClass v = rawDb.createVertexClass(Group.class.getSimpleName());
v.createProperty("name", OType.STRING);
v = rawDb.createVertexClass(Person.class.getSimpleName());
v.createProperty("name", OType.STRING);
v.createIndex(Person.class.getSimpleName() + ".name", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "name");
tx.success();
}
}
示例2: initTableClass
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
private void initTableClass()
{
OObjectDatabaseTx objectDatabaseTx = getObjectDatabaseTx();
OClass oClass = objectDatabaseTx.getMetadata().getSchema().getClass(Transaction.class);
if (oClass != null && !oClass.areIndexed("tid"))
{
oClass.createIndex("TransactionIdUnique", OClass.INDEX_TYPE.UNIQUE, "tid");
}
oClass = objectDatabaseTx.getMetadata().getSchema().getClass(ProfileData.class);
if (oClass != null && !oClass.areIndexed("tid", "sequence"))
{
oClass.createIndex("TransactionIdSequenceUnique", OClass.INDEX_TYPE.UNIQUE, "tid", "sequence");
}
objectDatabaseTx.close();
}
示例3: register
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
protected <T> void register(OObjectDatabaseTx db, OSchema schema, Class<T> aClass) {
if (schema.getClass(aClass.getSimpleName()) == null) {
db.getEntityManager().registerEntityClasses(aClass, true);
OClass cls = db.getMetadata().getSchema().getClass(aClass);
String indexName = aClass.getName() + ".unq";
Table t = aClass.getAnnotation(Table.class);
if (t != null) {
Set<String> fields = new HashSet<>();
for (UniqueConstraint uc : t.uniqueConstraints()) {
fields.addAll(Lists.newArrayList(uc.columnNames()));
}
if (fields.size() > 0) {
LOG.info("Registering unique constraint for fields: " + fields);
for (String field : fields)
cls.createIndex(indexName + "." + field, OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, field);
}
}
} else {
db.getEntityManager().registerEntityClasses(aClass, true);
}
}
示例4: upgradeSchema
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
public void upgradeSchema() throws Exception {
log.debug("Updgrading schema for trust store");
try (ODatabaseDocumentTx db = databaseInstance.get().connect()) {
OSchema schema = db.getMetadata().getSchema();
OClass type = schema.getClass(DB_CLASS);
if (type == null) {
type = schema.createClass(DB_CLASS);
type.createProperty(P_NAME, OType.STRING).setMandatory(true).setNotNull(true);
type.createProperty(P_BYTES, OType.BINARY).setMandatory(true).setNotNull(true);
type.createIndex(I_NAME, INDEX_TYPE.UNIQUE, P_NAME);
log.debug("Created schema type {}: properties={}, indexes={}", type, type.properties(), type.getIndexes());
}
else {
// NOTE: Upgrade steps run on each node but within a cluster, another node might already have upgraded the db
log.debug("Skipped creating existing schema type {}: properties={}, indexes={}", type, type.properties(),
type.getIndexes());
}
}
}
示例5: defineType
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
@Override
protected void defineType(final OClass type) {
type.createProperty(P_REPOSITORY_NAME, OType.STRING).setMandatory(true).setNotNull(true);
type.createProperty(P_ASSET_NAME, OType.STRING).setMandatory(true).setNotNull(true);
type.createProperty(P_NODE_ID, OType.STRING).setMandatory(true).setNotNull(true);
type.createProperty(P_COUNT, OType.LONG).setMandatory(true).setNotNull(true);
type.createProperty(P_DATE_TYPE, OType.STRING).setMandatory(true).setNotNull(true);
type.createProperty(P_DATE, OType.DATETIME).setMandatory(true).setNotNull(true);
type.createIndex(I_REPO_NAME_ASSET_NAME_DATE_TYPE_DATE, INDEX_TYPE.NOTUNIQUE, P_REPOSITORY_NAME, P_ASSET_NAME,
P_DATE_TYPE, P_DATE);
type.createIndex(I_NODE_ID_REPO_NAME_ASSET_NAME_DATE_TYPE_DATE, INDEX_TYPE.NOTUNIQUE, P_NODE_ID, P_REPOSITORY_NAME,
P_ASSET_NAME, P_DATE_TYPE, P_DATE);
type.createIndex(I_NODE_ID_DATE_TYPE_DATE, INDEX_TYPE.NOTUNIQUE, P_NODE_ID, P_DATE_TYPE, P_DATE);
type.createIndex(I_REPO_NAME_DATE_TYPE_DATE, INDEX_TYPE.NOTUNIQUE, P_REPOSITORY_NAME, P_DATE_TYPE);
}
示例6: defineType
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
@Override
protected void defineType(final OClass type) {
type.createProperty(P_APIKEY, OType.STRING)
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_DOMAIN, OType.STRING)
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_PRIMARY_PRINCIPAL, OType.STRING)
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_PRINCIPALS, OType.BINARY)
.setMandatory(true)
.setNotNull(true);
type.createIndex(I_APIKEY, INDEX_TYPE.UNIQUE, P_DOMAIN, P_APIKEY);
type.createIndex(I_PRIMARY_PRINCIPAL, INDEX_TYPE.UNIQUE, P_DOMAIN, P_PRIMARY_PRINCIPAL);
}
示例7: defineType
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
@Override
protected void defineType(final OClass type) {
super.defineType(type);
type.createProperty(P_NAME, OType.STRING)
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_GROUP, OType.STRING)
.setMandatory(true)
.setNotNull(false); // nullable
type.createProperty(P_JOB_TYPE, OType.STRING)
.setMandatory(true)
.setNotNull(true);
type.createIndex(I_NAME_GROUP, INDEX_TYPE.UNIQUE, P_NAME, P_GROUP);
}
示例8: createDocType
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
private void createDocType(final OSchema schema, final String doctype) {
logger.debug("Create document class '{}'", doctype );
OClass page = schema.createClass(doctype);
page.createProperty(String.valueOf(DocumentAttributes.SHA1), OType.STRING).setNotNull(true);
page.createIndex(doctype + "sha1Index", OClass.INDEX_TYPE.NOTUNIQUE, DocumentAttributes.SHA1.toString());
page.createProperty(String.valueOf(DocumentAttributes.SOURCE_URI), OType.STRING).setNotNull(true);
page.createIndex(doctype + "sourceUriIndex", OClass.INDEX_TYPE.UNIQUE, DocumentAttributes.SOURCE_URI.toString());
page.createProperty(String.valueOf(DocumentAttributes.CACHED), OType.BOOLEAN).setNotNull(true);
page.createIndex(doctype + "cachedIndex", OClass.INDEX_TYPE.NOTUNIQUE, DocumentAttributes.CACHED.toString());
page.createProperty(String.valueOf(DocumentAttributes.RENDERED), OType.BOOLEAN).setNotNull(true);
page.createIndex(doctype + "renderedIndex", OClass.INDEX_TYPE.NOTUNIQUE, DocumentAttributes.RENDERED.toString());
page.createProperty(String.valueOf(DocumentAttributes.STATUS), OType.STRING).setNotNull(true);
page.createIndex(doctype + "statusIndex", OClass.INDEX_TYPE.NOTUNIQUE, DocumentAttributes.STATUS.toString());
}
示例9: createSignatureType
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
private void createSignatureType(OSchema schema) {
OClass signatures = schema.createClass("Signatures");
signatures.createProperty(String.valueOf(DocumentAttributes.KEY), OType.STRING).setNotNull(true);
signatures.createIndex("keyIdx", OClass.INDEX_TYPE.NOTUNIQUE, DocumentAttributes.KEY.toString());
signatures.createProperty(String.valueOf(DocumentAttributes.SHA1), OType.STRING).setNotNull(true);
signatures.createIndex("sha1Idx", OClass.INDEX_TYPE.UNIQUE, DocumentAttributes.SHA1.toString());
}
示例10: initTableClass
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
private static void initTableClass()
{
ODatabaseDocumentTx documentTx = factory.getDatabase();
OSchema schema = documentTx.getMetadata().getSchema();
OClass oClass = schema.getClass("Classes");
if (oClass == null)
{
oClass = schema.createClass("Classes");
oClass.createProperty("name", OType.STRING);
oClass.createProperty("byteCode", OType.BINARY);
oClass.createIndex("ClassNameUnique", OClass.INDEX_TYPE.UNIQUE, "name");
}
}
示例11: init
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
@Override
protected void init(OObjectDatabaseTx db, OSchema schema) {
if (schema.getClass("Filter") == null) {
OClass filterClass = schema.createClass("Filter");
filterClass.createProperty("type", OType.STRING);
filterClass.createProperty("value", OType.STRING);
filterClass.createIndex("filter.type.indices", OClass.INDEX_TYPE.FULLTEXT_HASH_INDEX, "type");
filterClass.createIndex("filter.value.indices", OClass.INDEX_TYPE.FULLTEXT_HASH_INDEX, "value");
}
}
示例12: init
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
@Override
public void init() {
try (ODatabaseDocumentTx db = docDb()) {
OSchema schema = db.getMetadata().getSchema();
if (!schema.existsClass(GCP_CONFIG)) {
OClass newClass = schema.createClass(GCP_CONFIG);
newClass.createProperty("hg", OType.STRING);
newClass.createProperty("map", OType.EMBEDDEDMAP);
newClass.createIndex("hg.unq", OClass.INDEX_TYPE.UNIQUE, "hg");
db.commit(true);
db.command(new OCommandSQL("INSERT INTO " + GCP_CONFIG +
" SET hg=\"" + hostGroup + "\", map={}")).execute();
}
fetchFromDb(db);
executor.scheduleAtFixedRate(() -> {
LOG.info("Trying to reload configuration from main DB.");
putLock.writeLock().lock();
try {
if (!isClosed) {
try (ODatabaseDocumentTx _db = docDb()) {
fetchFromDb(_db);
}
}
} finally {
putLock.writeLock().unlock();
}
}, readLong(ConfigProperty.POLL_INTERVAL), readLong(ConfigProperty.POLL_INTERVAL), TimeUnit.MILLISECONDS);
}
}
示例13: defineType
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
@Override
protected void defineType(final OClass type) {
type.createProperty(P_NAME, OType.STRING).setNotNull(true);
type.createProperty(P_TYPE, OType.STRING).setNotNull(true);
type.createProperty(P_CONTENT, OType.STRING).setNotNull(true);
//ensure name is unique as it serves as the ID for a script
type.createIndex(I_NAME, INDEX_TYPE.UNIQUE, P_NAME);
}
示例14: defineType
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
@Override
protected void defineType(final OClass type) {
type.createProperty(P_NAME, OType.STRING)
.setCollate(new OCaseInsensitiveCollate())
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_TYPE, OType.STRING)
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_ATTRIBUTES, OType.EMBEDDEDMAP)
.setMandatory(true)
.setNotNull(true);
type.createIndex(I_NAME, INDEX_TYPE.UNIQUE, P_NAME);
}
示例15: defineType
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
@Override
protected void defineType(final OClass type) {
type.createProperty(P_REPOSITORY_NAME, OType.STRING)
.setCollate(new OCaseInsensitiveCollate())
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_RECIPE_NAME, OType.STRING)
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_ONLINE, OType.BOOLEAN)
.setMandatory(true)
.setNotNull(true);
type.createProperty(P_ATTRIBUTES, OType.EMBEDDEDMAP);
type.createIndex(I_REPOSITORY_NAME, INDEX_TYPE.UNIQUE, P_REPOSITORY_NAME);
}