use of org.apache.pig.impl.logicalLayer.FrontendException in project sketches-pig by DataSketches.
the class Union method outputSchema.
@Override
public Schema outputSchema(final Schema input) {
if (input != null) {
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Sketch", DataType.BYTEARRAY));
return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
} catch (final FrontendException e) {
// fall through
}
}
return null;
}
use of org.apache.pig.impl.logicalLayer.FrontendException in project sketches-pig by DataSketches.
the class UnionDoublesSketch method outputSchema.
@Override
public Schema outputSchema(final Schema input) {
if (input == null) {
return null;
}
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Sketch", DataType.BYTEARRAY));
return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
} catch (final FrontendException e) {
throw new RuntimeException(e);
}
}
use of org.apache.pig.impl.logicalLayer.FrontendException in project sketches-pig by DataSketches.
the class UnionItemsSketch method outputSchema.
@Override
public Schema outputSchema(final Schema input) {
if (input == null) {
return null;
}
try {
final Schema tupleSchema = new Schema();
tupleSchema.add(new Schema.FieldSchema("Sketch", DataType.BYTEARRAY));
return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), tupleSchema, DataType.TUPLE));
} catch (final FrontendException e) {
throw new RuntimeException(e);
}
}
use of org.apache.pig.impl.logicalLayer.FrontendException in project sketches-pig by DataSketches.
the class DataToVarOptSketch method outputSchema.
@Override
public Schema outputSchema(final Schema input) {
try {
if (input == null || input.size() == 0) {
throw new IllegalArgumentException("Degenerate input schema to VarOptSampling");
}
// first element must be a bag
if (input.getField(0).type != DataType.BAG) {
throw new IllegalArgumentException("VarOpt input must be a data bag: " + input.toString());
}
// record has a tuple in field 0
final Schema record = input.getField(0).schema;
final Schema fields = record.getField(0).schema;
if (fields.getField(weightIdx_).type != DataType.DOUBLE && fields.getField(weightIdx_).type != DataType.FLOAT) {
throw new IllegalArgumentException("weightIndex item of VarOpt tuple must be a " + "weight (double/float), found " + fields.getField(0).type + ": " + fields.toString());
}
return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.BYTEARRAY));
} catch (final FrontendException e) {
throw new RuntimeException(e);
}
}
use of org.apache.pig.impl.logicalLayer.FrontendException in project sketches-pig by DataSketches.
the class GetVarOptSamples method outputSchema.
@Override
public Schema outputSchema(final Schema input) {
try {
if (input == null || input.size() == 0 || input.getField(0).type != DataType.BYTEARRAY) {
throw new IllegalArgumentException("Input to GetVarOptSamples must be a DataByteArray: " + (input == null ? "null" : input.toString()));
}
final Schema weightedSampleSchema = new Schema();
weightedSampleSchema.add(new Schema.FieldSchema(WEIGHT_ALIAS, DataType.DOUBLE));
weightedSampleSchema.add(new Schema.FieldSchema(RECORD_ALIAS, DataType.TUPLE));
return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), weightedSampleSchema, DataType.BAG));
} catch (final FrontendException e) {
throw new RuntimeException(e);
}
}
Aggregations