private void writePropertyRecord(PropertyRecord record) throws IOException {
   byte inUse = record.inUse() ? Record.IN_USE.byteValue() : Record.NOT_IN_USE.byteValue();
   if (record.getRelId() != -1) {
     // Here we add 2, i.e. set the second lsb.
     inUse += Record.REL_PROPERTY.byteValue();
   }
   channel.put(inUse); // 1
   channel.putLong(record.getNextProp()).putLong(record.getPrevProp()); // 8 + 8
   long nodeId = record.getNodeId();
   long relId = record.getRelId();
   if (nodeId != -1) {
     channel.putLong(nodeId); // 8 or
   } else if (relId != -1) {
     channel.putLong(relId); // 8 or
   } else {
     // means this records value has not changed, only place in
     // prop chain
     channel.putLong(-1); // 8
   }
   channel.put((byte) record.numberOfProperties()); // 1
   for (PropertyBlock block : record) {
     assert block.getSize() > 0 : record + " seems kinda broken";
     writePropertyBlock(block);
   }
   writeDynamicRecords(record.getDeletedRecords());
 }
  @Test
  public void shouldReadNodeRecords() throws IOException {
    File storeDir = dir.graphDbDir();
    find19FormatHugeStoreDirectory(storeDir);
    Legacy19PropertyStoreReader propStoreReader =
        new Legacy19PropertyStoreReader(fs, new File(storeDir, "neostore.propertystore.db"));

    int propCount = 0;
    Iterator<PropertyRecord> iterator = propStoreReader.readPropertyStore();
    while (iterator.hasNext()) {
      PropertyRecord record = iterator.next();
      if (record.inUse()) {
        propCount++;
      }
    }
    assertEquals(6000, propCount);
    propStoreReader.close();
  }
    private PropertyRecord readPropertyRecord(long id) throws IOException {
      // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
      // prev_prop_id(long)+next_prop_id(long)
      PropertyRecord record = new PropertyRecord(id);
      byte inUseFlag = channel.get(); // 1
      long nextProp = channel.getLong(); // 8
      long prevProp = channel.getLong(); // 8
      record.setNextProp(nextProp);
      record.setPrevProp(prevProp);
      boolean inUse = false;
      if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
        inUse = true;
      }
      boolean nodeProperty = true;
      if ((inUseFlag & Record.REL_PROPERTY.byteValue()) == Record.REL_PROPERTY.byteValue()) {
        nodeProperty = false;
      }
      long primitiveId = channel.getLong(); // 8
      if (primitiveId != -1 && nodeProperty) {
        record.setNodeId(primitiveId);
      } else if (primitiveId != -1) {
        record.setRelId(primitiveId);
      }
      int nrPropBlocks = channel.get();
      assert nrPropBlocks >= 0;
      if (nrPropBlocks > 0) {
        record.setInUse(true);
      }
      while (nrPropBlocks-- > 0) {
        PropertyBlock block = readPropertyBlock();
        if (block == null) {
          return null;
        }
        record.addPropertyBlock(block);
      }

      if (readDynamicRecords(record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER) == -1) {
        return null;
      }

      if ((inUse && !record.inUse()) || (!inUse && record.inUse())) {
        throw new IllegalStateException(
            "Weird, inUse was read in as " + inUse + " but the record is " + record);
      }
      return record;
    }