text:
package org.apache.calcite.test;

import org.apache.calcite.linq4j.QueryProvider;
import org.apache.calcite.linq4j.Queryable;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelOptSchema;
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.prepare.Prepare;
import org.apache.calcite.rel.RelCollation;
import org.apache.calcite.rel.RelCollations;
import org.apache.calcite.rel.RelDistribution;
import org.apache.calcite.rel.RelDistributions;
import org.apache.calcite.rel.RelFieldCollation;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.logical.LogicalFilter;
import org.apache.calcite.rel.logical.LogicalProject;
import org.apache.calcite.rel.logical.LogicalTableScan;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeComparability;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.rel.type.RelDataTypeFieldImpl;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexInputRef;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.schema.ModifiableView;
import org.apache.calcite.schema.Path;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Schemas;
import org.apache.calcite.schema.Table;
import org.apache.calcite.sql.SqlAccessType;
import org.apache.calcite.sql.SqlFunctionCategory;
import org.apache.calcite.sql.SqlIdentifier;
import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.SqlSyntax;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.type.ObjectSqlType;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.validate.SqlModality;
import org.apache.calcite.sql.validate.SqlMoniker;
import org.apache.calcite.sql.validate.SqlMonikerImpl;
import org.apache.calcite.sql.validate.SqlMonikerType;
import org.apache.calcite.sql.validate.SqlMonotonicity;
import org.apache.calcite.sql.validate.SqlValidatorCatalogReader;
import org.apache.calcite.sql.validate.SqlValidatorUtil;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.ImmutableIntList;
import org.apache.calcite.util.Litmus;
import org.apache.calcite.util.Pair;
import org.apache.calcite.util.Util;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;

