use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class SchemaTransaction method removeSchema.
protected void removeSchema(SchemaElement schema) {
LOG.debug("SchemaTransaction remove {} by id '{}'", schema.type(), schema.id());
LockUtil.Locks locks = new LockUtil.Locks(this.graphName());
try {
locks.lockWrites(LockUtil.hugeType2Group(schema.type()), schema.id());
this.beforeWrite();
this.indexTx.updateNameIndex(schema, true);
BackendEntry e = this.serializer.writeId(schema.type(), schema.id());
this.doRemove(e);
this.afterWrite();
} finally {
locks.unlock();
}
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class RocksDBStore method query.
@Override
public Iterator<BackendEntry> query(Query query) {
Lock readLock = this.storeLock.readLock();
readLock.lock();
try {
this.checkOpened();
HugeType tableType = RocksDBTable.tableType(query);
RocksDBTable table;
RocksDBSessions.Session session;
if (query.olap()) {
table = this.table(this.olapTableName(tableType));
session = this.session(HugeType.OLAP);
} else {
table = this.table(tableType);
session = this.session(tableType);
}
Iterator<BackendEntry> entries = table.query(session, query);
// Merge olap results as needed
Set<Id> olapPks = query.olapPks();
if (this.isGraphStore && !olapPks.isEmpty()) {
List<Iterator<BackendEntry>> iterators = new ArrayList<>();
for (Id pk : olapPks) {
Query q = query.copy();
table = this.table(this.olapTableName(pk));
iterators.add(table.query(this.session(HugeType.OLAP), q));
}
entries = new MergeIterator<>(entries, iterators, BackendEntry::mergeable);
}
return entries;
} finally {
readLock.unlock();
}
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class BackendMutationTest method testAppendAndAppendEntryWithSameId.
@Test
public void testAppendAndAppendEntryWithSameId() {
BackendMutation mutation = new BackendMutation();
BackendEntry entry1 = constructBackendEntry("1", "name", "marko");
BackendEntry entry2 = constructBackendEntry("1", "city", "Wuhan");
mutation.add(entry1, Action.APPEND);
mutation.add(entry2, Action.APPEND);
Assert.assertEquals(2, get(mutation, "1").size());
Assert.assertEquals(Action.APPEND, get(mutation, "1").get(0).action());
Assert.assertEquals(Action.APPEND, get(mutation, "1").get(1).action());
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class BackendMutationTest method testEliminateAndAppendEntryWithSameEntry.
@Test
public void testEliminateAndAppendEntryWithSameEntry() {
BackendMutation mutation = new BackendMutation();
BackendEntry entry1 = constructBackendEntry("1", "name", "marko");
BackendEntry entry2 = constructBackendEntry("1", "name", "marko");
mutation.add(entry1, Action.ELIMINATE);
mutation.add(entry2, Action.APPEND);
Assert.assertEquals(1, get(mutation, "1").size());
Assert.assertEquals(Action.APPEND, get(mutation, "1").get(0).action());
}
use of com.baidu.hugegraph.backend.store.BackendEntry in project incubator-hugegraph by apache.
the class BackendMutationTest method testAppendAndEliminateEntryWithSameId.
@Test
public void testAppendAndEliminateEntryWithSameId() {
BackendMutation mutation = new BackendMutation();
BackendEntry entry1 = constructBackendEntry("1", "name", "marko");
BackendEntry entry2 = constructBackendEntry("1", "city", "Wuhan");
mutation.add(entry1, Action.APPEND);
mutation.add(entry2, Action.ELIMINATE);
Assert.assertEquals(2, get(mutation, "1").size());
Assert.assertEquals(Action.APPEND, get(mutation, "1").get(0).action());
Assert.assertEquals(Action.ELIMINATE, get(mutation, "1").get(1).action());
}
Aggregations