Examples of SortSpec


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, 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, 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

      } 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

     * @throws ParseException if query is malformed
     */
    private void attachSort(final ResponseBuilder rb,
                            final Spatial spatial)
        throws ParseException {
        final SortSpec sortSpec = rb.getSortSpec();
        final Sort sort = sortSpec.getSort();
        final SortField sortField = spatial.getSortField();

        if (sort == null) {
            sortSpec.setSort(new Sort(sortField));
        } else {
            final SortField[] existingSortFields = sort.getSort();
            final SortField[] sortFields =
                new SortField[existingSortFields.length + 1];
            int i;
            for (i = 0; i < existingSortFields.length; i++) {
                sortFields[i] = existingSortFields[i];
            }
            sortFields[i] = sortField;
            sortSpec.setSort(new Sort(sortFields));
        }
    }
View Full Code Here

Examples of org.apache.tajo.catalog.SortSpec

  public static SortSpec[] schemaToSortSpecs(Schema schema) {
    SortSpec[] specs = new SortSpec[schema.getColumnNum()];

    for (int i = 0; i < schema.getColumnNum(); i++) {
      specs[i] = new SortSpec(schema.getColumn(i), true, false);
    }

    return specs;
  }
View Full Code Here

Examples of org.apache.tajo.catalog.SortSpec

        DatumFactory.createInt4(25),
        DatumFactory.createInt4(109),
        DatumFactory.createInt4(4),
        DatumFactory.createText("abd")});

    SortSpec sortKey1 = new SortSpec(schema.getColumnByFQN("col4"), true, false);
    SortSpec sortKey2 = new SortSpec(schema.getColumnByFQN("col5"), true, false);

    TupleComparator tc = new TupleComparator(schema,
        new SortSpec[] {sortKey1, sortKey2});
    assertEquals(-1, tc.compare(tuple1, tuple2));
    assertEquals(1, tc.compare(tuple2, tuple1));
View Full Code Here

Examples of org.apache.tajo.catalog.SortSpec

          SortSpec [] sortSpecs = null;
          if (sortExec != null) {
            sortSpecs = sortExec.getSortSpecs();
          } else {
            Column[] columns = ctx.getDataChannel().getPartitionKey();
            SortSpec specs[] = new SortSpec[columns.length];
            for (int i = 0; i < columns.length; i++) {
              specs[i] = new SortSpec(columns[i]);
            }
          }

          return new IndexedStoreExec(ctx, sm, subOp,
              plan.getInSchema(), plan.getInSchema(), sortSpecs);
View Full Code Here

Examples of org.apache.tajo.catalog.SortSpec

      throws IOException {

    Column[] grpColumns = groupbyNode.getGroupingColumns();
    SortSpec[] sortSpecs = new SortSpec[grpColumns.length];
    for (int i = 0; i < grpColumns.length; i++) {
      sortSpecs[i] = new SortSpec(grpColumns[i], true, false);
    }

    if (property != null) {
      List<CatalogProtos.SortSpecProto> sortSpecProtos = property.getGroupby().getSortSpecsList();
      SortSpec[] enforcedSortSpecs = new SortSpec[sortSpecProtos.size()];
      int i = 0;

      for (int j = 0; j < sortSpecProtos.size(); i++, j++) {
        enforcedSortSpecs[i] = new SortSpec(sortSpecProtos.get(j));
      }

      sortSpecs = ObjectArrays.concat(sortSpecs, enforcedSortSpecs, SortSpec.class);
    }
View Full Code Here

Examples of org.apache.tajo.catalog.SortSpec

  public static SortSpec[] schemaToSortSpecs(Column [] columns) {
    SortSpec[] specs = new SortSpec[columns.length];

    for (int i = 0; i < columns.length; i++) {
      specs[i] = new SortSpec(columns[i], true, false);
    }

    return specs;
  }
View Full Code Here

Examples of org.apache.tajo.catalog.SortSpec

  public static SortSpec [] columnsToSortSpec(Collection<Column> columns) {
    SortSpec[] specs = new SortSpec[columns.size()];
    int i = 0;
    for (Column column : columns) {
      specs[i++] = new SortSpec(column, true, false);
    }

    return specs;
  }
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.