Package com.moesol.geoserver.sync.core

Examples of com.moesol.geoserver.sync.core.IdAndValueSha1s


    m_sha1 = MessageDigest.getInstance("SHA-1");
    m_data = new ArrayList<IdAndValueSha1s>();
    for (int i = 0; i < n; i++) {
      String v = "data" + i;
      Sha1Value aSha1 = new Sha1Value(m_sha1.digest(v.getBytes("UTF-8")));
      m_data.add(new IdAndValueSha1s(aSha1, aSha1));
    }
    m_grouper = new Sha1JsonLevelGrouper(VersionFeatures.VERSION1, m_data);
//    System.out.println(m_data);
  }
View Full Code Here


  public void testGroupForLevelOneWithOneChange() throws NoSuchAlgorithmException, UnsupportedEncodingException {
    m_grouper.groupForLevel(1);
    Sha1SyncJson json = m_grouper.getJson();
   
    Sha1Value aSha1 = new Sha1Value(m_sha1.digest("extra".getBytes("UTF-8")));
    m_data.add(new IdAndValueSha1s(aSha1, aSha1));
    m_grouper = new Sha1JsonLevelGrouper(VersionFeatures.VERSION1, m_data);
    m_grouper.groupForLevel(1);
    Sha1SyncJson json2 = m_grouper.getJson();

    for (int i = 0; i < json.h.size(); i++) {
View Full Code Here

  }
 
  public void testGroupSixWithCollision() {
    Sha1Value fake = new Sha1Value("");
    m_grouper = new Sha1JsonLevelGrouper(VersionFeatures.VERSION2, Arrays.asList(
        new IdAndValueSha1s(new Sha1Value("1091a76e395ba65b6a35f7ae5110eb02e0661137"), fake),
        new IdAndValueSha1s(new Sha1Value("4ef9968cef6257d719b5a8ee58037c7570270c0f"), fake),
        new IdAndValueSha1s(new Sha1Value("ba58d6e118850afcb9833c646cd5930c9edb33c3"), fake),
        new IdAndValueSha1s(new Sha1Value("c313c8e098040f0b8e7b233f589b809e80f14fc5"), fake),
        new IdAndValueSha1s(new Sha1Value("cf300c55b1d127f07005fe22d6ec12fa2501f089"), fake),
        new IdAndValueSha1s(new Sha1Value("cf64472f30a25d72b259b220cc484cab72b8fa4b"), fake)));
    m_grouper.groupForLevel(1);
    Sha1SyncJson json = m_grouper.getJson();
   
    assertEquals(1, json.level());
    assertEquals(5, json.hashes().size());
View Full Code Here

  }

  public void sha1One(Feature feature) {
    Sha1Value idSha1 = m_featureSha1Sync.computeIdSha1(feature);
    Sha1Value valueSha1 = m_featureSha1Sync.computeValueSha1(feature);
    m_featureSha1s.add(new IdAndValueSha1s(idSha1, valueSha1));
  }
View Full Code Here

    Feature feature = (Feature) object;
   
    Sha1Value idSha1 = m_featureSha1Evaluator.computeIdSha1(feature);
    Sha1Value valueSha1 = m_featureSha1Evaluator.computeValueSha1(feature);
    IdAndValueSha1s pair = new IdAndValueSha1s(idSha1, valueSha1);
    m_featureSha1s.add(pair);
    Sha1Value prefixSha1 = versionFeatures.getBucketPrefixSha1(pair);
   
    Sha1SyncJson remoteSha1Sync = REMOTE_SHA1_SYNC.get();
    if (remoteSha1Sync.max() > 1) {
View Full Code Here

    GroupPosition prefix = new GroupPosition(level);
    long maxCurrentGroup = 0;
   
    // Hmm, this could be written in terms of NavigableSet operations...
    if (m_sortedFeatureSha1s.size() > 0) {
      IdAndValueSha1s zero = m_sortedFeatureSha1s.get(0);
      prefix.setFromSha1(versionFeatures.getBucketPrefixSha1(zero));
      hashOne(zero.getValueSha1());
      maxCurrentGroup++;
    }
    for (int i = 1; i < m_sortedFeatureSha1s.size(); i++) {
      IdAndValueSha1s sha1 = m_sortedFeatureSha1s.get(i);

      if (versionFeatures.getBucketPrefixSha1(sha1).isPrefixMatch(prefix)) {
        hashOne(sha1.getValueSha1());
        maxCurrentGroup++;
        continue;
      }
     
      if (i < m_sortedFeatureSha1s.size()) {
        doGroupCompleted(prefix, new Sha1Value(m_sha1.digest()), maxCurrentGroup);
        updateMaxInGroup(maxCurrentGroup);
        maxCurrentGroup = 0;
        hashOne(sha1.getValueSha1());
        maxCurrentGroup++;
        prefix.setFromSha1(versionFeatures.getBucketPrefixSha1(sha1));
      }
    }
    if (m_sortedFeatureSha1s.size() > 0) {
View Full Code Here

TOP

Related Classes of com.moesol.geoserver.sync.core.IdAndValueSha1s

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.