Examples of OMemoryOutputStream


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

      record.setDirty();
    }

    final long timer = OProfiler.getInstance().startChrono();

    final OMemoryOutputStream outStream = new OMemoryOutputStream();

    try {
      outStream.add(pageSize);

      outStream.addAsFixed(parentRid.toStream());
      outStream.addAsFixed(leftRid.toStream());
      outStream.addAsFixed(rightRid.toStream());

      outStream.add(color);
      outStream.add(size);

      for (int i = 0; i < size; ++i)
        serializedKeys[i] = outStream.add(serializeNewKey(i));

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

      outStream.flush();

      final byte[] buffer = outStream.getByteArray();

      inStream.setSource(buffer);

      record.fromStream(buffer);
      return buffer;
View Full Code Here

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

    record = new ORecordBytesLazy(this);

    keySerializer = iKeySerializer;
    valueSerializer = iValueSerializer;

    entryRecordBuffer = new OMemoryOutputStream(getPageSize() * 15);

    setListener(this);
  }
 
View Full Code Here

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

      // ALREADY IN STACK, RETURN EMPTY
      return new byte[] {};
    } else
      marshalledRecords.add(identityRecord);

    OMemoryOutputStream stream = entryRecordBuffer;

    try {
      stream.add(CURRENT_PROTOCOL_VERSION);

      if (root != null) {
        OMVRBTreeEntryPersistent<K, V> pRoot = (OMVRBTreeEntryPersistent<K, V>) root;
        if (pRoot.record.getIdentity().isNew()) {
          // FIRST TIME: SAVE IT
          pRoot.save();
        }

        stream.addAsFixed(pRoot.record.getIdentity().toStream());
      } else
        stream.addAsFixed(ORecordId.EMPTY_RECORD_ID_STREAM);

      stream.add(size);
      stream.add(lastPageSize);

      stream.add(keySerializer.getName());
      stream.add(valueSerializer.getName());

      record.fromStream(stream.getByteArray());
      return record.toStream();

    } catch (IOException e) {
      throw new OSerializationException("Error on marshalling RB+Tree", e);
    } finally {
View Full Code Here

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

    }
    return this;
  }

  public byte[] toStream() throws OSerializationException {
    final OMemoryOutputStream buffer = new OMemoryOutputStream();
    try {
      buffer.add(text);

      if (parameters == null || parameters.size() == 0)
        buffer.add(new byte[0]);
      else {
        final ODocument param = new ODocument(database);
        param.field("params", parameters);
        buffer.add(param.toStream());
      }

    } catch (IOException e) {
      throw new OSerializationException("Error while marshalling OCommandRequestTextAbstract impl", e);
    }

    return buffer.toByteArray();
  }
View Full Code Here

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

    return this;
  }

  @SuppressWarnings("unchecked")
  public byte[] toStream() throws OSerializationException {
    final OMemoryOutputStream buffer = new OMemoryOutputStream();
    try {
      buffer.add(text); // TEXT AS STRING
      buffer.add(limit); // LIMIT AS INTEGER
      buffer.addAsFixed(beginRange.toStream()); // THE RID WHERE TO BEGIN, OR -1:-1 to ignore it
      buffer.addAsFixed(endRange.toStream()); // THE RID WHERE TO END, OR -1:-1 to ignore it
      buffer.add(fetchPlan != null ? fetchPlan : ""); // FETCH PLAN IN FORM OF STRING (to know more goto:
                                                      // http://code.google.com/p/orient/wiki/FetchingStrategies)

      if (parameters == null || parameters.size() == 0)
        // NO PARAMETER, JUST SEND 0
        buffer.add(new byte[0]);
      else {
        final Map<Object, Object> newParams = new HashMap<Object, Object>(parameters);

        for (Entry<Object, Object> entry : newParams.entrySet()) {
          final Object value = entry.getValue();

          if (value instanceof Set<?> && ((Set<?>) value).iterator().next() instanceof ORecord<?>) {
            // CONVERT RECORDS AS RIDS
            final Set<ORID> newSet = new HashSet<ORID>();
            for (ORecord<?> rec : (Set<ORecord<?>>) value) {
              newSet.add(rec.getIdentity());
            }
            parameters.put(entry.getKey(), newSet);

          } else if (value instanceof List<?> && ((List<?>) value).get(0) instanceof ORecord<?>) {
            // CONVERT RECORDS AS RIDS
            final List<ORID> newList = new ArrayList<ORID>();
            for (ORecord<?> rec : (List<ORecord<?>>) value) {
              newList.add(rec.getIdentity());
            }
            parameters.put(entry.getKey(), newList);

          } else if (value instanceof Map<?, ?> && ((Map<?, ?>) value).values().iterator().next() instanceof ORecord<?>) {
            // CONVERT RECORDS AS RIDS
            final Map<Object, ORID> newMap = new HashMap<Object, ORID>();
            for (Entry<?, ORecord<?>> mapEntry : ((Map<?, ORecord<?>>) value).entrySet()) {
              newMap.put(mapEntry.getKey(), mapEntry.getValue().getIdentity());
            }
            parameters.put(entry.getKey(), newMap);
          }
        }

        // PARAMETERS FOUND, SEND THEM AS DOCUMENT ITSELF
        final ODocument param = new ODocument();
        param.field("params", parameters);
        buffer.add(param.toStream());
      }

    } catch (IOException e) {
      throw new OSerializationException("Error while marshalling OSQLQuery", e);
    }

    return buffer.toByteArray();
  }
