Package com.datasalt.pangool

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);
  }
View Full Code Here


          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

          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

              Class<? extends FieldDeserializer> deser = (deserializerString == null) ? null:
                (Class<? extends FieldDeserializer>)Class.forName(deserializerString);
              pangoolField = Field.createObject(avroField.name(),ser,deser);
          }
          } 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

          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

    this.avroSchema = AvroUtils.toAvroSchema(pangoolSchema);
    this.conf = conf;
    try{
      this.hadoopSer = new HadoopSerialization(conf);
    } catch(IOException e){
      throw new PangoolRuntimeException(e);
    }
    this.customSerializers = SerializationInfo.getSerializers(pangoolSchema);
    initBuffers();
  }
View Full Code Here

     * the field's metadata (properties) is passed to the instance allowing stateful serialization.
     */
    @SuppressWarnings("rawtypes")
    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

        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

        deser.open(inputBuffer);
        record2 = deser.deserialize(record2);
        deser.close();
        return compare(record1, record2);
      } catch(IOException e){
        throw new PangoolRuntimeException(e);
      }
    }
View Full Code Here

        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

TOP

Related Classes of com.datasalt.pangool.PangoolRuntimeException

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.