Package com.orientechnologies.orient.core.serialization

Examples of com.orientechnologies.orient.core.serialization.OMemoryStream


      stream = null;
    else {
      if (stream != null)
        stream.setSource(buffer);
      else
        stream = new OMemoryStream(buffer);
    }

    return setDirty();
  }
View Full Code Here


      stream = null;
    else {
      if (stream != null)
        stream.setSource(buffer);
      else
        stream = new OMemoryStream(buffer);
    }

    return setDirty();
  }
View Full Code Here

    for (int i = 0; i < size; i++) {
      offset = serializeKey(outBuffer, offset, i);
    }

    final OMemoryStream outStream = new OMemoryStream(outBuffer);
    try {
      outStream.jump(offset);

      for (int i = 0; i < size; ++i)
        serializedValues[i] = outStream.set(serializeStreamValue(i));

      buffer = outStream.toByteArray();
    } finally {
      outStream.close();
    }

    if (stream == null)
      stream = new OMemoryStream(buffer);
    else
      stream.setSource(buffer);
  }
View Full Code Here

    serializedValues = new int[pageSize];
    values = (V[]) new Object[pageSize];

    if (stream == null)
      stream = new OMemoryStream(inBuffer);
    else
      stream.setSource(inBuffer);

    stream.jump(offset);
View Full Code Here

    return valueSerializer.fromStream(stream.getAsByteArray(serializedValues[iIndex]));
  }

  private byte[] convertIntoNewSerializationFormat(byte[] stream) throws IOException {
    final OMemoryStream oldStream = new OMemoryStream(stream);

    try {
      int oldPageSize = oldStream.getAsInteger();

      ORecordId oldParentRid = new ORecordId().fromStream(oldStream.getAsByteArrayFixed(ORecordId.PERSISTENT_SIZE));
      ORecordId oldLeftRid = new ORecordId().fromStream(oldStream.getAsByteArrayFixed(ORecordId.PERSISTENT_SIZE));
      ORecordId oldRightRid = new ORecordId().fromStream(oldStream.getAsByteArrayFixed(ORecordId.PERSISTENT_SIZE));

      boolean oldColor = oldStream.getAsBoolean();
      int oldSize = oldStream.getAsInteger();

      if (oldSize > oldPageSize)
        throw new OConfigurationException("Loaded index with page size set to " + oldPageSize
            + " while the loaded was built with: " + oldSize);

      K[] oldKeys = (K[]) new Object[oldPageSize];
      for (int i = 0; i < oldSize; ++i) {
        oldKeys[i] = (K) ((OMVRBTreeMapProvider<K, V>) treeDataProvider).streamKeySerializer.fromStream(oldStream.getAsByteArray());
      }

      V[] oldValues = (V[]) new Object[oldPageSize];
      for (int i = 0; i < oldSize; ++i) {
        oldValues[i] = (V) ((OMVRBTreeMapProvider<K, V>) treeDataProvider).valueSerializer.fromStream(oldStream.getAsByteArray());
      }

      byte[] result;
      if (((OMVRBTreeMapProvider<K, V>) treeDataProvider).valueSerializer instanceof OBinarySerializer)
        result = convertNewSerializationFormatBinarySerializer(oldSize, oldPageSize, oldParentRid, oldLeftRid, oldRightRid,
            oldColor, oldKeys, oldValues);
      else
        result = convertNewSerializationFormatStreamSerializer(oldSize, oldPageSize, oldParentRid, oldLeftRid, oldRightRid,
            oldColor, oldKeys, oldValues);

      return result;

    } finally {
      oldStream.close();
    }
  }
View Full Code Here

    for (int i = 0; i < oldSize; i++) {
      keySerializer.serialize(oldKeys[i], outBuffer, offset);
      offset += keySerializer.getObjectSize(oldKeys[i]);
    }

    final OMemoryStream outStream = new OMemoryStream(outBuffer);
    try {
      outStream.jump(offset);

      for (int i = 0; i < oldSize; ++i)
        outStream.set(valueSerializer.toStream(oldValues[i]));

      return outStream.toByteArray();

    } finally {
      outStream.close();
    }
  }
View Full Code Here

  public OMVRBTreeMapProvider(final OStorage iStorage, final String iClusterName, final OBinarySerializer<K> iKeySerializer,
      final OStreamSerializer iValueSerializer) {
    super(new ORecordBytesLazy(), iStorage, iClusterName);
    ((ORecordBytesLazy) record).recycle(this);
    stream = new OMemoryStream();
    keySerializer = iKeySerializer;
    valueSerializer = iValueSerializer;
  }
View Full Code Here

    this.language = language;
    return this;
  }

  public OSerializableStream fromStream(byte[] iStream) throws OSerializationException {
    final OMemoryStream buffer = new OMemoryStream(iStream);
    language = buffer.getAsString();
    fromStream(buffer);
    return this;
  }
View Full Code Here

    fromStream(buffer);
    return this;
  }

  public byte[] toStream() throws OSerializationException {
    final OMemoryStream buffer = new OMemoryStream();
    buffer.setUtf8(language);
    return toStream(buffer);
  }
View Full Code Here

    return (ORecord) (record != null ? record.getRecord() : null);
  }

  public byte[] toStream() throws OSerializationException {
    try {
      final OMemoryStream stream = new OMemoryStream();
      stream.set(type);
      ((ORecordId) record.getIdentity()).toStream(stream);

      switch (type) {
      case CREATED:
      case UPDATED:
        stream.set(ORecordInternal.getRecordType(record.getRecord()));
        stream.set(record.getRecord().toStream());
        break;
      }

      return stream.toByteArray();

    } catch (Exception e) {
      throw new OSerializationException("Cannot serialize record operation", e);
    }
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.serialization.OMemoryStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.