mirror of https://github.com/apache/lucene.git
SOLR-13047: Fix Pre-commit
This commit is contained in:
parent
f9cd8b0957
commit
6069ef6ca6
|
@ -20,7 +20,6 @@ package org.apache.solr.client.solrj.io.stream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -70,7 +69,6 @@ public class Facet2DStream extends TupleStream implements Expressible {
|
||||||
private int dimensionX;
|
private int dimensionX;
|
||||||
private int dimensionY;
|
private int dimensionY;
|
||||||
private FieldComparator bucketSort;
|
private FieldComparator bucketSort;
|
||||||
private int index;
|
|
||||||
|
|
||||||
protected transient SolrClientCache cache;
|
protected transient SolrClientCache cache;
|
||||||
protected transient CloudSolrClient cloudSolrClient;
|
protected transient CloudSolrClient cloudSolrClient;
|
||||||
|
@ -158,8 +156,8 @@ public class Facet2DStream extends TupleStream implements Expressible {
|
||||||
if (strDimensions.length != 2) {
|
if (strDimensions.length != 2) {
|
||||||
throw new IOException(String.format(Locale.ROOT, "invalid expression %s - two dimension values expected"));
|
throw new IOException(String.format(Locale.ROOT, "invalid expression %s - two dimension values expected"));
|
||||||
}
|
}
|
||||||
dimensionX = Integer.parseInt(strDimensions[0]);
|
dimensionX = Integer.parseInt(strDimensions[0].trim());
|
||||||
dimensionY = Integer.parseInt(strDimensions[1]);
|
dimensionY = Integer.parseInt(strDimensions[1].trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +282,6 @@ public class Facet2DStream extends TupleStream implements Expressible {
|
||||||
FieldComparator[] adjustedSorts = adjustSorts(x, y, bucketSort);
|
FieldComparator[] adjustedSorts = adjustSorts(x, y, bucketSort);
|
||||||
|
|
||||||
String json = getJsonFacetString(x, y, metric, adjustedSorts, dimensionX, dimensionY);
|
String json = getJsonFacetString(x, y, metric, adjustedSorts, dimensionX, dimensionY);
|
||||||
System.out.println("#######JSON:"+json);
|
|
||||||
//assert expectedJson(json);
|
//assert expectedJson(json);
|
||||||
|
|
||||||
ModifiableSolrParams paramsLoc = new ModifiableSolrParams(params);
|
ModifiableSolrParams paramsLoc = new ModifiableSolrParams(params);
|
||||||
|
@ -294,7 +291,6 @@ public class Facet2DStream extends TupleStream implements Expressible {
|
||||||
QueryRequest request = new QueryRequest(paramsLoc, SolrRequest.METHOD.POST);
|
QueryRequest request = new QueryRequest(paramsLoc, SolrRequest.METHOD.POST);
|
||||||
try {
|
try {
|
||||||
NamedList response = cloudSolrClient.request(request, collection);
|
NamedList response = cloudSolrClient.request(request, collection);
|
||||||
System.out.println("###### Response:"+response.toString());
|
|
||||||
getTuples(response, x, y, metric);
|
getTuples(response, x, y, metric);
|
||||||
this.out = tuples.iterator();
|
this.out = tuples.iterator();
|
||||||
|
|
||||||
|
@ -325,24 +321,6 @@ public class Facet2DStream extends TupleStream implements Expressible {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean expectedJson(String json) {
|
|
||||||
if (!json.contains("\"limit\":" + (this.dimensionX)) || !json.contains("\"limit\":" + (this.dimensionY))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!json.contains("\"" + x.toString() + "\":") || !json.contains("\"" + y.toString() + "\":")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String function = metric.getFunctionName();
|
|
||||||
if (!function.equals("count(*)")) {
|
|
||||||
if (!json.contains(metric.getIdentifier())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getJsonFacetString(Bucket x, Bucket y, Metric metric, FieldComparator[] adjustedSorts, int dimensionX, int dimensionY) {
|
private String getJsonFacetString(Bucket x, Bucket y, Metric metric, FieldComparator[] adjustedSorts, int dimensionX, int dimensionY) {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
appendJson(buf, x, y, metric, adjustedSorts, dimensionX, dimensionY);
|
appendJson(buf, x, y, metric, adjustedSorts, dimensionX, dimensionY);
|
||||||
|
@ -483,13 +461,6 @@ public class Facet2DStream extends TupleStream implements Expressible {
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDimensionX() {
|
|
||||||
return dimensionX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDimensionY() {
|
|
||||||
return dimensionY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bucket getX() {
|
public Bucket getX() {
|
||||||
return x;
|
return x;
|
||||||
|
|
Loading…
Reference in New Issue