예제 #1
0
 @Override
 public void load(
     String indexName,
     OBinarySerializer valueSerializer,
     boolean isAutomatic,
     OBinarySerializer keySerializer,
     OType[] keyTypes,
     boolean nullPointerSupport,
     int keySize,
     Map<String, String> engineProperties) {
   hashTable.load(indexName, keyTypes, nullPointerSupport);
   hashFunction.setValueSerializer(hashTable.getKeySerializer());
 }
예제 #2
0
  @Test
  public void testQuery() {
    create();
    for (int i = 0; i < ITERATIONS; ++i) {
      final int selectedClusterId =
          clusterIds[((int) (Math.abs(hashFunction.hashCode(i)) % clusterIds.length))];

      Iterable<ODocument> resultSet =
          database.command(new OCommandSQL("select from AutoShardingTest where id = ?")).execute(i);
      Assert.assertTrue(resultSet.iterator().hasNext());
      final ODocument sqlRecord = resultSet.iterator().next();
      Assert.assertEquals(sqlRecord.getIdentity().getClusterId(), selectedClusterId);
    }
  }
예제 #3
0
  @Override
  public void create(
      OBinarySerializer valueSerializer,
      boolean isAutomatic,
      OType[] keyTypes,
      boolean nullPointerSupport,
      OBinarySerializer keySerializer,
      int keySize,
      Set<String> clustersToIndex,
      Map<String, String> engineProperties,
      ODocument metadata) {
    hashFunction.setValueSerializer(keySerializer);

    hashTable.create(keySerializer, valueSerializer, keyTypes, nullPointerSupport);
  }
예제 #4
0
  private void create() {
    for (int i = 0; i < ITERATIONS; ++i) {
      final int selectedClusterId =
          clusterIds[((int) (Math.abs(hashFunction.hashCode(i)) % clusterIds.length))];

      ODocument sqlRecord =
          database
              .command(new OCommandSQL("insert into AutoShardingTest (id) values (" + i + ")"))
              .execute();
      Assert.assertEquals(sqlRecord.getIdentity().getClusterId(), selectedClusterId);

      ODocument apiRecord = new ODocument("AutoShardingTest").field("id", i).save();
      Assert.assertEquals(apiRecord.getIdentity().getClusterId(), selectedClusterId);
    }

    // TEST ALL CLUSTER HAVE RECORDS
    for (int clusterId : cls.getClusterIds()) {
      Assert.assertTrue(database.countClusterElements(clusterId) > 0);
    }
  }
예제 #5
0
  @BeforeMethod
  public void beforeMethod() throws Exception {
    super.beforeMethod();

    hashFunction.setValueSerializer(new OIntegerSerializer());

    if (database.getMetadata().getSchema().existsClass("AutoShardingTest"))
      database.getMetadata().getSchema().dropClass("AutoShardingTest");

    cls = database.getMetadata().getSchema().createClass("AutoShardingTest");
    cls.createProperty("id", OType.INTEGER);

    idx =
        cls.createIndex(
            "testAutoSharding",
            OClass.INDEX_TYPE.NOTUNIQUE.toString(),
            (OProgressListener) null,
            (ODocument) null,
            "AUTOSHARDING",
            new String[] {"id"});

    clusterIds = cls.getClusterIds();
  }