コード例 #1
0
 @Test
 public void stringArrayGetsStoredAsUtf8() throws Exception {
   String[] array = new String[] {"first", "second"};
   Collection<DynamicRecord> records = arrayStore.allocateRecords(arrayStore.nextBlockId(), array);
   Pair<byte[], byte[]> loaded = loadArray(records);
   assertStringHeader(loaded.first(), array.length);
   ByteBuffer buffer = ByteBuffer.wrap(loaded.other());
   for (String item : array) {
     byte[] expectedData = UTF8.encode(item);
     assertEquals(expectedData.length, buffer.getInt());
     byte[] loadedItem = new byte[expectedData.length];
     buffer.get(loadedItem);
     assertTrue(Arrays.equals(expectedData, loadedItem));
   }
 }
コード例 #2
0
 @Override
 protected void unsetRecovered() {
   super.unsetRecovered();
   stringPropertyStore.unsetRecovered();
   propertyIndexStore.unsetRecovered();
   arrayPropertyStore.unsetRecovered();
 }
コード例 #3
0
 @Override
 public void flushAll() {
   stringPropertyStore.flushAll();
   propertyIndexStore.flushAll();
   arrayPropertyStore.flushAll();
   super.flushAll();
 }
コード例 #4
0
 @Override
 public void makeStoreOk() {
   propertyIndexStore.makeStoreOk();
   stringPropertyStore.makeStoreOk();
   arrayPropertyStore.makeStoreOk();
   super.makeStoreOk();
 }
コード例 #5
0
 public PropertyRecord getRecord(long id) {
   PropertyRecord record;
   PersistenceWindow window = acquireWindow(id, OperationType.READ);
   try {
     record = getRecord(id, window, RecordLoad.NORMAL);
   } finally {
     releaseWindow(window);
   }
   for (PropertyBlock block : record.getPropertyBlocks()) {
     // assert block.inUse();
     if (block.getType() == PropertyType.STRING) {
       Collection<DynamicRecord> stringRecords =
           stringPropertyStore.getLightRecords(block.getSingleValueLong());
       for (DynamicRecord stringRecord : stringRecords) {
         stringRecord.setType(PropertyType.STRING.intValue());
         block.addValueRecord(stringRecord);
       }
     } else if (block.getType() == PropertyType.ARRAY) {
       Collection<DynamicRecord> arrayRecords =
           arrayPropertyStore.getLightRecords(block.getSingleValueLong());
       for (DynamicRecord arrayRecord : arrayRecords) {
         arrayRecord.setType(PropertyType.ARRAY.intValue());
         block.addValueRecord(arrayRecord);
       }
     }
   }
   return record;
 }
コード例 #6
0
 @Override
 public void rebuildIdGenerators() {
   propertyIndexStore.rebuildIdGenerators();
   stringPropertyStore.rebuildIdGenerators();
   arrayPropertyStore.rebuildIdGenerators();
   super.rebuildIdGenerators();
 }
コード例 #7
0
 @Override
 public void logIdUsage(StringLogger.LineLogger logger) {
   super.logIdUsage(logger);
   propertyIndexStore.logIdUsage(logger);
   stringPropertyStore.logIdUsage(logger);
   arrayPropertyStore.logIdUsage(logger);
 }
コード例 #8
0
 @Override
 public List<WindowPoolStats> getAllWindowPoolStats() {
   List<WindowPoolStats> list = new ArrayList<WindowPoolStats>();
   list.add(stringPropertyStore.getWindowPoolStats());
   list.add(arrayPropertyStore.getWindowPoolStats());
   list.add(getWindowPoolStats());
   return list;
 }
コード例 #9
0
 private void updateDynamicRecords(List<DynamicRecord> records) {
   for (DynamicRecord valueRecord : records) {
     if (valueRecord.getType() == PropertyType.STRING.intValue()) {
       stringPropertyStore.updateRecord(valueRecord);
     } else if (valueRecord.getType() == PropertyType.ARRAY.intValue()) {
       arrayPropertyStore.updateRecord(valueRecord);
     } else {
       throw new InvalidRecordException("Unknown dynamic record" + valueRecord);
     }
   }
 }
コード例 #10
0
 @Override
 protected void closeStorage() {
   if (stringPropertyStore != null) {
     stringPropertyStore.close();
     stringPropertyStore = null;
   }
   if (propertyIndexStore != null) {
     propertyIndexStore.close();
     propertyIndexStore = null;
   }
   if (arrayPropertyStore != null) {
     arrayPropertyStore.close();
     arrayPropertyStore = null;
   }
 }
コード例 #11
0
 /*
  * This will add the value records without checking if they are already
  * in the block - so make sure to call this after checking isHeavy() or
  * you will end up with duplicates.
  */
 public void makeHeavy(PropertyBlock record) {
   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);
     }
   }
 }
コード例 #12
0
 @After
 public void after() throws Exception {
   if (arrayStore != null) arrayStore.close();
 }
コード例 #13
0
 public int getArrayBlockSize() {
   return arrayPropertyStore.getBlockSize();
 }
コード例 #14
0
 public static Object getArrayFor(
     long startRecord, Iterable<DynamicRecord> records, DynamicArrayStore arrayPropertyStore) {
   return arrayPropertyStore.getRightArray(
       readFullByteArray(startRecord, records, arrayPropertyStore, PropertyType.ARRAY));
 }
コード例 #15
0
 private Collection<DynamicRecord> allocateArrayRecords(long valueBlockId, Object array) {
   return arrayPropertyStore.allocateRecords(valueBlockId, array);
 }
コード例 #16
0
 public void updateIdGenerators() {
   propertyIndexStore.updateIdGenerators();
   stringPropertyStore.updateHighId();
   arrayPropertyStore.updateHighId();
   this.updateHighId();
 }
コード例 #17
0
 private Collection<DynamicRecord> storeArray(Object array) {
   Collection<DynamicRecord> records = arrayStore.allocateRecords(arrayStore.nextBlockId(), array);
   for (DynamicRecord record : records) arrayStore.updateRecord(record);
   return records;
 }
コード例 #18
0
 public void freeArrayBlockId(long blockId) {
   arrayPropertyStore.freeBlockId(blockId);
 }
コード例 #19
0
 private long nextArrayBlockId() {
   return arrayPropertyStore.nextBlockId();
 }