Examples of ORecordId


Examples of com.orientechnologies.orient.core.id.ORecordId

  public void insertWithWildcards() {
    database.open("admin", "admin");

    ODocument doc = (ODocument) database.command(
        new OCommandSQL("insert into Profile (name, surname, salary, location, dummy) values (?,?,?,?,?)")).execute("Marc",
        "Smith", 120.0, new ORecordId(13, 3), "hooray");

    Assert.assertTrue(doc != null);
    Assert.assertEquals(doc.field("name"), "Marc");
    Assert.assertEquals(doc.field("surname"), "Smith");
    Assert.assertEquals(((Number) doc.field("salary")).floatValue(), 120.0f);
    Assert.assertEquals(doc.field("location", OType.LINK), new ORecordId(13, 3));
    Assert.assertEquals(doc.field("dummy"), "hooray");

    database.close();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

      cluster.lock();

    try {
      final OClusterPositionIterator iterator = cluster.absoluteIterator(iBeginRange, iEndRange);

      final ORecordId rid = new ORecordId(cluster.getId());
      final ODatabaseRecord database = ioRecord.getDatabase();

      // BROWSE ALL THE RECORDS
      while (iterator.hasNext()) {
        positionInPhyCluster = iterator.next();
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

  private void commitEntry(final OTransaction iTx, final OTransactionRecordEntry txEntry, final boolean iUseLog) throws IOException {

    if (txEntry.status != OTransactionRecordEntry.DELETED && !txEntry.getRecord().isDirty())
      return;

    final ORecordId rid = (ORecordId) txEntry.getRecord().getIdentity();

    final OCluster cluster = txEntry.clusterName != null ? storage.getClusterByName(txEntry.clusterName) : storage
        .getClusterById(rid.clusterId);

    if (cluster.getName().equals(OStorage.CLUSTER_INDEX_NAME))
      // AVOID TO COMMIT INDEX STUFF
      return;

    if (!(cluster instanceof OClusterLocal))
      // ONLY LOCAL CLUSTER ARE INVOLVED IN TX
      return;

    if (txEntry.getRecord() instanceof OTxListener)
      ((OTxListener) txEntry.getRecord()).onEvent(txEntry, OTxListener.EVENT.BEFORE_COMMIT);

    switch (txEntry.status) {
    case OTransactionRecordEntry.LOADED:
      break;

    case OTransactionRecordEntry.CREATED: {
      // CHECK 2 TIMES TO ASSURE THAT IT'S A CREATE OR AN UPDATE BASED ON RECURSIVE TO-STREAM METHOD
      byte[] stream = txEntry.getRecord().toStream();

      if (rid.isNew()) {
        if (iTx.getDatabase().callbackHooks(ORecordHook.TYPE.BEFORE_CREATE, txEntry.getRecord()))
          // RECORD CHANGED: RE-STREAM IT
          stream = txEntry.getRecord().toStream();

        rid.clusterId = cluster.getId();
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

            read(values[index++]));
        currentCluster = phyCluster;
      } else if (clusterType.equals("l"))
        // LOGICAL CLUSTER
        currentCluster = new OStorageLogicalClusterConfiguration(clusterName, clusterId, Integer.parseInt(read(values[index++])),
            new ORecordId(values[index++]));
      else
        // MEMORY CLUSTER
        currentCluster = new OStorageMemoryClusterConfiguration(clusterName, clusterId);

      // MAKE ROOMS, EVENTUALLY FILLING EMPTIES ENTRIES
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

    if (iValue == null)
      buffer.append("null");

    else if (iValue instanceof ORecordId) {
      final ORecordId rid = (ORecordId) iValue;
      buffer.append('\"');
      rid.toString(buffer);
      buffer.append('\"');

    } else if (iValue instanceof ORecord<?>) {
      final ORecord<?> linked = (ORecord<?>) iValue;
      if (linked.getIdentity().isValid()) {
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

    return this;
  }

  public ORecordAbstract<?> setIdentity(final int iClusterId, final long iClusterPosition) {
    if (_recordId == null || _recordId == ORecordId.EMPTY_RECORD_ID)
      _recordId = new ORecordId(iClusterId, iClusterPosition);
    else {
      _recordId.clusterId = iClusterId;
      _recordId.clusterPosition = iClusterPosition;
    }
    return this;
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

    return _size;
  }

  protected void setup() {
    if (_recordId == null)
      _recordId = new ORecordId();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

          fieldValue = fields[i + 1].trim();
          fieldValueAsString = fieldValue.length() >= 2 ? fieldValue.substring(1, fieldValue.length() - 1) : fieldValue;

          // RECORD ATTRIBUTES
          if (fieldName.equals(ATTRIBUTE_ID))
            iRecord.setIdentity(new ORecordId(fieldValueAsString));

          else if (fieldName.equals(ATTRIBUTE_VERSION))
            iRecord.setVersion(Integer.parseInt(fieldValue));

          else if (fieldName.equals(ATTRIBUTE_TYPE)) {
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

      case LINK:
        final int pos = iFieldValueAsString.indexOf('@');
        if (pos > -1)
          // CREATE DOCUMENT
          return new ODocument(iRecord.getDatabase(), iFieldValueAsString.substring(1, pos), new ORecordId(
              iFieldValueAsString.substring(pos + 1)));
        else
          // CREATE SIMPLE RID
          return new ORecordId(iFieldValueAsString.substring(1));

      case EMBEDDED:
        return fromString(iRecord.getDatabase(), iFieldValueAsString);

      case DATE:
View Full Code Here

Examples of com.orientechnologies.orient.core.id.ORecordId

  public void queryWithPagination() {
    database.open("admin", "admin");

    final OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("select from Profile LIMIT 3");

    ORID last = new ORecordId();

    for (List<ODocument> resultset = database.query(query); !resultset.isEmpty(); resultset = query.execute()) {
      Assert.assertTrue(resultset.size() <= 3);

      for (ODocument d : resultset)
        Assert.assertTrue(d.getIdentity().getClusterId() >= last.getClusterId()
            && d.getIdentity().getClusterPosition() > last.getClusterPosition());

      last = resultset.get(resultset.size() - 1).getIdentity();
    }

    database.close();
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.