我不是用javascript操作的。我是用java驱动操作的。
BSONObject options=new BasicBSONObject();
options.put("Compressed", true);
BasicBSONObject shardingKey = new BasicBSONObject();
shardingKey.put("a", 1);
shardingKey.put("b", 1);
options.put("ShardingKey", shardingKey);
String mainName="demo";
options.put("IsMainCL", true);
SequoiaDBUtils.createC(dbName, mainName, options);
List bList=new ArrayList();
bList.add(new Integer[]{0,500});
bList.add(new Integer[]{500,3000});
bList.add(new Integer[]{3000,-1});
List aList=new ArrayList();
aList.add(new Integer[]{0,10000});
aList.add(new Integer[]{10000,100000});
aList.add(new Integer[]{100000,1000000});
aList.add(new Integer[]{1000000,10000000});
aList.add(new Integer[]{10000000,999999999});
for(int i=0;i
for(int j=0;j
String cName="demo"+"_"+"A"+(i+1)+"B"+(j+1);
options=new BasicBSONObject();
options.put("Compressed", true);
options.put("IsMainCL", false);
SequoiaDBUtils.createC(dbName, cName, options);
Integer[] aCounts = aList.get(i);
Integer[] bCounts = bList.get(j);
System.out.println("aCounts"+aCounts[0]+"-"+aCounts[1]);
System.out.println("bCounts"+bCounts[0]+"-"+bCounts[1]);
BSONObject attachOptions=new BasicBSONObject();
BSONObject lowBoundOptions=new BasicBSONObject();
lowBoundOptions.put("b", bCounts[0]);
lowBoundOptions.put("a", aCounts[0]);
BSONObject upBoundOptions=new BasicBSONObject();
if(bCounts[1]!=-1){
upBoundOptions.put("b", bCounts[1]);
}
if(aCounts[1]!=-1){
upBoundOptions.put("a", aCounts[1]);
}
attachOptions.put("LowBound", lowBoundOptions);
if(aCounts[1]!=-1 || bCounts[1]!=-1){
attachOptions.put("UpBound", upBoundOptions);
}
SequoiaDBUtils.attachC(dbName, mainName, dbName+"."+cName, attachOptions);
}
}
在循环中,第二次执行attachCL操作时出错