Examples of PangoolRuntimeException


Examples of com.datasalt.pangool.PangoolRuntimeException

      case BYTES:
        String clazz = avroSchema.getProp(field.name());
        try{
        fields.add(Field.createObject(field.name(), Class.forName(clazz)));
        } catch(ClassNotFoundException e){
          throw new PangoolRuntimeException(e);
        }
        break;
      case ENUM:
        clazz = avroSchema.getProp(field.name());
        try{
          fields.add(Field.createEnum(field.name(),Class.forName(clazz)));
          } catch(ClassNotFoundException e){
            throw new PangoolRuntimeException(e);
          }
        break;
      default:
        throw new PangoolRuntimeException("Avro type:" + type + " can't be converted to Pangool Schema type");
      }
    }
    Schema schema = new Schema(avroSchema.getFullName(), fields);
    return schema;
  }
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

        case ENUM:
          avroFieldType = org.apache.avro.Schema.Type.ENUM;
          complexTypesMetadata.put(field.getName(),field.getObjectClass().getName());
          break;
        default:
          throw new PangoolRuntimeException("Not avro conversion from Pangool Schema type:" + field.getType());
       
      }
      org.apache.avro.Schema avroFieldSchema;
      if (avroFieldType == org.apache.avro.Schema.Type.ENUM){
        Object[] enumValues = field.getObjectClass().getEnumConstants();
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

        break;
      case OBJECT:
        b.append("{").append(tuple.get(i)).append("}");
        break;
      default:
        throw new PangoolRuntimeException("Not stringifiable type :" + f.getType());
      }
    }
    b.append("}");
    return b.toString();
  }
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

           b.append((char)bytes[p]);
        }
        b.append("\"}");
      break;
      default:
        throw new PangoolRuntimeException("Not stringifiable type :" + f.getType());
      }
    }
    b.append("}");
    return b.toString();
  }
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

     * If the Serialization class also implements {@link FieldConfigurable} then
     * the field's metadata (properties) is passed to the instance allowing stateful serialization.
     */
    public void setObjectSerialization(Class<? extends Serialization> serialization){
      if (type != Type.OBJECT){
        throw new PangoolRuntimeException("Can't set custom serialization for type " + type);
      }
      if (serializationClass != null){
        throw new PangoolRuntimeException("Serialization already set :" + serializationClass);
      }
      serializationClass = serialization;
    }
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

          ByteBuffer buffer2 = (ByteBuffer)element2;
          int start2 = buffer2.arrayOffset() + buffer2.position();
          int len2 = buffer2.limit() - buffer2.position();
          return compareBytes(buffer1,0,buffer1.length,buffer2.array(),start2,len2);
        } else {
          throw new PangoolRuntimeException("Can't compare byte[] with " + element2.getClass());
        }
      } else if(element1 instanceof ByteBuffer){
        ByteBuffer buffer1 = (ByteBuffer)element1;
        int pos1 = buffer1.position();
        int start1 = buffer1.arrayOffset() + pos1;
        int len1 = buffer1.limit() - pos1;
        if (element2 instanceof byte[]){
          byte[] buffer2 =(byte[]) element2;
          return compareBytes(buffer1.array(),start1,len1,buffer2,0,buffer2.length);
        } else if (element2 instanceof ByteBuffer){
          ByteBuffer buffer2 = (ByteBuffer)element2;
          int pos2 = buffer2.position();
          int start2 = buffer2.arrayOffset() + pos2;
          int len2 = buffer2.limit() - pos2;
          return compareBytes(buffer1.array(),start1,len1,buffer2.array(),start2,len2);
        } else {
          throw new PangoolRuntimeException("Can't compare byte[] with " + element2.getClass());
        }
      }  else if(element1 instanceof Comparable) {
          return ((Comparable) element1).compareTo(element2);
      } else if(element2 instanceof Comparable) {
          return -((Comparable) element2).compareTo(element1);
      } else {
        throw new PangoolRuntimeException("Not comparable elements:" + element1.getClass() + " with object " + element2.getClass());
      }
    }
  }
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

    this.pangoolSchema = AvroUtils.toPangoolSchema(avroSchema);
    this.conf = conf;
    try{
      this.hadoopSer = new HadoopSerialization(conf);
    } catch(IOException e){
      throw new PangoolRuntimeException(e);
    }
   
    this.customDeserializers = SerializationInfo.getDeserializers(pangoolSchema,conf);
  }
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

          ByteBuffer buffer = (ByteBuffer)objRecord;
          int offset = buffer.arrayOffset()+buffer.position();
          int length = buffer.limit()- buffer.position();
          inputBuffer.reset(buffer.array(),offset,length);
        } else {
          throw new PangoolRuntimeException("Can't convert to OBJECT from instance " + objRecord.getClass());
        }
        if (customDeser != null){
          customDeser.open(inputBuffer);
          tuple.set(pos,customDeser.deserialize(tuple.get(pos))); //TODO FIXME avro deserializer shouldn't reuse objects sometimes (UNION ?)
          customDeser.close(); //TODO is this ok ?
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

                  (Class<? extends Serialization>)Class.forName(serializationString);
              pangoolField.setObjectSerialization(ser);
          }
         
          } catch(ClassNotFoundException e) {
            throw new PangoolRuntimeException(e);
          }
        }
        break;
      case ENUM:
        String objectClazz = avroField.getProp(Field.METADATA_OBJECT_CLASS);
        try{
          pangoolField = Field.createEnum(avroField.name(),Class.forName(objectClazz));
          } catch(ClassNotFoundException e){
            throw new PangoolRuntimeException(e);
          }
        break;
      default:
        throw new PangoolRuntimeException("Avro type:" + type + " can't be converted to Pangool Schema type");
      }
      //add properties
      for(Map.Entry<String,String> entry : avroField.props().entrySet()){
        if (!Field.RESERVED_KEYWORDS.contains(entry.getKey())){
          pangoolField.addProp(entry.getKey(),entry.getValue());
View Full Code Here

Examples of com.datasalt.pangool.PangoolRuntimeException

          avroFieldSchema = org.apache.avro.Schema.createEnum(pangoolField.getName(),null,null, values);
          avroField = new org.apache.avro.Schema.Field(pangoolField.getName(),avroFieldSchema
              ,null,null);
          break;
        default:
          throw new PangoolRuntimeException("Not avro conversion from Pangool Schema type:" + pangoolField.getType());
       
      }
      if (pangoolField.getObjectClass() != null){
        avroField.addProp(Field.METADATA_OBJECT_CLASS, pangoolField.getObjectClass().getName());
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.