Package org.apache.blur.thrift.generated

Examples of org.apache.blur.thrift.generated.BlurQuery$BlurQueryTupleSchemeFactory


    assertEquals("Should find our row.", expected, results.getTotalResults());
  }

  private void assertTotalRecordResults(String table, String q, long expected) throws BlurException, TException {
    BlurQuery bquery = new BlurQuery();
    Query query = new Query();
    query.setQuery(q);
    query.setRowQuery(false);
    bquery.setQuery(query);

    BlurResults results = client().query(table, bquery);

    assertEquals("Should find our record.", expected, results.getTotalResults());
View Full Code Here


    // long maxQueryTime;
    // long minimumNumberOfResults;
    // List<Facet> facets;
    // List<SortField> sortFields;

    BlurQuery blurQuery = new BlurQuery();
    blurQuery.setQuery(query);
    Selector selector = new Selector(Main.selector);
    if (!query.isRowQuery()) {
      selector.setRecordOnly(true);
    }
    blurQuery.setSelector(selector);
    blurQuery.setCacheResult(false);
    blurQuery.setUseCacheIfPresent(false);

    if (commandLine.hasOption(START)) {
      String startStr = commandLine.getOptionValue(START);
      blurQuery.setStart(Long.parseLong(startStr));
    }
    if (commandLine.hasOption(FETCH)) {
      String fetchStr = commandLine.getOptionValue(FETCH);
      blurQuery.setFetch(Integer.parseInt(fetchStr));
    }
    if (commandLine.hasOption(MAX_QUERY_TIME)) {
      String maxQueryTimeStr = commandLine.getOptionValue(MAX_QUERY_TIME);
      blurQuery.setMaxQueryTime(Long.parseLong(maxQueryTimeStr));
    }
    if (commandLine.hasOption(MINIMUM_NUMBER_OF_RESULTS)) {
      String minNumbResultsStr = commandLine.getOptionValue(MINIMUM_NUMBER_OF_RESULTS);
      blurQuery.setMinimumNumberOfResults(Long.parseLong(minNumbResultsStr));
    }
    if (commandLine.hasOption(ROW_ID)) {
      String rowId = commandLine.getOptionValue(ROW_FILTER);
      blurQuery.setRowId(rowId);
    }
    List<Facet> facets = new ArrayList<Facet>();
    for (Option option : options) {
      if (option.getOpt().equals(FACET)) {
        List<String> valuesList = option.getValuesList();
        Facet facet = new Facet();
        facet.setQueryStr(join(valuesList, " "));
        facets.add(facet);
      }
    }
    if (!facets.isEmpty()) {
      blurQuery.setFacets(facets);
    }

    List<SortField> sortFields = new ArrayList<SortField>();
    for (Option option : options) {
      if (option.getOpt().equals(SORT)) {
        List<String> valuesList = option.getValuesList();
        if (valuesList.size() == 2) {
          sortFields.add(new SortField(valuesList.get(0), valuesList.get(1), false));
        } else if (valuesList.size() == 3) {
          sortFields.add(new SortField(valuesList.get(0), valuesList.get(1), Boolean.parseBoolean(valuesList.get(2))));
        } else {
          throw new RuntimeException("Sort take 2 or 3 parameters.");
        }
      }
    }
    if (!sortFields.isEmpty()) {
      blurQuery.setSortFields(sortFields);
    }

    if (Main.highlight) {
      blurQuery.getSelector().setHighlightOptions(new HighlightOptions());
    }

    return blurQuery;
  }
View Full Code Here

    selector.locationId = locationId;
    return selector;
  }

  public static BlurQuery newSimpleQuery(String queryStr) {
    BlurQuery blurQuery = new BlurQuery();
    Query query = new Query();
    query.setQuery(queryStr);
    blurQuery.setQuery(query);
    blurQuery.setSelector(new Selector());
    return blurQuery;
  }
