Package org.apache.jena.tdbloader4

Examples of org.apache.jena.tdbloader4.StatsDriver


    @Override
    public void close() {
        try {
            out.close() ;
        } catch (IOException e) {
            new TDBLoader4Exception("Problems closing") ;
        }
    }
View Full Code Here


                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 ;
        }
    }
View Full Code Here

        }
    }

    @Override
    public void remove() {
        throw new TDBLoader4Exception("Method not implemented.") ;
    }
View Full Code Here

    @Override
    public void close() {
        try {
            in.close() ;
        } catch (IOException e) {
            new TDBLoader4Exception("Problems closing") ;
        }       
    }
View Full Code Here

        out.getBuffer().length();
        OutputLangUtils.output(out, quad, null, null);
        try {
            return out.toString().getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new TDBLoader4Exception(e);
        }
    }
View Full Code Here

       
        Tool second = new SecondDriver(configuration);
        status = second.run(new String[] { args[0], args[1] + OUTPUT_PATH_POSTFIX_2 });
        if (status != 0){ return status ;}

        Tool third = new ThirdDriver(configuration);
        status = third.run(new String[] { args[1] + OUTPUT_PATH_POSTFIX_2, args[1] + OUTPUT_PATH_POSTFIX_3 });
        if (status != 0){ return status ;}

        Tool fourth = new FourthDriver(configuration);
        status = fourth.run(new String[] { args[1] + OUTPUT_PATH_POSTFIX_3, args[1] + OUTPUT_PATH_POSTFIX_4 });
        if (status != 0){ return status ;}
View Full Code Here

      InputSplit split = splits.get(i);
      log.debug("Sampling {} split", split);
      RecordReader<K, V> reader = inf.createRecordReader(split, samplingContext);
      reader.initialize(split, samplingContext);
      while ( reader.nextKeyValue() ) {
        LongQuadWritable currentKey = (LongQuadWritable)reader.getCurrentKey() ;
        // TODO: why do we need to do that? Why on earth we have -1 in subject, predicate or object position???
        if ( ( currentKey.get(0) > 0 ) && ( currentKey.get(1) > 0 ) && ( currentKey.get(2) > 0 ) ) {
          LongQuadWritable key = new LongQuadWritable(currentKey.get(0), currentKey.get(1), currentKey.get(2), currentKey.get(3));
          log.debug("Sampled {}", key);
          samples.add((K)key);
          ++records;
          if ( records >= (i + 1) * samplesPerSplit ) {
            log.debug("Records is {} and (i + 1) * samplesPerSplit is {}", records, (i + 1) * samplesPerSplit);
 
View Full Code Here

  // by construction, we know if our keytype
  @SuppressWarnings("unchecked")
  // is memcmp-able and uses the trie
  public int getPartition(K key, V value, int numPartitions) {
    LongQuadWritable quad = (LongQuadWritable)key;
    String indexName = quad.getIndexName();
    int indexOffset = ( numReduceTasks / 9 ) * LongQuadWritable.getIndexOffset(indexName) ;
    int indexPartition = partitions.get(indexName).findPartition(key);
    int partition = indexPartition + indexOffset;
    if ( log.isDebugEnabled() ) {
      log.debug("indexName = {}", indexName);
View Full Code Here

  @SuppressWarnings("unchecked")
  private static <K> K[] reshuffleSamples(K[] samples, String indexName, RawComparator<K> comparator, int numPartitions) {
    ArrayList<K> shuffledSamples = new ArrayList<K>(samples.length);
    for (K sample : samples) {
      if ( sample instanceof LongQuadWritable ) {
        LongQuadWritable q = (LongQuadWritable)sample;
       
        if ( (( q.get(3) != -1L ) && (indexName.length() == 4)) || (( q.get(3) == -1L ) && (indexName.length() == 3)) ) {
          LongQuadWritable shuffledQuad = null;
          if ( indexName.equals("GSPO") ) shuffledQuad = new LongQuadWritable(q.get(3), q.get(0), q.get(1), q.get(2));
          else if ( indexName.equals("GPOS") ) shuffledQuad = new LongQuadWritable(q.get(3), q.get(1), q.get(2), q.get(0));
          else if ( indexName.equals("GOSP") ) shuffledQuad = new LongQuadWritable(q.get(3), q.get(2), q.get(0), q.get(1));
          else if ( indexName.equals("SPOG") ) shuffledQuad = new LongQuadWritable(q.get(0), q.get(1), q.get(2), q.get(3));
          else if ( indexName.equals("POSG") ) shuffledQuad = new LongQuadWritable(q.get(1), q.get(2), q.get(0), q.get(3));
          else if ( indexName.equals("OSPG") ) shuffledQuad = new LongQuadWritable(q.get(2), q.get(0), q.get(1), q.get(3));
          else if ( indexName.equals("SPO") ) shuffledQuad = new LongQuadWritable(q.get(0), q.get(1), q.get(2), -1L);
          else if ( indexName.equals("POS") ) shuffledQuad = new LongQuadWritable(q.get(1), q.get(2), q.get(0), -1L);
          else if ( indexName.equals("OSP") ) shuffledQuad = new LongQuadWritable(q.get(2), q.get(0), q.get(1), -1L);
          shuffledSamples.add((K)shuffledQuad);
        }
       
      }
    }

    // This is to ensure we always have the same amount of split points
    int size = shuffledSamples.size();
    if ( size < numPartitions ) {
      log.debug("Found only {} samples for {} partitions...", shuffledSamples.size(), numPartitions);
      for (int i = 0; i < numPartitions - size; i++) {
        long id = 100L * (i + 1);
        K key = (K)new LongQuadWritable (id, id, id, indexName.length() == 3 ? -1L : id );
        log.debug("Added fake sample: {}", key);
        shuffledSamples.add(key);
      }
    }

View Full Code Here


public class TestLongQuadWritable {

  @Test public void test1() {
    LongQuadWritable lqw = new LongQuadWritable(0,1,2,3);
    assertEquals(0l, lqw.get(0));
    assertEquals(1l, lqw.get(1));
    assertEquals(2l, lqw.get(2));
    assertEquals(3l, lqw.get(3));
  }
View Full Code Here

TOP

Related Classes of org.apache.jena.tdbloader4.StatsDriver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.