mirror of https://github.com/apache/lucene.git
Fix license location and CloudSolrClient leak
This commit is contained in:
parent
01a21000ab
commit
e554ae404c
|
@ -1,12 +1,3 @@
|
||||||
package org.apache.solr.handler.sql;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.calcite.linq4j.Enumerator;
|
|
||||||
import org.apache.solr.client.solrj.io.Tuple;
|
|
||||||
import org.apache.solr.client.solrj.io.stream.TupleStream;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -23,6 +14,14 @@ import org.apache.solr.client.solrj.io.stream.TupleStream;
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.calcite.linq4j.Enumerator;
|
||||||
|
import org.apache.solr.client.solrj.io.Tuple;
|
||||||
|
import org.apache.solr.client.solrj.io.stream.TupleStream;
|
||||||
|
|
||||||
/** Enumerator that reads from a Solr collection. */
|
/** Enumerator that reads from a Solr collection. */
|
||||||
class SolrEnumerator implements Enumerator<Object> {
|
class SolrEnumerator implements Enumerator<Object> {
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package org.apache.solr.handler.sql;
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -16,23 +32,6 @@ import org.apache.calcite.rex.RexInputRef;
|
||||||
import org.apache.calcite.rex.RexLiteral;
|
import org.apache.calcite.rex.RexLiteral;
|
||||||
import org.apache.calcite.rex.RexNode;
|
import org.apache.calcite.rex.RexNode;
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of a {@link org.apache.calcite.rel.core.Filter} relational expression in Solr.
|
* Implementation of a {@link org.apache.calcite.rel.core.Filter} relational expression in Solr.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
package org.apache.solr.handler.sql;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.apache.calcite.linq4j.tree.Types;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -22,6 +14,13 @@ import org.apache.calcite.linq4j.tree.Types;
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.apache.calcite.linq4j.tree.Types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builtin methods in the Solr adapter.
|
* Builtin methods in the Solr adapter.
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package org.apache.solr.handler.sql;
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -16,23 +32,6 @@ import org.apache.calcite.rel.type.RelDataType;
|
||||||
import org.apache.calcite.rex.RexNode;
|
import org.apache.calcite.rex.RexNode;
|
||||||
import org.apache.calcite.util.Pair;
|
import org.apache.calcite.util.Pair;
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link org.apache.calcite.rel.core.Project} relational expression in Solr.
|
* Implementation of {@link org.apache.calcite.rel.core.Project} relational expression in Solr.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,14 +1,3 @@
|
||||||
package org.apache.solr.handler.sql;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.calcite.plan.Convention;
|
|
||||||
import org.apache.calcite.plan.RelOptTable;
|
|
||||||
import org.apache.calcite.rel.RelNode;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -25,6 +14,16 @@ import org.apache.calcite.rel.RelNode;
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.calcite.plan.Convention;
|
||||||
|
import org.apache.calcite.plan.RelOptTable;
|
||||||
|
import org.apache.calcite.rel.RelNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relational expression that uses Solr calling convention.
|
* Relational expression that uses Solr calling convention.
|
||||||
|
@ -32,8 +31,8 @@ import org.apache.calcite.rel.RelNode;
|
||||||
public interface SolrRel extends RelNode {
|
public interface SolrRel extends RelNode {
|
||||||
void implement(Implementor implementor);
|
void implement(Implementor implementor);
|
||||||
|
|
||||||
/** Calling convention for relational operations that occur in Cassandra. */
|
/** Calling convention for relational operations that occur in Solr. */
|
||||||
Convention CONVENTION = new Convention.Impl("SOLR", SolrRel.class);
|
Convention CONVENTION = new Convention.Impl("Solr", SolrRel.class);
|
||||||
|
|
||||||
/** Callback for the implementation process that converts a tree of {@link SolrRel} nodes into a Solr query. */
|
/** Callback for the implementation process that converts a tree of {@link SolrRel} nodes into a Solr query. */
|
||||||
class Implementor {
|
class Implementor {
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package org.apache.solr.handler.sql;
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
|
@ -19,23 +35,6 @@ import org.apache.calcite.rex.RexNode;
|
||||||
import org.apache.calcite.rex.RexVisitorImpl;
|
import org.apache.calcite.rex.RexVisitorImpl;
|
||||||
import org.apache.calcite.sql.validate.SqlValidatorUtil;
|
import org.apache.calcite.sql.validate.SqlValidatorUtil;
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rules and relational operators for
|
* Rules and relational operators for
|
||||||
* {@link SolrRel#CONVENTION}
|
* {@link SolrRel#CONVENTION}
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package org.apache.solr.handler.sql;
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -20,53 +36,40 @@ import org.apache.solr.client.solrj.request.LukeRequest;
|
||||||
import org.apache.solr.client.solrj.response.LukeResponse;
|
import org.apache.solr.client.solrj.response.LukeResponse;
|
||||||
import org.apache.solr.common.luke.FieldFlag;
|
import org.apache.solr.common.luke.FieldFlag;
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class SolrSchema extends AbstractSchema {
|
class SolrSchema extends AbstractSchema {
|
||||||
final CloudSolrClient cloudSolrClient;
|
final String zk;
|
||||||
|
|
||||||
SolrSchema(String zk) {
|
SolrSchema(String zk) {
|
||||||
super();
|
super();
|
||||||
this.cloudSolrClient = new CloudSolrClient(zk);
|
this.zk = zk;
|
||||||
this.cloudSolrClient.connect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Table> getTableMap() {
|
protected Map<String, Table> getTableMap() {
|
||||||
this.cloudSolrClient.connect();
|
try(CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zk).build()) {
|
||||||
Set<String> collections = this.cloudSolrClient.getZkStateReader().getClusterState().getCollections();
|
cloudSolrClient.connect();
|
||||||
|
Set<String> collections = cloudSolrClient.getZkStateReader().getClusterState().getCollections();
|
||||||
|
|
||||||
final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder();
|
final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder();
|
||||||
for (String collection : collections) {
|
for (String collection : collections) {
|
||||||
builder.put(collection, new SolrTable(this, collection));
|
builder.put(collection, new SolrTable(this, collection));
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, LukeResponse.FieldInfo> getFieldInfo(String collection) {
|
private Map<String, LukeResponse.FieldInfo> getFieldInfo(String collection) {
|
||||||
|
try(CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zk).build()) {
|
||||||
|
cloudSolrClient.connect();
|
||||||
LukeRequest lukeRequest = new LukeRequest();
|
LukeRequest lukeRequest = new LukeRequest();
|
||||||
lukeRequest.setNumTerms(0);
|
lukeRequest.setNumTerms(0);
|
||||||
LukeResponse lukeResponse;
|
LukeResponse lukeResponse = lukeRequest.process(cloudSolrClient, collection);
|
||||||
try {
|
return lukeResponse.getFieldInfo();
|
||||||
lukeResponse = lukeRequest.process(cloudSolrClient, collection);
|
|
||||||
} catch (SolrServerException | IOException e) {
|
} catch (SolrServerException | IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return lukeResponse.getFieldInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RelProtoDataType getRelDataType(String collection) {
|
RelProtoDataType getRelDataType(String collection) {
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
package org.apache.solr.handler.sql;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.calcite.schema.Schema;
|
|
||||||
import org.apache.calcite.schema.SchemaFactory;
|
|
||||||
import org.apache.calcite.schema.SchemaPlus;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -22,6 +14,13 @@ import org.apache.calcite.schema.SchemaPlus;
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.calcite.schema.Schema;
|
||||||
|
import org.apache.calcite.schema.SchemaFactory;
|
||||||
|
import org.apache.calcite.schema.SchemaPlus;
|
||||||
|
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public class SolrSchemaFactory implements SchemaFactory {
|
public class SolrSchemaFactory implements SchemaFactory {
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package org.apache.solr.handler.sql;
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -16,23 +32,6 @@ import org.apache.calcite.rel.type.RelDataTypeField;
|
||||||
import org.apache.calcite.rex.RexLiteral;
|
import org.apache.calcite.rex.RexLiteral;
|
||||||
import org.apache.calcite.rex.RexNode;
|
import org.apache.calcite.rex.RexNode;
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link org.apache.calcite.rel.core.Sort} relational expression in Solr.
|
* Implementation of {@link org.apache.calcite.rel.core.Sort} relational expression in Solr.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package org.apache.solr.handler.sql;
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -26,23 +42,6 @@ import org.apache.solr.client.solrj.io.stream.CloudSolrStream;
|
||||||
import org.apache.solr.client.solrj.io.stream.TupleStream;
|
import org.apache.solr.client.solrj.io.stream.TupleStream;
|
||||||
import org.apache.solr.common.params.CommonParams;
|
import org.apache.solr.common.params.CommonParams;
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table based on a Solr collection
|
* Table based on a Solr collection
|
||||||
*/
|
*/
|
||||||
|
@ -70,18 +69,18 @@ public class SolrTable extends AbstractQueryableTable implements TranslatableTab
|
||||||
return protoRowType.apply(typeFactory);
|
return protoRowType.apply(typeFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enumerable<Object> query(final CloudSolrClient cloudSolrClient) {
|
public Enumerable<Object> query(final String zk) {
|
||||||
return query(cloudSolrClient, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), null);
|
return query(zk, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Executes a Solr query on the underlying table.
|
/** Executes a Solr query on the underlying table.
|
||||||
*
|
*
|
||||||
* @param cloudSolrClient Solr CloudSolrClient
|
* @param zk Solr ZooKeeper connection string
|
||||||
* @param fields List of fields to project
|
* @param fields List of fields to project
|
||||||
* @param filterQueries A list of filterQueries which should be used in the query
|
* @param filterQueries A list of filterQueries which should be used in the query
|
||||||
* @return Enumerator of results
|
* @return Enumerator of results
|
||||||
*/
|
*/
|
||||||
public Enumerable<Object> query(final CloudSolrClient cloudSolrClient, List<String> fields,
|
public Enumerable<Object> query(final String zk, List<String> fields,
|
||||||
List<String> filterQueries, List<String> order, String limit) {
|
List<String> filterQueries, List<String> order, String limit) {
|
||||||
Map<String, String> solrParams = new HashMap<>();
|
Map<String, String> solrParams = new HashMap<>();
|
||||||
solrParams.put(CommonParams.Q, "*:*");
|
solrParams.put(CommonParams.Q, "*:*");
|
||||||
|
@ -117,7 +116,7 @@ public class SolrTable extends AbstractQueryableTable implements TranslatableTab
|
||||||
public Enumerator<Object> enumerator() {
|
public Enumerator<Object> enumerator() {
|
||||||
TupleStream cloudSolrStream;
|
TupleStream cloudSolrStream;
|
||||||
try {
|
try {
|
||||||
cloudSolrStream = new CloudSolrStream(cloudSolrClient.getZkHost(), collection, solrParams);
|
cloudSolrStream = new CloudSolrStream(zk, collection, solrParams);
|
||||||
cloudSolrStream.open();
|
cloudSolrStream.open();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -144,7 +143,7 @@ public class SolrTable extends AbstractQueryableTable implements TranslatableTab
|
||||||
|
|
||||||
public Enumerator<T> enumerator() {
|
public Enumerator<T> enumerator() {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
final Enumerable<T> enumerable = (Enumerable<T>) getTable().query(getCloudSolrClient());
|
final Enumerable<T> enumerable = (Enumerable<T>) getTable().query(getZK());
|
||||||
return enumerable.enumerator();
|
return enumerable.enumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +151,8 @@ public class SolrTable extends AbstractQueryableTable implements TranslatableTab
|
||||||
return (SolrTable) table;
|
return (SolrTable) table;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CloudSolrClient getCloudSolrClient() {
|
private String getZK() {
|
||||||
return schema.unwrap(SolrSchema.class).cloudSolrClient;
|
return schema.unwrap(SolrSchema.class).zk;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called via code-generation.
|
/** Called via code-generation.
|
||||||
|
@ -162,7 +161,7 @@ public class SolrTable extends AbstractQueryableTable implements TranslatableTab
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public Enumerable<Object> query(List<String> fields, List<String> filterQueries, List<String> order, String limit) {
|
public Enumerable<Object> query(List<String> fields, List<String> filterQueries, List<String> order, String limit) {
|
||||||
return getTable().query(getCloudSolrClient(), fields, filterQueries, order, limit);
|
return getTable().query(getZK(), fields, filterQueries, order, limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,3 @@
|
||||||
package org.apache.solr.handler.sql;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.calcite.plan.RelOptCluster;
|
|
||||||
import org.apache.calcite.plan.RelOptPlanner;
|
|
||||||
import org.apache.calcite.plan.RelOptRule;
|
|
||||||
import org.apache.calcite.plan.RelOptTable;
|
|
||||||
import org.apache.calcite.plan.RelTraitSet;
|
|
||||||
import org.apache.calcite.rel.RelNode;
|
|
||||||
import org.apache.calcite.rel.core.TableScan;
|
|
||||||
import org.apache.calcite.rel.type.RelDataType;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -27,6 +14,18 @@ import org.apache.calcite.rel.type.RelDataType;
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.calcite.plan.RelOptCluster;
|
||||||
|
import org.apache.calcite.plan.RelOptPlanner;
|
||||||
|
import org.apache.calcite.plan.RelOptRule;
|
||||||
|
import org.apache.calcite.plan.RelOptTable;
|
||||||
|
import org.apache.calcite.plan.RelTraitSet;
|
||||||
|
import org.apache.calcite.rel.RelNode;
|
||||||
|
import org.apache.calcite.rel.core.TableScan;
|
||||||
|
import org.apache.calcite.rel.type.RelDataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relational expression representing a scan of a Solr collection.
|
* Relational expression representing a scan of a Solr collection.
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package org.apache.solr.handler.sql;
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -27,23 +43,6 @@ import org.apache.calcite.rel.type.RelDataType;
|
||||||
import org.apache.calcite.runtime.Hook;
|
import org.apache.calcite.runtime.Hook;
|
||||||
import org.apache.calcite.util.BuiltInMethod;
|
import org.apache.calcite.util.BuiltInMethod;
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relational expression representing a scan of a table in Solr
|
* Relational expression representing a scan of a table in Solr
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
package org.apache.solr.handler.sql;
|
|
||||||
|
|
||||||
import org.apache.calcite.adapter.enumerable.EnumerableConvention;
|
|
||||||
import org.apache.calcite.plan.RelTraitSet;
|
|
||||||
import org.apache.calcite.rel.RelNode;
|
|
||||||
import org.apache.calcite.rel.convert.ConverterRule;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -21,6 +14,12 @@ import org.apache.calcite.rel.convert.ConverterRule;
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.apache.solr.handler.sql;
|
||||||
|
|
||||||
|
import org.apache.calcite.adapter.enumerable.EnumerableConvention;
|
||||||
|
import org.apache.calcite.plan.RelTraitSet;
|
||||||
|
import org.apache.calcite.rel.RelNode;
|
||||||
|
import org.apache.calcite.rel.convert.ConverterRule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rule to convert a relational expression from {@link SolrRel#CONVENTION} to {@link EnumerableConvention}.
|
* Rule to convert a relational expression from {@link SolrRel#CONVENTION} to {@link EnumerableConvention}.
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classes related to Apache Calcite implementation in {@link org.apache.solr.handler.SQLHandler}
|
* Classes related to Apache Calcite implementation in {@link org.apache.solr.handler.SQLHandler}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue