text:
package org.apache.calcite.test;

import org.apache.calcite.adapter.enumerable.EnumerableMergeJoin;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelOptPredicateList;
import org.apache.calcite.plan.RelOptSchema;
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.rel.InvalidRelException;
import org.apache.calcite.rel.RelCollation;
import org.apache.calcite.rel.RelCollationTraitDef;
import org.apache.calcite.rel.RelCollations;
import org.apache.calcite.rel.RelFieldCollation;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.RelRoot;
import org.apache.calcite.rel.core.Aggregate;
import org.apache.calcite.rel.core.AggregateCall;
import org.apache.calcite.rel.core.Join;
import org.apache.calcite.rel.core.JoinRelType;
import org.apache.calcite.rel.core.Project;
import org.apache.calcite.rel.core.SemiJoin;
import org.apache.calcite.rel.core.Sort;
import org.apache.calcite.rel.logical.LogicalAggregate;
import org.apache.calcite.rel.logical.LogicalFilter;
import org.apache.calcite.rel.logical.LogicalJoin;
import org.apache.calcite.rel.logical.LogicalProject;
import org.apache.calcite.rel.logical.LogicalSort;
import org.apache.calcite.rel.logical.LogicalTableScan;
import org.apache.calcite.rel.logical.LogicalUnion;
import org.apache.calcite.rel.logical.LogicalValues;
import org.apache.calcite.rel.metadata.CachingRelMetadataProvider;
import org.apache.calcite.rel.metadata.ChainedRelMetadataProvider;
import org.apache.calcite.rel.metadata.DefaultRelMetadataProvider;
import org.apache.calcite.rel.metadata.Metadata;
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelColumnOrigin;
import org.apache.calcite.rel.metadata.RelMdCollation;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexLiteral;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.tools.Frameworks;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.ImmutableIntList;

import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

import org.hamcrest.CoreMatchers;
import org.hamcrest.Matcher;
import org.junit.Ignore;
import org.junit.Test;

import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

/**
 * Unit test for {@link DefaultRelMetadataProvider}. See
 * {@link SqlToRelTestBase} class comments for details on the schema used. Note
 * that no optimizer rules are fired on the translation of the SQL into
 * relational algebra (e.g. join conditions in the WHERE clause will look like
 * filters), so it's necessary to phrase the SQL carefully.
 */
public class RelMetadataTest extends SqlToRelTestBase {
  //~ Static fields/initializers ---------------------------------------------

  private static final double EPSILON = 1.0e-5;

  private static final double DEFAULT_EQUAL_SELECTIVITY = 0.15;

  private static final double DEFAULT_EQUAL_SELECTIVITY_SQUARED =
      DEFAULT_EQUAL_SELECTIVITY * DEFAULT_EQUAL_SELECTIVITY;

  private static final double DEFAULT_COMP_SELECTIVITY = 0.5;

  private static final double DEFAULT_NOTNULL_SELECTIVITY = 0.9;

  private static final double DEFAULT_SELECTIVITY = 0.25;

  private static final double EMP_SIZE = 1000.0;

  private static final double DEPT_SIZE = 100.0;

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

  private static Matcher<? super Number> nearTo(Number v, Number epsilon) {
    return equalTo(v); // TODO: use epsilon
  }

  // ----------------------------------------------------------------------
  // Tests for getPercentageOriginalRows
  // ----------------------------------------------------------------------

  private RelNode convertSql(String sql) {
    final RelRoot root = tester.convertSqlToRel(sql);
    DefaultRelMetadataProvider provider = new DefaultRelMetadataProvider();
    root.rel.getCluster().setMetadataProvider(provider);
    return root.rel;
  }

  private void checkPercentageOriginalRows(String sql, double expected) {
    checkPercentageOriginalRows(sql, expected, EPSILON);
  }

  private void checkPercentageOriginalRows(
      String sql,
      double expected,
      double epsilon) {
    RelNode rel = convertSql(sql);
    Double result = RelMetadataQuery.getPercentageOriginalRows(rel);
    assertTrue(result != null);
    assertEquals(expected, result, epsilon);
  }

  @Test public void testPercentageOriginalRowsTableOnly() {
    checkPercentageOriginalRows(
        "select * from dept",
        1.0);
  }

  @Test public void testPercentageOriginalRowsAgg() {
    checkPercentageOriginalRows(
        "select deptno from dept group by deptno",
        1.0);
  }

  @Ignore
  @Test public void testPercentageOriginalRowsOneFilter() {
    checkPercentageOriginalRows(
        "select * from dept where deptno = 20",
        DEFAULT_EQUAL_SELECTIVITY);
  }

  @Ignore
  @Test public void testPercentageOriginalRowsTwoFilters() {
    checkPercentageOriginalRows("select * from (\n"
        + "  select * from dept where name='X')\n"
        + "where deptno = 20",
        DEFAULT_EQUAL_SELECTIVITY_SQUARED);
  }

  @Ignore
  @Test public void testPercentageOriginalRowsRedundantFilter() {
    checkPercentageOriginalRows("select * from (\n"
        + "  select * from dept where deptno=20)\n"
        + "where deptno = 20",
        DEFAULT_EQUAL_SELECTIVITY);
  }

  @Test public void testPercentageOriginalRowsJoin() {
    checkPercentageOriginalRows(
        "select * from emp inner join dept on emp.deptno=dept.deptno",
        1.0);
  }

  @Ignore
  @Test public void testPercentageOriginalRowsJoinTwoFilters() {
    checkPercentageOriginalRows("select * from (\n"
        + "  select * from emp where deptno=10) e\n"
        + "inner join (select * from dept where deptno=10) d\n"
        + "on e.deptno=d.deptno",
        DEFAULT_EQUAL_SELECTIVITY_SQUARED);
  }

  @Test public void testPercentageOriginalRowsUnionNoFilter() {
    checkPercentageOriginalRows(
        "select name from dept union all select ename from emp",
        1.0);
  }

  @Ignore
  @Test public void testPercentageOriginalRowsUnionLittleFilter() {
    checkPercentageOriginalRows(
        "select name from dept where deptno=20"
            + " union all select ename from emp",
        ((DEPT_SIZE * DEFAULT_EQUAL_SELECTIVITY) + EMP_SIZE)
            / (DEPT_SIZE + EMP_SIZE));
  }

  @Ignore
  @Test public void testPercentageOriginalRowsUnionBigFilter() {
    checkPercentageOriginalRows(
        "select name from dept"
            + " union all select ename from emp where deptno=20",
        ((EMP_SIZE * DEFAULT_EQUAL_SELECTIVITY) + DEPT_SIZE)
            / (DEPT_SIZE + EMP_SIZE));
  }

  // ----------------------------------------------------------------------
  // Tests for getColumnOrigins
  // ----------------------------------------------------------------------

  private Set<RelColumnOrigin> checkColumnOrigin(String sql) {
    RelNode rel = convertSql(sql);
    return RelMetadataQuery.getColumnOrigins(rel, 0);
  }

  private void checkNoColumnOrigin(String sql) {
    Set<RelColumnOrigin> result = checkColumnOrigin(sql);
    assertTrue(result != null);
    assertTrue(result.isEmpty());
  }

  public static void checkColumnOrigin(
      RelColumnOrigin rco,
      String expectedTableName,
      String expectedColumnName,
      boolean expectedDerived) {
    RelOptTable actualTable = rco.getOriginTable();
    List<String> actualTableName = actualTable.getQualifiedName();
    assertEquals(
        Iterables.getLast(actualTableName),
        expectedTableName);
    assertEquals(
        actualTable.getRowType()
            .getFieldList()
            .get(rco.getOriginColumnOrdinal())
            .getName(), expectedColumnName);
    assertEquals(
        rco.isDerived(), expectedDerived);
  }

  private void checkSingleColumnOrigin(
      String sql,
      String expectedTableName,
      String expectedColumnName,
      boolean expectedDerived) {
    Set<RelColumnOrigin> result = checkColumnOrigin(sql);
    assertTrue(result != null);
    assertEquals(
        1,
        result.size());
    RelColumnOrigin rco = result.iterator().next();
    checkColumnOrigin(
        rco, expectedTableName, expectedColumnName, expectedDerived);
  }

  // WARNING:  this requires the two table names to be different
  private void checkTwoColumnOrigin(
      String sql,
      String expectedTableName1,
      String expectedColumnName1,
      String expectedTableName2,
      String expectedColumnName2,
      boolean expectedDerived) {
    Set<RelColumnOrigin> result = checkColumnOrigin(sql);
    assertTrue(result != null);
    assertEquals(
        2,
        result.size());
    for (RelColumnOrigin rco : result) {
      RelOptTable actualTable = rco.getOriginTable();
      List<String> actualTableName = actualTable.getQualifiedName();
      String actualUnqualifiedName = Iterables.getLast(actualTableName);
      if (actualUnqualifiedName.equals(expectedTableName1)) {
        checkColumnOrigin(
            rco,
            expectedTableName1,
            expectedColumnName1,
            expectedDerived);
      } else {
        checkColumnOrigin(
            rco,
            expectedTableName2,
            expectedColumnName2,
            expectedDerived);
      }
    }
  }

  @Test public void testColumnOriginsTableOnly() {
    checkSingleColumnOrigin(
        "select name as dname from dept",
        "DEPT",
        "NAME",
        false);
  }

  @Test public void testColumnOriginsExpression() {
    checkSingleColumnOrigin(
        "select upper(name) as dname from dept",
        "DEPT",
        "NAME",
        true);
  }

  @Test public void testColumnOriginsDyadicExpression() {
    checkTwoColumnOrigin(
        "select name||ename from dept,emp",
        "DEPT",
        "NAME",
        "EMP",
        "ENAME",
        true);
  }

  @Test public void testColumnOriginsConstant() {
    checkNoColumnOrigin(
        "select 'Minstrelsy' as dname from dept");
  }

  @Test public void testColumnOriginsFilter() {
    checkSingleColumnOrigin(
        "select name as dname from dept where deptno=10",
        "DEPT",
        "NAME",
        false);
  }

  @Test public void testColumnOriginsJoinLeft() {
    checkSingleColumnOrigin(
        "select ename from emp,dept",
        "EMP",
        "ENAME",
        false);
  }

  @Test public void testColumnOriginsJoinRight() {
    checkSingleColumnOrigin(
        "select name as dname from emp,dept",
        "DEPT",
        "NAME",
        false);
  }

  @Test public void testColumnOriginsJoinOuter() {
    checkSingleColumnOrigin(
        "select name as dname from emp left outer join dept"
            + " on emp.deptno = dept.deptno",
        "DEPT",
        "NAME",
        true);
  }

  @Test public void testColumnOriginsJoinFullOuter() {
    checkSingleColumnOrigin(
        "select name as dname from emp full outer join dept"
            + " on emp.deptno = dept.deptno",
        "DEPT",
        "NAME",
        true);
  }

  @Test public void testColumnOriginsAggKey() {
    checkSingleColumnOrigin(
        "select name,count(deptno) from dept group by name",
        "DEPT",
        "NAME",
        false);
  }

  @Test public void testColumnOriginsAggReduced() {
    checkNoColumnOrigin(
        "select count(deptno),name from dept group by name");
  }

  @Test public void testColumnOriginsAggCountNullable() {
    checkSingleColumnOrigin(
        "select count(mgr),ename from emp group by ename",
        "EMP",
        "MGR",
        true);
  }

  @Test public void testColumnOriginsAggCountStar() {
    checkNoColumnOrigin(
        "select count(*),name from dept group by name");
  }

  @Test public void testColumnOriginsValues() {
    checkNoColumnOrigin(
        "values(1,2,3)");
  }

  @Test public void testColumnOriginsUnion() {
    checkTwoColumnOrigin(
        "select name from dept union all select ename from emp",
        "DEPT",
        "NAME",
        "EMP",
        "ENAME",
        false);
  }

  @Test public void testColumnOriginsSelfUnion() {
    checkSingleColumnOrigin(
        "select ename from emp union all select ename from emp",
        "EMP",
        "ENAME",
        false);
  }

