/** * Closes the ValueStore, releasing any file references, etc. Once closed, the ValueStore can no longer be * used. * * @exception IOException * If an I/O error occurred. */ public void close() throws IOException { dataStore.close(); }
public static void main(String[] args) throws Exception { File dataDir = new File(args[0]); ValueStore valueStore = new ValueStore(dataDir); int maxID = valueStore.dataStore.getMaxID(); for (int id = 1; id <= maxID; id++) { byte[] data = valueStore.dataStore.getData(id); if (valueStore.isNamespaceData(data)) { String ns = valueStore.data2namespace(data); System.out.println("[" + id + "] " + ns); } else { Value value = valueStore.data2value(id, data); System.out.println("[" + id + "] " + value.toString()); } } } }
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; }
/** * Stores the supplied value and returns the ID that has been assigned to it. In case the data to store is * already present, the ID of this existing data is returned. * * @param data * The data to store, must not be <tt>null</tt>. * @return The ID that has been assigned to the value. * @exception IOException * If an I/O error occurred. */ public int storeData(byte[] data) throws IOException { assert data != null : "data must not be null"; int id = getID(data); if (id == -1) { // Data not stored yet, store it under a new ID. long offset = dataFile.storeData(data); id = idFile.storeOffset(offset); hashFile.storeID(getDataHash(data), id); } return id; }
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; }
public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println( "Usage: java org.eclipse.rdf4j.sesame.sailimpl.nativerdf.datastore.DataStore <data-dir> <file-prefix>"); return; } System.out.println("Dumping DataStore contents..."); File dataDir = new File(args[0]); DataStore dataStore = new DataStore(dataDir, args[1]); DataFile.DataIterator iter = dataStore.dataFile.iterator(); while (iter.hasNext()) { byte[] data = iter.next(); System.out.println(ByteArrayUtil.toHexString(data)); } } }
/** * Synchronizes any changes that are cached in memory to disk. * * @exception IOException * If an I/O error occurred. */ public void sync() throws IOException { dataStore.sync(); }
/** * Removes all values from the ValueStore. * * @exception IOException * If an I/O error occurred. */ public void clear() throws IOException { try { Lock writeLock = lockManager.getWriteLock(); try { dataStore.clear(); valueCache.clear(); valueIDCache.clear(); namespaceCache.clear(); namespaceIDCache.clear(); initBNodeParams(); setNewRevision(); } finally { writeLock.release(); } } catch (InterruptedException e) { IOException ioe = new IOException("Failed to acquire write lock"); ioe.initCause(e); throw ioe; } }
int hash = getDataHash(queryData); HashFile.IDIterator iter = hashFile.getIDIterator(hash); try {
int id = dataStore.storeData(valueData);
/** * Stores the supplied value and returns the ID that has been assigned to it. In case the data to store is * already present, the ID of this existing data is returned. * * @param data * The data to store, must not be <tt>null</tt>. * @return The ID that has been assigned to the value. * @exception IOException * If an I/O error occurred. */ public int storeData(byte[] data) throws IOException { assert data != null : "data must not be null"; int id = getID(data); if (id == -1) { // Data not stored yet, store it under a new ID. long offset = dataFile.storeData(data); id = idFile.storeOffset(offset); hashFile.storeID(getDataHash(data), id); } return id; }
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; }
public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println( "Usage: java org.eclipse.rdf4j.sesame.sailimpl.nativerdf.datastore.DataStore <data-dir> <file-prefix>"); return; } System.out.println("Dumping DataStore contents..."); File dataDir = new File(args[0]); DataStore dataStore = new DataStore(dataDir, args[1]); DataFile.DataIterator iter = dataStore.dataFile.iterator(); while (iter.hasNext()) { byte[] data = iter.next(); System.out.println(ByteArrayUtil.toHexString(data)); } } }
/** * Synchronizes any changes that are cached in memory to disk. * * @exception IOException * If an I/O error occurred. */ public void sync() throws IOException { dataStore.sync(); }
/** * Removes all values from the ValueStore. * * @exception IOException * If an I/O error occurred. */ public void clear() throws IOException { try { Lock writeLock = lockManager.getWriteLock(); try { dataStore.clear(); valueCache.clear(); valueIDCache.clear(); namespaceCache.clear(); namespaceIDCache.clear(); initBNodeParams(); setNewRevision(); } finally { writeLock.release(); } } catch (InterruptedException e) { IOException ioe = new IOException("Failed to acquire write lock"); ioe.initCause(e); throw ioe; } }
int hash = getDataHash(queryData); HashFile.IDIterator iter = hashFile.getIDIterator(hash); try {
int id = dataStore.storeData(valueData);
public static void main(String[] args) throws Exception { File dataDir = new File(args[0]); ValueStore valueStore = new ValueStore(dataDir); int maxID = valueStore.dataStore.getMaxID(); for (int id = 1; id <= maxID; id++) { byte[] data = valueStore.dataStore.getData(id); if (valueStore.isNamespaceData(data)) { String ns = valueStore.data2namespace(data); System.out.println("[" + id + "] " + ns); } else { Value value = valueStore.data2value(id, data); System.out.println("[" + id + "] " + value.toString()); } } } }