Java Code Examples for org.apache.pig.impl.logicalLayer.schema.Schema#FieldSchema
The following examples show how to use
org.apache.pig.impl.logicalLayer.schema.Schema#FieldSchema .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaTupleClassGenerator.java From spork with Apache License 2.0 | 6 votes |
@Override public void process(int fieldPos, Schema.FieldSchema fs) { if (!isTuple()) { if (isPrimitive() && (primitives++ % 8 == 0)) { add("private byte isNull_"+ isNulls++ +" = (byte)0xFF;"); } if (isBoolean()) { if (booleans++ % 8 == 0) { add("private byte booleanByte_"+ booleanBytes++ +";"); } } else { add("private "+typeName()+" pos_"+fieldPos+";"); } } else { int id = SchemaTupleClassGenerator.generateSchemaTuple(fs.schema, isAppendable(), codeDir()); for (Queue<Integer> q : listOfQueuesForIds) { q.add(id); } add("private SchemaTuple_"+id+" pos_"+fieldPos+";"); } }
Example 2
Source File: TestResourceSchema.java From spork with Apache License 2.0 | 6 votes |
/** * Test one-level Pig Schema: multiple fields for a bag */ @Test public void testResourceSchemaWithInvalidPigSchema() throws FrontendException { String [] aliases ={"f1", "f2"}; byte[] types = {DataType.CHARARRAY, DataType.INTEGER}; Schema level0 = TypeCheckingTestUtil.genFlatSchema( aliases,types); Schema.FieldSchema fld0 = new Schema.FieldSchema("f0", level0, DataType.BAG); Schema level1 = new Schema(fld0); try { Schema.getPigSchema(new ResourceSchema(level1)); Assert.fail(); } catch(FrontendException e) { assertTrue(e.getErrorCode()==2218); } }
Example 3
Source File: TOKENIZE.java From spork with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public Schema outputSchema(Schema input) { try { Schema.FieldSchema tokenFs = new Schema.FieldSchema("token", DataType.CHARARRAY); Schema tupleSchema = new Schema(tokenFs); Schema.FieldSchema tupleFs; tupleFs = new Schema.FieldSchema("tuple_of_tokens", tupleSchema, DataType.TUPLE); Schema bagSchema = new Schema(tupleFs); bagSchema.setTwoLevelAccessRequired(true); Schema.FieldSchema bagFs = new Schema.FieldSchema( "bag_of_tokenTuples_from_" + input.getField(0).alias, bagSchema, DataType.BAG); return new Schema(bagFs); } catch (FrontendException e) { // throwing RTE because //above schema creation is not expected to throw an exception // and also because superclass does not throw exception throw new RuntimeException("Unable to compute TOKENIZE schema."); } }
Example 4
Source File: CondEntropy.java From datafu with Apache License 2.0 | 5 votes |
@Override public Schema outputSchema(Schema input) { try { Schema.FieldSchema inputFieldSchema = input.getField(0); if (inputFieldSchema.type != DataType.BAG) { throw new RuntimeException("Expected a BAG as input"); } Schema inputBagSchema = inputFieldSchema.schema; if (inputBagSchema.getField(0).type != DataType.TUPLE) { throw new RuntimeException(String.format("Expected input bag to contain a TUPLE, but instead found %s", DataType.findTypeName(inputBagSchema.getField(0).type))); } Schema tupleSchema = inputBagSchema.getField(0).schema; if(tupleSchema == null) { throw new RuntimeException("The tuple of the input bag has no schema"); } List<Schema.FieldSchema> fieldSchemaList = tupleSchema.getFields(); if(fieldSchemaList == null || fieldSchemaList.size() != 2) { throw new RuntimeException("The field schema of the input tuple is null or its size is not 2"); } return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass() .getName() .toLowerCase(), input), DataType.DOUBLE)); } catch (FrontendException e) { throw new RuntimeException(e); } }
Example 5
Source File: RegexExtract.java From spork with Apache License 2.0 | 5 votes |
@Override public Schema outputSchema(Schema input) { try { return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.CHARARRAY)); } catch (Exception e) { return null; } }
Example 6
Source File: AliasableEvalFunc.java From datafu with Apache License 2.0 | 5 votes |
private void constructFieldAliases(Map<String, Integer> aliases, Schema tupleSchema, String prefix) { int position = 0; for (Schema.FieldSchema field : tupleSchema.getFields()) { String alias = getPrefixedAliasName(prefix, field.alias); if (field.alias != null && !field.alias.equals("null")) { aliases.put(alias, position); log.debug("In instance: "+getInstanceName()+", stored alias " + alias + " as position " + position); } if (field.schema != null) { constructFieldAliases(aliases, field.schema, alias); } position++; } }
Example 7
Source File: DoubleMin.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE)); }
Example 8
Source File: STARTSWITH.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(null, DataType.BOOLEAN)); }
Example 9
Source File: LCFIRST.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(null, DataType.CHARARRAY)); }
Example 10
Source File: MIN.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE)); }
Example 11
Source File: InputSchemaUDF.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { Properties props = UDFContext.getUDFContext().getUDFProperties(this.getClass()); props.put("myschema", input); return new Schema(new Schema.FieldSchema(null, DataType.INTEGER)); }
Example 12
Source File: LAST_INDEX_OF.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(null, DataType.INTEGER)); }
Example 13
Source File: LongMin.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.LONG)); }
Example 14
Source File: VAR.java From datafu with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(null, DataType.DOUBLE)); }
Example 15
Source File: WeeksBetween.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.LONG)); }
Example 16
Source File: Base.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE)); }
Example 17
Source File: DoubleVAR.java From datafu with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(null, DataType.DOUBLE)); }
Example 18
Source File: FloatAbs.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.FLOAT)); }
Example 19
Source File: DoubleUlp.java From spork with Apache License 2.0 | 4 votes |
@Override public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE)); }
Example 20
Source File: TestEvalPipeline.java From spork with Apache License 2.0 | 4 votes |
public Schema outputSchema(Schema input) { return new Schema(new Schema.FieldSchema(null, DataType.MAP)); }