Tabnine Logo
ReflectiveSchema
Code IndexAdd Tabnine to your IDE (free)

How to use
ReflectiveSchema
in
net.hydromatic.optiq.impl.java

Best Java code snippets using net.hydromatic.optiq.impl.java.ReflectiveSchema (Showing top 20 results out of 315)

origin: org.apache.optiq/optiq-core

return new ReflectiveSchema(target);
origin: net.hydromatic/optiq

return ReflectiveSchema.create(schema, name, target);
origin: net.hydromatic/optiq

for (Field field : clazz.getFields()) {
 final String fieldName = field.getName();
 final Table<Object> table = fieldRelation(field);
 if (table == null) {
  continue;
  continue;
 final TableFunction tableFunction = methodMember(method);
 membersMap.put(methodName,
   new TableFunctionInSchemaImpl(this, methodName, tableFunction));
origin: org.apache.optiq/optiq-core

/** Returns a table based on a particular field of this schema. If the
 * field is not of the right type to be a relation, returns null. */
private <T> Table fieldRelation(final Field field) {
 final Type elementType = getElementType(field.getType());
 if (elementType == null) {
  return null;
 }
 Object o;
 try {
  o = field.get(target);
 } catch (IllegalAccessException e) {
  throw new RuntimeException(
    "Error while accessing field " + field, e);
 }
 @SuppressWarnings("unchecked")
 final Enumerable<T> enumerable = toEnumerable(o);
 return new FieldTable<T>(field, elementType, enumerable);
}
origin: net.hydromatic/optiq

final Type elementType = getElementType(field.getType());
if (elementType == null) {
 return null;
  relDataType,
  Expressions.field(
    ReflectiveSchema.this.getTargetExpression(),
    field)) {
 public String toString() {
origin: net.hydromatic/optiq

 public Schema create(
   MutableSchema parentSchema,
   String name,
   Map<String, Object> operand) {
  final ReflectiveSchema schema =
    ReflectiveSchema.create(parentSchema, name, new HrSchema());
  // Mine the EMPS table and add it under another name e.g. ELVIS
  final Table table = schema.getTable("emps", Object.class);
  String tableName = (String) operand.get("tableName");
  schema.addTable(
    new TableInSchemaImpl(
      schema, tableName, Schema.TableType.TABLE, table));
  final Boolean mutable = (Boolean) operand.get("mutable");
  if (mutable == null || mutable) {
   return schema;
  } else {
   // Wrap the schema in DelegatingSchema so that it does not
   // implement MutableSchema.
   return new DelegatingSchema(schema);
  }
 }
}
origin: org.apache.optiq/optiq-core

/** Returns an expression for the object wrapped by this schema (not the
 * schema itself). */
Expression getTargetExpression(SchemaPlus parentSchema, String name) {
 return Types.castIfNecessary(
   target.getClass(),
   Expressions.call(
     Schemas.unwrap(
       getExpression(parentSchema, name),
       ReflectiveSchema.class),
     BuiltinMethod.REFLECTIVE_SCHEMA_GET_TARGET.method));
}
origin: net.hydromatic/optiq

 public Table<T> apply(final List<Object> arguments) {
  final List<Expression> list = new ArrayList<Expression>();
  for (Object argument : arguments) {
   list.add(Expressions.constant(argument));
  }
  try {
   final Object o = method.invoke(schema, arguments.toArray());
   return new ReflectiveTable<T>(
     schema,
     elementType,
     relDataType,
     Expressions.call(
       schema.getTargetExpression(),
       method,
       list)) {
    public Enumerator<T> enumerator() {
     @SuppressWarnings("unchecked")
     final Enumerable<T> enumerable = toEnumerable(o);
     return enumerable.enumerator();
    }
   };
  } catch (IllegalAccessException e) {
   throw new RuntimeException(e);
  } catch (InvocationTargetException e) {
   throw new RuntimeException(e);
  }
 }
};
origin: org.apache.optiq/optiq-core

@Override
protected Map<String, Table> getTableMap() {
 final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder();
 for (Field field : clazz.getFields()) {
  final String fieldName = field.getName();
  final Table table = fieldRelation(field);
  if (table == null) {
   continue;
  }
  builder.put(fieldName, table);
 }
 return builder.build();
}
origin: net.hydromatic/optiq

public <T> TableFunction<T> methodMember(final Method method) {
 final ReflectiveSchema schema = this;
 final Type elementType = getElementType(method.getReturnType());
 final RelDataType relDataType = typeFactory.createType(elementType);
 final Class<?>[] parameterTypes = method.getParameterTypes();
origin: net.hydromatic/optiq

public ReflectiveTable(
  ReflectiveSchema schema,
  Type elementType,
  RelDataType relDataType,
  Expression expression) {
 super(schema.getQueryProvider(), elementType, expression);
 this.schema = schema;
 this.relDataType = relDataType;
}
origin: net.hydromatic/optiq

/** Returns an expression for the object wrapped by this schema (not the
 * schema itself). */
Expression getTargetExpression() {
 return Types.castIfNecessary(
   target.getClass(),
   Expressions.call(
     Types.castIfNecessary(
       ReflectiveSchema.class,
       getExpression()),
     BuiltinMethod.GET_TARGET.method));
}
origin: org.apache.optiq/optiq-core

 @Override
 public Expression getExpression(SchemaPlus schema, String tableName,
   Class clazz) {
  return Expressions.field(
    schema.unwrap(ReflectiveSchema.class).getTargetExpression(
      schema.getParentSchema(), schema.getName()), field);
 }
}
origin: net.hydromatic/optiq

/**
 * Creates a ReflectiveSchema within another schema.
 *
 * @param parentSchema Parent schema
 * @param name Name of new schema
 * @param target Object whose fields become the tables of the schema
 * @return New ReflectiveSchema
 */
public static ReflectiveSchema create(
  MutableSchema parentSchema,
  String name,
  Object target) {
 ReflectiveSchema schema =
   new ReflectiveSchema(
     parentSchema,
     name,
     target,
     parentSchema.getSubSchemaExpression(
       name, ReflectiveSchema.class));
 parentSchema.addSchema(name, schema);
 return schema;
}
origin: net.hydromatic/optiq

 public OptiqConnection createConnection() throws Exception {
  Class.forName("net.hydromatic.optiq.jdbc.Driver");
  Connection connection =
    DriverManager.getConnection("jdbc:optiq:");
  OptiqConnection optiqConnection =
    connection.unwrap(OptiqConnection.class);
  MutableSchema rootSchema =
    optiqConnection.getRootSchema();
  ReflectiveSchema.create(rootSchema, name, schema);
  optiqConnection.setSchema(name);
  return optiqConnection;
 }
});
origin: org.apache.optiq/optiq-core

 public OptiqConnection createConnection() throws Exception {
  Class.forName("net.hydromatic.optiq.jdbc.Driver");
  Connection connection =
    DriverManager.getConnection("jdbc:optiq:");
  OptiqConnection optiqConnection =
    connection.unwrap(OptiqConnection.class);
  SchemaPlus rootSchema =
    optiqConnection.getRootSchema();
  rootSchema.add(name, new ReflectiveSchema(schema));
  optiqConnection.setSchema(name);
  return optiqConnection;
 }
});
origin: net.hydromatic/optiq

