public void fillSerializationStatesFromDeserializedData() {
    for (NFTypeSerializer<?> serializer : getTopLevelSerializers()) {
      FastBlobTypeDeserializationState<?> state = getTypeDeserializationState(serializer.getName());

      state.fillSerializationState(this);
    }
  }
Exemple #2
0
 @Override
 @SuppressWarnings("unchecked")
 public void doSerialize(SortedMap<K, V> map, NFSerializationRecord rec) {
   serializationFramework
       .getFrameworkSerializer()
       .serializeSortedMap(rec, "map", keySerializer.getName(), valueSerializer.getName(), map);
 }
  /*
   * Copy serialization states whose serializer's name doesn't match the ones provided in the ignore collection
   */
  public void copyTo(
      FastBlobStateEngine otherStateEngine, Collection<String> topLevelSerializersToIgnore) {
    fillDeserializationStatesFromSerializedData();

    SimultaneousExecutor executor = new SimultaneousExecutor(4.0d);

    List<String> topLevelSerializersToCopy = new ArrayList<String>();
    for (NFTypeSerializer<?> serializer : getTopLevelSerializers()) {
      String serializerName = serializer.getName();
      if (!topLevelSerializersToIgnore.contains(serializerName)) {
        topLevelSerializersToCopy.add(serializer.getName());
      }
    }

    CountDownLatch latch =
        new CountDownLatch(executor.getMaximumPoolSize() * topLevelSerializersToCopy.size());

    for (String serializerizerName : topLevelSerializersToCopy) {
      executor.submit(
          getFillSerializationStateRunnable(otherStateEngine, serializerizerName, executor, latch));
    }

    try {
      latch.await();
    } catch (InterruptedException ie) {
      ie.printStackTrace();
    }
    executor.shutdown();
  }
 private <T> void createSerializationState(NFTypeSerializer<T> serializer) {
   FastBlobTypeSerializationState<T> serializationState =
       new FastBlobTypeSerializationState<T>(
           serializer, numberOfConfigurations, shouldUseObjectIdentityOrdinalCaching);
   serializationTypeStates.put(serializer.getName(), serializationState);
   orderedSerializationStates.add(serializationState);
   deserializationTypeStates.put(
       serializer.getName(), new FastBlobTypeDeserializationState<T>(serializer));
 }
  /**
   * Not intended for external consumption.
   *
   * <p>This method is only intended to be used during heap-friendly double snapshot refresh.
   */
  public void populateByteArrayOrdinalMap(ByteArrayOrdinalMap ordinalMap) {
    FastBlobSerializationRecord rec =
        new FastBlobSerializationRecord(serializer.getFastBlobSchema());
    ByteDataBuffer scratch = new ByteDataBuffer();

    for (int i = 0; i < objects.size(); i++) {
      T obj = objects.get(i);
      if (obj != null) {
        serializer.serialize(obj, rec);
        rec.writeDataTo(scratch);
        ordinalMap.put(scratch, i);
        scratch.reset();
        rec.reset();
      }
    }

    previousObjects = objects;
    objects = new ArrayList<T>(previousObjects.size());
  }
Exemple #6
0
 @Override
 public void setSerializationFramework(final SerializationFramework framework) {
   this.serializationFramework = framework;
   keySerializer.setSerializationFramework(framework);
   valueSerializer.setSerializationFramework(framework);
 }
 public void add(int ordinal, FastBlobDeserializationRecord rec) {
   T obj = serializer.deserialize(rec);
   ensureCapacity(ordinal + 1);
   objects.set(ordinal, obj);
 }
 public FastBlobSchema getSchema() {
   return serializer.getFastBlobSchema();
 }