import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Mock implementation of {@link SqlValidatorCatalogReader} which returns tables
 * "EMP", "DEPT", "BONUS", "SALGRADE" (same as Oracle's SCOTT schema).
 * Also two streams "ORDERS", "SHIPMENTS";
 * and a view "EMP_20".
 */
public class MockCatalogReader implements Prepare.CatalogReader {
  //~ Static fields/initializers ---------------------------------------------

  protected static final String DEFAULT_CATALOG = "CATALOG";
  protected static final String DEFAULT_SCHEMA = "SALES";

  public static final Ordering<Iterable<String>>
  CASE_INSENSITIVE_LIST_COMPARATOR =
      Ordering.from(String.CASE_INSENSITIVE_ORDER).lexicographical();

  //~ Instance fields --------------------------------------------------------

  protected final RelDataTypeFactory typeFactory;
  private final boolean caseSensitive;
  private final boolean elideRecord = true;
  private final Map<List<String>, MockTable> tables;
  protected final Map<String, MockSchema> schemas;
  private RelDataType addressType;

  //~ Constructors -----------------------------------------------------------

  /**
   * Creates a MockCatalogReader.
   *
   *
Caller must then call {@link #init} to populate with data.

   *
   * @param typeFactory Type factory
   */
  public MockCatalogReader(RelDataTypeFactory typeFactory,
      boolean caseSensitive) {
    this.typeFactory = typeFactory;
    this.caseSensitive = caseSensitive;
    if (caseSensitive) {
      tables = Maps.newHashMap();
      schemas = Maps.newHashMap();
    } else {
      tables = Maps.newTreeMap(CASE_INSENSITIVE_LIST_COMPARATOR);
      schemas = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
    }
  }

  /**
   * Initializes this catalog reader.
   */
  public MockCatalogReader init() {
    final RelDataType intType =
        typeFactory.createSqlType(SqlTypeName.INTEGER);
    final RelDataType intTypeNull =
        typeFactory.createTypeWithNullability(intType, true);
    final RelDataType varchar10Type =
        typeFactory.createSqlType(SqlTypeName.VARCHAR, 10);
    final RelDataType varchar20Type =
        typeFactory.createSqlType(SqlTypeName.VARCHAR, 20);
    final RelDataType timestampType =
        typeFactory.createSqlType(SqlTypeName.TIMESTAMP);
    final RelDataType booleanType =
        typeFactory.createSqlType(SqlTypeName.BOOLEAN);
    final RelDataType rectilinearCoordType =
        typeFactory.builder().add("X", intType).add("Y", intType).build();

    // TODO jvs 12-Feb-2005: register this canonical instance with type
    // factory
    addressType =
        new ObjectSqlType(
            SqlTypeName.STRUCTURED,
            new SqlIdentifier("ADDRESS", SqlParserPos.ZERO),
            false,
            Arrays.asList(
                new RelDataTypeFieldImpl("STREET", 0, varchar20Type),
                new RelDataTypeFieldImpl("CITY", 1, varchar20Type),
                new RelDataTypeFieldImpl("ZIP", 1, intType),
                new RelDataTypeFieldImpl("STATE", 1, varchar20Type)),
            RelDataTypeComparability.NONE);

    // Register "SALES" schema.
    MockSchema salesSchema = new MockSchema("SALES");
    registerSchema(salesSchema);

    // Register "EMP" table.
    final MockTable empTable =
        MockTable.create(this, salesSchema, "EMP", false, 14);
    empTable.addColumn("EMPNO", intType);
    empTable.addColumn("ENAME", varchar20Type);
    empTable.addColumn("JOB", varchar10Type);
    empTable.addColumn("MGR", intTypeNull);
    empTable.addColumn("HIREDATE", timestampType);
    empTable.addColumn("SAL", intType);
    empTable.addColumn("COMM", intType);
    empTable.addColumn("DEPTNO", intType);
    empTable.addColumn("SLACKER", booleanType);
    registerTable(empTable);

    // Register "DEPT" table.
    MockTable deptTable = MockTable.create(this, salesSchema, "DEPT", false, 4);
    deptTable.addColumn("DEPTNO", intType);
    deptTable.addColumn("NAME", varchar10Type);
    registerTable(deptTable);

    // Register "BONUS" table.
    MockTable bonusTable = MockTable.create(this, salesSchema, "BONUS", false, 0);
    bonusTable.addColumn("ENAME", varchar20Type);
    bonusTable.addColumn("JOB", varchar10Type);
    bonusTable.addColumn("SAL", intType);
    bonusTable.addColumn("COMM", intType);
    registerTable(bonusTable);

    // Register "SALGRADE" table.
    MockTable salgradeTable = MockTable.create(this, salesSchema, "SALGRADE", false, 5);
    salgradeTable.addColumn("GRADE", intType);
    salgradeTable.addColumn("LOSAL", intType);
    salgradeTable.addColumn("HISAL", intType);
    registerTable(salgradeTable);

    // Register "EMP_ADDRESS" table
    MockTable contactAddressTable =
        MockTable.create(this, salesSchema, "EMP_ADDRESS", false, 26);
    contactAddressTable.addColumn("EMPNO", intType);
    contactAddressTable.addColumn("HOME_ADDRESS", addressType);
    contactAddressTable.addColumn("MAILING_ADDRESS", addressType);
    registerTable(contactAddressTable);

    // Register "CUSTOMER" schema.
    MockSchema customerSchema = new MockSchema("CUSTOMER");
    registerSchema(customerSchema);

    // Register "CONTACT" table.
    MockTable contactTable = MockTable.create(this, customerSchema, "CONTACT",
        false, 1000);
    contactTable.addColumn("CONTACTNO", intType);
    contactTable.addColumn("FNAME", varchar10Type);
    contactTable.addColumn("LNAME", varchar10Type);
    contactTable.addColumn("EMAIL", varchar20Type);
    contactTable.addColumn("COORD", rectilinearCoordType);
    registerTable(contactTable);

    // Register "ACCOUNT" table.
    MockTable accountTable = MockTable.create(this, customerSchema, "ACCOUNT",
        false, 457);
    accountTable.addColumn("ACCTNO", intType);
    accountTable.addColumn("TYPE", varchar20Type);
    accountTable.addColumn("BALANCE", intType);
    registerTable(accountTable);

    // Register "ORDERS" stream.
    MockTable ordersStream = MockTable.create(this, salesSchema, "ORDERS",
        true, Double.POSITIVE_INFINITY);
    ordersStream.addColumn("ROWTIME", timestampType);
    ordersStream.addMonotonic("ROWTIME");
    ordersStream.addColumn("PRODUCTID", intType);
    ordersStream.addColumn("ORDERID", intType);
    registerTable(ordersStream);

    // Register "SHIPMENTS" stream.
    MockTable shipmentsStream = MockTable.create(this, salesSchema, "SHIPMENTS",
        true, Double.POSITIVE_INFINITY);
    shipmentsStream.addColumn("ROWTIME", timestampType);
    shipmentsStream.addMonotonic("ROWTIME");
    shipmentsStream.addColumn("ORDERID", intType);
    registerTable(shipmentsStream);

    // Register "PRODUCTS" table.
    MockTable productsTable = MockTable.create(this, salesSchema, "PRODUCTS",
        false, 200D);
    productsTable.addColumn("PRODUCTID", intType);
    productsTable.addColumn("NAME", varchar20Type);
    productsTable.addColumn("SUPPLIERID", intType);
    registerTable(productsTable);

    // Register "SUPPLIERS" table.
    MockTable suppliersTable = MockTable.create(this, salesSchema, "SUPPLIERS",
        false, 10D);
    suppliersTable.addColumn("SUPPLIERID", intType);
    suppliersTable.addColumn("NAME", varchar20Type);
    suppliersTable.addColumn("CITY", intType);
    registerTable(suppliersTable);

    // Register "EMP_20" view.
    // Same columns as "EMP",
    // but "DEPTNO" not visible and set to 20 by default
    // and "SAL" is visible but must be greater than 1000
    MockTable emp20View = new MockTable(this, salesSchema.getCatalogName(),
        salesSchema.name, "EMP_20", false, 600) {
      private final Table table = empTable.unwrap(Table.class);
      private final ImmutableIntList mapping =
          ImmutableIntList.of(0, 1, 2, 3, 4, 5, 6, 8);

      @Override public RelNode toRel(ToRelContext context) {
        // Expand to the equivalent of:
        //   SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, SLACKER
        //   FROM EMP
        //   WHERE DEPTNO = 20 AND SAL > 1000
        RelNode rel = LogicalTableScan.create(context.getCluster(), empTable);
        final RexBuilder rexBuilder = context.getCluster().getRexBuilder();
        rel = LogicalFilter.create(rel,
            rexBuilder.makeCall(
                SqlStdOperatorTable.AND,
                rexBuilder.makeCall(SqlStdOperatorTable.EQUALS,
                    rexBuilder.makeInputRef(rel, 7),
                    rexBuilder.makeExactLiteral(BigDecimal.valueOf(20))),
                rexBuilder.makeCall(SqlStdOperatorTable.GREATER_THAN,
                    rexBuilder.makeInputRef(rel, 5),
                    rexBuilder.makeExactLiteral(BigDecimal.valueOf(1000)))));
        final List<RelDataTypeField> fieldList =
            rel.getRowType().getFieldList();
        final List<Pair<RexNode, String>> projects =
            new AbstractList<Pair<RexNode, String>>() {
              @Override public Pair<RexNode, String> get(int index) {
                return RexInputRef.of2(mapping.get(index), fieldList);
              }

              @Override public int size() {
                return mapping.size();
              }
            };
        return LogicalProject.create(rel, Pair.left(projects),
            Pair.right(projects));
      }

      @Override public <T> T unwrap(Class<T> clazz) {
        if (clazz.isAssignableFrom(ModifiableView.class)) {
          return clazz.cast(
              new JdbcTest.AbstractModifiableView() {
                @Override public Table getTable() {
                  return empTable.unwrap(Table.class);
                }

                @Override public Path getTablePath() {
                  final ImmutableList.Builder<Pair<String, Schema>> builder =
                      ImmutableList.builder();
                  builder.add(Pair.<String, Schema>of(empTable.names.get(0), null));
                  builder.add(Pair.<String, Schema>of(empTable.names.get(1), null));
                  builder.add(Pair.<String, Schema>of(empTable.names.get(2), null));
                  return Schemas.path(builder.build());
//                  return empTable.names;
                }

                @Override public ImmutableIntList getColumnMapping() {
                  return mapping;
                }

                @Override public RexNode getConstraint(RexBuilder rexBuilder,
                    RelDataType tableRowType) {
                  final RelDataTypeField deptnoField =
                      tableRowType.getFieldList().get(7);
                  final RelDataTypeField salField =
                      tableRowType.getFieldList().get(5);
                  final List<RexNode> nodes = Arrays.asList(
                      rexBuilder.makeCall(SqlStdOperatorTable.EQUALS,
                          rexBuilder.makeInputRef(deptnoField.getType(),
                              deptnoField.getIndex()),
                          rexBuilder.makeExactLiteral(BigDecimal.valueOf(20L),
                              deptnoField.getType())),
                      rexBuilder.makeCall(SqlStdOperatorTable.GREATER_THAN,
                          rexBuilder.makeInputRef(salField.getType(),
                              salField.getIndex()),
                          rexBuilder.makeExactLiteral(BigDecimal.valueOf(1000L),
                              salField.getType())));
                  return RexUtil.composeConjunction(rexBuilder, nodes, false);
                }

                @Override public RelDataType
                getRowType(final RelDataTypeFactory typeFactory) {
                  return typeFactory.createStructType(
                      new AbstractList<Map.Entry<String, RelDataType>>() {
                        @Override public Map.Entry<String, RelDataType>
                        get(int index) {
                          return table.getRowType(typeFactory).getFieldList()
                              .get(mapping.get(index));
                        }

                        @Override public int size() {
                          return mapping.size();
                        }
                      }
                  );
                }
              });
        }
        return super.unwrap(clazz);
      }
    };
    salesSchema.addTable(Util.last(emp20View.getQualifiedName()));
    emp20View.addColumn("EMPNO", intType);
    emp20View.addColumn("ENAME", varchar20Type);
    emp20View.addColumn("JOB", varchar10Type);
    emp20View.addColumn("MGR", intTypeNull);
    emp20View.addColumn("HIREDATE", timestampType);
    emp20View.addColumn("SAL", intType);
    emp20View.addColumn("COMM", intType);
    emp20View.addColumn("SLACKER", booleanType);
    registerTable(emp20View);

    return this;
  }

  //~ Methods ----------------------------------------------------------------

  public void lookupOperatorOverloads(SqlIdentifier opName,
      SqlFunctionCategory category, SqlSyntax syntax,
      List<SqlOperator> operatorList) {
  }

  public List<SqlOperator> getOperatorList() {
    return ImmutableList.of();
  }

  public Prepare.CatalogReader withSchemaPath(List<String> schemaPath) {
    return this;
  }

  public Prepare.PreparingTable getTableForMember(List<String> names) {
    return getTable(names);
  }

  public RelDataTypeFactory getTypeFactory() {
    return typeFactory;
  }

  public void registerRules(RelOptPlanner planner) {
  }

  protected void registerTable(MockTable table) {
    table.onRegister(typeFactory);
    tables.put(table.getQualifiedName(), table);
  }

  protected void registerSchema(MockSchema schema) {
    schemas.put(schema.name, schema);
  }

  public Prepare.PreparingTable getTable(final List<String> names) {
    switch (names.size()) {
    case 1:
      // assume table in SALES schema (the original default)
      // if it's not supplied, because SqlValidatorTest is effectively
      // using SALES as its default schema.
      return tables.get(
          ImmutableList.of(DEFAULT_CATALOG, DEFAULT_SCHEMA, names.get(0)));
    case 2:
      return tables.get(
          ImmutableList.of(DEFAULT_CATALOG, names.get(0), names.get(1)));
    case 3:
      return tables.get(names);
    default:
      return null;
    }
  }

  public RelDataType getNamedType(SqlIdentifier typeName) {
    if (typeName.equalsDeep(addressType.getSqlIdentifier(), Litmus.IGNORE)) {
      return addressType;
    } else {
      return null;
    }
  }

  public List<SqlMoniker> getAllSchemaObjectNames(List<String> names) {
    List<SqlMoniker> result;
    switch (names.size()) {
    case 0:
      // looking for catalog and schema names
      return ImmutableList.<SqlMoniker>builder()
          .add(new SqlMonikerImpl(DEFAULT_CATALOG, SqlMonikerType.CATALOG))
          .addAll(getAllSchemaObjectNames(ImmutableList.of(DEFAULT_CATALOG)))
          .build();
    case 1:
      // looking for schema names
      result = Lists.newArrayList();
      for (MockSchema schema : schemas.values()) {
        final String catalogName = names.get(0);
        if (schema.getCatalogName().equals(catalogName)) {
          final ImmutableList<String> names1 =
              ImmutableList.of(catalogName, schema.name);
          result.add(new SqlMonikerImpl(names1, SqlMonikerType.SCHEMA));
        }
      }
      return result;
    case 2:
      // looking for table names in the given schema
      MockSchema schema = schemas.get(names.get(1));
      if (schema == null) {
        return Collections.emptyList();
      }
      result = Lists.newArrayList();
      for (String tableName : schema.tableNames) {
        result.add(
            new SqlMonikerImpl(
                ImmutableList.of(schema.getCatalogName(), schema.name,
                    tableName),
                SqlMonikerType.TABLE));
      }
      return result;
    default:
      return Collections.emptyList();
    }
  }

  public List<String> getSchemaName() {
    return ImmutableList.of(DEFAULT_CATALOG, DEFAULT_SCHEMA);
  }

  public RelDataTypeField field(RelDataType rowType, String alias) {
    return SqlValidatorUtil.lookupField(caseSensitive, elideRecord, rowType,
        alias);
  }

  public int fieldOrdinal(RelDataType rowType, String alias) {
    final RelDataTypeField field = field(rowType, alias);
    return field != null ? field.getIndex() : -1;
  }

  public boolean matches(String string, String name) {
    return Util.matches(caseSensitive, string, name);
  }

  public int match(List<String> strings, String name) {
    return Util.findMatch(strings, name, caseSensitive);
  }

  public RelDataType createTypeFromProjection(final RelDataType type,
      final List<String> columnNameList) {
    return SqlValidatorUtil.createTypeFromProjection(type, columnNameList,
        typeFactory, caseSensitive, elideRecord);
  }

  private static List<RelCollation> deduceMonotonicity(
      Prepare.PreparingTable table) {
    final List<RelCollation> collationList = Lists.newArrayList();

    // Deduce which fields the table is sorted on.
    int i = -1;
    for (RelDataTypeField field : table.getRowType().getFieldList()) {
      ++i;
      final SqlMonotonicity monotonicity =
          table.getMonotonicity(field.getName());
      if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) {
        final RelFieldCollation.Direction direction =
            monotonicity.isDecreasing()
                ? RelFieldCollation.Direction.DESCENDING
                : RelFieldCollation.Direction.ASCENDING;
        collationList.add(
            RelCollations.of(
                new RelFieldCollation(i, direction)));
      }
    }
    return collationList;
  }

  //~ Inner Classes ----------------------------------------------------------

  /** Mock schema. */
  public static class MockSchema {
    private final List<String> tableNames = Lists.newArrayList();
    private String name;

    public MockSchema(String name) {
      this.name = name;
    }

    public void addTable(String name) {
      tableNames.add(name);
    }

    public String getCatalogName() {
      return DEFAULT_CATALOG;
    }
  }

  /**
   * Mock implementation of
   * {@link org.apache.calcite.prepare.Prepare.PreparingTable}.
   */
  public static class MockTable implements Prepare.PreparingTable {
    protected final MockCatalogReader catalogReader;
    private final boolean stream;
    private final double rowCount;
    private final List<Map.Entry<String, RelDataType>> columnList =
        Lists.newArrayList();
    private RelDataType rowType;
    private List<RelCollation> collationList;
    protected final List<String> names;
    private final Set<String> monotonicColumnSet = Sets.newHashSet();

    public MockTable(MockCatalogReader catalogReader, String catalogName,
        String schemaName, String name, boolean stream, double rowCount) {
      this.catalogReader = catalogReader;
      this.stream = stream;
      this.rowCount = rowCount;
      this.names = ImmutableList.of(catalogName, schemaName, name);
    }

    public static MockTable create(MockCatalogReader catalogReader,
        MockSchema schema, String name, boolean stream, double rowCount) {
      MockTable table =
          new MockTable(catalogReader, schema.getCatalogName(), schema.name,
              name, stream, rowCount);
      schema.addTable(name);
      return table;
    }

    public <T> T unwrap(Class<T> clazz) {
      if (clazz.isInstance(this)) {
        return clazz.cast(this);
      }
      if (clazz.isAssignableFrom(Table.class)) {
        return clazz.cast(
            new JdbcTest.AbstractModifiableTable(Util.last(names)) {
              @Override public RelDataType
              getRowType(RelDataTypeFactory typeFactory) {
                return typeFactory.createStructType(rowType.getFieldList());
              }

              @Override public Collection getModifiableCollection() {
                return null;
              }

              @Override public <E> Queryable<E>
              asQueryable(QueryProvider queryProvider, SchemaPlus schema,
                  String tableName) {
                return null;
              }

              @Override public Type getElementType() {
                return null;
              }

              @Override public Expression getExpression(SchemaPlus schema,
                  String tableName, Class clazz) {
                return null;
              }
            });
      }
      return null;
    }

    public double getRowCount() {
      return rowCount;
    }

    public RelOptSchema getRelOptSchema() {
      return catalogReader;
    }

    public RelNode toRel(ToRelContext context) {
      return LogicalTableScan.create(context.getCluster(), this);
    }

    public List<RelCollation> getCollationList() {
      return collationList;
    }

    public RelDistribution getDistribution() {
      return RelDistributions.BROADCAST_DISTRIBUTED;
    }

    public boolean isKey(ImmutableBitSet columns) {
      return false;
    }

    public RelDataType getRowType() {
      return rowType;
    }

    public boolean supportsModality(SqlModality modality) {
      return modality == (stream ? SqlModality.STREAM : SqlModality.RELATION);
    }

    public void onRegister(RelDataTypeFactory typeFactory) {
      rowType = typeFactory.createStructType(columnList);
      collationList = deduceMonotonicity(this);
    }

    public List<String> getQualifiedName() {
      return names;
    }

    public SqlMonotonicity getMonotonicity(String columnName) {
      return monotonicColumnSet.contains(columnName)
          ? SqlMonotonicity.INCREASING
          : SqlMonotonicity.NOT_MONOTONIC;
    }

    public SqlAccessType getAllowedAccess() {
      return SqlAccessType.ALL;
    }

    public Expression getExpression(Class clazz) {
      throw new UnsupportedOperationException();
    }

    public void addColumn(String name, RelDataType type) {
      columnList.add(Pair.of(name, type));
    }

    public void addMonotonic(String name) {
      monotonicColumnSet.add(name);
      assert Pair.left(columnList).contains(name);
    }

    public RelOptTable extend(List<RelDataTypeField> extendedFields) {
      final MockTable table = new MockTable(catalogReader, names.get(0),
          names.get(1), names.get(2), stream, rowCount);
      table.columnList.addAll(columnList);
      table.columnList.addAll(extendedFields);
      table.onRegister(catalogReader.typeFactory);
      return table;
    }
  }
}

