Package org.apache.hcatalog.data.schema

Examples of org.apache.hcatalog.data.schema.HCatSchema


     */
    public void testGetSetByType2() throws HCatException {
        HCatRecord inpRec = getGetSet2InpRec();

        HCatRecord newRec = new DefaultHCatRecord(inpRec.size());
        HCatSchema hsch =
                HCatSchemaUtils.getHCatSchema("a:binary,b:map<string,string>,c:array<int>,d:struct<i:int>");


        newRec.setByteArray("a", hsch, inpRec.getByteArray("a", hsch));
        newRec.setMap("b", hsch, inpRec.getMap("b", hsch));
View Full Code Here


                break;
            }
            if (valueToken != JsonToken.START_OBJECT) {
                throw new IOException("Start of Object expected");
            }
            HCatSchema subSchema = hcatFieldSchema.getStructSubSchema();
            int sz = subSchema.getFieldNames().size();

            List<Object> struct = new ArrayList<Object>(Collections.nCopies(sz, null));
            while ((valueToken = p.nextToken()) != JsonToken.END_OBJECT) {
                populateRecord(struct, valueToken, p, subSchema);
            }
View Full Code Here

                // the table
                // information passed to HCatOutputFormat was not right
                throw new PigException(he.getMessage(),
                    PigHCatUtil.PIG_EXCEPTION_CODE, he);
            }
            HCatSchema hcatTblSchema = HCatOutputFormat.getTableSchema(job);
            try {
                doSchemaValidations(pigSchema, hcatTblSchema);
            } catch (HCatException he) {
                throw new FrontendException(he.getMessage(), PigHCatUtil.PIG_EXCEPTION_CODE, he);
            }
View Full Code Here

        job.setMapOutputKeyClass(BytesWritable.class);
        job.setMapOutputValueClass(DefaultHCatRecord.class);

        job.setNumReduceTasks(0);

        HCatOutputFormat.setSchema(job, new HCatSchema(columns));

        boolean success = job.waitForCompletion(true);
        Assert.assertTrue(success == false);
    }
View Full Code Here

    public static class MapHCatWrite extends Mapper<LongWritable, Text, BytesWritable, HCatRecord> {
        @Override
        public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
            OutputJobInfo jobInfo = (OutputJobInfo) HCatUtil.deserialize(context.getConfiguration().get(HCatConstants.HCAT_KEY_OUTPUT_INFO));
            HCatRecord record = new DefaultHCatRecord(3);
            HCatSchema schema = jobInfo.getOutputSchema();
            String vals[] = value.toString().split(",");
            record.setInteger("key", schema, Integer.parseInt(vals[0]));
            for (int i = 1; i < vals.length; i++) {
                String pair[] = vals[i].split(":");
                record.set(pair[0], schema, pair[1]);
View Full Code Here

        }
    }

    private HCatSchema getProjectionSchema() throws HCatException {

        HCatSchema schema = new HCatSchema(new ArrayList<HCatFieldSchema>());
        schema.append(new HCatFieldSchema("key", HCatFieldSchema.Type.STRING,
            ""));
        schema.append(new HCatFieldSchema("testqualifier1",
            HCatFieldSchema.Type.STRING, ""));
        return schema;
    }
View Full Code Here

        // initialize HCatOutputFormat
        HCatOutputFormat.setOutput(job, OutputJobInfo.create(
            dbName, outputTableName, outputPartitionKvps));


        HCatSchema s = HCatInputFormat.getTableSchema(job);
        HCatOutputFormat.setSchema(job, s);
        job.setInputFormatClass(HCatInputFormat.class);
        job.setOutputFormatClass(HCatOutputFormat.class);
        job.setJarByClass(StoreComplex.class);
        job.setMapperClass(ComplexMapper.class);
View Full Code Here

            dbName, tableName, null));
        // initialize HCatOutputFormat
        HCatOutputFormat.setOutput(job, OutputJobInfo.create(
            dbName, outputTableName, outputPartitionKvps));
        // test with and without specifying schema randomly
        HCatSchema s = HCatInputFormat.getTableSchema(job);
        if (writeToNonPartPigTable) {
            List<HCatFieldSchema> newHfsList = new ArrayList<HCatFieldSchema>();
            // change smallint and tinyint to int
            for (HCatFieldSchema hfs : s.getFields()) {
                if (hfs.getTypeString().equals("smallint")) {
                    newHfsList.add(new HCatFieldSchema(hfs.getName(),
                        HCatFieldSchema.Type.INT, hfs.getComment()));
                } else if (hfs.getTypeString().equals("tinyint")) {
                    newHfsList.add(new HCatFieldSchema(hfs.getName(),
                        HCatFieldSchema.Type.INT, hfs.getComment()));
                } else {
                    newHfsList.add(hfs);
                }
            }
            s = new HCatSchema(newHfsList);
        }
        HCatOutputFormat.setSchema(job, s);


        job.setInputFormatClass(HCatInputFormat.class);
View Full Code Here

        job.setOutputKeyClass(WritableComparable.class);
        job.setOutputValueClass(DefaultHCatRecord.class);
        job.setNumReduceTasks(0);
        HCatOutputFormat.setOutput(job, OutputJobInfo.create(dbName,
            outputTableName, null));
        HCatSchema s = HCatInputFormat.getTableSchema(job);
        System.err.println("INFO: output schema explicitly set for writing:"
            + s);
        HCatOutputFormat.setSchema(job, s);
        job.setOutputFormatClass(HCatOutputFormat.class);
        return (job.waitForCompletion(true) ? 0 : 1);
View Full Code Here

            dbName, tableName, null));
        // initialize HCatOutputFormat
        HCatOutputFormat.setOutput(job, OutputJobInfo.create(
            dbName, outputTableName, outputPartitionKvps));
        // test with and without specifying schema randomly
        HCatSchema s = HCatInputFormat.getTableSchema(job);
        System.err.println("INFO: output schema explicitly set for writing:" + s);
        HCatOutputFormat.setSchema(job, s);

        job.setInputFormatClass(HCatInputFormat.class);
        job.setOutputFormatClass(HCatOutputFormat.class);
View Full Code Here

TOP

Related Classes of org.apache.hcatalog.data.schema.HCatSchema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.