  private void checkRowCount(
      String sql,
      double expected) {
    RelNode rel = convertSql(sql);
    Double result = RelMetadataQuery.getRowCount(rel);
    assertTrue(result != null);
    assertEquals(expected, result, 0d);
  }

  @Ignore
  @Test public void testRowCountEmp() {
    checkRowCount(
        "select * from emp",
        EMP_SIZE);
  }

  @Ignore
  @Test public void testRowCountDept() {
    checkRowCount(
        "select * from dept",
        DEPT_SIZE);
  }

  @Ignore
  @Test public void testRowCountCartesian() {
    checkRowCount(
        "select * from emp,dept",
        EMP_SIZE * DEPT_SIZE);
  }

  @Ignore
  @Test public void testRowCountJoin() {
    checkRowCount(
        "select * from emp inner join dept on emp.deptno = dept.deptno",
        EMP_SIZE * DEPT_SIZE * DEFAULT_EQUAL_SELECTIVITY);
  }

  @Ignore
  @Test public void testRowCountUnion() {
    checkRowCount(
        "select ename from emp union all select name from dept",
        EMP_SIZE + DEPT_SIZE);
  }

  @Ignore
  @Test public void testRowCountFilter() {
    checkRowCount(
        "select * from emp where ename='Mathilda'",
        EMP_SIZE * DEFAULT_EQUAL_SELECTIVITY);
  }

  @Ignore
  @Test public void testRowCountSort() {
    checkRowCount(
        "select * from emp order by ename",
        EMP_SIZE);
  }

  private void checkFilterSelectivity(
      String sql,
      double expected) {
    RelNode rel = convertSql(sql);
    Double result = RelMetadataQuery.getSelectivity(rel, null);
    assertTrue(result != null);
    assertEquals(expected, result, EPSILON);
  }

  @Test public void testSelectivityIsNotNullFilter() {
    checkFilterSelectivity(
        "select * from emp where mgr is not null",
        DEFAULT_NOTNULL_SELECTIVITY);
  }

  @Test public void testSelectivityIsNotNullFilterOnNotNullColumn() {
    checkFilterSelectivity(
        "select * from emp where deptno is not null",
        1.0d);
  }

  @Test public void testSelectivityComparisonFilter() {
    checkFilterSelectivity(
        "select * from emp where deptno > 10",
        DEFAULT_COMP_SELECTIVITY);
  }

  @Test public void testSelectivityAndFilter() {
    checkFilterSelectivity(
        "select * from emp where ename = 'foo' and deptno = 10",
        DEFAULT_EQUAL_SELECTIVITY_SQUARED);
  }

  @Test public void testSelectivityOrFilter() {
    checkFilterSelectivity(
        "select * from emp where ename = 'foo' or deptno = 10",
        DEFAULT_SELECTIVITY);
  }

  @Test public void testSelectivityJoin() {
    checkFilterSelectivity(
        "select * from emp join dept using (deptno) where ename = 'foo'",
        DEFAULT_EQUAL_SELECTIVITY);
  }

  private void checkRelSelectivity(
      RelNode rel,
      double expected) {
    Double result = RelMetadataQuery.getSelectivity(rel, null);
    assertTrue(result != null);
    assertEquals(expected, result, EPSILON);
  }

  @Test public void testSelectivityRedundantFilter() {
    RelNode rel = convertSql("select * from emp where deptno = 10");
    checkRelSelectivity(rel, DEFAULT_EQUAL_SELECTIVITY);
  }

  @Test public void testSelectivitySort() {
    RelNode rel =
        convertSql("select * from emp where deptno = 10"
            + "order by ename");
    checkRelSelectivity(rel, DEFAULT_EQUAL_SELECTIVITY);
  }

  @Test public void testSelectivityUnion() {
    RelNode rel =
        convertSql("select * from (\n"
            + "  select * from emp union all select * from emp) "
            + "where deptno = 10");
    checkRelSelectivity(rel, DEFAULT_EQUAL_SELECTIVITY);
  }

  @Test public void testSelectivityAgg() {
    RelNode rel =
        convertSql("select deptno, count(*) from emp where deptno > 10 "
            + "group by deptno having count(*) = 0");
    checkRelSelectivity(
        rel,
        DEFAULT_COMP_SELECTIVITY * DEFAULT_EQUAL_SELECTIVITY);
  }

  /** Checks that we can cache a metadata request that includes a null
   * argument. */
  @Test public void testSelectivityAggCached() {
    RelNode rel =
        convertSql("select deptno, count(*) from emp where deptno > 10 "
            + "group by deptno having count(*) = 0");
    rel.getCluster().setMetadataProvider(
        new CachingRelMetadataProvider(
            rel.getCluster().getMetadataProvider(),
            rel.getCluster().getPlanner()));
    Double result = RelMetadataQuery.getSelectivity(rel, null);
    assertThat(result,
        nearTo(DEFAULT_COMP_SELECTIVITY * DEFAULT_EQUAL_SELECTIVITY, EPSILON));
  }

  @Test public void testDistinctRowCountTable() {
    // no unique key information is available so return null
    RelNode rel = convertSql("select * from emp where deptno = 10");
    ImmutableBitSet groupKey = ImmutableBitSet.of();
    Double result =
        RelMetadataQuery.getDistinctRowCount(
            rel, groupKey, null);
    assertTrue(result == null);
  }

  /** Asserts that {@link RelMetadataQuery#getUniqueKeys(RelNode)}
   * and {@link RelMetadataQuery#areColumnsUnique(RelNode, ImmutableBitSet)}
   * return consistent results. */
  private void assertUniqueConsistent(RelNode rel) {
    Set<ImmutableBitSet> uniqueKeys = RelMetadataQuery.getUniqueKeys(rel);
    final ImmutableBitSet allCols =
        ImmutableBitSet.range(0, rel.getRowType().getFieldCount());
    for (ImmutableBitSet key : allCols.powerSet()) {
      Boolean result2 = RelMetadataQuery.areColumnsUnique(rel, key);
      assertTrue(result2 == null || result2 == isUnique(uniqueKeys, key));
    }
  }

  /** Returns whether {@code keys} is unique, that is, whether it or a superset
   * is in {@code keySets}. */
  private boolean isUnique(Set<ImmutableBitSet> uniqueKeys, ImmutableBitSet key) {
    for (ImmutableBitSet uniqueKey : uniqueKeys) {
      if (key.contains(uniqueKey)) {
        return true;
      }
    }
    return false;
  }

  /** Test case for
   * [CALCITE-509]
   * "RelMdColumnUniqueness uses ImmutableBitSet.Builder twice, gets
   * NullPointerException". */
  @Test public void testJoinUniqueKeys() {
    RelNode rel = convertSql("select * from emp join dept using (deptno)");
    Set<ImmutableBitSet> result = RelMetadataQuery.getUniqueKeys(rel);
    assertThat(result.isEmpty(), is(true));
    assertUniqueConsistent(rel);
  }

  @Test public void testGroupByEmptyUniqueKeys() {
    RelNode rel = convertSql("select count(*) from emp");
    Set<ImmutableBitSet> result = RelMetadataQuery.getUniqueKeys(rel);
    assertThat(result,
        CoreMatchers.<Set<ImmutableBitSet>>equalTo(
            ImmutableSet.of(ImmutableBitSet.of())));
    assertUniqueConsistent(rel);
  }

  @Test public void testGroupByEmptyHavingUniqueKeys() {
    RelNode rel = convertSql("select count(*) from emp where 1 = 1");
    Set<ImmutableBitSet> result = RelMetadataQuery.getUniqueKeys(rel);
    assertThat(result,
        CoreMatchers.<Set<ImmutableBitSet>>equalTo(
            ImmutableSet.of(ImmutableBitSet.of())));
    assertUniqueConsistent(rel);
  }

  @Test public void testGroupBy() {
    RelNode rel = convertSql("select deptno, count(*), sum(sal) from emp\n"
            + "group by deptno");
    Set<ImmutableBitSet> result = RelMetadataQuery.getUniqueKeys(rel);
    assertThat(result,
        CoreMatchers.<Set<ImmutableBitSet>>equalTo(
            ImmutableSet.of(ImmutableBitSet.of(0))));
    assertUniqueConsistent(rel);
  }

  @Test public void testUnion() {
    RelNode rel = convertSql("select deptno from emp\n"
            + "union\n"
            + "select deptno from dept");
    Set<ImmutableBitSet> result = RelMetadataQuery.getUniqueKeys(rel);
    assertThat(result,
        CoreMatchers.<Set<ImmutableBitSet>>equalTo(
            ImmutableSet.of(ImmutableBitSet.of(0))));
    assertUniqueConsistent(rel);
  }

  @Test public void testCustomProvider() {
    final List<String> buf = Lists.newArrayList();
    ColTypeImpl.THREAD_LIST.set(buf);

    RelNode rel =
        convertSql("select deptno, count(*) from emp where deptno > 10 "
            + "group by deptno having count(*) = 0");
    rel.getCluster().setMetadataProvider(
        ChainedRelMetadataProvider.of(
            ImmutableList.of(
                ColTypeImpl.SOURCE, rel.getCluster().getMetadataProvider())));

    // Top node is a filter. Its metadata uses getColType(RelNode, int).
    assertThat(rel, instanceOf(LogicalFilter.class));
    assertThat(rel.metadata(ColType.class).getColType(0),
        equalTo("DEPTNO-rel"));
    assertThat(rel.metadata(ColType.class).getColType(1),
        equalTo("EXPR$1-rel"));

    // Next node is an aggregate. Its metadata uses
    // getColType(LogicalAggregate, int).
    final RelNode input = rel.getInput(0);
    assertThat(input, instanceOf(LogicalAggregate.class));
    assertThat(input.metadata(ColType.class).getColType(0),
        equalTo("DEPTNO-agg"));

    // There is no caching. Another request causes another call to the provider.
    assertThat(buf.toString(), equalTo("[DEPTNO-rel, EXPR$1-rel, DEPTNO-agg]"));
    assertThat(buf.size(), equalTo(3));
    assertThat(input.metadata(ColType.class).getColType(0),
        equalTo("DEPTNO-agg"));
    assertThat(buf.size(), equalTo(4));

    // Now add a cache. Only the first request for each piece of metadata
    // generates a new call to the provider.
    final RelOptPlanner planner = rel.getCluster().getPlanner();
    rel.getCluster().setMetadataProvider(
        new CachingRelMetadataProvider(
            rel.getCluster().getMetadataProvider(), planner));
    assertThat(input.metadata(ColType.class).getColType(0),
        equalTo("DEPTNO-agg"));
    assertThat(buf.size(), equalTo(5));
    assertThat(input.metadata(ColType.class).getColType(0),
        equalTo("DEPTNO-agg"));
    assertThat(buf.size(), equalTo(5));
    assertThat(input.metadata(ColType.class).getColType(1),
        equalTo("EXPR$1-agg"));
    assertThat(buf.size(), equalTo(6));
    assertThat(input.metadata(ColType.class).getColType(1),
        equalTo("EXPR$1-agg"));
    assertThat(buf.size(), equalTo(6));
    assertThat(input.metadata(ColType.class).getColType(0),
        equalTo("DEPTNO-agg"));
    assertThat(buf.size(), equalTo(6));

    // With a different timestamp, a metadata item is re-computed on first call.
    long timestamp = planner.getRelMetadataTimestamp(rel);
    assertThat(timestamp, equalTo(0L));
    ((MockRelOptPlanner) planner).setRelMetadataTimestamp(timestamp + 1);
    assertThat(input.metadata(ColType.class).getColType(0),
        equalTo("DEPTNO-agg"));
    assertThat(buf.size(), equalTo(7));
    assertThat(input.metadata(ColType.class).getColType(0),
        equalTo("DEPTNO-agg"));
    assertThat(buf.size(), equalTo(7));
  }

  /** Unit test for
   * {@link org.apache.calcite.rel.metadata.RelMdCollation#project}
   * and other helper functions for deducing collations. */
  @Test public void testCollation() {
    final Project rel = (Project) convertSql("select * from emp, dept");
    final Join join = (Join) rel.getInput();
    final RelOptTable empTable = join.getInput(0).getTable();
    final RelOptTable deptTable = join.getInput(1).getTable();
    Frameworks.withPlanner(
        new Frameworks.PlannerAction<Void>() {
          public Void apply(RelOptCluster cluster,
              RelOptSchema relOptSchema,
              SchemaPlus rootSchema) {
            checkCollation(cluster, empTable, deptTable);
            return null;
          }
        });
  }

