Class ElasticsearchSchema
- java.lang.Object
-
- org.apache.calcite.schema.impl.AbstractSchema
-
- org.apache.calcite.adapter.elasticsearch.ElasticsearchSchema
-
- All Implemented Interfaces:
Schema
public class ElasticsearchSchema extends AbstractSchema
Schema mapped onto an index of ELASTICSEARCH types.Each table in the schema is an ELASTICSEARCH type in that index.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.calcite.schema.impl.AbstractSchema
AbstractSchema.Factory
-
Nested classes/interfaces inherited from interface org.apache.calcite.schema.Schema
Schema.TableType
-
-
Field Summary
Fields Modifier and Type Field Description private org.elasticsearch.client.RestClient
client
private int
fetchSize
Default batch size to be used during scrolling.private java.lang.String
index
private com.fasterxml.jackson.databind.ObjectMapper
mapper
private java.util.Map<java.lang.String,Table>
tableMap
-
Constructor Summary
Constructors Constructor Description ElasticsearchSchema(org.elasticsearch.client.RestClient client, com.fasterxml.jackson.databind.ObjectMapper mapper, java.lang.String index)
Allows schema to be instantiated from existing elastic search client.ElasticsearchSchema(org.elasticsearch.client.RestClient client, com.fasterxml.jackson.databind.ObjectMapper mapper, java.lang.String index, java.lang.String type)
ElasticsearchSchema(org.elasticsearch.client.RestClient client, com.fasterxml.jackson.databind.ObjectMapper mapper, java.lang.String index, java.lang.String type, int fetchSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.Map<java.lang.String,Table>
createTables(java.lang.Iterable<java.lang.String> types)
java.lang.String
getIndex()
protected java.util.Map<java.lang.String,Table>
getTableMap()
Returns a map of tables in this schema by name.private java.util.Set<java.lang.String>
listTypesFromElastic()
Queries_mapping
definition to automatically detect all types for an index-
Methods inherited from class org.apache.calcite.schema.impl.AbstractSchema
getExpression, getFunctionMultimap, getFunctionNames, getFunctions, getSubSchema, getSubSchemaMap, getSubSchemaNames, getTable, getTableNames, getType, getTypeMap, getTypeNames, isMutable, snapshot
-
-
-
-
Field Detail
-
index
private final java.lang.String index
-
client
private final org.elasticsearch.client.RestClient client
-
mapper
private final com.fasterxml.jackson.databind.ObjectMapper mapper
-
tableMap
private final java.util.Map<java.lang.String,Table> tableMap
-
fetchSize
private final int fetchSize
Default batch size to be used during scrolling.
-
-
Constructor Detail
-
ElasticsearchSchema
public ElasticsearchSchema(org.elasticsearch.client.RestClient client, com.fasterxml.jackson.databind.ObjectMapper mapper, java.lang.String index)
Allows schema to be instantiated from existing elastic search client. This constructor is used in tests.- Parameters:
client
- existing client instancemapper
- mapper for JSON (de)serializationindex
- name of ES index
-
ElasticsearchSchema
public ElasticsearchSchema(org.elasticsearch.client.RestClient client, com.fasterxml.jackson.databind.ObjectMapper mapper, java.lang.String index, java.lang.String type)
-
ElasticsearchSchema
ElasticsearchSchema(org.elasticsearch.client.RestClient client, com.fasterxml.jackson.databind.ObjectMapper mapper, java.lang.String index, java.lang.String type, int fetchSize)
-
-
Method Detail
-
getTableMap
protected java.util.Map<java.lang.String,Table> getTableMap()
Description copied from class:AbstractSchema
Returns a map of tables in this schema by name.The implementations of
AbstractSchema.getTableNames()
andAbstractSchema.getTable(String)
depend on this map. The default implementation of this method returns the empty map. Override this method to change their behavior.- Overrides:
getTableMap
in classAbstractSchema
- Returns:
- Map of tables in this schema by name
-
createTables
private java.util.Map<java.lang.String,Table> createTables(java.lang.Iterable<java.lang.String> types)
-
listTypesFromElastic
private java.util.Set<java.lang.String> listTypesFromElastic() throws java.io.IOException
Queries_mapping
definition to automatically detect all types for an index- Returns:
- list of types associated with this index
- Throws:
java.io.IOException
- for any IO related issuesjava.lang.IllegalStateException
- if reply is not understood
-
getIndex
public java.lang.String getIndex()
-
-