@Override public Status delete(String table, String key) { while (true) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); dictionary.remove(key); return Status.OK; } catch (OConcurrentModificationException cme) { continue; } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } } }
if (!db.getMetadata().getSchema().existsClass(CLASS)) { db.getMetadata().getSchema().createClass(CLASS);
public final void updateSchema() { if (db.isClosed()) { db.create(); } OSchema schema = db.getMetadata().getSchema(); for (String docType : DocumentTypes.getDocumentTypes()) { if (!schema.existsClass(docType)) { createDocType(schema, docType); } } if (!schema.existsClass("Signatures")) { createSignatureType(schema); } }
protected OSchemaHelper(ODatabaseDocument db) { this.db = db; this.schema = db.getMetadata().getSchema(); }
@Override public int addBlobCluster(final String iClusterName, final Object... iParameters) { int id; if (!existsCluster(iClusterName)) { id = addCluster(iClusterName, iParameters); } else { id = getClusterIdByName(iClusterName); } getMetadata().getSchema().addBlobCluster(id); return id; }
public OSchema getSchema() { return db.getMetadata().getSchema(); }
private OIndexManager getIndexManager() { return database.getMetadata().getIndexManager(); }
public OIndexManager call(ODatabaseDocumentInternal database) { return database.getMetadata().getIndexManager(); } });
/** * @return {@link OSchema} for current request */ public OSchema getSchema() { return getDatabase().getMetadata().getSchema(); }
private void fetchSchemaIfCan(ODatabaseDocumentInternal db) { if (_schema == null) { if (db != null && !db.isClosed()) { OMetadataInternal metadata = db.getMetadata(); _schema = metadata.getImmutableSchemaSnapshot(); } } }
protected OSchemaHelper(ODatabaseDocument db) { this.db = db; this.schema = db.getMetadata().getSchema(); }
@Override public Status insert(String table, String key, Map<String, ByteIterator> values) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODocument document = new ODocument(CLASS); for (Map.Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { document.field(entry.getKey(), entry.getValue()); } document.save(); final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); dictionary.put(key, document); return Status.OK; } catch (Exception e) { e.printStackTrace(); } return Status.ERROR; }
protected OIndexManager getIndexManager() { if(indexManager==null) { indexManager = getDatabase().getMetadata().getIndexManager(); } return indexManager; }
public OIndexManager call(ODatabaseDocumentInternal database) { return database.getMetadata().getIndexManager(); } });
private OSchema getSchema() { return database.getMetadata().getSchema(); }
@Override public Status update(String table, String key, Map<String, ByteIterator> values) { while (true) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); final ODocument document = dictionary.get(key); if (document != null) { for (Map.Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { document.field(entry.getKey(), entry.getValue()); } document.save(); return Status.OK; } } catch (OConcurrentModificationException cme) { continue; } catch (Exception e) { e.printStackTrace(); return Status.ERROR; } } }
public OSchema getSchema() { return getMetadata().getSchema(); }
@Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { try (ODatabaseDocumentTx db = databasePool.acquire()) { final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); final ODocument document = dictionary.get(key); if (document != null) { if (fields != null) { for (String field : fields) { result.put(field, new StringByteIterator((String) document.field(field))); } } else { for (String field : document.fieldNames()) { result.put(field, new StringByteIterator((String) document.field(field))); } } return Status.OK; } } catch (Exception e) { e.printStackTrace(); } return Status.ERROR; }
final ODictionary<ORecord> dictionary = db.getMetadata().getIndexManager().getDictionary(); final OIndexCursor entries = dictionary.getIndex().iterateEntriesMajor(startkey, true, true);
public void rebuildIndexes() { if (metadata.getIndexManager().autoRecreateIndexesAfterCrash()) { metadata.getIndexManager().recreateIndexes(); } }