  private void checkCollation(RelOptCluster cluster, RelOptTable empTable,
      RelOptTable deptTable) {
    final RexBuilder rexBuilder = cluster.getRexBuilder();
    final LogicalTableScan empScan = LogicalTableScan.create(cluster, empTable);

    List<RelCollation> collations =
        RelMdCollation.table(empScan.getTable());
    assertThat(collations.size(), equalTo(0));

    // ORDER BY field#0 ASC, field#1 ASC
    final RelCollation collation =
        RelCollations.of(new RelFieldCollation(0), new RelFieldCollation(1));
    collations = RelMdCollation.sort(collation);
    assertThat(collations.size(), equalTo(1));
    assertThat(collations.get(0).getFieldCollations().size(), equalTo(2));

    final Sort empSort = LogicalSort.create(empScan, collation, null, null);

    final List<RexNode> projects =
        ImmutableList.of(rexBuilder.makeInputRef(empSort, 1),
            rexBuilder.makeLiteral("foo"),
            rexBuilder.makeInputRef(empSort, 0),
            rexBuilder.makeCall(SqlStdOperatorTable.MINUS,
                rexBuilder.makeInputRef(empSort, 0),
                rexBuilder.makeInputRef(empSort, 3)));

    collations = RelMdCollation.project(empSort, projects);
    assertThat(collations.size(), equalTo(1));
    assertThat(collations.get(0).getFieldCollations().size(), equalTo(2));
    assertThat(collations.get(0).getFieldCollations().get(0).getFieldIndex(),
        equalTo(2));
    assertThat(collations.get(0).getFieldCollations().get(1).getFieldIndex(),
        equalTo(0));

    final LogicalProject project = LogicalProject.create(empSort, projects,
        ImmutableList.of("a", "b", "c", "d"));

    final LogicalTableScan deptScan =
        LogicalTableScan.create(cluster, deptTable);

    final RelCollation deptCollation =
        RelCollations.of(new RelFieldCollation(0), new RelFieldCollation(1));
    final Sort deptSort =
        LogicalSort.create(deptScan, deptCollation, null, null);

    final ImmutableIntList leftKeys = ImmutableIntList.of(2);
    final ImmutableIntList rightKeys = ImmutableIntList.of(0);
    final EnumerableMergeJoin join;
    try {
      join = EnumerableMergeJoin.create(project, deptSort,
          rexBuilder.makeLiteral(true), leftKeys, rightKeys, JoinRelType.INNER);
    } catch (InvalidRelException e) {
      throw Throwables.propagate(e);
    }
    collations =
        RelMdCollation.mergeJoin(project, deptSort, leftKeys, rightKeys);
    assertThat(collations,
        equalTo(join.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE)));

    // Values (empty)
    collations = RelMdCollation.values(empTable.getRowType(),
        ImmutableList.<ImmutableList<RexLiteral>>of());
    assertThat(collations.toString(),
        equalTo("[[0, 1, 2, 3, 4, 5, 6, 7, 8], "
            + "[1, 2, 3, 4, 5, 6, 7, 8], "
            + "[2, 3, 4, 5, 6, 7, 8], "
            + "[3, 4, 5, 6, 7, 8], "
            + "[4, 5, 6, 7, 8], "
            + "[5, 6, 7, 8], "
            + "[6, 7, 8], "
            + "[7, 8], "
            + "[8]]"));

    final LogicalValues emptyValues =
        LogicalValues.createEmpty(cluster, empTable.getRowType());
    assertThat(RelMetadataQuery.collations(emptyValues), equalTo(collations));

    // Values (non-empty)
    final RelDataType rowType = cluster.getTypeFactory().builder()
        .add("a", SqlTypeName.INTEGER)
        .add("b", SqlTypeName.INTEGER)
        .add("c", SqlTypeName.INTEGER)
        .add("d", SqlTypeName.INTEGER)
        .build();
    final ImmutableList.Builder<ImmutableList<RexLiteral>> tuples =
        ImmutableList.builder();
    // sort keys are [a], [a, b], [a, b, c], [a, b, c, d], [a, c], [b], [b, a],
    //   [b, d]
    // algorithm deduces [a, b, c, d], [b, d] which is a useful sub-set
    addRow(tuples, rexBuilder, 1, 1, 1, 1);
    addRow(tuples, rexBuilder, 1, 2, 0, 3);
    addRow(tuples, rexBuilder, 2, 3, 2, 2);
    addRow(tuples, rexBuilder, 3, 3, 1, 4);
    collations = RelMdCollation.values(rowType, tuples.build());
    assertThat(collations.toString(),
        equalTo("[[0, 1, 2, 3], [1, 3]]"));

    final LogicalValues values =
        LogicalValues.create(cluster, rowType, tuples.build());
    assertThat(RelMetadataQuery.collations(values), equalTo(collations));
  }

  private void addRow(ImmutableList.Builder<ImmutableList<RexLiteral>> builder,
      RexBuilder rexBuilder, Object... values) {
    ImmutableList.Builder<RexLiteral> b = ImmutableList.builder();
    for (Object value : values) {
      final RexLiteral literal;
      if (value == null) {
        literal = (RexLiteral) rexBuilder.makeNullLiteral(SqlTypeName.VARCHAR);
      } else if (value instanceof Integer) {
        literal = rexBuilder.makeExactLiteral(
            BigDecimal.valueOf((Integer) value));
      } else {
        literal = rexBuilder.makeLiteral((String) value);
      }
      b.add(literal);
    }
    builder.add(b.build());
  }

  /** Unit test for
   * {@link org.apache.calcite.rel.metadata.RelMetadataQuery#getAverageColumnSizes(org.apache.calcite.rel.RelNode)},
   * {@link org.apache.calcite.rel.metadata.RelMetadataQuery#getAverageRowSize(org.apache.calcite.rel.RelNode)}. */
  @Test public void testAverageRowSize() {
    final Project rel = (Project) convertSql("select * from emp, dept");
    final Join join = (Join) rel.getInput();
    final RelOptTable empTable = join.getInput(0).getTable();
    final RelOptTable deptTable = join.getInput(1).getTable();
    Frameworks.withPlanner(
        new Frameworks.PlannerAction<Void>() {
          public Void apply(RelOptCluster cluster,
              RelOptSchema relOptSchema,
              SchemaPlus rootSchema) {
            checkAverageRowSize(cluster, empTable, deptTable);
            return null;
          }
        });
  }

  private void checkAverageRowSize(RelOptCluster cluster, RelOptTable empTable,
      RelOptTable deptTable) {
    final RexBuilder rexBuilder = cluster.getRexBuilder();
    final LogicalTableScan empScan = LogicalTableScan.create(cluster, empTable);

    Double rowSize = RelMetadataQuery.getAverageRowSize(empScan);
    List<Double> columnSizes = RelMetadataQuery.getAverageColumnSizes(empScan);

    assertThat(columnSizes.size(),
        equalTo(empScan.getRowType().getFieldCount()));
    assertThat(columnSizes,
        equalTo(Arrays.asList(4.0, 40.0, 20.0, 4.0, 8.0, 4.0, 4.0, 4.0, 1.0)));
    assertThat(rowSize, equalTo(89.0));

    // Empty values
    final LogicalValues emptyValues =
        LogicalValues.createEmpty(cluster, empTable.getRowType());
    rowSize = RelMetadataQuery.getAverageRowSize(emptyValues);
    columnSizes = RelMetadataQuery.getAverageColumnSizes(emptyValues);
    assertThat(columnSizes.size(),
        equalTo(emptyValues.getRowType().getFieldCount()));
    assertThat(columnSizes,
        equalTo(Arrays.asList(4.0, 40.0, 20.0, 4.0, 8.0, 4.0, 4.0, 4.0, 1.0)));
    assertThat(rowSize, equalTo(89.0));

    // Values
    final RelDataType rowType = cluster.getTypeFactory().builder()
        .add("a", SqlTypeName.INTEGER)
        .add("b", SqlTypeName.VARCHAR)
        .add("c", SqlTypeName.VARCHAR)
        .build();
    final ImmutableList.Builder<ImmutableList<RexLiteral>> tuples =
        ImmutableList.builder();
    addRow(tuples, rexBuilder, 1, "1234567890", "ABC");
    addRow(tuples, rexBuilder, 2, "1",          "A");
    addRow(tuples, rexBuilder, 3, "2",          null);
    final LogicalValues values =
        LogicalValues.create(cluster, rowType, tuples.build());
    rowSize = RelMetadataQuery.getAverageRowSize(values);
    columnSizes = RelMetadataQuery.getAverageColumnSizes(values);
    assertThat(columnSizes.size(),
        equalTo(values.getRowType().getFieldCount()));
    assertThat(columnSizes, equalTo(Arrays.asList(4.0, 8.0, 3.0)));
    assertThat(rowSize, equalTo(15.0));

    // Union
    final LogicalUnion union =
        LogicalUnion.create(ImmutableList.<RelNode>of(empScan, emptyValues),
            true);
    rowSize = RelMetadataQuery.getAverageRowSize(union);
    columnSizes = RelMetadataQuery.getAverageColumnSizes(union);
    assertThat(columnSizes.size(), equalTo(9));
    assertThat(columnSizes,
        equalTo(Arrays.asList(4.0, 40.0, 20.0, 4.0, 8.0, 4.0, 4.0, 4.0, 1.0)));
    assertThat(rowSize, equalTo(89.0));

    // Filter
    final LogicalTableScan deptScan =
        LogicalTableScan.create(cluster, deptTable);
    final LogicalFilter filter =
        LogicalFilter.create(deptScan,
            rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN,
                rexBuilder.makeInputRef(deptScan, 0),
                rexBuilder.makeExactLiteral(BigDecimal.TEN)));
    rowSize = RelMetadataQuery.getAverageRowSize(filter);
    columnSizes = RelMetadataQuery.getAverageColumnSizes(filter);
    assertThat(columnSizes.size(), equalTo(2));
    assertThat(columnSizes, equalTo(Arrays.asList(4.0, 20.0)));
    assertThat(rowSize, equalTo(24.0));

    // Project
    final LogicalProject deptProject =
        LogicalProject.create(filter,
            ImmutableList.of(
                rexBuilder.makeInputRef(filter, 0),
                rexBuilder.makeInputRef(filter, 1),
                rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
                    rexBuilder.makeInputRef(filter, 0),
                    rexBuilder.makeExactLiteral(BigDecimal.ONE)),
                rexBuilder.makeCall(SqlStdOperatorTable.CHAR_LENGTH,
                    rexBuilder.makeInputRef(filter, 1))),
            (List<String>) null);
    rowSize = RelMetadataQuery.getAverageRowSize(deptProject);
    columnSizes = RelMetadataQuery.getAverageColumnSizes(deptProject);
    assertThat(columnSizes.size(), equalTo(4));
    assertThat(columnSizes, equalTo(Arrays.asList(4.0, 20.0, 4.0, 4.0)));
    assertThat(rowSize, equalTo(32.0));

    // Join
    final LogicalJoin join =
        LogicalJoin.create(empScan, deptProject, rexBuilder.makeLiteral(true),
            JoinRelType.INNER, ImmutableSet.<String>of());
    rowSize = RelMetadataQuery.getAverageRowSize(join);
    columnSizes = RelMetadataQuery.getAverageColumnSizes(join);
    assertThat(columnSizes.size(), equalTo(13));
    assertThat(columnSizes,
        equalTo(
            Arrays.asList(4.0, 40.0, 20.0, 4.0, 8.0, 4.0, 4.0, 4.0, 1.0, 4.0,
                20.0, 4.0, 4.0)));
    assertThat(rowSize, equalTo(121.0));

    // Aggregate
    final LogicalAggregate aggregate =
        LogicalAggregate.create(join, false, ImmutableBitSet.of(2, 0),
            ImmutableList.<ImmutableBitSet>of(),
            ImmutableList.of(
                AggregateCall.create(
                    SqlStdOperatorTable.COUNT, false, ImmutableIntList.of(), -1,
                    2, join, null, null)));
    rowSize = RelMetadataQuery.getAverageRowSize(aggregate);
    columnSizes = RelMetadataQuery.getAverageColumnSizes(aggregate);
    assertThat(columnSizes.size(), equalTo(3));
    assertThat(columnSizes, equalTo(Arrays.asList(4.0, 20.0, 8.0)));
    assertThat(rowSize, equalTo(32.0));

    // Smoke test Parallelism and Memory metadata providers
    assertThat(RelMetadataQuery.memory(aggregate), nullValue());
    assertThat(RelMetadataQuery.cumulativeMemoryWithinPhase(aggregate),
        nullValue());
    assertThat(RelMetadataQuery.cumulativeMemoryWithinPhaseSplit(aggregate),
        nullValue());
    assertThat(RelMetadataQuery.isPhaseTransition(aggregate), is(false));
    assertThat(RelMetadataQuery.splitCount(aggregate), is(1));
  }

  /** Unit test for
   * {@link org.apache.calcite.rel.metadata.RelMdPredicates#getPredicates(SemiJoin)}. */
  @Test public void testPredicates() {
    final Project rel = (Project) convertSql("select * from emp, dept");
    final Join join = (Join) rel.getInput();
    final RelOptTable empTable = join.getInput(0).getTable();
    final RelOptTable deptTable = join.getInput(1).getTable();
    Frameworks.withPlanner(
        new Frameworks.PlannerAction<Void>() {
          public Void apply(RelOptCluster cluster,
              RelOptSchema relOptSchema,
              SchemaPlus rootSchema) {
            checkPredicates(cluster, empTable, deptTable);
            return null;
          }
        });
  }

  private void checkPredicates(RelOptCluster cluster, RelOptTable empTable,
      RelOptTable deptTable) {
    final RexBuilder rexBuilder = cluster.getRexBuilder();
    final LogicalTableScan empScan = LogicalTableScan.create(cluster, empTable);

    RelOptPredicateList predicates =
        RelMetadataQuery.getPulledUpPredicates(empScan);
    assertThat(predicates.pulledUpPredicates.isEmpty(), is(true));

    final LogicalFilter filter =
        LogicalFilter.create(empScan,
            rexBuilder.makeCall(SqlStdOperatorTable.EQUALS,
                rexBuilder.makeInputRef(empScan,
                    empScan.getRowType().getFieldNames().indexOf("EMPNO")),
                rexBuilder.makeExactLiteral(BigDecimal.ONE)));

    predicates = RelMetadataQuery.getPulledUpPredicates(filter);
    assertThat(predicates.pulledUpPredicates.toString(), is("[=($0, 1)]"));

    final LogicalTableScan deptScan =
        LogicalTableScan.create(cluster, deptTable);

    final RelDataTypeField leftDeptnoField =
        empScan.getRowType().getFieldList().get(
            empScan.getRowType().getFieldNames().indexOf("DEPTNO"));
    final RelDataTypeField rightDeptnoField =
        deptScan.getRowType().getFieldList().get(
            deptScan.getRowType().getFieldNames().indexOf("DEPTNO"));
    final SemiJoin semiJoin =
        SemiJoin.create(filter, deptScan,
            rexBuilder.makeCall(SqlStdOperatorTable.EQUALS,
                rexBuilder.makeInputRef(leftDeptnoField.getType(),
                    leftDeptnoField.getIndex()),
                rexBuilder.makeInputRef(rightDeptnoField.getType(),
                    rightDeptnoField.getIndex()
                        + empScan.getRowType().getFieldCount())),
            ImmutableIntList.of(leftDeptnoField.getIndex()),
            ImmutableIntList.of(rightDeptnoField.getIndex()
                    + empScan.getRowType().getFieldCount()));

    predicates = RelMetadataQuery.getPulledUpPredicates(semiJoin);
    assertThat(predicates.pulledUpPredicates.toString(), is("[=($0, 1)]"));
    assertThat(predicates.leftInferredPredicates.toString(), is("[]"));
    assertThat(predicates.rightInferredPredicates.isEmpty(), is(true));
  }

  /** Custom metadata interface. */
  public interface ColType extends Metadata {
    String getColType(int column);
  }

  /** A provider for {@link org.apache.calcite.test.RelMetadataTest.ColType} via
   * reflection. */
  public static class ColTypeImpl {
    static final ThreadLocal<List<String>> THREAD_LIST = new ThreadLocal<>();
    static final Method METHOD;
    static {
      try {
        METHOD = ColType.class.getMethod("getColType", int.class);
      } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
      }
    }

    public static final RelMetadataProvider SOURCE =
        ReflectiveRelMetadataProvider.reflectiveSource(
            METHOD, new ColTypeImpl());

    /** Implementation of {@link ColType#getColType(int)} for
     * {@link org.apache.calcite.rel.logical.LogicalAggregate}, called via
     * reflection. */
    @SuppressWarnings("UnusedDeclaration")
    public String getColType(Aggregate rel, int column) {
      final String name =
          rel.getRowType().getFieldList().get(column).getName() + "-agg";
      THREAD_LIST.get().add(name);
      return name;
    }

    /** Implementation of {@link ColType#getColType(int)} for
     * {@link RelNode}, called via reflection. */
    @SuppressWarnings("UnusedDeclaration")
    public String getColType(RelNode rel, int column) {
      final String name =
          rel.getRowType().getFieldList().get(column).getName() + "-rel";
      THREAD_LIST.get().add(name);
      return name;
    }
  }
}

