Esempio n. 1
0
    @SuppressWarnings("unchecked")
    @Override
    protected void getAsync(UserTObject object, Object key, FutureWithCallback<Object> future) {
        if (object.getSharedVersion_objectfabric().getUnion() instanceof Record) {
            long record = getOrFetchRecord(object.getSharedVersion_objectfabric());

            if (Record.isStored(record)) {
                BTree tree = BTree.load(getRecordManager(), record, false);
                _writer.write(key);
                byte[] data = new byte[_writer.getOffset()];
                PlatformAdapter.arraycopy(_writer.getBuffer(), 0, data, 0, data.length);
                long id = tree.fetch(data);

                if (id != 0) {
                    data = getRecordManager().fetch(id);
                    Object value = _reader.read(data);

                    _reader.readVersions();

                    Version version = _reader.getOrCreateVersion(object);
                    TKeyedEntry entry = new TKeyedEntry(key, TKeyed.hash(key), value, false);

                    if (Debug.ENABLED)
                        Debug.assertion(value != TKeyedEntry.REMOVAL);

                    ((LazyMapVersion) version).putEntry(key, entry, true, true);
                    _reader.importVersions();
                    future.set(value);
                    return;
                }
            }
        }

        future.set(null);
    }
Esempio n. 2
0
  final void readTKeyedRead() {
    boolean fullyReadDone = false;

    if (interrupted()) fullyReadDone = resumeBoolean();

    if (!fullyReadDone) {
      if (!canReadBoolean()) {
        interruptBoolean(false);
        return;
      }

      boolean fullyRead = readBoolean();

      for (int i = 0; i < _versions.length; i++)
        ((TKeyedRead) _versions[i]).setFullyRead(fullyRead);

      if (fullyRead) return;
    }

    for (; ; ) {
      Object key = readObject();

      if (interrupted()) {
        interruptBoolean(true);
        return;
      }

      if (key == null) break;

      if (key instanceof TObject[]) {
        TObject[] objects = (TObject[]) key;

        for (int i = 0; i < _versions.length; i++) {
          TKeyedEntry entry = new TKeyedEntry(objects[i], TKeyed.hash(objects[i]), null);
          ((TKeyedRead) _versions[i]).putEntry(entry, true, true, true);
        }
      } else {
        for (int i = 0; i < _versions.length; i++) {
          TKeyedEntry entry = new TKeyedEntry(key, TKeyed.hash(key), null);
          ((TKeyedRead) _versions[i]).putEntry(entry, true, true, true);
        }
      }
    }
  }
Esempio n. 3
0
  private final boolean visitTKeyed() {
    boolean clearHasBeenRead = false;
    boolean keyHasBeenRead = false;
    boolean cleared = false;
    Object key = null;

    if (interrupted()) {
      clearHasBeenRead = resumeBoolean();
      keyHasBeenRead = resumeBoolean();
      cleared = resumeBoolean();
      key = resume();
    }

    if (!clearHasBeenRead) {
      if (!canReadBoolean()) {
        interrupt(null);
        interruptBoolean(cleared);
        interruptBoolean(false);
        interruptBoolean(false);
        return false;
      }

      cleared = readBoolean();
    }

    for (; ; ) {
      if (!keyHasBeenRead) {
        key = readObject();

        if (interrupted()) {
          interrupt(key);
          interruptBoolean(cleared);
          interruptBoolean(false);
          interruptBoolean(true);
          return false;
        }

        if (key == null) break;
      }

      Object value = readObject();

      if (interrupted()) {
        interrupt(key);
        interruptBoolean(cleared);
        interruptBoolean(true);
        interruptBoolean(true);
        return false;
      }

      for (int i = 0; i < _versions.length; i++) {
        Object key_, value_;

        if (key instanceof TObject[]) key_ = ((TObject[]) key)[i];
        else key_ = key;

        if (value instanceof TObject[]) value_ = ((TObject[]) value)[i];
        else value_ = value;

        TKeyedEntry entry = new TKeyedEntry(key_, TKeyed.hash(key_), value_);
        ((TKeyedBase2) _versions[i]).putEntry(entry, true, false, true);
      }

      keyHasBeenRead = false;
    }

    return cleared;
  }