Esempio n. 1
0
 public Tuple query(Object... keys) {
   Object key = keys[0];
   if (labels.contains(key)) {
     return PrototypedTuple.singleton(labels.indexOf(key));
   }
   return PrototypedTuple.singleton(null);
 }
Esempio n. 2
0
 public Tuple query(Object... args) {
   Object key = args[0];
   long value = 0;
   if (counts.containsKey(key)) {
     value = counts.get(key);
   }
   return PrototypedTuple.singleton(value);
 }
Esempio n. 3
0
    /**
     * Returns a color value if the first key object is between the current max and min. Otherwise
     * it returns a null-valued tuple.
     */
    public Tuple query(Object... keys) {
      float d = Float.parseFloat(keys[0].toString());

      if (d >= min && d <= max) {
        return map(keys);
      } else {
        return PrototypedTuple.singleton(null);
      }
    }
Esempio n. 4
0
 public Tuple map(Object... keys) {
   Tuple rv;
   Object key;
   // TODO: Handle more than just the first value...concatenate the values or something, like
   // compound keys in Rank operator
   key = keys[0];
   if (!labels.contains(key)) {
     labels.add(key.toString());
   }
   rv = PrototypedTuple.singleton(labels.indexOf(key));
   return rv;
 }
Esempio n. 5
0
    /**
     * Returns a value between Red (low) and White (high) that represents the percentage of the
     * difference seen between the highest and the lowest value.
     *
     * <p>If multiple keys are passed, only the first one is used. If the key passed cannot be
     * parsed as number and 'throwExceptions' is set to false, black is returned. If the key passed
     * cannot be parsed and 'throwExceptions' is set to true, an exception is thrown.
     */
    public Tuple map(Object... keys) {
      float d;
      float p = -1;
      Tuple t;

      try {
        d = Float.parseFloat(keys[0].toString());
      } catch (Exception e) {
        if (throwExceptions) {
          throw new RuntimeException(
              "Could not parse value for heat scale:" + keys[0].toString(), e);
        } else {
          return PrototypedTuple.singleton(new Color(0, 0, 0));
        }
      }

      try {
        if (d > max || Double.isNaN(max)) {
          max = d;
        }
        if (d < min || Double.isNaN(min)) {
          min = d;
        }
        if (max == min) {
          p = 1;
        } else {
          p = 1 - ((max - d) / (max - min));
        }
        t = PrototypedTuple.singleton(averageColors(p));
        //				t = BasicTuple.singleton(new Color(1.0f,p,p));
      } catch (Exception e) {
        if (throwExceptions) {
          throw new RuntimeException("Error creating colors with range point:" + p, e);
        } else {
          t = PrototypedTuple.singleton(new Color(0, 0, 0));
        }
      }

      return t;
    }
Esempio n. 6
0
 public Tuple map(Object... args) {
   Object key = args[0];
   long value;
   if (counts.containsKey(key)) {
     Long l = counts.get(key);
     value = l.longValue();
     value++;
     counts.put(key, value);
   } else {
     value = 1;
     counts.put(key, value);
   }
   return PrototypedTuple.singleton(value);
 }
Esempio n. 7
0
 public Tuple query(Object... args) {
   return PrototypedTuple.singleton(count.get());
 }
Esempio n. 8
0
 public Tuple map(Object... args) {
   return PrototypedTuple.singleton(count.getAndAdd(1));
 }