Skip to content

Commit

Permalink
[CALCITE-4199] Add nullability annotations
Browse files Browse the repository at this point in the history
The commit includes javadoc updates and refactorings made by Julian Hyde in apache#2278
  • Loading branch information
vlsi committed Nov 29, 2020
1 parent 2f2fc40 commit d9a81b8
Show file tree
Hide file tree
Showing 1,017 changed files with 13,418 additions and 8,263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.apache.calcite.util.TimestampString;
import org.apache.calcite.util.Util;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -85,7 +87,7 @@ public CassandraFilter(
assert getConvention() == child.getConvention();
}

@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
@Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
return super.computeSelfCost(planner, mq).multiplyBy(0.1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.apache.calcite.rex.RexLiteral;
import org.apache.calcite.rex.RexNode;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.List;

/**
Expand All @@ -44,7 +46,7 @@ public CassandraLimit(RelOptCluster cluster, RelTraitSet traitSet,
assert getConvention() == input.getConvention();
}

@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
@Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
// We do this so we get the limit for free
return planner.getCostFactory().makeZeroCost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

import com.google.common.collect.ImmutableList;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -51,7 +53,7 @@ public CassandraProject(RelOptCluster cluster, RelTraitSet traitSet,
rowType);
}

@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
@Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
return super.computeSelfCost(planner, mq).multiplyBy(0.1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.rex.RexNode;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -44,7 +46,7 @@ public CassandraSort(RelOptCluster cluster, RelTraitSet traitSet,
assert getConvention() == child.getConvention();
}

@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
@Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
RelOptCost cost = super.computeSelfCost(planner, mq);
if (!collation.getFieldCollations().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.apache.calcite.util.Pair;
import org.apache.calcite.util.Util;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -63,7 +65,7 @@ protected CassandraToEnumerableConverter(
getCluster(), traitSet, sole(inputs));
}

@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
@Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
return super.computeSelfCost(planner, mq).multiplyBy(.1);
}
Expand Down
17 changes: 9 additions & 8 deletions core/src/main/codegen/templates/Parser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ void debug_message1() {
}

JAVACODE String unquotedIdentifier() {
return SqlParserUtil.strip(getToken(0).image, null, null, null,
unquotedCasing);
return SqlParserUtil.toCase(getToken(0).image, unquotedCasing);
}

/**
Expand Down Expand Up @@ -4387,7 +4386,8 @@ SqlNode StringLiteral() :
|
<BIG_QUERY_DOUBLE_QUOTED_STRING>
{
p = SqlParserUtil.strip(getToken(0).image, DQ, DQ, "\\\"", Casing.UNCHANGED);
p = SqlParserUtil.stripQuotes(getToken(0).image, DQ, DQ, "\\\"",
Casing.UNCHANGED);
try {
return SqlLiteral.createCharString(p, charSet, getPos());
} catch (java.nio.charset.UnsupportedCharsetException e) {
Expand All @@ -4398,7 +4398,8 @@ SqlNode StringLiteral() :
|
<BIG_QUERY_QUOTED_STRING>
{
p = SqlParserUtil.strip(getToken(0).image, "'", "'", "\\'", Casing.UNCHANGED);
p = SqlParserUtil.stripQuotes(getToken(0).image, "'", "'", "\\'",
Casing.UNCHANGED);
try {
return SqlLiteral.createCharString(p, charSet, getPos());
} catch (java.nio.charset.UnsupportedCharsetException e) {
Expand Down Expand Up @@ -4881,19 +4882,19 @@ void IdentifierSegment(List<String> names, List<SqlParserPos> positions) :
}
|
<QUOTED_IDENTIFIER> {
id = SqlParserUtil.strip(getToken(0).image, DQ, DQ, DQDQ,
id = SqlParserUtil.stripQuotes(getToken(0).image, DQ, DQ, DQDQ,
quotedCasing);
pos = getPos().withQuoting(true);
}
|
<BACK_QUOTED_IDENTIFIER> {
id = SqlParserUtil.strip(getToken(0).image, "`", "`", "``",
id = SqlParserUtil.stripQuotes(getToken(0).image, "`", "`", "``",
quotedCasing);
pos = getPos().withQuoting(true);
}
|
<BRACKET_QUOTED_IDENTIFIER> {
id = SqlParserUtil.strip(getToken(0).image, "[", "]", "]]",
id = SqlParserUtil.stripQuotes(getToken(0).image, "[", "]", "]]",
quotedCasing);
pos = getPos().withQuoting(true);
}
Expand All @@ -4902,7 +4903,7 @@ void IdentifierSegment(List<String> names, List<SqlParserPos> positions) :
span = span();
String image = getToken(0).image;
image = image.substring(image.indexOf('"'));
image = SqlParserUtil.strip(image, DQ, DQ, DQDQ, quotedCasing);
image = SqlParserUtil.stripQuotes(image, DQ, DQ, DQDQ, quotedCasing);
}
[
<UESCAPE> <QUOTED_STRING> {
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/java/org/apache/calcite/DataContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import com.google.common.base.CaseFormat;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Modifier;
Expand All @@ -42,17 +44,17 @@ public interface DataContext {
/**
* Returns a sub-schema with a given name, or null.
*/
SchemaPlus getRootSchema();
@Nullable SchemaPlus getRootSchema();

/**
* Returns the type factory.
*/
JavaTypeFactory getTypeFactory();
@Nullable JavaTypeFactory getTypeFactory();

/**
* Returns the query provider.
*/
QueryProvider getQueryProvider();
@Nullable QueryProvider getQueryProvider();

/**
* Returns a context variable.
Expand All @@ -62,7 +64,7 @@ public interface DataContext {
*
* @param name Name of variable
*/
Object get(String name);
@Nullable Object get(String name);

/** Variable that may be asked for in a call to {@link DataContext#get}. */
enum Variable {
Expand Down
Loading

0 comments on commit d9a81b8

Please sign in to comment.