static OptiqConnection getConnection(String... schema)
  throws ClassNotFoundException, SQLException {
 Class.forName("net.hydromatic.optiq.jdbc.Driver");
 Connection connection =
   DriverManager.getConnection("jdbc:optiq:");
 OptiqConnection optiqConnection =
   connection.unwrap(OptiqConnection.class);
 MutableSchema rootSchema = optiqConnection.getRootSchema();
 final List<String> schemaList = Arrays.asList(schema);
 if (schemaList.contains("hr")) {
  ReflectiveSchema.create(rootSchema, "hr", new HrSchema());
 }
 if (schemaList.contains("foodmart")) {
  ReflectiveSchema.create(
    rootSchema, "foodmart", new FoodmartSchema());
 }
 if (schemaList.contains("lingual")) {
  ReflectiveSchema.create(
    rootSchema, "SALES", new LingualSchema());
 }
 if (schemaList.contains("metadata")) {
  // always present
 }
 return optiqConnection;
}
origin: org.apache.optiq/optiq-core

  connection.unwrap(OptiqConnection.class);
SchemaPlus rootSchema = optiqConnection.getRootSchema();
rootSchema.add("hr", new ReflectiveSchema(new Hr()));
rootSchema.add("foodmart", new ReflectiveSchema(new Foodmart()));
Statement statement = connection.createStatement();
ResultSet resultSet =
origin: net.hydromatic/optiq

  connection.unwrap(OptiqConnection.class);
MutableSchema rootSchema = optiqConnection.getRootSchema();
ReflectiveSchema.create(rootSchema, "hr", new HrSchema());
ReflectiveSchema.create(rootSchema, "foodmart", new FoodmartSchema());
Statement statement = connection.createStatement();
ResultSet resultSet =
origin: org.apache.optiq/optiq-core

/** Test case for bug where if two tables have different element classes
 * but those classes have identical fields, Optiq would generate code to use
 * the wrong element class; a {@link ClassCastException} would ensue. */
@Test public void testDifferentTypesSameFields() throws Exception {
 Class.forName("net.hydromatic.optiq.jdbc.Driver");
 Connection connection = DriverManager.getConnection("jdbc:optiq:");
 OptiqConnection optiqConnection =
   connection.unwrap(OptiqConnection.class);
 final SchemaPlus rootSchema = optiqConnection.getRootSchema();
 rootSchema.add("TEST", new ReflectiveSchema(new MySchema()));
 Statement statement = optiqConnection.createStatement();
 ResultSet resultSet =
   statement.executeQuery("SELECT \"myvalue\" from TEST.\"mytable2\"");
 assertEquals("myvalue=2\n", OptiqAssert.toString(resultSet));
 resultSet.close();
 statement.close();
 connection.close();
}
net.hydromatic.optiq.impl.javaReflectiveSchema

Javadoc

Implementation of net.hydromatic.optiq.Schema that exposes the public fields and methods in a Java object.

Most used methods

  • <init>
    Creates a ReflectiveSchema.
  • create
    Creates a ReflectiveSchema within another schema.
  • fieldRelation
    Returns a table based on a particular field of this schema. If the field is not of the right type to
  • getElementType
    Deduces the element type of a collection; same logic as #toEnumerable
  • getExpression
  • getTargetExpression
    Returns an expression for the object wrapped by this schema (not the schema itself).
  • addTable
  • getQueryProvider
  • getTable
  • getTableMap
  • getTarget
    Returns the wrapped object. (May not appear to be used, but is used in generated code via BuiltinMet
  • methodMember
  • getTarget,
  • methodMember,
  • toEnumerable

Popular in Java

  • Creating JSON documents from java classes using gson
  • findViewById (Activity)
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now