Esempio n. 1
0
 protected void writeIndexCommandHeader(IndexCommand command) throws IOException {
   writeIndexCommandHeader(
       command.getValueType(),
       command.getEntityType(),
       needsLong(command.getEntityId()),
       command.startNodeNeedsLong(),
       command.endNodeNeedsLong(),
       command.getIndexNameId(),
       command.getKeyId());
 }
Esempio n. 2
0
 public void writeToFile(IndexCommand command) throws IOException {
   /* c: commandType
    * e: entityType
    * n: indexNameId
    * k: keyId
    * i: entityId
    * v: value type
    * u: value
    * x: 0=entityId needs 4b, 1=entityId needs 8b
    * y: 0=startNode needs 4b, 1=startNode needs 8b
    * z: 0=endNode needs 4b, 1=endNode needs 8b
    *
    * [cccv,vvex][yznn,nnnn][kkkk,kkkk]
    * [iiii,iiii] x 4 or 8
    * (either string value)
    * [llll,llll][llll,llll][llll,llll][string chars...]
    * (numeric value)
    * [uuuu,uuuu] x 2-8 (depending on value type)
    */
   writeIndexCommandHeader(command);
   putIntOrLong(command.getEntityId());
   // Value
   Object value = command.getValue();
   switch (command.getValueType()) {
     case IndexCommand.VALUE_TYPE_STRING:
       write3bLengthAndString(channel, value.toString());
       break;
     case IndexCommand.VALUE_TYPE_SHORT:
       channel.putShort(((Number) value).shortValue());
       break;
     case IndexCommand.VALUE_TYPE_INT:
       channel.putInt(((Number) value).intValue());
       break;
     case IndexCommand.VALUE_TYPE_LONG:
       channel.putLong(((Number) value).longValue());
       break;
     case IndexCommand.VALUE_TYPE_FLOAT:
       channel.putFloat(((Number) value).floatValue());
       break;
     case IndexCommand.VALUE_TYPE_DOUBLE:
       channel.putDouble(((Number) value).doubleValue());
       break;
     case IndexCommand.VALUE_TYPE_NULL:
       break;
     default:
       throw new RuntimeException("Unknown value type " + command.getValueType());
   }
 }