// End MockCatalogReader.java

redpajama_set_name: RedPajamaGithub


The reowned HK director Zheng Jicheng and gold medal screenwriter Qin Ting's coopertation drama JIANG JI JIU JI, which stars Alec Su You Peng, Li Qian, Ye Tong, Qin Pei, and Fan Yimin, has entered the finally filming stage. Having filmed for more than two months, the entire crew and staff is quite confident with its modern drama. Especially Su You Peng, who from the early beginning and throughout filming has fully praised JIANG JI JIU JI, claiming he was "unable to put down the script". Because of this, many fans of Su You Peng, Li Qian, Ye Tong and Qin Pei have high hopes on the new drama and all are very much anticipating its broadcast date.
And also because of it, Su You Peng was unable to attend this year's Mid-Autumn's Festival. He told us, he was actually very much anticipating to meet again with Wu Qinlong and Chen Zhipeng for the "Small Tiger" reunion. But due to time conflict schedule of JIANG JI JIU JI, a drama in which he feels he has very much responsibility and passionate love towards, thus had chosen to give up attending the festival event.


text:
Western Philosophy
https://www.mindmeister.com/23290325/western-philosophy
12 Visualizations That Will Change the Way You View Scale in Your World Scale is a simple concept. From a very early age, children know about big and small, heavy and light, more and less. Extreme scales, however, are another story. Try to imagine, for example, the size of the universe… or $1 trillion made up entirely of dollar bills. Exactly. Grasping the actual quantities involved in extreme scales can be difficult, which makes managing scale in visualizations an interesting problem. Sun Tzu If you know your enemies and know yourself, you will not be imperiled in a hundred battles... if you do not know your enemies nor yourself, you will be imperiled in every single battle. Sun Tzu 孫子; Sūn Zǐ; (c. 6th century BCE) was a Chinese general, military strategist, and author of The Art of War, an immensely influential ancient Chinese book on military strategy; also known as Sun Wu (孫武; Sūn Wǔ), and Chang Qing (長卿; Cháng Qīng). The Art of War[edit]
Anarchism: For & Against by Albert Meltzer Table of Contents Introduction Inalienable Tenets of Anarchism The Class Struggle Organisation and Anarchism The Role of an Anarchist in an Authoritarian Society Bringing About the New Society The Marxist Criticism of Anarchism The Social-Democratic Critique of Anarchism The Liberal-Democratic Objection to Anarchism The Fascist Objection to Anarchism The Average Person's Objection to Anarchism Introduction
The Brain—Information about the Brain 1 Introduction "I think, therefore I am." —René Descartes, 17th-century philosopher What topics science lovers link to the most Hilary Mason, chief scientist at bitly, examined links to 600 science pages and the pages that those people visited next: The results revealed which subjects were strongly and weakly associated. Chemistry was linked to almost no other science.
How to read and understand a scientific paper: a guide for non-scientists Update (1/3/18) I've been overwhelmed with requests for the shorter guide, and the email address below no longer works. So I've uploaded a copy of the guide for anyone to download and share here: How to read and understand a scientific article. Please feel free to use it however you wish (although I'd appreciate being credited as the author). All About Anarchism This classic statement of anarchism was written by a diverse group of anarchists in Cardiff around 1980 and it is an interesting historical record of the optimism of mainstream anarchist thought at that time. There is probably more rubbish talked about anarchism than any other political idea. Actually, it has nothing to do with a belief in chaos, death and destruction. Anarchists do not normally carry bombs, nor do they ascribe any virtue to beating up old ladies. It is no accident that the sinister image of the mad anarchist is so accepted.
7 stupid thinking errors you probably make The brain isn't a flawless piece of machinery. Although it is powerful and comes in an easy to carry container, it has it's weaknesses. A field in psychology which studies these errors, known as biases. Although you can't upgrade your mental hardware, noticing these biases can clue you into possible mistakes.How Bias Hurts You
Related: Compilations • Philosophy • liurhea
Related: Reductionism - Wikipedia, the free encyclopedia - Philosophy - Wikipedia, the free encyclopedia - Uncertainty principle - Wikipedia, the free encyclopedia - Atheism - Metacognition - Wikipedia, the free encyclopedia - Fractal - Wikipedia, the free encyclopedia - Uncertainty - Wikipedia, the free encyclopedia - Religion - Wikipedia, the free encyclopedia - Pantheism - Wikipedia, the free encyclopedia - Deism - Wikipedia, the free encyclopedia - Free will - Wikipedia, the free encyclopedia - Post-structuralism - Wikipedia, the free encyclopedia - Structuralism - Wikipedia, the free encyclopedia - Agnosticism - Wikipedia, the free encyclopedia - Skepticism - Wikipedia, the free encyclopedia - Nihilism - Wikipedia, the free encyclopedia - Philosophy of mind - Wikipedia, the free encyclopedia - Philosophy of religion - Wikipedia, the free encyclopedia - Emergentism - Wikipedia, the free encyclopedia - Positivism - Wikipedia, the free encyclopedia - Philosophy of science - Wikipedia, the free encyclopedia - Rhetoric - Wikipedia, the free encyclopedia - 'Pataphysics - Wikipedia, the free encyclopedia - Existentialism - Wikipedia, the free encyclopedia - Determinism - Wikipedia, the free encyclopedia - Holism - Wikipedia, the free encyclopedia - Scientism - Wikipedia, the free encyclopedia - Gödel's incompleteness theorems - Epicureanism - Wikipedia, the free encyclopedia - Dinosaur - Wikipedia, the free encyclopedia - Materialism - Wikipedia, the free encyclopedia - Physicalism - Wikipedia, the free encyclopedia - Mereology - Wikipedia, the free encyclopedia - Online Psychology Research | Links to hundreds of Psychology studies running on the internet | Online Psychology Research Ltd - Idealism - Wikipedia, the free encyclopedia - Absurdism - Wikipedia, the free encyclopedia

redpajama_set_name: RedPajamaCommonCrawl


text:
Víctor Morales Lezcano (Las Palmas de Gran Canaria, España) es un historiador español, autor de varias obras sobre el Magreb y sus relaciones con España.

Biografía
Nacido en las islas Canarias, es doctor por la Universidad Complutense de Madrid.

Es autor de obras como El colonialismo español en Marruecos, 1850-1956 (1976), Historia de la no-beligerancia española durante la segunda guerra mundial (1980), España y el Norte de África. El Protectorado de Marruecos (1912-1956) (1984), Africanismo y orientalismo español en el siglo XIX (1988), España y mundo árabe: imágenes cruzadas (1993), El final del protectorado hispano-francés en Marruecos. El desafío del nacionalismo (1945-1962) (1998), Diálogos ribereños (I). Conversaciones con miembros de la élite marroquí, Diálogos ribereños (II). Conversaciones con miembros de la élite tunecina (2005), Historia de Marruecos: de los orígenes tribales y las poblaciones nómadas a la independencia y la monarquía actual (2006), Actas del Primer Simposio Canarias y el Noroeste de África : historia de una frontera (2007), junto a Javier Ponce Marrero, o Entre ambas orillas: ensayos de historia hispano-magrebíes (2008), entre otras.

Referencias

Bibliografía

Nacidos en Las Palmas de Gran Canaria
Historiadores de España del siglo XX
Historiadores de España del siglo XXI
Alumnado de la Universidad Complutense de Madrid
Profesores de la Universidad Nacional de Educación a Distancia
Estudiosos del protectorado español de Marruecos
Estudiosos de las relaciones internacionales de España

redpajama_set_name: RedPajamaWikipedia


text:
William Shakespeare's 400th: Your complete guide to Doctor Who and the Bard
Cameron K McEwanSaturday 23 Apr 2016 9:00 am
Dean Lennox Kelly taking his bow as the Bard in The Shakespeare Code (Picture: BBC)
Words fans rejoice as the inventor of every word known to mankind, William Shakespeare, is celebrating his 400th deathday.
Well, it might not be every word ever, but he definitely came up with the best ones.
Speaking of the best, Doctor Who has referenced the Bard and his works on a plethora of occasions. In fact, Shakespeare has even met everyone's favourite Time Lord. In preparation for the big day, here's a handy guide to the world's best television show and the world's greatest writer.
The very first mention of Billy S came courtesy of school teacher and companion, Barbara, in the show's second season. Ever the educator, she wanted to spread the word of Romeo & Juliet in the historic adventure The Crusade.
Fans of timey-wimey fun will note that Shakespeare would come into existence some 400 years or so after the events of the story. Cheeky old Babs.
A few episodes later and the original Team TARDIS took a bit of time off from their adventures to tune in to the Time-Space Visualiser, where they could enjoy "any event" in history.
Along with The Beatles (who we mentioned last week from the same ep), the gang observed Queen Elizabeth I and Francis Bacon meeting with the writer, discussing Falstaff and Hamlet.
Shakespeare appeared in The Chase, but didn't meet the Doctor face-to-face (Picture: BBC)
In the very next story, The Meddling Monk, the titular monk wanted to meddle with time, thus allowing Shakey to put on Hamlet live on television. The crazy bastard didn't get away with it though.
It would be some years later until Big Willy got another citation. In 1974's Revenge Of The Cybermen, The Fourth Doctor quoted Macbeth after killing one the Cybermen – "dusty death. Out, out with."
The following year, in the mindf**k story (in a good way), Planet Of Evil, Tom Baker referred to the playwright as a "charming fellow," but a "dreadful actor." OUCH! He also almost gets "Night's candles are burnt out, and jocund day stands tiptoe on the misty mountain tops," from Romeo & Juliet word-perfect in the same adventure.
Eagle-eyed viewers in 1976's The Masque Of Mandragora will have noticed that many of the costumes were originally used in Renato Castellani's 1954 big screen version of Romeo & Juliet.
In fan-favourite City Of Death, the Fourth Doctor described a young Shakespeare as "very taciturn," whilst also boasting about warning William off using the mixed metaphor, "to take arms against a sea of troubles," in Hamlet. More from the same play in the same season when the Gallifreyan exclaimed, "Oh my prophetic soul," in The Horns Of Nimon.
Moving ahead a couple of years with a new fresh-faced Time Lord, Peter Davison found his thespian notions in Kinda, where he misquotes The Tempest; delivering, "Such stuff as dreams are made of," instead of "on." Give him a break, he was almost 900 years old!
David Tennant did a much better job remembering his lines when he played Hamlet (Picture: RSC)
Moving on to the next and more vulgar regeneration, The Sixth Doctor slotted in three references to the writer during his short time in the TARDIS. In Timelash, a story featuring author HG Wells, the Time Lord misquotes Hamlet once more whilst in the following story, The Two Doctors, he gets it right this time, quoting the same play's, "Good Night Sweet Prince." And in Colin Baker's final television story, The Ultimate Foe, Hamlet is quoted at him by his nemesis, The Valeyard.
On to new Who with the Tenth Doctor and a memorable meeting with the Bard himself!
Will and the Doctor finally met after years of references and misquotes (Picture: BBC)
In The Shakespeare Code, the Tenth Doctor and companion Martha Jones took a trip back in time to enjoy some jovial japes with a more rock 'n' roll version of the famed writer than we've been used to.
The episode itself featured numerous references to plays – some written, some yet to be – with the Time Lord influencing the odd idea here and there.
Fans smirked when aliens the Sycorax from The Christmas Invasion got name-checked, causing William to comment, "Nice word. I'll have that off you as well." Sycorax was an unseen character in Shakey's, The Tempest (the same play cropped up in a conversation between an Eleventh Doctor lookalike teacher and Clara in 2014's The Caretaker).
A couple of episodes after their meeting with the Bard, Daleks in Manhattan would see Martha Jones recall her time on stage performing Shakespeare.
Most recently in 2015, the episode title Sleep No More, written by Sherlock co-creator and award-winning thespian Mark Gatiss, is taken from Macbeth. Peter Capaldi's Twelfth Doctor also mourns, "Glamis hath murdered sleep, therefore Cawdor shall sleep no more. Macbeth shall sleep no more."
So there you go! Raise a glass and stick on a Doctor Who story of your choice to celebrate William Shakespeare's anniversary.
MORE: 10th anniversary of David Tennant's Doctor Who: 10 great things about his first series
MORE: Peter Capaldi, Jenna Coleman and 5 more cameos we'd love to see in new Doctor Who spin-off Class
David TennantDoctor WhoWilliam Shakespeare
Doctor Who's Jodie Whittaker and Matt Smith at risk of creating time rift at festival
Jodie Whittaker turns up to set of Doctor Who season 12 in her actual birthday suit
Freema Agyeman reflects on life after Doctor Who: 'Fandom does affect your career'
The Simpsons to spoof Stranger Things in Treehouse Of Horror XXX
Who plays Alexei in Stranger Things season three?
Fair City and Peaky Blinders actor Karl Shiels dies suddenly aged 47
Love Island set to welcome new bombshell tonight on top of savage dumping twist
Love Island newbie Harley Brash already knows Amber Gill and has connections to previous contestants
Home › Entertainment › TV


