Package org.cyclop.model

Examples of org.cyclop.model.QueryEntry$Adapter


      LOG.debug("Executing {} with offset {}", query, queryIdx);
      session.execute(query.part);

      long runTime = System.currentTimeMillis() - startTime;
      if (iconfig.isUpdateHistory()) {
        QueryEntry entry = new QueryEntry(query, runTime);
        history.add(entry);
      }
      resultWriter.success(query, runTime);
      status.success.getAndIncrement();
    } catch (DriverException e) {
View Full Code Here


    historyTable = new PageableListView<QueryEntry>("historyRow", model, 1) {

      @Override
      protected void populateItem(ListItem<QueryEntry> item) {
        QueryEntry entry = item.getModel().getObject();

        populateExecutedOn(item, entry);
        populateRuntime(item, entry);
        populateQuery(item, entry);
      }
View Full Code Here

    return result;
  }

  private void updateHistory(CqlQuery query, long startTime) {
    long runTime = System.currentTimeMillis() - startTime;
    QueryEntry entry = new QueryEntry(query, runTime);
    historyService.addAndStore(entry);
  }
View Full Code Here

    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) {
View Full Code Here

    QueryFavourites hist = new QueryFavourites();
    assertEquals(0, hist.size());
    assertFalse(hist.copyAsSortedSet().iterator().hasNext());

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

  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);
    assertEquals(1, readHistory.get().size());
    int idx = 0;
    List<QueryEntry> histList = readHistory.get().copyAsList();
    try (QueryHistory.HistoryIterator historyIterator = readHistory.get().iterator()) {
      assertTrue(historyIterator.hasNext());
      QueryEntry readEntry = historyIterator.next();
      assertEquals(histList.get(idx++), readEntry);
      assertEquals(query, readEntry.query);
      assertEquals(histEntry.executedOnUtc.toString(), readEntry.executedOnUtc.toString());

      assertEquals(0, storage.getLockRetryCount());
View Full Code Here

  public void testCreateAndRead_SingleFavouritesEntry() {
    UserIdentifier userId = new UserIdentifier(UUID.randomUUID());
    QueryFavourites newHistory = new QueryFavourites();

    CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable");
    QueryEntry favEntry = new QueryEntry(query, 234);
    newHistory.addWithSizeCheck(favEntry);

    storage.store(userId, newHistory);

    Optional<QueryFavourites> readHistory = storage.read(userId, QueryFavourites.class);
    assertNotNull(readHistory);
    assertEquals(1, readHistory.get().size());
    assertTrue(readHistory.get().copyAsSortedSet().iterator().hasNext());
    QueryEntry readEntry = readHistory.get().copyAsSortedSet().iterator().next();
    assertEquals(query, readEntry.query);
    assertEquals(favEntry.executedOnUtc.toString(), readEntry.executedOnUtc.toString());
    assertEquals(0, storage.getLockRetryCount());
  }
View Full Code Here

    UserIdentifier userId = new UserIdentifier(UUID.randomUUID());
    QueryFavourites history = new QueryFavourites();
    {
      for (int i = 0; i < 50; i++) {
        CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable where id=" + i);
        assertTrue(history.addWithSizeCheck(new QueryEntry(query, 234)));
      }
      assertEquals(50, history.size());
    }

    checkFavLimitContent(history);

    {
      for (int i = 0; i < 10; i++) {
        CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTableA where id=" + i);
        assertFalse(history.addWithSizeCheck(new QueryEntry(query, 456)));
      }
      checkFavLimitContent(history);
    }

    {
      for (int i = 0; i < 20; i++) {
        CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable where id=" + i);
        assertTrue(history.addWithSizeCheck(new QueryEntry(query, 234)));
      }
      checkFavLimitContent(history);
    }

    {
View Full Code Here

    assertEquals(50, fav.size());
    assertEquals(50, history.size());
    for (int i = 0; i < 50; i++) {
      assertTrue(favIt.hasNext());
      CqlQuery query = new CqlQuery(CqlQueryType.SELECT, "select * from MyTable where id=" + i);
      assertTrue(history.contains(new QueryEntry(query, 7754)));
      assertTrue(history.contains(favIt.next()));
    }
  }
View Full Code Here

  private void testHistRange(QueryHistory history, int from, int to) {
    try (QueryHistory.HistoryIterator hit = history.iterator()) {
      for (int i = from; i >= to; 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

TOP

Related Classes of org.cyclop.model.QueryEntry$Adapter

Copyright © 2018 www.massapicom. 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.