コード例 #1
0
ファイル: TableBackedMap.java プロジェクト: winash/poseidon
 public void removeSingleElement(Object key, Element value) {
   final Delete delete = new Delete(ByteArraySerializer.fromObject(key));
   delete.deleteColumns(Bytes.toBytes(VALUES), (byte[]) value.getId());
   try {
     backingTable.delete(delete);
   } catch (IOException e) {
     LOG.severe("Cannot delete from backing table");
     e.printStackTrace();
   }
 }
コード例 #2
0
ファイル: PTableImpl.java プロジェクト: cclien/phoenix
 @Override
 public void setValue(PColumn column, byte[] byteValue) {
   deleteRow = null;
   byte[] family = column.getFamilyName().getBytes();
   byte[] qualifier = column.getName().getBytes();
   PDataType type = column.getDataType();
   // Check null, since some types have no byte representation for null
   if (byteValue == null || byteValue.length == 0) {
     if (!column.isNullable()) {
       throw new ConstraintViolationException(
           name.getString() + "." + column.getName().getString() + " may not be null");
     }
     removeIfPresent(setValues, family, qualifier);
     unsetValues.deleteColumns(family, qualifier, ts);
   } else {
     Integer byteSize = column.getByteSize();
     if (type.isFixedWidth()) { // TODO: handle multi-byte characters
       if (byteValue.length != byteSize) {
         throw new ConstraintViolationException(
             name.getString()
                 + "."
                 + column.getName().getString()
                 + " must be "
                 + byteSize
                 + " bytes ("
                 + type.toObject(byteValue)
                 + ")");
       }
     } else if (byteSize != null && byteValue.length > byteSize) {
       throw new ConstraintViolationException(
           name.getString()
               + "."
               + column.getName().getString()
               + " may not exceed "
               + byteSize
               + " bytes ("
               + type.toObject(byteValue)
               + ")");
     }
     removeIfPresent(unsetValues, family, qualifier);
     setValues.add(family, qualifier, ts, byteValue);
   }
 }