コード例 #1
0
 /**
  * Make type conversion of keys for specific index.
  *
  * @param index - index for which keys prepared for.
  * @param keys - which should be prepared.
  * @return keys converted to necessary type.
  */
 private Set<Comparable> prepareKeys(OIndex<?> index, Object keys) {
   final OIndexDefinition indexDefinition = index.getDefinition();
   if (keys instanceof Collection) {
     final Set<Comparable> newKeys = new TreeSet<Comparable>();
     for (Object o : ((Collection) keys)) {
       newKeys.add((Comparable) indexDefinition.createValue(o));
     }
     return newKeys;
   } else {
     return Collections.singleton((Comparable) indexDefinition.createValue(keys));
   }
 }
コード例 #2
0
  /**
   * Register statistic information about usage of index in {@link OProfilerStub}.
   *
   * @param index which usage is registering.
   */
  private void updateStatistic(OIndex<?> index) {

    final OProfiler profiler = Orient.instance().getProfiler();
    if (profiler.isRecording()) {
      Orient.instance()
          .getProfiler()
          .updateCounter(
              profiler.getDatabaseMetric(index.getDatabaseName(), "query.indexUsed"),
              "Used index in query",
              +1);

      final int paramCount = index.getDefinition().getParamCount();
      if (paramCount > 1) {
        final String profiler_prefix =
            profiler.getDatabaseMetric(index.getDatabaseName(), "query.compositeIndexUsed");
        profiler.updateCounter(profiler_prefix, "Used composite index in query", +1);
        profiler.updateCounter(
            profiler_prefix + "." + paramCount,
            "Used composite index in query with " + paramCount + " params",
            +1);
      }
    }
  }
コード例 #3
0
 private static boolean isComposite(OIndex<?> currentIndex) {
   return currentIndex.getDefinition().getParamCount() > 1;
 }
コード例 #4
0
 /** {@inheritDoc} */
 public OIndexDefinition getDefinition() {
   return lastIndex.getDefinition();
 }