public void run(TriplesInputStream stream) throws IOException {
		while (true) {
			Triple next = stream.nextTriple();
			if (next == null) {
				if (currentSubject != null) {
					handleSubject(currentSubject, currentProps, currentLinks);
				}
				return;
			}

			String s = next.getSubject();

			// Try to url-decode the subject, errors allowed
			try {
				s = URLDecoder.decode(s, "utf8");
			} catch (IllegalArgumentException e) {

			}
			// And simplify the namespaces 
			s = URISimplifier.simplify(next.getSubject());


			if (!s.equals(currentSubject)) {
				/* New subject, handle the current one before accumulate */
				if (currentSubject != null) handleSubject(currentSubject, currentProps, currentLinks);
				currentSubject = s;
				currentProps.clear();
				currentLinks.clear();
			}
			if (next instanceof DataTriple) {
				DataTriple dt = (DataTriple)next;
				URISimplifier.simplify(dt);
				//				System.out.println("SIMPLIFIED TRIPLE --> " + dt.getSubject());
				currentProps.add(dt);
			} else {
				currentLinks.add((LinkTriple)next);
			}
			if (++processedTriples % 20000 == 0) {
				System.out.println("Processed " + processedTriples + " triples (current subject: " + currentSubject + ")");
				//				((MergedInputStream)stream).debug();
				//				break;
			}
		}

	}