Package uk.ac.open.kmi.smartproducts.sesame.sail.model

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.model.NativeValue


  public NativeValue getValue(int id)
    throws IOException
  {
    // Check value cache
    Integer cacheID = new Integer(id);
    NativeValue resultValue = valueCache.get(cacheID);

    if (resultValue == null) {
      // Value not in cache, fetch it from file
      byte[] data = dataStore.getData(id);
View Full Code Here


  {
    // Try to get the internal ID from the value itself
    boolean isOwnValue = isOwnValue(value);

    if (isOwnValue) {
      NativeValue nativeValue = (NativeValue)value;

      if (revisionIsCurrent(nativeValue)) {
        int id = nativeValue.getInternalID();

        if (id != NativeValue.UNKNOWN_ID) {
          return id;
        }
      }
    }

    // Check cache
    Integer cachedID = valueIDCache.get(value);

    if (cachedID != null) {
      int id = cachedID.intValue();

      if (isOwnValue) {
        // Store id in value for fast access in any consecutive calls
        ((NativeValue)value).setInternalID(id, revision);
      }

      return id;
    }

    // ID not cached, search in file
    byte[] data = value2data(value, false);

    if (data != null) {
      int id = dataStore.getID(data);

      if (id != NativeValue.UNKNOWN_ID) {
        if (isOwnValue) {
          // Store id in value for fast access in any consecutive calls
          ((NativeValue)value).setInternalID(id, revision);
        }
        else {
          // Store id in cache
          NativeValue nv = getNativeValue(value);
          nv.setInternalID(id, revision);
          valueIDCache.put(nv, new Integer(id));
        }
      }

      return id;
View Full Code Here

  {
    // Try to get the internal ID from the value itself
    boolean isOwnValue = isOwnValue(value);

    if (isOwnValue) {
      NativeValue nativeValue = (NativeValue)value;

      if (revisionIsCurrent(nativeValue)) {
        // Value's ID is still current
        int id = nativeValue.getInternalID();

        if (id != NativeValue.UNKNOWN_ID) {
          return id;
        }
      }
    }

    // ID not stored in value itself, try the ID cache
    Integer cachedID = valueIDCache.get(value);

    if (cachedID != null) {
      int id = cachedID.intValue();

      if (isOwnValue) {
        // Store id in value for fast access in any consecutive calls
        ((NativeValue)value).setInternalID(id, revision);
      }

      return id;
    }

    // Unable to get internal ID in a cheap way, just store it in the data
    // store which will handle duplicates
    byte[] valueData = value2data(value, true);

    int id = dataStore.storeData(valueData);

    NativeValue nv = isOwnValue ? (NativeValue)value : getNativeValue(value);

    // Store id in value for fast access in any consecutive calls
    nv.setInternalID(id, revision);

    // Update cache
    valueIDCache.put(nv, new Integer(id));

    return id;
View Full Code Here

TOP

Related Classes of uk.ac.open.kmi.smartproducts.sesame.sail.model.NativeValue

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.