<commit_before>#include "storage/write/node_batch.h"

#include "storage/id/edge_id.h"
#include "storage/id/node_property_id.h"

namespace GraphDB {

NodeBatch::NodeBatch(BasicIterator* const iter, bool events):
	iterator_(iter),
	events_(events) { }

uint32_t NodeBatch::getCurrent() {
	return this->iterator_->getCurrent();
}

void NodeBatch::create() {
	EdgeId edge(0, 1, EdgeDirection::Outbound, this->getCurrent());

	this->set<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::INSERT, edge);
}

void NodeBatch::discard() {
	EdgeId edge(0, 1, EdgeDirection::Outbound, this->getCurrent());

	this->remove<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::REMOVE, edge);

	edge.typeId = 2;

	this->set<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::INSERT, edge);
}

void NodeBatch::connectTo(uint32_t toId, uint16_t typeId) {
	EdgeId edge(this->getCurrent(), typeId, EdgeDirection::Outbound, toId);

	this->set<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::INSERT, edge);

	edge.direction = EdgeDirection::Inbound;

	this->set<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::INSERT, edge);
}

void NodeBatch::disconnectFrom(uint32_t toId, uint16_t typeId) {
	EdgeId edge(this->getCurrent(), typeId, EdgeDirection::Outbound, toId);

	this->remove<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::REMOVE, edge);

	edge.direction = EdgeDirection::Inbound;

	this->remove<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::REMOVE, edge);
}

void NodeBatch::setProperty(uint16_t propertyId, const PropertyValue& value) {
	this->set<NodePropertyId>(
		NodePropertyId(this->getCurrent(), propertyId),
		value
	);
}

void NodeBatch::removeProperty(uint16_t propertyId) {
	this->remove<NodePropertyId>(
		NodePropertyId(this->getCurrent(), propertyId)
	);
}
<commit_msg>Fixed inbound edge generation in NodeBatch * fromId and nodeId were not switched which made ordered queries for all inbound edges of a node impossible<commit_after>#include "storage/write/node_batch.h"

#include "storage/id/edge_id.h"
#include "storage/id/node_property_id.h"

namespace GraphDB {

NodeBatch::NodeBatch(BasicIterator* const iter, bool events):
	iterator_(iter),
	events_(events) { }

uint32_t NodeBatch::getCurrent() {
	return this->iterator_->getCurrent();
}

void NodeBatch::create() {
	EdgeId edge(0, 1, EdgeDirection::Outbound, this->getCurrent());

	this->set<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::INSERT, edge);
}

void NodeBatch::discard() {
	EdgeId edge(0, 1, EdgeDirection::Outbound, this->getCurrent());

	this->remove<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::REMOVE, edge);

	edge.typeId = 2;

	this->set<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::INSERT, edge);
}

void NodeBatch::connectTo(uint32_t toId, uint16_t typeId) {
	EdgeId edge(this->getCurrent(), typeId, EdgeDirection::Outbound, toId);

	this->set<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::INSERT, edge);

	edge.fromId    = toId;
	edge.direction = EdgeDirection::Inbound;
	edge.nodeId    = this->getCurrent();

	this->set<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::INSERT, edge);
}

void NodeBatch::disconnectFrom(uint32_t toId, uint16_t typeId) {
	EdgeId edge(this->getCurrent(), typeId, EdgeDirection::Outbound, toId);

	this->remove<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::REMOVE, edge);

	edge.fromId    = toId;
	edge.direction = EdgeDirection::Inbound;
	edge.nodeId    = this->getCurrent();

	this->remove<EdgeId>(edge);
	this->addEvent(EdgeStreamEventType::REMOVE, edge);
}

void NodeBatch::setProperty(uint16_t propertyId, const PropertyValue& value) {
	this->set<NodePropertyId>(
		NodePropertyId(this->getCurrent(), propertyId),
		value
	);
}

void NodeBatch::removeProperty(uint16_t propertyId) {
	this->remove<NodePropertyId>(
		NodePropertyId(this->getCurrent(), propertyId)
	);
}

{'fraction_non_alphanumeric': 0.15358539765319426, 'fraction_numerical': 0.009908735332464147, 'mean_word_length': 7.07578947368421, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3374793', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1287, 'n_words': 223}