Skip to content

Commit

Permalink
get correct key type in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
steeve authored and segfault committed Jan 4, 2012
1 parent 04aaab6 commit b3bf0b6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/java/src/org/apache/cassandra/pig/CassandraStorage.java
Expand Up @@ -187,10 +187,12 @@ private List<AbstractType> getDefaultMarshallers(CfDef cfDef) throws IOException
ArrayList<AbstractType> marshallers = new ArrayList<AbstractType>();
AbstractType comparator = null;
AbstractType default_validator = null;
AbstractType key_validator = null;
try
{
comparator = TypeParser.parse(cfDef.getComparator_type());
default_validator = TypeParser.parse(cfDef.getDefault_validation_class());
key_validator = TypeParser.parse(cfDef.getKey_validation_class());
}
catch (ConfigurationException e)
{
Expand All @@ -199,13 +201,14 @@ private List<AbstractType> getDefaultMarshallers(CfDef cfDef) throws IOException

marshallers.add(comparator);
marshallers.add(default_validator);
marshallers.add(key_validator);
return marshallers;
}

private Map<ByteBuffer, AbstractType> getValidatorMap(CfDef cfDef) throws IOException
private Map<ByteBuffer, AbstractType> getValidatorMap(CfDef cfDef) throws IOException
{
Map<ByteBuffer, AbstractType> validators = new HashMap<ByteBuffer, AbstractType>();
for (ColumnDef cd : cfDef.column_metadata)
for (ColumnDef cd : cfDef.getColumn_metadata())
{
if (cd.getValidation_class() != null && !cd.getValidation_class().isEmpty())
{
Expand Down Expand Up @@ -321,19 +324,21 @@ public ResourceSchema getSchema(String location, Job job) throws IOException
// top-level schema, no type
ResourceSchema schema = new ResourceSchema();

// get default marshallers and validators
List<AbstractType> marshallers = getDefaultMarshallers(cfDef);
Map<ByteBuffer,AbstractType> validators = getValidatorMap(cfDef);

// add key
ResourceFieldSchema keyFieldSchema = new ResourceFieldSchema();
keyFieldSchema.setName("key");
keyFieldSchema.setType(DataType.CHARARRAY); //TODO: get key type
keyFieldSchema.setType(getPigType(marshallers.get(2)));

// will become the bag of tuples
ResourceFieldSchema bagFieldSchema = new ResourceFieldSchema();
bagFieldSchema.setName("columns");
bagFieldSchema.setType(DataType.BAG);
ResourceSchema bagSchema = new ResourceSchema();

List<AbstractType> marshallers = getDefaultMarshallers(cfDef);
Map<ByteBuffer,AbstractType> validators = getValidatorMap(cfDef);
List<ResourceFieldSchema> tupleFields = new ArrayList<ResourceFieldSchema>();

// default comparator/validator
Expand Down

0 comments on commit b3bf0b6

Please sign in to comment.