text:
Shops Contact us Find a foodbank
Login into Assemble
How food banks work
More than food
Find a Food Bank
Church support
Start a Food bank
Find a foodbank
Opportunity details
Food bank driver (Redbridge Foodbank Drivers)
Our food bank provides emergency food and compassionate, practical support to people in crisis, while campaigning for a UK without the need for food banks. Without our volunteers, selflessly donating their time, we simply would not be able to support the thousands of people in crisis.
The number of people needing food banks has increased in recent years and we anticipate this trend to continue especially in light of the Covid-19 pandemic. As a driver you will play a vital role to our food bank ensuring that we are meeting the demand for our services, providing help and support to people in crisis in the local community.
We need drivers to help deliver food parcels to our local foodbank centres and pick up food donations from supermarkets and different destinations around Redbridge . If you are over 25, have been driving for over a year and have no points on your licence then please apply.
Fundraise-old
Events-old
© 2020 Reg. Charity in England & Wales (1110522) and Scotland (SC044246). Reg. Ltd. Co. in England & Wales (5434524)
Website by Reason Digital


text:
Road closed after cladding fell from roof
(Last Updated On: August 4, 2014)
A road was closed in Torquay yesterday (Saturday 2 August) after cladding from a roof became loose and fell onto the road below.
Emergency services were called to Mckay Avenue just after 2pm and the road was closed whilst the area was made safe.
Police attended the scene due to a window of a parked car being damaged by falling cladding.
The fire service said:
"One fire appliance from Torquay attended a block of flats which had an unsafe roof, with bits of cladding blowing off.
"Crews arrived on scene and requested the attendance of the aerial ladder platform from Torquay.
"Crews put a cordon in place and made the roof safe using the aerial appliance and small tools. Duty of care was left with the housing association."
The road was reopened after 2 hours.
Keep up to date about what's happening around South Devon,
join us on facebook.
Living Coasts: an exotic roof-garden with penguins?
Change is in the air at Living Coasts – or perhaps it's in the soil. There's a new and distinctly exotic feel to Torquay's coastal zoo, but it has nothing to do with the penguins or fur seals. This is…
Upcoming free events in Torbay
Looking for things to do this summer? We have combined a list of local FREE events happening around Torbay. From Carnival week to Lights and lanterns, there is plenty for you and the family to g…
Children's nurse awarded top nursing title
Lisa Pullen, a community children's nurse with Torbay and South Devon NHS Foundation Trust has been awarded the prestigious title of Queen's Nurse (QN). Lisa was awarded the nationally important ti…