// End RelMetadataTest.java

redpajama_set_name: RedPajamaGithub


Subject: We hear you and what do you think of soft recs?
The intention behind rec-to-post ratios has always been to reward the best contributions to Fooldom. We stated this from the get-go, and also laid out a fair amount of our rationale right on this board and elsewhere, ahead of time. We don't find any significant number of people disagreeing that more meaningful rec-to-post ratios would be a good addition, rewarding the best contributors. In fact, once we up the minimum past 30-day postings to a more proper 15, I think you'll find this a worthy addition.
What many people clearly don't like is the limiting of the opportunity to hit the Rec button. Judging from early returns (first 12 hours), this is a mistake. We don't use 12 hours to judge anything, but we will closely follow community discussion and thought on this decision over the very short term. We have already let you know repeatedly that we're open to change as the community wishes (and to tell you the truth I wish a few more people would recognize this, and maybe cut Bogey some slack). If this is not deemed an improvement, we'll scotch it! As stated earlier, we already believe that the soft rec concept suggested by RJMason and others several days ago will solve most of these problems.
To review, here's the concept. Everyone gets as many recs as they like every day. The value of your first 20 recs (say) is 1.0, and for every additional rec you make beyond that on a given day, it revalues your recs proportionately (rec #21 makes them worth slightly less, and so forth). This superior (to my thinking) approach enables anyone to hit the rec button anytime (the biggest member complaint) and yet still keeps the focus on recs rewarding quality effort. However, you'd still get to see the number of times that people hit the rec button to show agreement with your post.
I appreciate the strength of feeling many are expressing here, because at the very least it shows how much you care. We care a tremendous amount as well, and if and when we make bad decisions, we will change them. We would hope that long-time Fools know us well enough to know that we'll work hard to improve our service, when we screw up (note I didn't say "if," since we're human) in our attempts to improve it for you.
We also hope you'll remember what Radish wrote, which is that virtually every change we make to online interface solicits charges of "New Coke," as has been the case for several years. If we had immediately acted on these comments in every case, Fool.com wouldn't have recs at all (since that was an addition), nor would our portfolio have tracked against the S&P 500, nor would we have a My Fool page, etc. etc. etc. No colors ever would have changed, etc.
So in the context of working together to improve the service, we commit to you our firm intent to fix things that are broken, including in some cases "unfixing" things if they weren't broken. But we also ask something in return, which is your patience and in some cases forebearance. Any truly bad change we make can be lifted or changed; please acknowledge this and fear not. At the same time, please give yourself a chance to take in the sights (site) for a few days, and then give us your reasoning.


We, at Pyramid Technology Solutions (PTS), know your IT requirements may not be full-time but we understand those once in a while needs are extremely critical. Our team at PTS effectively addresses these needs through a program that enables the companies to gain access to our expert teams.
We are ready with competent solutions for your requirements of system and network maintenance, web/client server maintenance, database administration and any other IT-related support.
Flexibility and cost-efficiency are the two elements that complement our efficiency and qualitative outputs. Whether completion of projects on site or remote assistance, flexibility is what we ensure and assure. Be it per-hour pay or per-project pay, we ensure satisfaction at both the levels for customer satisfaction is what satisfies us at Pyramid Technology Solutions (PTS).


Three men were killed and two others injured were when the fuel-laden truck in which they were travelling turned over twice as it tumbled down a hill in the Puruni River area, police said.
Those, who perished are Clifford Anthony Bhim,24, a porter of Itaballi Landing; David Choo-Wee-Nam,52, a miner of Four Miles, Bartica and Jude James,39, a miner of Yarrowkabra, Soesdyke/Linden Highway.
Injured are driver Ravi Dookram,29,of 757 Section C ,Block Y Golden Grove, East Bank Demerara and his stepson 18-year old Steve Carr. They were taken to the Bartica Hospital and Dookram was later air-dashed to Georgetown.
Police said the incident occurred late Saturday afternoon, October 20, 2018 at Kumung Kumung Trail, Puruni River.
Investigators were told that a truck, GWW 4811, transporting about 44 drums of diesels was driving up a hill when it developed mechanical problems and began to descend; in the process , it reportedly turned- turtle twice.
At the time,there were two persons inside of the cabin with the driver and two others in the tray.


text:
Midwest TimesRegional WAMid West
Musician set to mesmerise crowds
Francesca MannMidwest Times
Mon, 15 May 2017 2:39PM
Fijian-born multi-instrumentalist Jay Hoad will return to the Mid West and Gascoyne this weekend, bringing with him a whopping 17 instruments for his Off the Cuff Tour.
Playing at Kalbarri, Shark Bay and Carnarvon, Hoad will mesmerise the crowds with his incredible talent to play up to five instruments at once.
With an interest in almost every musical genre under the sun, Hoad's sound is a unique fusion of reggae, roots, funk and rock, and everything in between.
The 37-year-old has a penchant for the weird and wacky. He has a shovel guitar, a cricket bat guitar and a wine box bass among his arsenal of instruments.
"I randomly picked them up along my adventures," Hoad said.
"Most of them have been given to me or purchased from professional guitar makers who have dabbled into some weird and wonderful kinds of instruments.
"I have a passion for touring in Third World countries and I get exposed to a lot of unusual styles of music, and I bring some of those influences back with me.
"Definitely my passion is for the odd stringed instruments."
Hoad's passion for music was ignited at a young age; the discovery of Nirvana and Pearl Jam when he was 10 years old introduced him to a musical world outside of classical.
But he continued to study classical music, and later started a degree in jazz music, joining the Australian Jazz Quartet on a tour of America.
By the time Hoad turned 23 he was working as a musician full time and began touring around the world.
Hoad's fifth studio album Off the Cuff was released last year and scored him the prestigious ARBA Blues and Roots Album of the Year award.
While touring off the back of the album, Hoad has been busily working on his next album, hoping to release it in the next few months.
"About three months ago we finished a recording studio in the van so I'm able to record on the road this year, which is really exciting," he said.
"The next album has been recorded, mixed and mastered, we're just finalising artwork; it'll be out around July or August.
"I'm really excited that we're finally back in WA and coming through town; (the show) is definitely something that people have never seen before.
"I feel honoured and privileged to tour around the world playing original music, it's really special and I don't take it lightly."
Hoad will play at the Kalbarri Hotel on May 19, the Shark Bay Hotel on May 20 and the Gascoyne Hotel on May 26.
Exmouth makers' sessions to encourage repurposing, recycling
'Absolutely essential': Urgent IVF callsPremium
East among best in Freo win

redpajama_set_name: RedPajamaCommonCrawl


