Examples of OIndex


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

    final OProperty prop = iSchemaClass.getProperty(item.getName());
    if (prop != null && prop.isIndexed()) {
      // TODO: IMPROVE THIS MANAGEMENT
      // ONLY EQUALS IS SUPPORTED NOW!
      OIndex idx = prop.getIndex().getUnderlying();
      idx = idx.getInternal();

      if (((idx instanceof OIndexUnique || idx instanceof OIndexNotUnique) && iCondition.getOperator() instanceof OQueryOperatorEquals)
          || idx instanceof OIndexFullText && iCondition.getOperator() instanceof OQueryOperatorContainsText) {
        Object value = iCondition.getLeft() == iItem ? iCondition.getRight() : iCondition.getLeft();
        if (value != null) {
View Full Code Here

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

      foreach(record);
    }
  }

  private void searchInIndex() {
    final OIndex index = database.getMetadata().getIndexManager().getIndex(compiledFilter.getTargetIndex());
    if (index == null)
      throw new OCommandExecutionException("Target index '" + compiledFilter.getTargetIndex() + "' not found");

    if (compiledFilter.getRootCondition() != null) {
      if (!"KEY".equalsIgnoreCase(compiledFilter.getRootCondition().getLeft().toString()))
        throw new OCommandExecutionException("'Key' field is required for queries against indexes");

      final Object right = compiledFilter.getRootCondition().getRight();

      Collection<OIdentifiable> result = null;
      if (compiledFilter.getRootCondition().getOperator() instanceof OQueryOperatorBetween) {
        final Object[] values = (Object[]) compiledFilter.getRootCondition().getRight();
        result = index.getBetween(OSQLHelper.getValue(values[0]), OSQLHelper.getValue(values[2]));

      } else
        result = index.get(OSQLHelper.getValue(right));

      if (result != null)
        for (OIdentifiable r : result) {
          addResult((ORecord<?>) r);
        }
    } else {
      if (anyFunctionAggregates) {
        for (Entry<String, Object> projection : projections.entrySet()) {
          if (projection.getValue() instanceof OSQLFunctionRuntime) {
            final OSQLFunctionRuntime f = (OSQLFunctionRuntime) projection.getValue();
            f.setResult(index.getSize());
          }
        }
      }
    }
  }
View Full Code Here

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

    if (document.field("linkedType") != null)
      linkedType = OType.getById(((Integer) document.field("linkedType")).byteValue());

    if (document.field("index") != null) {
      if (document.field("index-type") == null) {
        final OIndex underlyingIndex = document.getDatabase().getMetadata().getIndexManager()
            .getIndex((ORecordId) document.field("index", ORID.class));

        if (underlyingIndex != null)
          index = new OPropertyIndex(underlyingIndex, new String[] { name });
        else
View Full Code Here

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

    final OProperty prop = iSchemaClass.getProperty(item.getName());
    if (prop != null && prop.isIndexed()) {
      // TODO: IMPROVE THIS MANAGEMENT
      // ONLY EQUALS IS SUPPORTED NOW!
      OIndex idx = prop.getIndex().getUnderlying();
      if (((idx instanceof OIndexUnique || idx instanceof OIndexNotUnique) && iCondition.getOperator() instanceof OQueryOperatorEquals)
          || idx instanceof OIndexFullText && iCondition.getOperator() instanceof OQueryOperatorContainsText) {
        Object value = iCondition.getLeft() == iItem ? iCondition.getRight() : iCondition.getLeft();
        if (value != null) {
          if (value instanceof OSQLFilterItemParameter)
View Full Code Here

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

  public Object execute(final Map<Object, Object> iArgs) {
    if (fieldNames == null)
      throw new OCommandExecutionException("Can't execute the command because it hasn't been parsed yet");

    if (indexName != null) {
      final OIndex index = database.getMetadata().getIndexManager().getIndex(indexName);
      if (index == null)
        throw new OCommandExecutionException("Target index '" + indexName + "' not found");

      // BIND VALUES
      Object key = null;
      OIdentifiable value = null;
      for (int i = 0; i < fieldNames.size(); ++i) {
        final String fieldName = fieldNames.get(i);
        if (fieldName.equalsIgnoreCase(KEYWORD_KEY))
          key = fieldValues[i];
        else if (fieldName.equalsIgnoreCase(KEYWORD_RID))
          value = (OIdentifiable) fieldValues[i];
      }

      index.put(key, value);
      return null;
    } else {
      // CREATE NEW DOCUMENT
      ODocument doc = className != null ? new ODocument(database, className) : new ODocument(database);
View Full Code Here

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

    do {
      final String indexName = jsonReader.readString(OJSONReader.FIELD_ASSIGNMENT);

      listener.onMessage("\n- Index '" + indexName + "'...");

      final OIndex index = database.getMetadata().getIndexManager().getIndex(indexName);

      long tot = 0;

      jsonReader.readNext(OJSONReader.BEGIN_OBJECT);

      String n;
      do {
        jsonReader.readNext(new char[] { ':', '}' });

        if (jsonReader.lastChar() != '}') {
          key = jsonReader.checkContent("\"key\"").readString(OJSONReader.COMMA_SEPARATOR);
          value = jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT).checkContent("\"value\"")
              .readString(OJSONReader.NEXT_IN_OBJECT);

          if (index != null)
            if (value.length() >= 4) {
              if (value.charAt(0) == '[')
                // REMOVE []
                value = value.substring(1, value.length() - 1);

              List<String> rids = OStringSerializerHelper.split(value, ',', new char[] { '#', '"' });

              for (String rid : rids) {
                doc.setIdentity(new ORecordId(rid));
                index.put(key, doc);
              }
            }

          tot++;
        }
View Full Code Here

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

      // AGAINST CLUSTERS AND CLASSES
      query.execute(iArgs);
      return recordCount;
    } else {
      // AGAINST INDEXES
      final OIndex index = database.getMetadata().getIndexManager().getIndex(indexName);
      if (index == null)
        throw new OCommandExecutionException("Target index '" + indexName + "' not found");

      Object key = null;
      Object value = VALUE_NOT_FOUND;

      if (KEYWORD_KEY.equalsIgnoreCase(compiledFilter.getRootCondition().getLeft().toString()))
        // FOUND KEY ONLY
        key = compiledFilter.getRootCondition().getRight();
      else if (compiledFilter.getRootCondition().getLeft() instanceof OSQLFilterCondition) {
        // KEY AND VALUE
        final OSQLFilterCondition leftCondition = (OSQLFilterCondition) compiledFilter.getRootCondition().getLeft();
        if (KEYWORD_KEY.equalsIgnoreCase(leftCondition.getLeft().toString()))
          key = leftCondition.getRight();

        final OSQLFilterCondition rightCondition = (OSQLFilterCondition) compiledFilter.getRootCondition().getRight();
        if (KEYWORD_RID.equalsIgnoreCase(rightCondition.getLeft().toString()))
          value = rightCondition.getRight();

      }

      if (key == null)
        throw new OCommandExecutionException("'Key' field is required for queries against indexes");

      final boolean result;
      if (value != VALUE_NOT_FOUND)
        result = index.remove(key, (OIdentifiable) value);
      else
        result = index.remove(key);

      return result;
    }
  }
View Full Code Here

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

   */
  public Object execute(final Map<Object, Object> iArgs) {
    if (name == null)
      throw new OCommandExecutionException("Can't execute the command because it hasn't been parsed yet");

    final OIndex idx;
    if (name.indexOf('.') > -1) {
      // PROPERTY INDEX
      final String[] parts = name.split("\\.");
      final String className = parts[0];
      if (className == null)
View Full Code Here

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

    listener.onMessage("\nRebuilding " + propertyIndexes.size() + " automatic indexes...");

    database.getMetadata().getIndexManager().load();

    for (Entry<OProperty, String> e : propertyIndexes.entrySet()) {
      final OIndex idx = database.getMetadata().getIndexManager().getIndex(e.getValue());

      ((OPropertyImpl) e.getKey()).setIndex(idx);
      idx.setCallback(e.getKey().getIndex());

      listener.onMessage("\n- Index '" + idx.getName() + "'...");

      // idx.rebuild(new OProgressListener() {
      // public boolean onProgress(Object iTask, long iCounter, float iPercent) {
      // if (iPercent % 10 == 0)
      // listener.onMessage(".");
      // return false;
      // }
      //
      // public void onCompletition(Object iTask, boolean iSucceed) {
      // }
      //
      // public void onBegin(Object iTask, long iTotal) {
      // }
      // });

      listener.onMessage("OK (" + idx.getSize() + " records)");
    }
  }
View Full Code Here

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

      if (indexName == null || indexName.length() == 0)
        return;

      listener.onMessage("\n- Index '" + indexName + "'...");

      final OIndex index = database.getMetadata().getIndexManager().getIndex(indexName);

      long tot = 0;

      jsonReader.readNext(OJSONReader.BEGIN_OBJECT);

      String n;
      do {
        jsonReader.readNext(new char[] { ':', '}' });

        if (jsonReader.lastChar() != '}') {
          key = jsonReader.checkContent("\"key\"").readString(OJSONReader.COMMA_SEPARATOR);
          value = jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT).checkContent("\"value\"")
              .readString(OJSONReader.NEXT_IN_OBJECT);

          if (index != null)
            if (value.length() >= 4) {
              if (value.charAt(0) == '[')
                // REMOVE []
                value = value.substring(1, value.length() - 1);

              List<String> rids = OStringSerializerHelper.split(value, ',', new char[] { '#', '"' });

              for (String rid : rids) {
                doc.setIdentity(new ORecordId(rid));
                index.put(key, doc);
              }
            }

          tot++;
        }
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.