public String getType() { return delegate.getType(); }
/** * Compares current index configuration with new signature. * Used to decide if index should be dropped and re-created or its completely equal to new signature. * * @param signs original index signs to compare * @return matcher object to specify new signature signs (order is important!) */ @SuppressWarnings("PMD.LinguisticNaming") public IndexMatchVerifier isIndexSigns(final Object... signs) { final List<Object> idxsigns = Lists.newArrayList(); idxsigns.add(index.getType()); idxsigns.addAll(Arrays.asList(signs)); return new IndexMatchVerifier(idxsigns); }
/** * Checks that current index type is equal to one of provided types. * If not, exception thrown. Type check is important for fulltext and lucene indexes because, * most likely, if existing index type is different from that specific index type then index name was set * by mistake and to avoid replacing existing index error should be thrown (programmer mistake). * * @param types allowed index types */ public void checkTypeCompatible(final OClass.INDEX_TYPE... types) { final Set<String> allowed = Sets.newHashSet(Iterables.transform(Arrays.asList(types), new Function<OClass.INDEX_TYPE, String>() { @Nonnull @Override public String apply(@Nonnull final OClass.INDEX_TYPE input) { return input.name(); } })); check(allowed.contains(index.getType()), "Existing index '%s' (class '%s') type '%s' is incompatible with '%s'. " + "Either drop existing index or rename index.", index.getName(), index.getDefinition().getClassName(), index.getType(), Joiner.on(',').join(allowed)); }
return -1; final OClass.INDEX_TYPE indexType = OClass.INDEX_TYPE.valueOf(index.getType()); final boolean isComposite = isComposite(index); final boolean supportNullValues = supportNullValues(index);
@Override protected OIndex<?> createInstance(OIndex proxy) { OSchema schema = OrientDbWebSession.get().getDatabase().getMetadata().getSchema(); OClass oClass = schema.getClass(proxy.getDefinition().getClassName()); String name = proxy.getName(); List<String> fields = proxy.getDefinition().getFields(); String type = proxy.getType(); if(name==null) name=oClass.getName()+"."+fields.get(0); ODocument metadata = proxy.getMetadata(); String algorithm = proxy.getAlgorithm(); values.keySet().retainAll(RW_ATTRS); return oClass.createIndex(name, type, null, metadata, algorithm, fields.toArray(new String[0])); }
@Override protected OIndex<?> createInstance(OIndex proxy) { OSchema schema = OrientDbWebSession.get().getDatabase().getMetadata().getSchema(); OClass oClass = schema.getClass(proxy.getDefinition().getClassName()); String name = proxy.getName(); List<String> fields = proxy.getDefinition().getFields(); String type = proxy.getType(); if(name==null) name=oClass.getName()+"."+fields.get(0); ODocument metadata = proxy.getMetadata(); String algorithm = proxy.getAlgorithm(); values.keySet().retainAll(RW_ATTRS); return oClass.createIndex(name, type, null, metadata, algorithm, fields.toArray(new String[0])); }
@Override public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) { if (!index.getType().toLowerCase().contains("fulltext")) { return null; } if (index.getAlgorithm() == null || !index.getAlgorithm().toLowerCase().contains("lucene")) { return null; } Set<OIdentifiable> indexResult = (Set<OIdentifiable>) index .get(new OLuceneKeyAndMetadata(new OLuceneCompositeKey(keyParams).setContext(iContext), new ODocument())); if (indexResult == null) return new OIndexCursorSingleValue((OIdentifiable) indexResult, new OLuceneCompositeKey(keyParams)); return new OIndexCursorCollectionValue(indexResult, new OLuceneCompositeKey(keyParams)); }
if (!unique || oIndex.getType().equals(INDEX_TYPE.UNIQUE.name())) indexes.add(oIndex); boolean notUniqueIndex = !(idx.getType().equals(INDEX_TYPE.UNIQUE.name())); res.setProperty("INDEX_QUALIFIER", (Object) null); res.setProperty("INDEX_NAME", idx.getName()); res.setProperty("TYPE", idx.getType()); res.setProperty("ORDINAL_POSITION", 0); res.setProperty("COLUMN_NAME", fieldNames.substring(1, fieldNames.length() - 1));
row.field("TYPE", index.getType()); row.field("RECORDS", indexSize);
@Override public ResultSet getPrimaryKeys(final String catalog, final String schema, final String table) throws SQLException { database.activateOnCurrentThread(); final Set<OIndex<?>> classIndexes = database.getMetadata().getIndexManager().getClassIndexes(table); final Set<OIndex<?>> uniqueIndexes = new HashSet<>(); for (OIndex<?> oIndex : classIndexes) { if (oIndex.getType().equals(INDEX_TYPE.UNIQUE.name())) uniqueIndexes.add(oIndex); } final OInternalResultSet resultSet = new OInternalResultSet(); for (OIndex<?> unique : uniqueIndexes) { int keyFiledSeq = 1; for (String keyFieldName : unique.getDefinition().getFields()) { final OResultInternal res = new OResultInternal(); res.setProperty("TABLE_CAT", catalog); res.setProperty("TABLE_SCHEM", catalog); res.setProperty("TABLE_NAME", table); res.setProperty("COLUMN_NAME", keyFieldName); res.setProperty("KEY_SEQ", keyFiledSeq); res.setProperty("PK_NAME", unique.getName()); keyFiledSeq++; resultSet.add(res); } } return new OrientJdbcResultSet(new OrientJdbcStatement(connection), resultSet, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); }
writer.beginObject(2, true, null); writer.writeAttribute(3, true, "name", index.getName()); writer.writeAttribute(3, true, "type", index.getType()); if (index.getAlgorithm() != null) writer.writeAttribute(3, true, "algorithm", index.getAlgorithm());
private static RecordType getRecordType(OClass oClass) { RecordType type = new RecordType(oClass.getName()); for (OProperty oProperty : oClass.properties()) { OType oType = oProperty.getType(); Class javaType = oType.getDefaultJavaType(); if (oType == OType.LINK) { javaType = RecordId.class; } FieldDefinition field = new FieldDefinition(oProperty.getName(), javaType); field.withNotNull(oProperty.isNotNull()); for (OIndex oIndex : oProperty.getAllIndexes()) { OIndexDefinition def = oIndex.getDefinition(); if (def.isAutomatic() && def.getFields().size() == 1) { boolean unique = oIndex.getType().equalsIgnoreCase(INDEX_TYPE.UNIQUE.name()); field.withIndexed(true).withUnique(unique); } } type.withField(field); } type.withStrict(oClass.isStrictMode()); OClass oSuperClass = oClass.getSuperClass(); if (oSuperClass != null) { type.withSuperType(getRecordType(oSuperClass)); } type.withAbstract(oClass.isAbstract()); return type; }
if (!indexOne.getType().equals(indexTwo.getType())) { ok = false; listener.onMessage("\n- ERR: Index types for index " + indexOne.getName() + " are different."); listener.onMessage("\n--- DB1: " + indexOne.getType()); listener.onMessage("\n--- DB2: " + indexTwo.getType()); listener.onMessage("\n"); ++differences; if (((compareEntriesForAutomaticIndexes && !indexOne.getType().equals("DICTIONARY")) || !indexOne.isAutomatic())) { final OIndexKeyCursor indexKeyCursorOne = makeDbCall(databaseOne, new ODbRelatedCall<OIndexKeyCursor>() { public OIndexKeyCursor call(ODatabaseDocumentInternal database) {