Examples of OIndexDefinition


Examples of com.orientechnologies.orient.core.index.OIndexDefinition

           throw new IllegalArgumentException("Index's entry value is null");

         record = new ODocument().fromJSON(iRequest.content);
       }

       final OIndexDefinition indexDefinition = index.getDefinition();
       final Object key;
       if (indexDefinition != null)
         key = indexDefinition.createValue(urlParts[3]);
       else
         key = urlParts[3];

       if (key == null)
         throw new IllegalArgumentException("Invalid key value : " + urlParts[3]);
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

      for (final OIndex<?> index : indexes) {
        json.beginObject(4, true, null);
        json.writeAttribute(4, true, "name", index.getName());
        json.writeAttribute(4, true, "type", index.getType());

        final OIndexDefinition indexDefinition = index.getDefinition();
        if (indexDefinition != null && !indexDefinition.getFields().isEmpty())
          json.writeAttribute(4, true, "fields", indexDefinition.getFields());
        json.endObject(3, true);
      }
      json.endCollection(1, true);
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

            } else
              collatesList.add(null);
          }
        }

        final OIndexDefinition idxDef = OIndexDefinitionFactory.createIndexDefinition(oClass, Arrays.asList(fields),
            Arrays.asList(keyTypes), collatesList);

        idx = database.getMetadata().getIndexManager()
            .createIndex(indexName, indexType.name(), idxDef, oClass.getPolymorphicClusterIds(), null, metadataDoc, engine);
      }
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

       for (final OIndex<?> index : indexes) {
         json.beginObject(4, true, null);
         json.writeAttribute(4, true, "name", index.getName());
         json.writeAttribute(4, true, "type", index.getType());

         final OIndexDefinition indexDefinition = index.getDefinition();
         if (indexDefinition != null && !indexDefinition.getFields().isEmpty())
           json.writeAttribute(4, true, "fields", indexDefinition.getFields());
         json.endObject(3, true);
       }
       json.endCollection(1, true);
     }
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

      message("\n\nINDEXES (" + indexes.size() + " altogether)");
      message("\n-------------------------------+----------------+");
      message("\n NAME                          | PROPERTIES     |");
      message("\n-------------------------------+----------------+");
      for (final OIndex<?> index : indexes) {
        final OIndexDefinition indexDefinition = index.getDefinition();
        if (indexDefinition != null) {
          final List<String> fields = indexDefinition.getFields();
          message("\n %-30s| %-15s|", index.getName(), fields.get(0) + (fields.size() > 1 ? " (+)" : ""));

          for (int i = 1; i < fields.size(); i++) {
            if (i < fields.size() - 1)
              message("\n %-30s| %-15s|", "", fields.get(i) + " (+)");
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

        }
      });

      for (final OIndex<?> index : indexes) {
        try {
          final OIndexDefinition indexDefinition = index.getDefinition();
          final long size = index.getKeySize();
          if (indexDefinition == null || indexDefinition.getClassName() == null) {
            message("\n %-45s| %-10s | %-22s| %-15s|%11d |", format(index.getName(), 45), format(index.getType(), 10), "", "", size);
          } else {
            final List<String> fields = indexDefinition.getFields();
            if (fields.size() == 1) {
              message("\n %-45s| %-10s | %-22s| %-15s|%11d |", format(index.getName(), 45), format(index.getType(), 10),
                  format(indexDefinition.getClassName(), 22), format(fields.get(0), 10), size);
            } else {
              message("\n %-45s| %-10s | %-22s| %-15s|%11d |", format(index.getName(), 45), format(index.getType(), 10),
                  format(indexDefinition.getClassName(), 22), format(fields.get(0), 10), size);
              for (int i = 1; i < fields.size(); i++) {
                message("\n %-45s| %-10s | %-22s| %-15s|%11s |", "", "", "", fields.get(i), "");
              }
            }
          }
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

  }

  @Override
  public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) {

    final OIndexDefinition indexDefinition = index.getDefinition();
    if (indexDefinition.getParamCount() > 1)
      return null;

    final OIndex<?> internalIndex = index.getInternal();

    OIndexCursor cursor;
    if (internalIndex instanceof OIndexFullText) {
      final Object key = indexDefinition.createValue(keyParams);
      final Object indexResult = index.get(key);

      if (indexResult == null || indexResult instanceof OIdentifiable)
        cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, key);
      else
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

    return OIndexReuseType.NO_INDEX;
  }

  @Override
  public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) {
    final OIndexDefinition indexDefinition = index.getDefinition();

    OIndexCursor cursor;
    final OIndexInternal<?> internalIndex = index.getInternal();
    if (!internalIndex.canBeUsedInEqualityOperators())
      return null;

    if (indexDefinition.getParamCount() == 1) {
      final Object key;
      if (indexDefinition instanceof OIndexDefinitionMultiValue)
        key = ((OIndexDefinitionMultiValue) indexDefinition).createSingleValue(keyParams.get(0));
      else
        key = indexDefinition.createValue(keyParams);

      if (key == null)
        return null;

      final Object indexResult;

      indexResult = index.get(key);

      if (indexResult == null || indexResult instanceof OIdentifiable)
        cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, key);
      else
        cursor = new OIndexCursorCollectionValue(((Collection<OIdentifiable>) indexResult).iterator(), key);
    } else {
      // in case of composite keys several items can be returned in case of we perform search
      // using part of composite key stored in index.

      final OCompositeIndexDefinition compositeIndexDefinition = (OCompositeIndexDefinition) indexDefinition;

      final Object keyOne = compositeIndexDefinition.createSingleValue(keyParams);

      if (keyOne == null)
        return null;

      final Object keyTwo = compositeIndexDefinition.createSingleValue(keyParams);
      if (internalIndex.hasRangeQuerySupport()) {
        cursor = index.iterateEntriesBetween(keyOne, true, keyTwo, true, ascSortOrder);
      } else {
        int indexParamCount = indexDefinition.getParamCount();
        if (indexParamCount == keyParams.size()) {
          final Object indexResult;
          indexResult = index.get(keyOne);

          if (indexResult == null || indexResult instanceof OIdentifiable)
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

  private OIndexUnique mockUniqueIndex() {
    final OIndexUnique uniqueIndex = mock(OIndexUnique.class);
    when(uniqueIndex.getInternal()).thenReturn(uniqueIndex);

    final OIndexDefinition definition = mock(OIndexDefinition.class);
    when(definition.getParamCount()).thenReturn(1);

    when(uniqueIndex.getDefinition()).thenReturn(definition);
    when(uniqueIndex.getType()).thenReturn(OClass.INDEX_TYPE.UNIQUE.toString());

    return uniqueIndex;
View Full Code Here

Examples of com.orientechnologies.orient.core.index.OIndexDefinition

  private OIndexUnique mockUniqueCompositeIndex() {
    final OIndexUnique uniqueIndex = mock(OIndexUnique.class);
    when(uniqueIndex.getInternal()).thenReturn(uniqueIndex);

    final OIndexDefinition definition = mock(OIndexDefinition.class);
    when(definition.getParamCount()).thenReturn(2);

    when(uniqueIndex.getDefinition()).thenReturn(definition);
    when(uniqueIndex.getType()).thenReturn(OClass.INDEX_TYPE.UNIQUE.toString());

    return uniqueIndex;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.