@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));
   }
 }
Ejemplo n.º 2
0
 private Collection<DynamicRecord> allocateArrayRecords(long valueBlockId, Object array) {
   return arrayPropertyStore.allocateRecords(valueBlockId, array);
 }
 private Collection<DynamicRecord> storeArray(Object array) {
   Collection<DynamicRecord> records = arrayStore.allocateRecords(arrayStore.nextBlockId(), array);
   for (DynamicRecord record : records) arrayStore.updateRecord(record);
   return records;
 }