text:
Horror, Sci-Fi, and Fantasy
Friday the 13th remake
By JackFetch, October 3, 2007 in Horror, Sci-Fi, and Fantasy
I'd rather die than go to heaven.
It could have been better. I mean it covers 12 films, but the Halloween documentary was longer only covering 8 films.
His Name Was Jason is like 6 hours long.
Version I saw was 90 minutes.
It comes in two discs and with features included it's at least twice as long.
annericelover
Location:Bayonne, NJ
The special features are all pretty much extended versions of the interviews on the documentary. I'm talking about the documentary itself is shorter than the Halloween documentary. The Halloween documentary still managed to include extended interviews also while still having a longer run time of the main feature.
Koete
Black and White Movie Guy
Ouch. Friday dropped 80% in its second week, bringing in $7,825,000.
http://www.boxofficemojo.com/weekend/chart/
SuaveStar
I am reality.
But it still made a very good profit, so their will be a sequel.
Also most fans of the movie would have seen it in the first week.
I was going to see it today, but was twenty minutes late to the showing........
I went to see Bolt in 3-D instead.
It was awesome.
Father of two
Location:The United States of America
Yeah, they could have shut the whole thing down after the first weekend and still doubled the investment they made in actually making the movie, so everything after the first weekend is gravy. Plus they have the international market, DVD sales and whatever other marketing they do. I wouldn't be surprised to see someone take another shot at a Friday the 13th video game, either.
Saw it last night.
After the opening sequence I thought it would be shit, then the movie really started and it was awesome.
I really hope it gets a sequel.


text:
Jeff Williamson, Digital Content Manager
Published: July 10, 2020, 2:15 pm
Tags: Roanoke, Lynchburg, Blacksburg, New River Valley, Southside, Money, Data
See the six area businesses that received more than $5 million under the Paycheck Protection Program
Interactive map shows which Southwest, Central Virginia businesses received PPP funds
Six businesses received payouts between $5 and $10 million
Map of Paycheck Protection Program loans distributed in Southwest, Central Virginia (ESRI, WSLS 10)
ROANOKE, Va. – Officials have released some of the businesses that received funding under the Payment Protection Program, also known as PPP.
The companies whose names were released had to have received at least $150,000.
In the WSLS 10 coverage area, 1,357 businesses received at least that much.
The amounts were broken into five thresholds, with six business receiving the highest amount, $5 to $10 million.
$150,000 - $350,000 780
$350,000 - $1 million 422
$1-2 million 92
$5-10 million 6
In the map below, each circle represents one of the 1,357 businesses and the bigger the circle, the more funds that business received.
Jeff Williamson


Play Bowling Games online and free at Colouredgames.
Test your skill and accuracy in this classic peace, competitive bowling game.
Target the ground of the white cross Iside the Bowl ad Tikle bottomless.
Test your skill and accuracy in this classic quiet, competitive bowling game.
Like one, ????? seaso make wonderful bowl o Lear.
Mix Igrediets I the Bowl jaw a cake display they decorate transfers the pattern.
It is the blood Bowl! CA you ru tackled the ball field without Gettig Dow?
Take white dough, roll out, add test devices, put the PuTTY I Ove, jaw display add it, the bowl of soup.
Eemies noodles have throw all over the bowls of oodles. All of them gather, ride your moped display.
I pay the cafeteria at a high school-OE staff delicious soup I have a bowl. His Movemets must be graceful so Othig buried.
A nice, where you play little, online flash version of bowling against a PIN pal of your choice.
Chicken marsala is a delicious dish that is often served with pasta, potatoes or pilaf. Learn this delicious recipe make by following the instructions in this cooking game. Start the preparation by chopping, the shallots, mushrooms, parsley and place them in separate bowls for later use. In a bowl, mix the flour, salt and pepper and then add the chicken and mix well with a spoon. Cook the prepared chicken with melted butter and oil in a saucepan. After removing the cooked chicken from the pot butter, chopped onions, mushrooms add and for 2-3 Cook minutes. now add the chicken marsala to the mixture and cook for few minutes. Finally add the chopped parsley to the cooking session complete. Enjoy!
Her family want to make some doughnuts? Today you will learn how this delicious treat to make, by you the following simple steps. Yup, it is a quick and easy recipe that can be prepared in just a few minutes. beat the eggs and the sugar in a bowl, then add yogurt, salt, vanilla essence and butter to the mixture. blend the mixture well and keep it aside for later use. now the flour, baking powder, and baking soda in a bowl type, mix thoroughly with spatula. After you are combine both mixtures together and prepare the donut. Now you must provide for the doughnuts frying. Start the prepared donut dough in oil FRY and then sprinkle sugar on it. Voila, tasty, easy to cook doughnuts are ready!
Have you ever bowled? We bet you have. Don't you love it? We sure do!
Here is your chance to prove, you're the perfect shooter! simply aim the white cross in the bowl and enjoy not your trainers! Better once again try if that would be much syringes!
I this game, you're I for free from a soup Stad Salvador Thai soup! For the first time, what they play, a trial to roud show how to do it. First add the tons (but so do I rise also), the vegetables, put this Ito the bowl. Add to sauce the balls, ad Fially Spades.
This is Islads paper Bowl - a race over paper of Islads cosmos where Cotestats will compete for the coveted paper Islads Paper Cup. There ca oly to be ö Wier - do you have what it takes?
a delicious meal that can be prepared very easily by anyone is crispy and cheesy baked ravioli. It requires only a few ingredients such as ravioli, different types of cheese, meat and sauces. Let us buy the necessary items from the shop. After shopping in the kitchen and collect the tools to start the cooking process. Add the prepared meat and sauce in the bowl and mix it with the help of spatula; and add this mixture in the casserole with pasta and mozzarella cheese. Bake the mixture 30 minutes that add ravioli and Parmesan cheese to mixture and then 15 minutes bake it. Their easy baked ravioli is ready to eat!
Brownie ice cream of sandwiches are a delicious dessert, which can be prepared by some simple instructions. After gathering all the necessary ingredients, turn off the stove and add the semi-sweet chocolate and butter in the Pan, prepare the sauce. the bowl of flour, egg, vanilla and prepared sauce add and mix the contents well to prepare the chocolate cake mixture. Pour the mixture into two separate pans for baking. You turn on ice one of the baked brownie and you create drüber then a different chocolate cake. After it cool for a few minutes in the refrigerator you cut the sandwiches and serve you, your love. Enjoy!
Vegetable soup is a tasty and easy to cook. Vegetable soup is the perfect vegetarian dish that gives all the goodness of vegetables not only you, but also helps to reduce and maintain weight. If you are curious to learn this recipe then you have to play this cooking game know, every step in the preparation involved in this healthy dish. You begin your cooking process by the oil in a large saucepan, heat and chopped leeks, garlic, salt, carrots, potatoes, green beans, add and mix well. Add it after cooking kosher salt in the pot for a few minutes vegetable broth, tomatoes, maize, lemon juice, parsley and a pinch. put black pepper after the vegetable soup into a bowl and serve it immediately to your love.
Courtney is back to learn a new, delicious recipe spaghetti and meatballs called,. the famous recipe is extremely delicious and absolutely suitable for a family dinner. You can easily learn the recipe, if you the instructions just follow. in the kitchen and start collecting the ingredients required so that the ground beef and sauce,. Prepare mixing the ingredients for the meatballs and the spicy sauce, Courtney follow instructions. After placing, the meatballs on the baking sheet, slowly you pour over the prepared sauce and baking it in the oven. Cook the spaghetti and place it in the bowl. garnish the Meatball and spaghetti with grated cheese sprinkled.
Today, this charming will cook a beautiful Blueberry Pie in their beautiful kitchen. This time she wants to share this recipe with you, with you connect you invited has. to this recipe to learn she will guide his every step and you must successfully according to specified instructions. in accordance with your boss directions which Bowl Add flour, salt, sugar and cinnamon add and mix it well with the help of a spatula. now, blueberries and lemon juice add the mixture and mix thoroughly. then, the Blueberry mixture add the pastry shell. Then brush the top of the pastry with beaten egg and baking it in the oven quick cooking exit. Enjoy!
This is a very cool ad Fuy Bowlig game. The player's positioning, as well as the Directio display makes the ball display just place your o your way to the Bowlig history.
Doraemo has to play Ivited Bowlig with him. You will find when you move it ca, a higher score-tha.
Kock Dow as may-PIs as possible.
You are I the Moarch bucking this game but how login? You need the Summit defed, by those who would dethroe.
I got this Fuy mixture of Bowlig dodgeball display space Ivaders.
RAIA is Goig out Bowlig with her did. Will help you to select her an outfit?
Goal is to disable all PIs I two cups or less.


text:
"There's no need to feel _____________" and other lies we've been told
by KCLAnderson | Jul 13, 2018 | Awareness, Emotions, Feminism, Generational patterns, Mother-daughter relationship, narcissism, Relationships, The Wisdom of Others, Trauma
Just now I was reading a novel in which one character (let's call her Ann) says to another (let's call her Zoe), "There's no need to feel embarrassed."
Ostensibly, Ann wants Zoe to feel better. She doesn't want Zoe to feel embarrassed.
Why do we even say things like this?
You're overreacting.
Don't be so sensitive.
Calm down.
There's no need to feel that way.
One theory I have is that other people's uncomfortable emotions and experiences are uncomfortable for us and we don't want to be uncomfortable.
And sometimes they're downright inconvenient.
As a little girl of three, I had tremendous grief when my mother and father divorced. My grief was inconvenient. Stuff had to get done. People had jobs to go to and money to make and things to take care of.
Two short years later my mother married my stepfather. I was the flower girl and I was excited to wear my pretty yellow dress and black patent leather Mary Janes. After the ceremony, the truth – that my mother and father weren't ever going to get back together – sunk in and I was inconsolable. My stepfather had to carry me out of the church because I was crying so hard.
No one had the time to be cracked open by the messiness of my vulnerability and grief. This was supposed to be a celebration.
So I danced at the reception in my pretty yellow dress and black patent leather Mary Janes.
The grief? I put it off and denied and stuffed and resisted it for years. Decades.
If being human tends to be messy and inconvenient, then dealing with deep, systemic trauma can be overwhelming.
We live in a country – in a world – that has a history of traumatizing children.
"We've gone from separating Native American babies from their parents (and then exterminating them), to stealing babies from their slave parents (and then re-selling them into slavery), to building a country on child labor (working in factories as young as 8-yrs. old), to incarcerating Japanese-American toddlers in internment camps, to allowing priests to sexually abuse children for decades, to forcing buckets of high-fructose corn syrup down kids' throats until half of them are part of a childhood obesity epidemic, to turning our schools into killing fields because we love our guns more than we love our kids." ~ Michael Moore in response to people saying "This isn't who we are" in response to our current President's policy of separating children from their parents who are seeking asylum in the U.S.
I don't pretend to think that my writing about it will solve such deep, systemic trauma in my lifetime. But I do know that the connections we make, the truths that we tell, the messiness we are willing to explore, the inconveniences we are willing to experience, the dollars we are willing to donate, the time we are willing to spend calling, faxing, and emailing those in supposed "power," the protests we are willing to attend, the dreams we are willing to have, will help us reach a tipping point, eventually.
Getting back to "There's no need to feel _____________" and other lies we've been told.
Humans also have a history of gaslighting.
"Women have been driven mad – gaslighted – for centuries by the refutation of our experience and our instincts in a culture which validates only the white, cis-gendered male experience. The truth of our bodies and our minds has been mystified to us. We, therefore, have a primary obligation to each other: not to undermine each other's sense of reality for the sake of expediency; not to gaslight each other. We have often felt insane when cleaving to the truth of our experience. Our future depends on the sanity of each of us, and we have a profound stake, beyond the personal, in the project of describing our reality as candidly and fully as we can to each other. When a woman tells the truth they are creating the possibility for more truth around them." ~ Adrienne Rich, On Lies, Secrets, and Silence
Our mothers sometimes (sometimes? mostly? always?) internalized this kind of misogyny so we sometimes (sometimes? mostly? always?) were on the receiving end of our mothers' refutation of our emotions, experiences, and instincts.
And why would our mothers do this? If they're full-blown narcissists, it's part of the manipulative behavior that goes with such a personality disorder.
But it also happens, I believe, because they were (and we are) surrounded by it…swimming in it without realizing it's there.
Because experiences, instincts, and emotions were (and are) often not convenient and in some cases they were (and are) overwhelming. And perhaps our mothers felt like they couldn't do anything about it. So they did nothing.
In a recent Facebook post, Leesa Renee Hall wrote: "I'd never tell someone they're wrong about their interpretation of their own experience based on their own perspective. I wish that we would not centre ourselves in someone else's lived experience. I wish, instead, that we would turn inward and ask ourselves this simple question: Why am I triggered reading/hearing about their lived experience? About what's true for them?"
Denying someone's lived experience is not helpful (and I say this as someone who used to do that and sometimes still does). Denying someone's lived experience is to make them doubt who they are and what they feel. It's gaslighting and saying, "what you feel isn't real."
That is the very essence of trauma.
I have been both – the gaslighted and the gaslighter. Because of course, I've been both…most of us grew up being gaslighted (even if from seemingly benign comments like, "don't be sad") and so it's all we ever knew to do.
On both micro and macro levels, some experiences and emotions are messy, inconvenient and sometimes guilt-inducing.
But you are never wrong about your interpretation of your own experience based on your own perspective.
This piece first appeared on Patreon. THANK YOU to my current Patrons!
If you love my writing and would like to have access to it when it debuts, consider joining my exclusive community for as little as $2/month. There you will find all my best work. There you can ask me for advice and I will give you my very best answer…and if it's unclear or you need additional insight, I will provide it. Patreon allows artists, writers, musicians, and others a place to debut their work to their fans. Think of it as a "tip jar."
My current goal is 100 Patrons. When I reach this goal I will make a monthly donation to Women's March, whose mission is to harness the political power of diverse women and their communities to create transformative social change.


