Beispiel #1
0
 public void ensureHeavy(PropertyBlock block) {
   if (block.getType() == PropertyType.STRING) {
     if (block.isLight()) {
       Collection<DynamicRecord> stringRecords =
           stringPropertyStore.getLightRecords(block.getSingleValueLong());
       for (DynamicRecord stringRecord : stringRecords) {
         stringRecord.setType(PropertyType.STRING.intValue());
         block.addValueRecord(stringRecord);
       }
     }
     for (DynamicRecord stringRecord : block.getValueRecords()) {
       stringPropertyStore.ensureHeavy(stringRecord);
     }
   } else if (block.getType() == PropertyType.ARRAY) {
     if (block.isLight()) {
       Collection<DynamicRecord> arrayRecords =
           arrayPropertyStore.getLightRecords(block.getSingleValueLong());
       for (DynamicRecord arrayRecord : arrayRecords) {
         arrayRecord.setType(PropertyType.ARRAY.intValue());
         block.addValueRecord(arrayRecord);
       }
     }
     for (DynamicRecord arrayRecord : block.getValueRecords()) {
       arrayPropertyStore.ensureHeavy(arrayRecord);
     }
   }
 }
Beispiel #2
0
  private void updateRecord(PropertyRecord record, PersistenceWindow window) {
    long id = record.getId();
    registerIdFromUpdateRecord(id);
    Buffer buffer = window.getOffsettedBuffer(id);
    if (record.inUse()) {
      // Set up the record header
      short prevModifier =
          record.getPrevProp() == Record.NO_NEXT_RELATIONSHIP.intValue()
              ? 0
              : (short) ((record.getPrevProp() & 0xF00000000L) >> 28);
      short nextModifier =
          record.getNextProp() == Record.NO_NEXT_RELATIONSHIP.intValue()
              ? 0
              : (short) ((record.getNextProp() & 0xF00000000L) >> 32);
      byte modifiers = (byte) (prevModifier | nextModifier);
      /*
       * [pppp,nnnn] previous, next high bits
       */
      buffer.put(modifiers);
      buffer.putInt((int) record.getPrevProp()).putInt((int) record.getNextProp());

      // Then go through the blocks
      int longsAppended = 0; // For marking the end of blocks
      for (PropertyBlock block : record.getPropertyBlocks()) {
        long[] propBlockValues = block.getValueBlocks();
        for (long propBlockValue : propBlockValues) {
          buffer.putLong(propBlockValue);
        }

        longsAppended += propBlockValues.length;
        /*
         * For each block we need to update its dynamic record chain if
         * it is just created. Deleted dynamic records are in the property
         * record and dynamic records are never modified. Also, they are
         * assigned as a whole, so just checking the first should be enough.
         */
        if (!block.isLight() && block.getValueRecords().get(0).isCreated()) {
          updateDynamicRecords(block.getValueRecords());
        }
      }
      if (longsAppended < PropertyType.getPayloadSizeLongs()) {
        buffer.putLong(0);
      }
    } else {
      if (!isInRecoveryMode()) {
        freeId(id);
      }
      // skip over the record header, nothing useful there
      buffer.setOffset(buffer.getOffset() + 9);
      buffer.putLong(0);
    }
    updateDynamicRecords(record.getDeletedRecords());
  }
Beispiel #3
0
 public void makeHeavyIfLight(PropertyBlock record) {
   if (record.isLight()) {
     /*
      * This will add the value records without checking if they are already
      * in the block - so we only call this after checking isLight() or
      * else we will end up with duplicates.
      */
     if (record.getType() == PropertyType.STRING) {
       Collection<DynamicRecord> stringRecords =
           stringPropertyStore.getLightRecords(record.getSingleValueLong());
       for (DynamicRecord stringRecord : stringRecords) {
         stringRecord.setType(PropertyType.STRING.intValue());
         record.addValueRecord(stringRecord);
       }
     } else if (record.getType() == PropertyType.ARRAY) {
       Collection<DynamicRecord> arrayRecords =
           arrayPropertyStore.getLightRecords(record.getSingleValueLong());
       for (DynamicRecord arrayRecord : arrayRecords) {
         arrayRecord.setType(PropertyType.ARRAY.intValue());
         record.addValueRecord(arrayRecord);
       }
     }
   }
 }
 public Object getArrayFor(PropertyBlock propertyBlock) {
   assert !propertyBlock.isLight();
   return getArrayFor(
       propertyBlock.getSingleValueLong(), propertyBlock.getValueRecords(), arrayPropertyStore);
 }