use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.
the class MockReplicationSource method sendSequence.
/**
* Sends a replication sequence containing dummy data to the destination.
*/
public void sendSequence() {
// Initialise the replication stream.
ReplicationState state = new ReplicationState();
Map<String, Object> metaData = new HashMap<String, Object>(1);
metaData.put(ReplicationState.META_DATA_KEY, state);
changeSink.initialize(metaData);
// allowed. We'll only send a single record for simplicity.
if (state.getSequenceNumber() > 0) {
// We'll do a create action on the first replication pass, and modify subsequently.
ChangeAction action;
if (state.getSequenceNumber() == 1) {
action = ChangeAction.Create;
} else {
action = ChangeAction.Modify;
}
// Create a change record which data derived from the
// replication sequence number itself.
ChangeContainer change = new ChangeContainer(new NodeContainer(new Node(new CommonEntityData(10, (int) state.getSequenceNumber(), new Date(state.getSequenceNumber() * 1000), new OsmUser(11, "test"), state.getSequenceNumber() * 2), state.getSequenceNumber() * 3, state.getSequenceNumber() * 4)), action);
// Send the record downstream.
changeSink.process(change);
}
state.setTimestamp(new Date(state.getSequenceNumber() * 1000));
changeSink.complete();
}
use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.
the class ApidbWriter method flushNodes.
/**
* Flushes nodes to the database. If complete is false, this will only write nodes until the
* remaining node count is less than the multi-row insert statement row count. If complete is
* true, all remaining rows will be written using single row insert statements.
*
* @param complete If true, all data will be written to the database. If false, some data may be
* left until more data is available.
*/
private void flushNodes(boolean complete) {
while (nodeBuffer.size() >= INSERT_BULK_ROW_COUNT_NODE) {
int prmIndex;
List<Node> processedNodes;
processedNodes = new ArrayList<Node>(INSERT_BULK_ROW_COUNT_NODE);
prmIndex = 1;
for (int i = 0; i < INSERT_BULK_ROW_COUNT_NODE; i++) {
Node node;
node = nodeBuffer.remove(0);
processedNodes.add(node);
populateNodeParameters(bulkNodeStatement, prmIndex, node);
prmIndex += INSERT_PRM_COUNT_NODE;
transactionSizeCount++;
}
try {
bulkNodeStatement.executeUpdate();
if (transactionSizeCount % TRANSACTION_SIZE == 0) {
dbCtx.commit();
}
} catch (SQLException e) {
throw new OsmosisRuntimeException("Unable to bulk insert nodes into the database.", e);
}
for (Node node : processedNodes) {
addNodeTags(node);
}
}
if (complete) {
while (nodeBuffer.size() > 0) {
Node node;
node = nodeBuffer.remove(0);
populateNodeParameters(singleNodeStatement, 1, node);
try {
singleNodeStatement.executeUpdate();
} catch (SQLException e) {
throw new OsmosisRuntimeException("Unable to insert a node into the database.", e);
}
addNodeTags(node);
}
}
dbCtx.commit();
}
use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.
the class ApidbWriter method process.
/**
* {@inheritDoc}
*/
public void process(NodeContainer nodeContainer) {
Node node;
long nodeId;
node = nodeContainer.getEntity();
nodeId = node.getId();
if (nodeId >= maxNodeId) {
maxNodeId = nodeId + 1;
}
if (nodeId < minNodeId) {
minNodeId = nodeId;
}
nodeBuffer.add(node);
flushNodes(false);
}
use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.
the class DatasetDriver method process.
/**
* {@inheritDoc}
*/
@Override
public void process(Dataset dataset) {
try (DatasetContext dsCtx = dataset.createReader()) {
EntityManager<Node> nodeManager = dsCtx.getNodeManager();
OsmUser user;
Node node;
// Create the user for edits to be performed under. This is an existing user with an
// updated name.
user = new OsmUser(10, "user10b");
// Modify node 1 to add a new tag.
node = nodeManager.getEntity(1).getWriteableInstance();
node.setUser(user);
node.getTags().add(new Tag("change", "new tag"));
nodeManager.modifyEntity(node);
// Delete node 6.
nodeManager.removeEntity(6);
// Add node 7 using the NONE user.
node = new Node(new CommonEntityData(7, 16, buildDate("2008-01-02 18:19:20"), OsmUser.NONE, 93), -11, -12);
node.getTags().addAll(Arrays.asList(new Tag[] { new Tag("created_by", "Me7"), new Tag("change", "new node") }));
nodeManager.addEntity(node);
dsCtx.complete();
}
}
use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.
the class CopyFilesetBuilder method process.
/**
* {@inheritDoc}
*/
public void process(NodeContainer nodeContainer) {
Node node;
node = nodeContainer.getEntity();
nodeWriter.writeField(node.getId());
nodeWriter.writeField(node.getVersion());
nodeWriter.writeField(node.getUser().getId());
nodeWriter.writeField(node.getTimestamp());
nodeWriter.writeField(node.getChangesetId());
nodeWriter.writeField(buildTags(node));
nodeWriter.writeField(pointBuilder.createPoint(node.getLatitude(), node.getLongitude()));
nodeWriter.endRecord();
if (enableBboxBuilder || enableLinestringBuilder) {
wayGeometryBuilder.addNodeLocation(node);
}
}
Aggregations