Ready to discover Vine Cliff Estate Winery's Reserve Wines? Did you know that as early as the 1880s Vine Cliff Winery was already known to garner the highest prices for their wines due to their quality and exclusivity? Today we are the hidden gem that maintains the quality and exclusivity that is our history but still at a relative value compared to our "Cult" status neighbors.
Enjoy a comparison Flight of Vine Cliff Private Stock "16 Rows" Cabernet Sauvignon from our Oakville Estate Vineyards, in one of our beautifully designed St. Helena tasting lounge's private salons.This Tasting includes our 2003, 2008 and 2013 vintage of the best of the best Cabernet Sauvignon we make, accompanied by a cheese pairing selected by Estate Chef Tom Stafford. Reservations are suggested for this 45 minute tasting.


text:
The Valiant Navigator or The Brave Seafarer (German: Der mutige Seefahrer) is a 1935 German comedy film directed by Hans Deppe and starring Paul Kemp, Lucie Englisch and Maria Krahn.

It was based on a play by Georg Kaiser which was later adapted into the 1940 American film The Ghost Comes Home.

Synopsis
A young man plans to emigrate to the United States with his fiancée but becomes extremely fearful about the ocean crossing due to a local superstition. Eventually he decides to stay at home and marry his girl.

Cast
 Paul Kemp as Berthold Jebs
 Lucie Englisch as Grete Holm
 Maria Krahn as Paula Jebs
 Harald Paulsen as Otto Jebs
 Otto Wernicke as Bäckermeister Holm
 Carsta Löck as Tine Peterson
 Harry Frank as Joe Jefferson
 Paul Westermeier as Timm, ein Landstreicher
 Hans Mierendorff as Jan, ein Matrose
 Paul Beckers
 Elli Blank
 Rudolf Essek
 Karl Harbacher
 Oskar Höcker
 Werner Pledath
 Arthur Reppert
 Ernst Rückert
 Otto Sauter-Sarto
 Willi Schaeffers
 Hans Hermann Schaufuß
 Toni Tetzlaff
 Petra Unkel

References

Bibliography
 Waldman, Harry. Nazi Films in America, 1933-1942. McFarland, 2008.

External links

1935 films
1935 comedy films
German comedy films
Films of Nazi Germany
1930s German-language films
Films directed by Hans Deppe
Films based on works by Georg Kaiser
German films based on plays
Tobis Film films
German black-and-white films
1930s German films

redpajama_set_name: RedPajamaWikipedia


The two biggest threats to your bromeliads living outdoors are pests and rot. We lose more plants to root and stem rot than we do from pests, but pests can destroy leaves and slow growth if not not controlled.
Pest problems are not as common for bromeliads as some other cultivated hobbyist plants but that doesn't mean you shouldn't be watchful. Careful, regular inspection will turn up any problems before they can get out of control.
Most often hand removal and quarantining infested plants should prevent any major damage.
Healthy plants will better withstand minor attacks from common pests, but if outbreaks are common in your area, it is a good idea to have a regular program of spraying with either a contact insecticide such as Malathion or a systemic such as Safari.
Bromeliads can be sensitive to any chemical so always test a small portion first. I typically start off with half the recommended amount as directed to avoid burning the leaves.
For snails and slugs, regular use of a bait works best. I prefer a product called Deadline.
At Bromeliad Paradise, we dip all of our newly potted and purchased plants in a solution of Malathion to ensure the plants and potting mix are bug free.
When there is a lack of air movement around the plant stem or roots, they are susceptible to attack by fungus or bacteria, which begins to cause rot.
The best cure is to remove the plant from its potting medium, clean it thoroughly with a anti-bacterial soap such as Physan-20, and cut away all old roots and any rotting stem.
Once the stem is dry and free from any rotted tissue, plant the bromeliad in a pot one size smaller than the pot previously occupied using a very porous mixture (I recommend at least 60% small pine bark nuggets).
Water with a solution of 1 tablespoon of hydrogen peroxide to 1 gallon of water. This will provide more oxygen to the roots and help kill any lingering bacteria in the roots or the potting mix.
You should use this solution until the plant is growing new luxurious leaves. Once it is thriving it can be up-potted to the original size pot and watered normally.
We can't stress enough that how important a healthy root system is to a bromeliads health. A bromeliad with a well-established root system is able to use those roots to replace moisture that is lost through its leaves due to transpiration. A well aerated potting mix is the key.
Too much sun and your bromeliad will get ugly dead spots on the leaves from sun burn. Too little light and it will go green and 'leggy' or eventually die altogether. 50% shade is the general rule of thumb but you can adjust this based on your observations or your grower's recommendations.
Good air circulation not only reduces chances of bacterial or fungal infections, but reduces the chance your plants will be attacked by pests. This doesn't mean that they need a lot of wind, just that they should not be obstructed from air flow or be planted in soil that cannot "breath".
Finally, do not overwater! A light spray can be beneficial to increase humidity and keep the leaves hydrated, but bromeliads do much better when the roots get plenty of aeration. This can only happen if the soil is not oversaturated with water. Remember, to have a healthy root system means to have a healthy bromeliad.
Using these tips and having a little patience will greatly improve your chances of enjoying Bromeliads that are healthy, colorful and productive.


text:
Pregnant woman, man seriously injured in Loop stabbing during argument over ride share
By Alice Yin
An officer walks under police tape near Randolph and State streets near the scene where a woman and man were stabbed on the 100 block of East Washington Street in Chicago on July 7, 2019. (Armando L. Sanchez / Chicago Tribune)
Two people were stabbed and seriously wounded in the Loop late Saturday when a fight broke out over a ride share.
About 11:30 p.m., six people were standing on a sidewalk in the first block of East Washington Street after ordering a ride-share service. A vehicle pulled over with a male driver and female passenger inside offering them a ride, according to Chicago police.
The two groups began to argue, leading to the male and female exiting the vehicle to fight the six people outside. The male pulled out a knife during the altercation and stabbed a woman once in the abdomen and a man twice in the abdomen, police said.
The woman, 27, was in critical condition after the attack and told paramedics she was three months pregnant as they loaded her into an ambulance, according to the Chicago Fire Department.
The man, 26, was in serious condition. Both were taken to Northwestern Memorial Hospital, police said.
The attackers escaped eastbound on Washington Street. No one is in custody.
ayin@chicagotribune.com


Packed full of different functionality this mens timepiece is sure to make the perfect gift for any gadget enthusiast. The large black dial features luminescent hands for an easy read time display even in low lit conditions, as well as many other useful features.
Watch will not beep when switching from one function to another. Preset alarm or countdown timers remain active when the button tones are deactivated.
With a push of a button, hands move away to permit free visibility.
Once the high tide time has been entered for a selected location, the watch can display the low and high tide phases at this location on any given date. This can be quite useful if you want to know the patterns of the tides at your destination in advance.


Do you have a picture of 'Indegardegarda Pool'?
Indegardegarda Pool, when full, covers an area of around 8 hectares and is located in WA.
The Indegardegarda Pool is fed by the Murchison River.
Towns, villages or cities near Indegardegarda Pool include the village of Cue (show me), the village of Meekatharra (show me) and the village of Mount Magnet (show me).
Have you caught or seen fish at Indegardegarda Pool? Contribute your knowledge by clicking here.
Are you a keen bird watcher? Have you been bird watching in Indegardegarda Pool? What birds have you seen in Indegardegarda Pool? Contribute your knowledge by clicking here. As a Bonzle sub-project, we're trying to build Australia's most comprehensive bird location atlas. A big thankyou to all that have contributed and continue to contribute sightings.
Do you know what facilities are available in Indegardegarda Pool? Contribute your knowledge by clicking here.
Do you know what recreational activities are available in Indegardegarda Pool? Contribute your knowledge by clicking here.


text:
\section{Introduction}

It is well known the fact that possibility theory is an alternative theory to the probability theory, dealing with certain types of uncertainty and treatment of incomplete information (see, e.g., \cite{DubPrad} or \cite{Cooman}).
In the possibilistic models, all the probabilistic indicators (like expected value, variance, probability measure,
etc) are replaced with suitable possibilistic indicators.

Variants of the classical laws of large numbers in probability theory, were studied in the general setting of some non-additive set functions in a large number of papers, see, e.g., \cite{Fuller1}, \cite{Fuller2}, \cite{Hong}, \cite{Hong2}, \cite{Teran}, \cite{Teran2}, \cite{Cooman2}, \cite{Chen}.             .
They are, in essence, based on arithmetic means of the variables (fuzzy numbers), on some non-additive set valued functions including upper and lower probabilities, on very special concepts of possibilistic mean value, including those based on Choquet integrals.

In this paper, we consider a completely different approach. Thus, we use the "maxitive" concepts of possibilistic expectation and possibilistic variance as defined in \cite{DubPrad} (see also
\cite{Cooman}) and instead of the sum of a finite number of real functions, we consider the maximum of them.

It is worth noting that the idea of replacing for real functions the sum operator with the maximum operator, has been also proved very fruitful in constructing the so-called possibilistic (or max-product) approximation operators, see \cite{Gal-Pos}, \cite{CGOT}, \cite{BCG}. Among others, this approach allowed in the above mentioned works to introduce a possibilistic Feller's scheme, analogue
to the probabilistic Feller's scheme used in approximation by linear and positive operators.

Section 2 contains some preliminaries in the possibility theory, while in Section 3 we obtain some possibilistic variants of strong laws of large numbers.

\section{Preliminaries in Possibility Theory}

Firstly, in this section we present some known concepts and results in possibility theory, which will be useful in the next section. As it is easily seen, in fact they are the corresponding concepts for those in probability theory, like random variable, probability distribution, mean value, probability, so on.
For details, see, e.g., \cite{DubPrad} or \cite{Cooman}.

{\bf Definition 2.1.} Let $\Omega$ be a non-empty set.

(i) An application $X:\Omega\to \mathbb{R}$ will be called (random) variable.

(ii) A possibility distribution (on $\Omega$), is a function $\lambda : \Omega \to [0, 1]$, such that $\sup\{\lambda(s) ; s\in \Omega\}=1$.

(iii) The possibility expectation of a variable $X$ (on $\Omega$), with the possibility distribution $\lambda$, is defined by
$E_{sup}(X)=\sup_{s\in \Omega}X(s)\lambda(s)$. The possibility variance of $X$ is defined by $Var_{sup}(X)=\sup\{(X(s)-E_{sup}(X))^{2}\lambda(s) ; s\in \Omega\}$.