View Full Code Here

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

    }
    return this;
  }

  public byte[] toStream() throws OSerializationException {
    final OMemoryOutputStream buffer = new OMemoryOutputStream();
    try {
      buffer.add(text); // TEXT AS STRING
      buffer.add(limit); // LIMIT AS INTEGER
      buffer.addAsFixed(beginRange.toStream()); // THE RID WHERE TO BEGIN, OR -1:-1 to ignore it
      buffer.addAsFixed(endRange.toStream()); // THE RID WHERE TO END, OR -1:-1 to ignore it
      buffer.add(fetchPlan != null ? fetchPlan : ""); // FETCH PLAN IN FORM OF STRING (to know more goto:
                                                      // http://code.google.com/p/orient/wiki/FetchingStrategies)

      if (parameters == null || parameters.size() == 0)
        // NO PARAMETER, JUST SEND 0
        buffer.add(new byte[0]);
      else {
        // PARAMETERS FOUND, SEND THEM AS DOCUMENT ITSELF
        final ODocument param = new ODocument();
        param.field("params", parameters);
        buffer.add(param.toStream());
      }

    } catch (IOException e) {
      throw new OSerializationException("Error while marshalling OSQLQuery", e);
    }

    return buffer.toByteArray();
  }
View Full Code Here

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

    } catch (IOException e) {
      e.printStackTrace();
    }
    System.out.println("Data Output Stream " + (System.currentTimeMillis() - time));
    time = System.currentTimeMillis();
    OMemoryOutputStream mou = new OMemoryOutputStream();
    try {

      for (int i = 0; i < 1000000; i++) {
        mou.add("adfsdfsdfadfsdfsdfadfsdfsdfadfsdfsdf");
        mou.add(32);
        mou.add(32l);
        mou.add((byte) 32);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }

    System.out.println("OMemoryOutputStream " + (System.currentTimeMillis() - time));

    System.out.println("" + s.toByteArray().length + " " + mou.toByteArray().length);

  }
View Full Code Here

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

    }
    return this;
  }

  public byte[] toStream() throws OSerializationException {
    final OMemoryOutputStream buffer = new OMemoryOutputStream();
    try {
      buffer.add(text); // TEXT AS STRING
      buffer.add(limit); // LIMIT AS INTEGER
      buffer.addAsFixed(beginRange.toStream()); // THE RID WHERE TO BEGIN, OR -1:-1 to ignore it
      buffer.addAsFixed(endRange.toStream()); // THE RID WHERE TO END, OR -1:-1 to ignore it
      buffer.add(fetchPlan != null ? fetchPlan : ""); // FETCH PLAN IN FORM OF STRING (to know more goto:
                                                      // http://code.google.com/p/orient/wiki/FetchingStrategies)

      if (parameters == null || parameters.size() == 0)
        // NO PARAMETER, JUST SEND 0
        buffer.add(new byte[0]);
      else {
        // PARAMETERS FOUND, SEND THEM AS DOCUMENT ITSELF
        final ODocument param = new ODocument();
        param.field("params", parameters);
        buffer.add(param.toStream());
      }

    } catch (IOException e) {
      throw new OSerializationException("Error while marshalling OSQLQuery", e);
    }

    return buffer.toByteArray();
  }
View Full Code Here

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

    record = new ORecordBytesLazy(this);

    keySerializer = iKeySerializer;
    valueSerializer = iValueSerializer;

    entryRecordBuffer = new OMemoryOutputStream(getPageSize() * 15);

    setListener(this);
  }
 
View Full Code Here

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

      // ALREADY IN STACK, RETURN EMPTY
      return new byte[] {};
    } else
      marshalledRecords.add(identityRecord);

    OMemoryOutputStream stream = entryRecordBuffer;

    try {
      stream.add(CURRENT_PROTOCOL_VERSION);

      if (root != null) {
        OMVRBTreeEntryPersistent<K, V> pRoot = (OMVRBTreeEntryPersistent<K, V>) root;
        if (pRoot.record.getIdentity().isNew()) {
          // FIRST TIME: SAVE IT
          pRoot.save();
        }

        stream.addAsFixed(pRoot.record.getIdentity().toStream());
      } else
        stream.addAsFixed(ORecordId.EMPTY_RECORD_ID_STREAM);

      stream.add(size);
      stream.add(lastPageSize);

      stream.add(keySerializer.getName());
      stream.add(valueSerializer.getName());

      record.fromStream(stream.getByteArray());
      return record.toStream();

    } catch (IOException e) {
      throw new OSerializationException("Error on marshalling RB+Tree", e);
    } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.