private String getNamespace(int id) throws IOException { Integer cacheID = new Integer(id); String namespace = namespaceCache.get(cacheID); if (namespace == null) { byte[] namespaceData = dataStore.getData(id); namespace = data2namespace(namespaceData); namespaceCache.put(cacheID, namespace); } return namespace; }
private String getNamespace(int id) throws IOException { Integer cacheID = new Integer(id); String namespace = namespaceCache.get(cacheID); if (namespace == null) { byte[] namespaceData = dataStore.getData(id); namespace = data2namespace(namespaceData); namespaceCache.put(cacheID, namespace); } return namespace; }
private int getNamespaceID(String namespace, boolean create) throws IOException { Integer cacheID = namespaceIDCache.get(namespace); if (cacheID != null) { return cacheID.intValue(); } byte[] namespaceData = namespace.getBytes("UTF-8"); int id; if (create) { id = dataStore.storeData(namespaceData); } else { id = dataStore.getID(namespaceData); } if (id != -1) { namespaceIDCache.put(namespace, new Integer(id)); } return id; }
private int getNamespaceID(String namespace, boolean create) throws IOException { Integer cacheID = namespaceIDCache.get(namespace); if (cacheID != null) { return cacheID.intValue(); } byte[] namespaceData = namespace.getBytes("UTF-8"); int id; if (create) { id = dataStore.storeData(namespaceData); } else { id = dataStore.getID(namespaceData); } if (id != -1) { namespaceIDCache.put(namespace, new Integer(id)); } return id; }
/** * Gets the value for the specified ID. * * @param id * A value ID. * @return The value for the ID, or <tt>null</tt> no such value could be found. * @exception IOException * If an I/O error occurred. */ 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); if (data != null) { resultValue = data2value(id, data); // Store value in cache valueCache.put(cacheID, resultValue); } } return resultValue; }
/** * Gets the value for the specified ID. * * @param id * A value ID. * @return The value for the ID, or <tt>null</tt> no such value could be found. * @exception IOException * If an I/O error occurred. */ 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); if (data != null) { resultValue = data2value(id, data); // Store value in cache valueCache.put(cacheID, resultValue); } } return resultValue; }
valueIDCache.put(nv, new Integer(id));
valueIDCache.put(nv, new Integer(id));
valueIDCache.put(nv, new Integer(id));
valueIDCache.put(nv, new Integer(id));