Giter Site home page Giter Site logo

Comments (4)

tsuna avatar tsuna commented on July 22, 2024

Can you please pastebin the raw data so I can reproduce the query?

from opentsdb.

tch avatar tch commented on July 22, 2024

The following code inserts the datapoints:

    final WritableDataPoints dpAsk = tsdb.newDataPoints();
    java.util.Map<String, String> tagsAsk = new HashMap<String, String>(10);        
    tagsAsk.put("type", "ask");     
    dpAsk.setSeries("AAA", tagsAsk);

    Deferred<Object> d;
        d = dpAsk.addPoint(10001001,(float)0.1);
        d = dpAsk.addPoint(10002002,(float)0.2);
        d = dpAsk.addPoint(10003003,(float)0.3);

    final WritableDataPoints dpBid = tsdb.newDataPoints();
    java.util.Map<String, String> tagsBid = new HashMap<String, String>(10);                
    tagsBid.put("type", "bid");

    dpBid.setSeries("AAA", tagsBid);

        d = dpBid.addPoint(10001011,(float)0.11);
        d = dpBid.addPoint(10002022,(float)0.22);
        d = dpBid.addPoint(10003033,(float)0.33);

from opentsdb.

manolama avatar manolama commented on July 22, 2024

Just confirmed this. Setting start time to 0 works or setting it to the row time works, but 100 and some other values don't. Odd.

package net.opentsdb.core;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.stumbleupon.async.Deferred;

import net.opentsdb.utils.Config;

public class SCRATCH {

  @Test
  public void foo() throws Exception {
    
    TSDB tsdb = new TSDB(new Config(true));
    
    final WritableDataPoints dpAsk = tsdb.newDataPoints();
    java.util.Map<String, String> tagsAsk = new HashMap<String, String>(10);        
    tagsAsk.put("type", "ask");     
    dpAsk.setSeries("AAA", tagsAsk);

    List<Deferred<Object>> deferreds = Lists.newArrayList();
    deferreds.add(dpAsk.addPoint(10001001,(float)0.1));
    deferreds.add(dpAsk.addPoint(10002002,(float)0.2));
    deferreds.add(dpAsk.addPoint(10003003,(float)0.3));
    
    Deferred.group(deferreds).join();
    System.out.println("Wrote first set...");

    final WritableDataPoints dpBid = tsdb.newDataPoints();
    java.util.Map<String, String> tagsBid = new HashMap<String, String>(10);                
    tagsBid.put("type", "bid");

    dpBid.setSeries("AAA", tagsBid);
    deferreds.clear();
    deferreds.add(dpBid.addPoint(10001011,(float)0.11));
    deferreds.add(dpBid.addPoint(10002022,(float)0.22));
    deferreds.add(dpBid.addPoint(10003033,(float)0.33));
        
    Deferred.group(deferreds).join();
    System.out.println("Wrote second set...");
    
    Map<String, String> tags = Maps.newHashMap();
    tags.put("type", "*");
//    Query qAAAAny = tsdb.newQuery();  
//    qAAAAny.setTimeSeries("AAA", tags, null, false);
//    qAAAAny.setStartTime(1199);  
//    qAAAAny.setEndTime(11000000);
//    DataPoints[] results = qAAAAny.run();
    
    TSQuery q = new TSQuery();
    TSSubQuery sub = new TSSubQuery();
    sub.setMetric("AAA");
    sub.setTags(tags);
    sub.setAggregator("none");
    q.setStart("100");
    q.setEnd("11000000");
    q.setQueries(Lists.newArrayList(sub));
    q.validateAndSetQuery();
    
    Query[] queries = q.buildQueries(tsdb);
    DataPoints[] results = queries[0].run();
    
    System.out.println("Total results: " + results.length);
    for (final DataPoints dps : results) {
      SeekableView it = dps.iterator();
      while (it.hasNext()) {
        DataPoint dp = it.next();
        System.out.println(dp.timestamp() + " " + dp.doubleValue());
      }
    }
  }
  
}

from opentsdb.

IDerr avatar IDerr commented on July 22, 2024

Hi @tch,
If your question has been answered, could you please close this issue ?

thanks :)

from opentsdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.