Examples of SortSpec


Examples of org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec

        assertNotNull(walker);

        List<SortSpec> orderBys = queryObj.getOrderBys();
        assertTrue(1 == orderBys.size());

        SortSpec sp = orderBys.get(0);
        assertTrue(sp.isAscending());

        CmisSelector sortSpec = sp.getSelector();
        assert(sortSpec instanceof ColumnReference);
        assertEquals("abc", ((ColumnReference)sortSpec).getQualifier());
        assertEquals("def", ((ColumnReference)sortSpec).getPropertyQueryName());
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec

        assertNotNull(walker);

        List<SortSpec> orderBys = queryObj.getOrderBys();
        assertTrue(1 == orderBys.size());

        SortSpec sp = orderBys.get(0);
        assertFalse(sp.isAscending());

        CmisSelector sortSpec = sp.getSelector();
        assert(sortSpec instanceof ColumnReference);
        assertNull(((ColumnReference)sortSpec).getQualifier());
        assertEquals("def", ((ColumnReference)sortSpec).getPropertyQueryName());
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec

            LOG.warn("ORDER BY has more than one sort criterium, all but the first are ignored.");
        class ResultComparator implements Comparator<StoredObject> {

            @SuppressWarnings("unchecked")
            public int compare(StoredObject so1, StoredObject so2) {
                SortSpec s = orderBy.get(0);
                CmisSelector sel = s.getSelector();
                int result;

                if (sel instanceof ColumnReference) {
                    String propId = ((ColumnReference) sel).getPropertyId();
                    Object propVal1 = so1.getProperties().get(propId).getFirstValue();
                    Object propVal2 = so2.getProperties().get(propId).getFirstValue();
                    if (propVal1 == null && propVal2 == null)
                        result = 0;
                    else if (propVal1 == null)
                        result = -1;
                    else if (propVal2 == null)
                        result = 1;
                    else
                        result = ((Comparable<Object>) propVal1).compareTo(propVal2);
                } else {
                    // String funcName = ((FunctionReference) sel).getName();
                    // evaluate function here, currently ignore
                    result = 0;
                }
                if (!s.isAscending())
                    result = -result;
                return result;
            }
        }
View Full Code Here

Examples of org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec

            LOG.warn("ORDER BY has more than one sort criterium, all but the first are ignored.");
        class ResultComparator implements Comparator<StoredObject> {

            @SuppressWarnings("unchecked")
            public int compare(StoredObject so1, StoredObject so2) {
                SortSpec s = orderBy.get(0);
                CmisSelector sel = s.getSelector();
                int result;

                if (sel instanceof ColumnReference) {
                    String propId = ((ColumnReference) sel).getPropertyId();
                    Object propVal1 = so1.getProperties().get(propId).getFirstValue();
                    Object propVal2 = so2.getProperties().get(propId).getFirstValue();
                    if (propVal1 == null && propVal2 == null)
                        result = 0;
                    else if (propVal1 == null)
                        result = -1;
                    else if (propVal2 == null)
                        result = 1;
                    else
                        result = ((Comparable<Object>) propVal1).compareTo(propVal2);
                } else {
                    // String funcName = ((FunctionReference) sel).getName();
                    // evaluate function here, currently ignore
                    result = 0;
                }
                if (!s.isAscending())
                    result = -result;
                return result;
            }
View Full Code Here

Examples of org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec

        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        assertNotNull(walker);
        List<SortSpec> orderBys = queryObj.getOrderBys();
        assertTrue(1 == orderBys.size());
        SortSpec sp = orderBys.get(0);
        assertTrue(sp.isAscending());
        CmisSelector sortSpec = sp.getSelector();
        assert(sortSpec instanceof ColumnReference);
        assertEquals("abc", ((ColumnReference)sortSpec).getTypeQueryName());
        assertEquals("def", ((ColumnReference)sortSpec).getPropertyQueryName());
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.server.support.query.QueryObject.SortSpec

        String statement = "SELECT * FROM MyType ORDER BY def DESC";
        CmisQueryWalker walker = traverseStatementAndCatchExc(statement);
        assertNotNull(walker);
        List<SortSpec> orderBys = queryObj.getOrderBys();
        assertTrue(1 == orderBys.size());
        SortSpec sp = orderBys.get(0);
        assertFalse(sp.isAscending());
        CmisSelector sortSpec = sp.getSelector();
        assert(sortSpec instanceof ColumnReference);
        assertNull(((ColumnReference)sortSpec).getTypeQueryName());
        assertEquals("def", ((ColumnReference)sortSpec).getPropertyQueryName());
    }
View Full Code Here

Examples of org.apache.solr.search.SortSpec

      } catch (ParseException e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
      }
   
    Query query = rb.getQuery();
      SortSpec sortspec = rb.getSortSpec();
      Sort sort = null;
      if (sortspec!=null){
        sort = sortspec.getSort();
      }

      SolrParams solrParams = rb.req.getParams();

    String shardsVal = solrParams.get(ShardParams.SHARDS, null);
View Full Code Here

