158159160161162163
class TupleSerializationFactory implements SerializationFactory<Tuple<Long>> { @Override public Iterator<Tuple<Long>> createDeserializer(InputStream in) { return new TupleInputStream(in, 3); } @Override public Sink<Tuple<Long>> createSerializer(OutputStream out) { return new TupleOutputStream(out); } @Override public long getEstimatedMemorySize(Tuple<Long> item) { throw new TDBLoader4Exception("Method not implemented.") ; }
166167168169170171172173174175176
class TupleComparator implements Comparator<Tuple<Long>> { @Override public int compare(Tuple<Long> t1, Tuple<Long> t2) { int size = t1.size(); if ( size != t2.size() ) throw new TDBLoader4Exception("Cannot compare tuple of different sizes.") ; for ( int i = 0; i < size; i++ ) { int result = t1.get(i).compareTo(t2.get(i)) ; if ( result != 0 ) { return result ; }
192193194195196197198199200
Iterator<Long> iter = tuple.iterator() ; while ( iter.hasNext() ) { try { out.writeLong( iter.next() ) ; } catch (IOException e) { new TDBLoader4Exception("Problems writing") ; } } }
202203204205206207208209
@Override public void flush() { try { out.flush() ; } catch (IOException e) { new TDBLoader4Exception("Problems flushing") ; } }
211212213214215216217218
@Override public void close() { try { out.close() ; } catch (IOException e) { new TDBLoader4Exception("Problems closing") ; } }
255256257258259260261262263264265
long p = in.readLong() ; long o = in.readLong() ; long g = in.readLong() ; return Tuple.create(s, p, o, g) ; } else { throw new TDBLoader4Exception("Unsupported size.") ; } } catch (IOException e) { return null ; } }
264265266267268269270
} } @Override public void remove() { throw new TDBLoader4Exception("Method not implemented.") ; }
272273274275276277278279
@Override public void close() { try { in.close() ; } catch (IOException e) { new TDBLoader4Exception("Problems closing") ; } }
8990919293949596
out.getBuffer().length(); OutputLangUtils.output(out, quad, null, null); try { return out.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new TDBLoader4Exception(e); } }