Examples of QueryHistory


Examples of com.dianping.cosmos.hive.server.store.domain.QueryHistory

    String resultLocation = "";
    if (result.getStoreFileLocation() != null){
      resultLocation = result.getStoreFileLocation();
    }
   
    QueryHistory history = new QueryHistory();
    history.setHql(input.getHql());
    history.setUsername(input.getUsername());
    history.setAddtime(new Date(input.getTimestamp()));
    history.setFilename(resultLocation);
    queryHistoryService.insertQueryHistory(history);
   
    HiveQueryOutputBo bo = result.toHiveQueryOutputBo();
    return bo;
  }
View Full Code Here

Examples of com.dianping.cosmos.hive.server.store.domain.QueryHistory

  @Autowired
  private QueryHistoryService queryHistoryService;

  @Test
  public void testInsertQueryHistory() throws Exception {
    QueryHistory qh = new QueryHistory();
    qh.setUsername("yukang.chen");
    qh.setHql("select * from hippolog limit 3");
    qh.setAddtime(new Date());
    qh.setFilename("file_" + UUID.randomUUID());
    queryHistoryService.insertQueryHistory(qh);
  }
View Full Code Here

Examples of org.cyclop.model.QueryHistory

    if (queries.isEmpty()) {
      LOG.debug("No data to import");
      return;
    }

    QueryHistory history = historyService.read();

    List<Future<Void>> futures = startWorkers(queries, resultWriter, status, iconfig, history);
    waitForImport(futures);

    if (iconfig.isUpdateHistory()) {
View Full Code Here

Examples of org.cyclop.model.QueryHistory

    return QueryHistory.class;
  }

  @Override
  protected QueryHistory createEmpty() {
    return new QueryHistory();
  }
View Full Code Here

Examples of org.cyclop.model.QueryHistory

    return new QueryHistory();
  }

  @Override
  public void addAndStore(@NotNull QueryEntry entry) {
    QueryHistory hist = read();
    hist.add(entry);
    store(hist);
  }
View Full Code Here

Examples of org.cyclop.model.QueryHistory

    assertFalse(storage.read(new UserIdentifier(UUID.randomUUID()), QueryHistory.class).isPresent());
  }

  @Test
  public void testEmptyHistory() {
    QueryHistory hist = new QueryHistory();
    assertEquals(0, hist.size());
    try (QueryHistory.HistoryIterator iterator = hist.iterator()) {
      assertFalse(iterator.hasNext());
    }

    CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable");
    QueryEntry histEntry = new QueryEntry(query, 234);
    assertFalse(hist.contains(histEntry));
    try {
      hist.iterator().next();
      fail();
    } catch (NoSuchElementException e) {
      // OK
    }
  }
View Full Code Here

Examples of org.cyclop.model.QueryHistory

  }

  @Test
  public void testCreateAndRead_SingleHistoryEntry() {
    UserIdentifier userId = new UserIdentifier(UUID.randomUUID());
    QueryHistory newHistory = new QueryHistory();

    CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable");
    QueryEntry histEntry = new QueryEntry(query, 6645);
    newHistory.add(histEntry);

    storage.store(userId, newHistory);

    Optional<QueryHistory> readHistory = storage.read(userId, QueryHistory.class);
    assertNotNull(readHistory);
View Full Code Here

Examples of org.cyclop.model.QueryHistory

  @Test
  public void testEvictHistory() {
    UserIdentifier userId = new UserIdentifier(UUID.randomUUID());

    {
      QueryHistory history = new QueryHistory();

      for (int i = 0; i < 600; i++) {
        CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable1 where id=" + i);
        history.add(new QueryEntry(query, 4563));
      }
      assertEquals(500, history.size());
      testHistRange(history, 599, 100);
      storage.store(userId, history);
    }

    {
      Optional<QueryHistory> history = storage.read(userId, QueryHistory.class);
      assertNotNull(history);
      assertEquals(500, history.get().size());
      testHistRange(history.get(), 599, 100);

      for (int i = 0; i < 10; i++) {
        CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable2 where id=" + i);
        history.get().add(new QueryEntry(query, 567));
      }
      storage.store(userId, history.get());
    }

    {
      QueryHistory history = storage.read(userId, QueryHistory.class).get();
      assertNotNull(history);
      assertEquals(500, history.size());

      try (QueryHistory.HistoryIterator hit = history.iterator()) {
        for (int i = 9; i >= 0; i--) {
          assertTrue(hit.hasNext());
          QueryEntry entry = hit.next();
          assertTrue(history.contains(entry));
          assertNotNull(entry.executedOnUtc);
          assertEquals("select * from MyTable2 where id=" + i, entry.query.part);
        }
        for (int i = 599; i > 110; i--) {
          assertTrue(hit.hasNext());
          QueryEntry entry = hit.next();
          assertTrue(history.contains(entry));
          assertNotNull(entry.executedOnUtc);
          assertEquals("select * from MyTable1 where id=" + i, entry.query.part);
        }
      }
    }
View Full Code Here

Examples of org.cyclop.model.QueryHistory

  @Before
  public void setup() throws Exception {
    super.setup();
    asyncFileStore.flush();
    QueryHistory history = historyService.read();
    assertNotNull(history);
    history.clear();

    assertEquals(0, history.size());

    user = historyService.getUser();
    assertNotNull(user);
    assertNotNull(user.id);
  }
View Full Code Here

Examples of org.cyclop.model.QueryHistory

    assertNotNull(user.id);
  }

  @Test
  public void testCreateReadAndClear() throws Exception {
    QueryHistory history = historyService.read();

    for (int i = 0; i < 600; i++) {
      historyService.addAndStore(new QueryEntry(new CqlQuery(CqlQueryType.SELECT, "select * " + CR
          + "from HistoryTest where " + CR + "id=" + i), 1000 + i));
      QueryHistory historyQueue = asyncFileStore.getFromWriteQueue(user).get();
      assertNotNull(historyQueue);

      // should be the same instance
      assertSame(history, historyQueue);
    }
    assertEquals(500, history.size());

    asyncFileStore.flush();
    assertFalse(asyncFileStore.getFromWriteQueue(user).isPresent());

    assertSame(history, historyService.read());

    QueryHistory readHist = storage.read(user, QueryHistory.class).get();
    assertNotSame(history, readHist);

    for (int i = 100; i < 600; i++) {
      QueryEntry tofind = new QueryEntry(new CqlQuery(CqlQueryType.SELECT, "select * from HistoryTest where id="
          + i), 2000 + i);
      assertTrue(tofind + " NOT FOUND IN: " + readHist, readHist.contains(tofind));

      ImmutableList<QueryEntry> readList = readHist.copyAsList();
      int index = readList.indexOf(tofind);
      assertTrue(index >= 0);
      QueryEntry read = readList.get(index);
      assertNotNull(read.executedOnUtc);
      assertEquals(1000 + i, read.runTime);
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.