Skip to content

Commit

Permalink
instantiate aggregate dataypes on node start, not on first use
Browse files Browse the repository at this point in the history
which caused a NullPointerException when one or more nodes in the cluster
have not used the datatype before
  • Loading branch information
chaudum committed Jun 22, 2015
1 parent 3ad8a0b commit 0c08232
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class AverageAggregation extends AggregationFunction<AverageAggregation.A
public static final String NAME = NAMES[0];
private final FunctionInfo info;

static {
DataTypes.register(AverageStateType.ID, AverageStateType.INSTANCE);
}

/**
* register as "avg" and "mean"
*/
Expand Down Expand Up @@ -97,10 +101,6 @@ public static class AverageStateType extends DataType<AverageState>
public static final int ID = 1024;
private static final AverageStateType INSTANCE = new AverageStateType();

private AverageStateType() {
DataTypes.register(ID, this);
}

@Override
public int id() {
return ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class GeometricMeanAggregation extends AggregationFunction<GeometricMeanA

public static final String NAME = "geometric_mean";

static {
DataTypes.register(GeometricMeanStateType.ID, GeometricMeanStateType.INSTANCE);
}

public static void register(AggregationImplModule mod) {
for (DataType<?> t : DataTypes.NUMERIC_PRIMITIVE_TYPES) {
mod.register(new GeometricMeanAggregation(new FunctionInfo(
Expand Down Expand Up @@ -116,10 +120,6 @@ public static class GeometricMeanStateType extends DataType<GeometricMeanState>
public static final GeometricMeanStateType INSTANCE = new GeometricMeanStateType();
public static final int ID = 4096;

private GeometricMeanStateType() {
DataTypes.register(ID, this);
}

@Override
public int id() {
return ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class StandardDeviationAggregation extends AggregationFunction<StandardDe

public static final String NAME = "stddev";

static {
DataTypes.register(StdDevStateType.ID, StdDevStateType.INSTANCE);
}

public static void register(AggregationImplModule mod) {
for (DataType<?> t : DataTypes.NUMERIC_PRIMITIVE_TYPES) {
Expand Down Expand Up @@ -85,10 +88,6 @@ public static class StdDevStateType extends DataType<StdDevState>
public static final StdDevStateType INSTANCE = new StdDevStateType();
public static final int ID = 8192;

private StdDevStateType() {
DataTypes.register(ID, this);
}

@Override
public int id() {
return ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class VarianceAggregation extends AggregationFunction<VarianceAggregation

public static final String NAME = "variance";

static {
DataTypes.register(VarianceStateType.ID, VarianceStateType.INSTANCE);
}

public static void register(AggregationImplModule mod) {
for (DataType<?> t : DataTypes.NUMERIC_PRIMITIVE_TYPES) {
mod.register(new VarianceAggregation(new FunctionInfo(
Expand Down Expand Up @@ -85,10 +89,6 @@ public static class VarianceStateType extends DataType<VarianceState>
public static final VarianceStateType INSTANCE = new VarianceStateType();
public static final int ID = 2048;

private VarianceStateType() {
DataTypes.register(ID, this);
}

@Override
public int id() {
return ID;
Expand Down

0 comments on commit 0c08232

Please sign in to comment.