use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class ORidBagTest method testAddRemoveSBTreeContainsValues.
public void testAddRemoveSBTreeContainsValues() {
ORidBag bag = new ORidBag();
bag.setAutoConvertToRecord(false);
bag.add(new ORecordId("#77:2"));
bag.add(new ORecordId("#77:2"));
bag.add(new ORecordId("#77:3"));
bag.add(new ORecordId("#77:4"));
bag.add(new ORecordId("#77:4"));
bag.add(new ORecordId("#77:4"));
bag.add(new ORecordId("#77:5"));
bag.add(new ORecordId("#77:6"));
assertEmbedded(bag.isEmbedded());
ODocument doc = new ODocument();
doc.field("ridbag", bag);
doc.save();
ORID rid = doc.getIdentity();
OStorage storage = database.getStorage();
database.close();
storage.close(true, false);
database = new ODatabaseDocumentTx(database.getURL());
database.open("admin", "admin");
doc = database.load(rid);
doc.setLazyLoad(false);
bag = doc.field("ridbag");
assertEmbedded(bag.isEmbedded());
bag.remove(new ORecordId("#77:1"));
bag.remove(new ORecordId("#77:2"));
bag.remove(new ORecordId("#77:2"));
bag.remove(new ORecordId("#77:4"));
bag.remove(new ORecordId("#77:6"));
final List<OIdentifiable> rids = new ArrayList<OIdentifiable>();
rids.add(new ORecordId("#77:3"));
rids.add(new ORecordId("#77:4"));
rids.add(new ORecordId("#77:4"));
rids.add(new ORecordId("#77:5"));
for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
assertTrue(rids.isEmpty());
for (OIdentifiable identifiable : bag) rids.add(identifiable);
doc = new ODocument();
ORidBag otherBag = new ORidBag();
for (OIdentifiable id : bag) otherBag.add(id);
assertEmbedded(otherBag.isEmbedded());
doc.field("ridbag", otherBag);
doc.save();
rid = doc.getIdentity();
doc = database.load(rid);
doc.setLazyLoad(false);
bag = doc.field("ridbag");
assertEmbedded(bag.isEmbedded());
for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
assertTrue(rids.isEmpty());
}
use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class ORidBagTest method testAddSBTreeAddInMemoryIterate.
public void testAddSBTreeAddInMemoryIterate() {
List<OIdentifiable> rids = new ArrayList<OIdentifiable>();
ORidBag bag = new ORidBag();
assertEmbedded(bag.isEmbedded());
bag.setAutoConvertToRecord(false);
bag.add(new ORecordId("#77:2"));
rids.add(new ORecordId("#77:2"));
bag.add(new ORecordId("#77:2"));
rids.add(new ORecordId("#77:2"));
bag.add(new ORecordId("#77:3"));
rids.add(new ORecordId("#77:3"));
bag.add(new ORecordId("#77:4"));
rids.add(new ORecordId("#77:4"));
bag.add(new ORecordId("#77:4"));
rids.add(new ORecordId("#77:4"));
assertEmbedded(bag.isEmbedded());
ODocument doc = new ODocument();
doc.field("ridbag", bag);
doc.save();
ORID rid = doc.getIdentity();
OStorage storage = database.getStorage();
database.close();
storage.close(true, false);
database = new ODatabaseDocumentTx(database.getURL());
database.open("admin", "admin");
doc = database.load(rid);
doc.setLazyLoad(false);
bag = doc.field("ridbag");
assertEmbedded(bag.isEmbedded());
bag.add(new ORecordId("#77:0"));
rids.add(new ORecordId("#77:0"));
bag.add(new ORecordId("#77:1"));
rids.add(new ORecordId("#77:1"));
bag.add(new ORecordId("#77:2"));
rids.add(new ORecordId("#77:2"));
bag.add(new ORecordId("#77:3"));
rids.add(new ORecordId("#77:3"));
bag.add(new ORecordId("#77:5"));
rids.add(new ORecordId("#77:5"));
bag.add(new ORecordId("#77:6"));
rids.add(new ORecordId("#77:6"));
assertEmbedded(bag.isEmbedded());
for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
assertTrue(rids.isEmpty());
for (OIdentifiable identifiable : bag) rids.add(identifiable);
doc = new ODocument();
final ORidBag otherBag = new ORidBag();
for (OIdentifiable id : bag) otherBag.add(id);
doc.field("ridbag", otherBag);
doc.save();
rid = doc.getIdentity();
doc = database.load(rid);
doc.setLazyLoad(false);
bag = doc.field("ridbag");
assertEmbedded(bag.isEmbedded());
for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
assertTrue(rids.isEmpty());
}
use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class OConsoleDatabaseApp method listProperties.
@ConsoleCommand(description = "Display the database properties")
public void listProperties() {
if (currentDatabase == null)
return;
final OStorage stg = currentDatabase.getStorage();
final OStorageConfiguration dbCfg = stg.getConfiguration();
message("\n\nDATABASE PROPERTIES");
if (dbCfg.getProperties() != null) {
final List<ODocument> resultSet = new ArrayList<ODocument>();
if (dbCfg.name != null)
resultSet.add(new ODocument().field("NAME", "Name").field("VALUE", dbCfg.name));
resultSet.add(new ODocument().field("NAME", "Version").field("VALUE", dbCfg.version));
resultSet.add(new ODocument().field("NAME", "Conflict-Strategy").field("VALUE", dbCfg.getConflictStrategy()));
resultSet.add(new ODocument().field("NAME", "Date-Format").field("VALUE", dbCfg.dateFormat));
resultSet.add(new ODocument().field("NAME", "Datetime-Format").field("VALUE", dbCfg.dateTimeFormat));
resultSet.add(new ODocument().field("NAME", "Timezone").field("VALUE", dbCfg.getTimeZone().getID()));
resultSet.add(new ODocument().field("NAME", "Locale-Country").field("VALUE", dbCfg.getLocaleCountry()));
resultSet.add(new ODocument().field("NAME", "Locale-Language").field("VALUE", dbCfg.getLocaleLanguage()));
resultSet.add(new ODocument().field("NAME", "Charset").field("VALUE", dbCfg.getCharset()));
resultSet.add(new ODocument().field("NAME", "Schema-RID").field("VALUE", dbCfg.schemaRecordId, OType.LINK));
resultSet.add(new ODocument().field("NAME", "Index-Manager-RID").field("VALUE", dbCfg.indexMgrRecordId, OType.LINK));
resultSet.add(new ODocument().field("NAME", "Dictionary-RID").field("VALUE", dbCfg.dictionaryRecordId, OType.LINK));
final OTableFormatter formatter = new OTableFormatter(this);
formatter.writeRecords(resultSet, -1);
message("\n");
if (!dbCfg.getProperties().isEmpty()) {
message("\n\nDATABASE CUSTOM PROPERTIES:");
final List<ODocument> dbResultSet = new ArrayList<ODocument>();
for (OStorageEntryConfiguration cfg : dbCfg.getProperties()) dbResultSet.add(new ODocument().field("NAME", cfg.name).field("VALUE", cfg.value));
final OTableFormatter dbFormatter = new OTableFormatter(this);
dbFormatter.writeRecords(dbResultSet, -1);
}
}
}
use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class LocalCreateBinaryDocumentSpeedTest method cycle.
@Override
@Test(enabled = false)
public void cycle() {
final OStorage storage = database.getStorage();
((OAbstractPaginatedStorage) storage).startGatheringPerformanceStatisticForCurrentThread();
record = new ORecordBytes(database, payload);
record.save();
if (data.getCyclesDone() == data.getCycles() - 1)
database.commit();
OSessionStoragePerformanceStatistic sessionStoragePerformanceStatistic = ((OAbstractPaginatedStorage) storage).completeGatheringPerformanceStatisticForCurrentThread();
System.out.println(sessionStoragePerformanceStatistic.toDocument().toJSON("prettyPrint"));
}
use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.
the class OConsoleDatabaseApp method info.
@ConsoleCommand(aliases = { "status" }, description = "Display information about the database", onlineHelp = "Console-Command-Info")
public void info() {
if (currentDatabaseName != null) {
message("\nCurrent database: " + currentDatabaseName + " (url=" + currentDatabase.getURL() + ")");
final OStorage stg = currentDatabase.getStorage();
if (stg instanceof OStorageRemote) {
listServers();
}
listProperties();
listClusters(null);
listClasses();
listIndexes();
}
}
Aggregations