(iv) A possibility measure is a mapping $P:{\cal{P}}(\Omega)\to [0, 1]$, satisfying the axioms $P(\emptyset)=0$, $P(\Omega)=1$ and $P(\bigcup_{i\in I}A_{i})=\sup\{P(A_{i}) ; i\in I\}$ for all $A_{i}\in \Omega$, and any $I$, an arbitrary family of indices (if $\Omega$ is finite then obviously $I$ must be finite too). Note that if $A, B\subset \Omega$, satisfy $A\subset B$, then by the last property it easily follows that $P(A)\le P(B)$ and that $P(A\bigcup B)\le P(A)+P(B)$.

It is well-known (see, e.g., \cite{DubPrad}) that any possibility distribution $\lambda$ on $\Omega$, induces a possibility measure $P_{\lambda}:{\cal{P}}(\Omega)\to [0, 1]$, given by the formula $P_{\lambda}(A)=\sup \{\lambda(s) ; s\in A\}$, for all $A\subset \Omega$.

A key tool in our proofs is the following simple possibilistic analogue of the Chebyshev's inequality in probability theory.

{\bf Theorem 2.2.} (see, e.g., \cite{Gal-Pos}) {\it Let $\Omega$ be a non-empty set, $\lambda:\Omega \to [0, 1]$
and consider $X:\Omega \to \mathbb{R}$ be with the possibility distribution $\lambda$.
Then, for any  $r>0$, we have
$$P_{\lambda}(\{s\in \Omega ; |X(s)-E_{sup}(X)|\ge r\})\le \frac{Var_{sup}(X)}{r^{2}},$$
where $P_{\lambda}$ is the possibilistic measure induced by $\lambda$.}

This result was proved by Theorem 2.2 in \cite{Gal-Pos} for $\Omega$ discrete set, but analyzing its proof it is obvious that it remains valid for arbitrary non-empty sets too.

We also need the following concepts, known in fact for the more general case of non-additive set functions (see, e.g., \cite{Couso}, \cite{Denn}, \cite{WK1}).

{\bf Definition 2.3.} Let $X_{n}, X:\Omega\to \mathbb{R}$, $n\in \mathbb{N}$ and $P_{\lambda}$ be a possibility measure on $\Omega$.

(i) We say that $X_{n}$ converges to $X$ in the possibility measure $P_{\lambda}$, if for any $\varepsilon>0$, we have
$$\lim_{n\to \infty}P_{\lambda}(\{\omega\in \Omega ; |X_{n}(\omega)-X(\omega)|\ge \varepsilon \})=0.$$

(ii) We say that $X_{n}$ converges to $X$, almost everywhere with respect to the possibility measure $P_{\lambda}$, if
$$P_{\lambda}(\{\omega\in \Omega ; X_{n}(\omega)\not \to X(\omega)\})=0,$$
where the notation $X_{n}(\omega)\not \to X(\omega)$ includes the both cases when $(X_{n}(\omega))_{n}$ has not limit and when $(X_{n}(\omega))_{n}$ has a limit but it is different from $X(\omega)$.

{\bf Remark.} If $X_{n}$ converges to $X$, almost everywhere with respect to the possibility measure $P_{\lambda}$, then we have
$$P_{\lambda}(\{\omega\in \Omega ; \lim_{n\to \infty}X_{n}(\omega)=X(\omega)\})=1.$$
Indeed, denoting by $A=\{\omega\in \Omega ; X_{n}(\omega)\not \to X(\omega)\}$,
since any possibility measure is obviously subadditive we get
$$1=P_{\lambda}(\Omega)=P_{\lambda}(A\bigcup (\Omega\setminus A))\le P_{\lambda}(A)+P_{\lambda}(\Omega\setminus A)=
P_{\lambda}(\Omega\setminus A),$$
which obviously implies that $P_{\lambda}(\Omega\setminus A)=1$.

Also, we need the following auxiliary results.

{\bf Lemma 2.4.} {\it Let $P_{\lambda}$ be a possibility measure on $\Omega$ and $B_{n}\subset \Omega$, $n\in \mathbb{N}$. If $\lim_{n\to \infty}P_{\lambda}(B_{n})=0$, then
$\lim_{m\to \infty}\sup\{P_{\lambda}(B_{n}); n\ge m\}=0$, for all $n\in \mathbb{N}$.}

{\bf Proof.} Denoting $A_{m}=\sup\{P_{\lambda}(B_{n}); n\ge m\}$, $n\in \mathbb{N}$, it is immediate that the sequence of positive numbers $(A_{m})_{m\in \mathbb{N}}$ is non-increasing.

Let $\varepsilon >0$. By hypothesis, there exists $m_{0}\in \mathbb{N}$, such that $P_{\lambda}(B_{n})<\varepsilon$, for all $n\ge m_{0}$. This implies that $A_{m_{0}}=\sup\{P_{\lambda}(B_{n}) ; n\ge m_{0}\}<\varepsilon$ and since $(A_{m})_{m}$ is non-increasing, it follows $0\le A_{m}\le A_{m_{0}}<\varepsilon$, for all $m\ge m_{0}$.

In other words, $\lim_{m\to \infty}A_{m}=0$, which proves the lemma. $\hfill \square$

{\bf Lemma 2.5.} (Possibilistic Borel-Cantelli lemma) {\it Let $P_{\lambda}$ be a possibility measure on
$\Omega$. Denoting
$B_{\infty}=\bigcap_{m=1}^{\infty}\bigcup_{n=m}^{\infty}B_{n}$, if $\lim_{m\to \infty}\sup\{P_{\lambda}(B_{n}); n\ge m\}=0$, then $P_{\lambda}(B_{\infty})=0$.}

{\bf Proof.} Indeed, from the properties of the possibility measure $P_{\lambda}$ in Definition 2.1, (iv), it follows
$$P_{\lambda}(B_{\infty})\le P_{\lambda}(\bigcup_{n=m}^{\infty}B_{n})=\sup\{P_{\lambda}(B_{n}); n\ge m\}, \mbox{ for all } m\in \mathbb{N}.$$
Passing with $m\to \infty$, it follows $P_{\lambda}(B_{\infty})=0$.

It is useful to note here that in fact we can write
$$B_{\infty}=\{\omega\in \Omega ;  \mbox{ such that }  \omega \in B_{n} \mbox{ for infinitely many } n\}.$$
$\hfill \square$

{\bf Corollary 2.6.} {\it Let $X_{n}, X:\Omega\to \mathbb{R}$, $n\in \mathbb{N}$ and $P_{\lambda}$ be a possibility measure on $\Omega$.

If $X_{n}$ converges to $X$ in the possibility measure $P_{\lambda}$,
then $X_{n}$ converges to $X$, almost everywhere with respect to the possibility measure $P_{\lambda}$.}

{\bf Proof.} Let $\varepsilon>0$ be arbitrary. Denoting $B_{n}(\varepsilon)=\{\omega\in \Omega; |X_{n}(\omega)-X(\omega)|\ge \varepsilon\}$, since by hypothesis we have $\lim_{n\to \infty}P_{\lambda}(B_{n}(\varepsilon))=0$, Lemma 2.4 implies $\lim_{m\to \infty}\sup\{P_{\lambda}(B_{n}(\varepsilon)); n\ge m\}=0$, which by Lemma 2.5 implies $P_{\lambda}(B_{\infty}(\varepsilon))=0$, where
$$B_{\infty}(\varepsilon)=\{\omega\in \Omega ;  \mbox{ such that }  \omega \in B_{n}(\varepsilon) \mbox{ for infinitely many } n\}.$$
This means that for any  $\varepsilon>0$ and $\omega\in B_{\infty}(\varepsilon)$, we have that $X_{n}(\omega)\not \to X(\omega)$.

Now, let $(\varepsilon_{k})_{k}$ be a sequence with $\varepsilon_{k}\searrow 0$. It is clear that
$$\{\omega\in \Omega ; X_{n}(\omega)\not \to X(\omega)\}=\bigcup_{k=1}^{\infty}B_{\infty}(\varepsilon_{k}),$$
which implies
$$P_{\lambda}(\{\omega\in \Omega ; X_{n}(\omega)\not \to X(\omega)\})=\sup\{P_{\lambda}(B_{\infty}(\varepsilon_{k})) ;k\in \mathbb{N}\}=0.$$
Also, by the Remark after Definition 2.3, it follows that $P_{\lambda}(\{\omega\in \Omega ; X_{n}(\omega)\to X(\omega)\})=1$, which ends the proof of corollary. $\hfill \square$

{\bf Remarks.} 1) It is worth noting that different from what is happening in probability theory, in general, the almost everywhere convergence in Definition 2.3, (ii), does not imply the convergence in possibility measure.
A simple counterexample in this sense could be Example 7.6, p. 163 in \cite{WK1}. This is happening because of the following reasons. Indeed,
it is known that in probability theory, the validity of "a.e. convergence implies convergence in measure"  is based on the continuity from above of a probability measure. But it is easy to show that  while any possibility measure is continuous from below (that is
if $A_{1}\subset ... \subset A_{n}\subset A_{n+1}\subset ... \subset \Omega$ and  $A=\bigcup_{n=1}^{\infty}A_{n}$, then $P_{\lambda}(A)=\lim_{n\to \infty}P_{\lambda}(A_{n})$), in general it is not continuous from
above (that is by decreasing sequences of sets).

2) Corollary 2.6 will have as a consequence the fact that in this frame, the weak form of the law of large numbers, will always imply the strong law of large numbers.

\section{Laws of Large Numbers in Possibility Theory}

The following classical result in probability theory is well known.

{\bf Theorem 3.1.} (Kolmogorov, \cite{Kol}) {\it Let $(X_{k})_{k\in \mathbb{N}}$ be a sequence of independent random variables with finite variances $Var(X_{k})$ and denote $S_{n}=\sum_{k=1}^{n}X_{k}$. If $\sum_{k=1}^{\infty}\frac{Var(X_{k})}{k^{2}}<+\infty$, then $\frac{S_{n}-E(S_{n})}{n}\to 0$, almost sure in probability. Here $E(S_{n})$ denotes the probability expectation of $S_{n}$ and $Var(X_{k})$ denotes the probabilistic variance.}

In the same spirit of ideas, Petrov in \cite{Petrov1}, proved the following result.

{\bf Theorem 3.2.} {\it Let $(X_{k})_{k\in \mathbb{N}}$ be a sequence of independent random variables with finite variances $Var(X_{K})$ and denote $S_{n}=\sum_{k=1}^{n}X_{k}$. If $Var(X_{n})=O\left (\frac{n^{2}}{\Psi(n)}\right )$,
with a $\Psi$ positive, nondecreasing function satisfying $\sum_{n=1}^{\infty}\frac{1}{n \Psi(n)}<+\infty$,
then $\frac{S_{n}-E(S_{n})}{n}\to 0$, almost sure in probability.}

{\bf Remark.} Korchevsky proved in \cite{Kor1} that Theorem 3.2 is in fact a consequence of Theorem 3.1.

In this section, among others, we will obtain possibilistic variants of the above two results.

Thus, let $\Omega$ be a nonempty set and $P_{\lambda}:{\cal{P}}(\Omega)\to [0, 1]$ be a possibility measure generated by the possibility distribution $\lambda$.

Let $(X_{k})_{k\in \mathbb{N}}$ be a sequence of fuzzy variables. The main idea is to replace in the
above probabilistic laws of large numbers, the sum $\sum_{k=1}^{n}X_{k}(s)$ by the maximum $\max\{X_{1}(s), ..., X_{n}(s)\}, s\in \Omega$, the probabilistic variance and expectation with the their possibilistic variants in Definition 2.1, (iii) and the probability measure with the possibility measure in Definition 2.1, (iv).

The first possibilistic strong law of large numbers is the following.

