Examples of LongQuadWritable


Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

      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

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

  // 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

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

  @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

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable


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

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

    assertEquals(2l, lqw.get(2));
    assertEquals(3l, lqw.get(3));
  }
 
  @Test public void test2() {
    LongQuadWritable lqw1 = new LongQuadWritable(0,1,2,3);
    LongQuadWritable lqw2 = new LongQuadWritable(0,1,2,3);
    LongQuadWritable lqw3 = new LongQuadWritable(0,-1,2,3);
    assertEquals(lqw1, lqw2);
    assertEquals(lqw2, lqw1);
    assertFalse(lqw1.equals(lqw3));
    assertFalse(lqw3.equals(lqw1));
  }
View Full Code Here

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

    assertFalse(lqw1.equals(lqw3));
    assertFalse(lqw3.equals(lqw1));
  }

  @Test public void test3() {
    LongQuadWritable lqw1 = new LongQuadWritable(0,1,2,3);
    LongQuadWritable lqw2 = new LongQuadWritable(0,1,2,3);
    assertEquals(0, lqw1.compareTo(lqw2));
  }
View Full Code Here

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

    LongQuadWritable lqw2 = new LongQuadWritable(0,1,2,3);
    assertEquals(0, lqw1.compareTo(lqw2));
  }

  @Test public void test3a() {
    LongQuadWritable lqw1 = new LongQuadWritable(0,1,2,3);
    LongQuadWritable lqw2 = new LongQuadWritable(0,1,2,3, null);
    assertEquals(lqw1, lqw2);
  }
View Full Code Here

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

    LongQuadWritable lqw2 = new LongQuadWritable(0,1,2,3, null);
    assertEquals(lqw1, lqw2);
  }

  @Test public void test3b() {
    LongQuadWritable lqw1 = new LongQuadWritable(0,1,2,3);
    LongQuadWritable lqw2 = new LongQuadWritable(0,1,2,3, "NON EXISTING");
    assertEquals(lqw1, lqw2);
  }
View Full Code Here

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

    LongQuadWritable lqw2 = new LongQuadWritable(0,1,2,3, "NON EXISTING");
    assertEquals(lqw1, lqw2);
  }

  @Test public void test3c() {
    LongQuadWritable lqw1 = new LongQuadWritable(0,1,2,3);
    LongQuadWritable lqw2 = new LongQuadWritable(0,1,2,3, "SPO");
    assertFalse(lqw1.equals(lqw2));
    assertEquals(-1, lqw1.compareTo(lqw2));
    assertEquals(1, lqw2.compareTo(lqw1));
  }
View Full Code Here

Examples of org.apache.jena.tdbloader4.io.LongQuadWritable

    assertEquals(-1, lqw1.compareTo(lqw2));
    assertEquals(1, lqw2.compareTo(lqw1));
  }

  @Test public void test4() {
    LongQuadWritable lqw1 = new LongQuadWritable(0,1,2,3);
    LongQuadWritable lqw2 = new LongQuadWritable(-0l,1,2,3);
    assertEquals(0, lqw1.compareTo(lqw2));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.