View Full Code Here

    String store = indexQuery.getStore();
    String family = getFamily(store);
    String queryString = getQueryString(family, condition);
    Query query = new Query();
    query.setQuery(queryString);
    BlurQuery blurQuery = new BlurQuery();
    blurQuery.setQuery(query);
    if (indexQuery.hasLimit()) {
      blurQuery.setFetch(indexQuery.getLimit());
    }

    String tableName = getTableName(store);
    Iface client = getClient();
    try {
View Full Code Here

    RowMutation rowMutation = BlurUtil.toRowMutation(table, row);
    client.mutate(rowMutation);
  }

  private void searchRow(String table, int i, Iface client) throws BlurException, TException {
    BlurQuery blurQuery = BlurThriftHelper.newSimpleQuery("test.test:" + i);
    System.out.println("Running [" + blurQuery + "]");
    BlurResults results = client.query(table, blurQuery);
    if (results.getTotalResults() != 1L) {
      throw new RuntimeException("we got a problem here.");
    }
View Full Code Here

    String tableName = args[1];
    String queryStr = args[2];

    Iface client = BlurClient.getClient(connectionStr);

    final BlurQuery blurQuery = new BlurQuery();
    Query query = new Query();
    blurQuery.setQuery(query);
    query.setQuery(queryStr);

    blurQuery.addToFacets(new Facet("fam1.col1:value1 OR fam1.col1:value2", 10000));
    blurQuery.addToFacets(new Facet("fam1.col1:value100 AND fam1.col1:value200", Long.MAX_VALUE));

    BlurResults results = client.query(tableName, blurQuery);
    System.out.println("Total Results: " + results.totalResults);

    List<Long> facetCounts = results.getFacetCounts();
    List<Facet> facets = blurQuery.getFacets();
    for (int i = 0; i < facets.size(); i++) {
      System.out.println("Facet [" + facets.get(i) + "] got [" + facetCounts.get(i) + "]");
    }
    for (BlurResult result : results.getResults()) {
      System.out.println(result);
View Full Code Here

    Iface client = BlurClient.getClient(connectionStr);

    String uuid = UUID.randomUUID().toString();
    Trace.setupTrace(uuid);
    UserContext.setUser(new User("me", null));
    final BlurQuery blurQuery = new BlurQuery();
    Query query = new Query();
    blurQuery.setQuery(query);
    query.setQuery(queryStr);
    blurQuery.setSelector(new Selector());
    BlurResults results = client.query(tableName, blurQuery);
    System.out.println("Total Results: " + results.totalResults);

    for (BlurResult result : results.getResults()) {
      System.out.println(result);
View Full Code Here

    for (String q : joinTest)
      System.out.println(q + " hits: " + hits(client, table, q, true));
  }

  private static long hits(Iface client, String table, String queryStr, boolean superQuery) throws BlurException, TException {
    BlurQuery bq = new BlurQuery();
    Query sq = new Query();
    sq.query = queryStr;
    sq.rowQuery = superQuery;
    bq.query = sq;
    BlurResults query = client.query(table, bq);
View Full Code Here

  }

  // really only useful against the table that was filled via loadupTable
  public void queryTable(int times) throws BlurException, TException {
    long start = System.currentTimeMillis();
    BlurQuery bq = new BlurQuery();
    bq.fetch = 10;
    for (int i = 1; i <= times; i++) {
      Query sq = new Query();
      sq.query = "numberField:" + random.nextInt(1000);
      sq.rowQuery = true;
View Full Code Here

  public void testBlurQueryWithRowId() throws BlurException, TException, InterruptedException, IOException {
    String tableName = "testBlurQueryWithRowId";
    createTable(tableName);
    loadTable(tableName);
    Blur.Iface client = getClient();
    BlurQuery blurQuery = new BlurQuery();
    Query query = new Query();
    query.setQuery("*");
    blurQuery.setQuery(query);
    BlurResults results1 = client.query(tableName, blurQuery);
    assertEquals(numberOfDocs, results1.getTotalResults());
    String id1 = results1.getResults().iterator().next().getFetchResult().getRowResult().getRow().getId();

    blurQuery.setRowId(id1);

    query.setRowQuery(false);
    BlurResults results2 = client.query(tableName, blurQuery);
    assertEquals(1, results2.getTotalResults());
    String id2 = results2.getResults().iterator().next().getFetchResult().getRecordResult().getRowid();
View Full Code Here

TOP

Related Classes of org.apache.blur.thrift.generated.BlurQuery$BlurQueryTupleSchemeFactory

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.