Examples of org.apache.solr.search.SortSpec

  /**
   * {@inheritDoc}
   */
  public void process(ResponseBuilder rb, ShardRequest shardRequest) {
    SortSpec ss = rb.getSortSpec();
    Sort groupSort = rb.getGroupingSpec().getGroupSort();
    String[] fields = rb.getGroupingSpec().getFields();

    Map<String, List<Collection<SearchGroup<String>>>> commandSearchGroups = new HashMap<String, List<Collection<SearchGroup<String>>>>();
    Map<String, Map<SearchGroup<String>, String>> tempSearchGroupToShard = new HashMap<String, Map<SearchGroup<String>, String>>();
    for (String field : fields) {
      commandSearchGroups.put(field, new ArrayList<Collection<SearchGroup<String>>>(shardRequest.responses.size()));
      tempSearchGroupToShard.put(field, new HashMap<SearchGroup<String>, String>());
      if (!rb.searchGroupToShard.containsKey(field)) {
        rb.searchGroupToShard.put(field, new HashMap<SearchGroup<String>, String>());
      }
    }

    SearchGroupsResultTransformer serializer = new SearchGroupsResultTransformer(rb.req.getSearcher());
    try {
      for (ShardResponse srsp : shardRequest.responses) {
        @SuppressWarnings("unchecked")
        NamedList<NamedList> firstPhaseResult = (NamedList<NamedList>) srsp.getSolrResponse().getResponse().get("firstPhase");
        Map<String, Collection<SearchGroup<String>>> result = serializer.transformToNative(firstPhaseResult, groupSort, null, srsp.getShard());
        for (String field : commandSearchGroups.keySet()) {
          Collection<SearchGroup<String>> searchGroups = result.get(field);
          if (searchGroups == null) {
            continue;
          }

          commandSearchGroups.get(field).add(searchGroups);
          for (SearchGroup<String> searchGroup : searchGroups) {
            tempSearchGroupToShard.get(field).put(searchGroup, srsp.getShard());
          }
        }
      }
      for (String groupField : commandSearchGroups.keySet()) {
        List<Collection<SearchGroup<String>>> topGroups = commandSearchGroups.get(groupField);
        Collection<SearchGroup<String>> mergedTopGroups = SearchGroup.merge(topGroups, ss.getOffset(), ss.getCount(), groupSort);
        if (mergedTopGroups == null) {
          continue;
        }

        rb.mergedSearchGroups.put(groupField, mergedTopGroups);
View Full Code Here

Examples of org.apache.solr.search.SortSpec

      }

     
      // if the sort is 'score desc' use a custom sorting method to
      // insert documents in their proper place
      SortSpec sortSpec = rb.getSortSpec();
      if( sortSpec.getSort() == null ) {
        sortSpec.setSort( new Sort( new SortField[] {
            new SortField(idField, booster.comparatorSource, false ),
            new SortField(null, SortField.SCORE, false)
        }));
      }
      else {
        // Check if the sort is based on score
        boolean modify = false;
        SortField[] current = sortSpec.getSort().getSort();
        ArrayList<SortField> sorts = new ArrayList<SortField>( current.length + 1 );
        // Perhaps force it to always sort by score
        if( force && current[0].getType() != SortField.SCORE ) {
          sorts.add( new SortField(idField, booster.comparatorSource, false ) );
          modify = true;
        }
        for( SortField sf : current ) {
          if( sf.getType() == SortField.SCORE ) {
            sorts.add( new SortField(idField, booster.comparatorSource, sf.getReverse() ) );
            modify = true;
          }
          sorts.add( sf );
        }
        if( modify ) {
          sortSpec.setSort( new Sort( sorts.toArray( new SortField[sorts.size()] ) ) );
        }
      }
    }
   
    // Add debugging information
View Full Code Here

Examples of org.apache.solr.search.SortSpec

      }
      rb.setQuery( newq );
     
      // if the sort is 'score desc' use a custom sorting method to
      // insert documents in their proper place
      SortSpec sortSpec = rb.getSortSpec();
      if( sortSpec.getSort() == null ) {
        sortSpec.setSort( new Sort( new SortField[] {
            new SortField(idField, new ElevationComparatorSource(booster.priority), false ),
            new SortField(null, SortField.SCORE, false)
        }));
      }
      else {
        // Check if the sort is based on score
        boolean modify = false;
        SortField[] current = sortSpec.getSort().getSort();
        ArrayList<SortField> sorts = new ArrayList<SortField>( current.length + 1 );
        // Perhaps force it to always sort by score
        if( forceElevation && current[0].getType() != SortField.SCORE ) {
          sorts.add( new SortField(idField,
              new ElevationComparatorSource(booster.priority), false ) );
          modify = true;
        }
        for( SortField sf : current ) {
          if( sf.getType() == SortField.SCORE ) {
            sorts.add( new SortField(idField,
                new ElevationComparatorSource(booster.priority), sf.getReverse() ) );
            modify = true;
          }
          sorts.add( sf );
        }
        if( modify ) {
          sortSpec.setSort( new Sort( sorts.toArray( new SortField[sorts.size()] ) ) );
        }
      }
    }
   
    // Add debugging information
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.