{\bf Theorem 3.3.} {\it Let $\Psi(n)$, $n\in \mathbb{N}$, be such that $\Psi(n)>0$ for all $n\in \mathbb{N}$,
and $\Psi(n)\to \infty$. If the sequence $X_{k}:\Omega \to \mathbb{R}$, $k\in \mathbb{N}$, satisfies
$$\max\{Var_{sup}(X_{1}), ..., Var_{sup}(X_{n})\}\le C\cdot \left (\frac{n^{2}}{\Psi(n)}\right ), \mbox{ for all } n\in \mathbb{N},$$
with $C>0$ a constant independent of $n$, then denoting
$$M_{n}(\omega)=\max\{X_{1}(\omega), ..., X_{n}(\omega)\},$$
for $n\to \infty$ we have that $\frac{M_{n}-E_{sup}(M_{n})}{n}\to 0$, almost everywhere with respect to the measure of possibility $P_{\lambda}$. Also, it follows
$$P_{\lambda}\left (\left \{\omega\in \Omega ; \frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}\not \to 0 \right \}\right )=0$$ and
$$P_{\lambda}\left (\left \{\omega\in \Omega ; \lim_{n\to \infty}\frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}=0 \right \}\right )=1.$$}

{\bf Proof.} Firstly, we have
$$E_{sup}(M_{n})$$
$$=\sup\{M_{n}(\omega)\cdot \lambda(\omega); \omega\in \Omega\}=\sup\{\max\{X_{1}(\omega)\lambda(\omega), ..., X_{n}(\omega)\lambda(\omega)\}; \omega\in \Omega\}$$
$$=\max\{\sup\{X_{k}(\omega)\cdot \lambda(\omega) ; \omega\in \Omega\}; k=1, ..., n\}$$
$$=\max\{E_{sup}(X_{k}); k=1, ..., n\}.$$
Denoting $A_{n}(\omega)=\frac{M_{n}(\omega)}{n}$, the above calculation immediately implies
$$E_{sup}(A_{n})=\frac{\max\{E_{sup}(X_{k}); k=1, ..., n\}}{n}=\frac{E_{sup}(M_{n})}{n}.$$
In what follows we will use the inequality (see Lemma 11.3.1 in \cite{BCG}, p. 4.4.3)
$$|\max\{a_{i};i=1, ...,n\}-\max\{b_{i};i=1, ...,n\}|$$
$$\le \max\{|a_{i}-b_{i}|;i=1, ...,n\}, a_{i},b_{i}\in \mathbb{R}, i=1, ..., n.$$
Then, we get
$$Var_{sup}(A_{n})=$$
$$\sup\left \{\left (\frac{\max\{X_{1}(\omega), ...,X_{n}(\omega)\}}{n}-\frac{\max\{E_{sup}(X_{k}); k=1, ..., n\}}{n}  \right )^{2}\lambda(\omega); \omega\in \Omega \right \}$$
$$=\frac{1}{n^{2}}$$
$$\cdot \sup\left \{\left |\max\{X_{1}(\omega), ...,X_{n}(\omega)\}-\max\{E_{sup}(X_{k}); k=1, ..., n\}  \right |^{2}\lambda(\omega); \omega\in \Omega \right \}$$
$$\le \frac{1}{n^{2}}\sup\left \{\left (\max\{|X_{k}(\omega)-E_{sup}(X_{k})|; k=1, ..., n\}  \right )^{2}\lambda(\omega); \omega\in \Omega \right \}$$
$$=\frac{1}{n^{2}}\sup\left \{\max\{|X_{k}(\omega)-E_{sup}(X_{k})|^{2}; k=1, ..., n\}\lambda(\omega); \omega\in \Omega \right \}$$
$$=\frac{1}{n^{2}}\sup\left \{\max\{|X_{k}(\omega)-E_{sup}(X_{k})|^{2}\lambda(\omega); k=1, ..., n\}; \omega\in \Omega \right \}$$
$$=\frac{1}{n^{2}}\cdot \max\{Var_{sup}(X_{1}), ..., Var_{sup}(X_{n})\}\le \frac{1}{n^{2}}\cdot C \cdot \frac{n^{2}}{\Psi(n)}=\frac{C}{\Psi(n)}.$$
Applying now the Chebyshev's inequality in Theorem 2.2, for any $\varepsilon >0$ we immediately get
$$P_{\lambda}(\{\omega\in \Omega ; |A_{n}(\omega)-E_{sup}(A_{n})|\ge \varepsilon \})\le \frac{Var_{sup}(A_{n})}{\varepsilon^{2}}\le \frac{C}{\Psi(n) \varepsilon^{2}}.$$
This means that the sequence $Y_{n}(\omega)=\frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}$, $n\in \mathbb{N}$, converges
to $0$ in the possibilistic measure $P_{\lambda}$.

Applying now Corollary 2.6 and the Remark after Definition 2.3, it immediately follows the conclusion of the theorem. $\hfill \square$

{\bf Remarks.}  1) If $\Psi(n)$, $n\in \mathbb{N}$, is such that $\Psi(n)>0$ for all $n\in \mathbb{N}$,
$\Psi(n)\nearrow \infty$, the sequence $\left (\frac{n^{2}}{\Psi(n)}\right )_{n}$ is non-decreasing in $n$ and
$(X_{k})_{k\in \mathbb{N}}$ satisfies $Var_{sup}(X_{k})\le C\cdot \left (\frac{k^{2}}{\Psi(k)}\right )$, for all $k\in \mathbb{N}$, then it is immediate that
$$\max\{Var_{sup}(X_{1}), ..., Var_{sup}(X_{n})\}\le C\cdot \left (\frac{n^{2}}{\Psi(n)}\right ), \mbox{ for all } n\in \mathbb{N},$$
which transform Theorem 3.3 into a kind of possibilistic analogue to Theorem 3.2.

2) Simple examples for the sequences $\Psi(n)$ in Theorem 3.3 and in the above Remark 1 are $\Psi(n)=n^{\delta}$ with $0<\delta \le 2$, or
$\Psi(n)=[\ln(n+1)]^{\delta}$ with $0<\delta \le 1$.

The second possibilistic strong law of large numbers is the following.

{\bf Theorem 3.4.} {\it Let $\delta\in (0, 2)$. If the sequence $X_{k}:\Omega \to \mathbb{R}$, $k\in \mathbb{N}$, satisfies
\begin{equation}\label{eq1}
\sup_{n\in \mathbb{N}}\frac{1}{n^{\delta}}\cdot \max\{Var_{sup}(X_{1}), ..., Var_{sup}(X_{n})\} = C < +\infty,
\end{equation}
then denoting
$$M_{n}(\omega)=\max\{X_{1}(\omega), ..., X_{n}(\omega)\},$$
we have that $Y_{n}(\omega):=\frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}$ converges to $0$, almost everywhere with respect to $P_{\lambda}$. Also, it follows
$$P_{\lambda}\left (\left \{\omega\in \Omega ; \frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}\not \to 0\right \}\right )=0,$$ and
$$P_{\lambda}\left (\left \{\omega\in \Omega ; \lim_{n\to \infty}\frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}=0 \right \}\right )=1.$$}

{\bf Proof.} Denote $A_{n}=\frac{M_{n}}{n}$. By the proof of Theorem 3.3 and by hypothesis, we easily get
$$Var_{sup}(A_{n})\le \frac{\max\{Var_{sup}(X_{1}), ..., Var_{sup}(X_{n})\}}{n^{2}}$$
$$\le \frac{1}{n^{2-\delta}}\left (\frac{1}{n^{\delta}}\max\left \{Var_{\sup}(X_{1}), ..., Var_{\sup}(X_{n})\right \}\right )
\le \frac{1}{n^{2-\delta}}\cdot C, \mbox{ for all } n\in \mathbb{N}.$$
Applying now the Chebyshev's inequality in Theorem 2.2, for any $\varepsilon >0$ we immediately obtain
$$P_{\lambda}\left (\left \{\omega\in \Omega ; \left |\frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}\right |\ge \varepsilon \right \}\right )\le \frac{Var_{sup}(A_{n})}{\varepsilon^{2}}\le \frac{C}{n^{2-\delta} \varepsilon^{2}}.$$
This means that $Y_{n}(\omega):=\frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}$ converges to $0$ in the possibility measure $P_{\lambda}$, which by Corollary 2.6 and the Remark after Definition 2.3, it immediately implies the conclusion of the theorem. $\hfill \square$

{\bf Remark.} Theorem 3.4 could be considered as a possibilistic analogue of Theorem 2.6.1, p. 51 in the book \cite{Knill}, by replacing the condition (\ref{eq1}), by the stronger one
$$\sup_{n\in \mathbb{N}}\frac{1}{n^{\delta}}\cdot \sum_{k=1}^{n}Var_{sup}(X_{k})\le C < +\infty.$$

The third possibilistic strong law of large numbers can be considered as a kind of possibilistic analogue to the
Kolmogorov's result in Theorem 3.1.

{\bf Theorem 3.5.} {\it Let $\delta\in (0, 2)$. If the sequence $X_{k}:\Omega \to \mathbb{R}$, $k\in \mathbb{N}$, satisfies
\begin{equation}\label{eq2}
\sum_{k=1}^{\infty}\frac{Var_{sup}(X_{k})}{k^{\delta}}< +\infty,
\end{equation}
then denoting
$$M_{n}(\omega)=\max\{X_{1}(\omega), ..., X_{n}(\omega)\},$$
we have that $Y_{n}(\omega):=\frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}$ converges to $0$, almost everywhere with respect to $P_{\lambda}$. Also, it follows
$$P_{\lambda}\left (\left \{\omega\in \Omega ; \frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}\not \to 0\right \}\right )=0,$$ and
$$P_{\lambda}\left (\left \{\omega\in \Omega ; \lim_{n\to \infty}\frac{M_{n}(\omega)-E_{sup}(M_{n})}{n}=0 \right \}\right )=1.$$}

{\bf Proof.} Denoting $a_{k}=\frac{Var_{sup}(X_{k})}{k^{\delta}}$, by hypothesis (\ref{eq2}) it follows that $a_{k}\to 0$ as $k\to \infty$ and therefore there exists $C>0$ such that $0\le a_{k}\le C$, for all $k\in \mathbb{N}$. By the proof of Theorem 3.4 and keeping the notations there, we get
$$Var_{sup}(A_{n})\le \frac{\max\{Var_{sup}(X_{1}), ..., Var_{sup}(X_{n})\}}{n^{2}}$$
$$=\frac{1}{n^{2-\delta}}\cdot \max\left \{\frac{a_{k} k^{\delta}}{n^{\delta}} ; 1\le k\le n\right \}
\le \frac{1}{n^{2-\delta}}\cdot \max\left \{a_{k}; 1\le k\le n\right \}\le \frac{C}{n^{2-\delta}}.$$
From this point, the reasonings are identical with those in the proof of Theorem 3.4.
$\hfill \square$

{\bf Remark.} If to the hypothesis in Theorem 3.3, or in Theorem 3.4, or in Theorem 3.5 we add the hypothesis
that the sequence $(X_{k}(\omega))_{k}$ satisfies
$X_{k}(\omega)\ge 0$, for all $\omega\in \Omega$, $k\in \mathbb{N}$  and $E_{sup}(X_{k})=k\mu$, for all $k\in \mathbb{N}$, then we easily get that the sequence $\left (\frac{M_{n}(\omega)}{n}\right )_{n\in \mathbb{N}}$ converges as $n\to \infty$ to $\mu=E_{sup}(X_{1})$, almost everywhere in $\Omega$ with respect to the possibility measure $P_{\lambda}$.

{\bf Conclusion.} As we already have mentioned in Introduction, there are many papers devoted to the large laws of numbers for nonadditive set-functions. Their proofs are pretty technical due, in my opinion, to the use of arithmetical mean of variables. The natural replacement of the arithmetic mean of variables with their maximum (due to the "maxitive" property of possibility measures), makes the proofs of laws of large numbers so simple as in the probability theory. For this reason, we consider that the results in this paper can be considered as very natural extensions of those in probability theory o possibility theory.
The next interesting study would be to obtain central limit theorems in this frame.

redpajama_set_name: RedPajamaArXiv


G L A M G L I T Z .com | Love doesn't need….
G L A M G L I T Z .com > Picture Quotes > Love Picture Quotes > Love doesn't need….
« Without you. . .
This entry was posted on Tuesday, June 19th, 2012 at 2:53 pm	and is filed under Love Picture Quotes. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.