The use of the BigInteger class in the SimpleFeature will cause an error:
Exception in thread "main" java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
at org.apache.accumulo.core.data.Value.(Value.java:86)
at org.apache.accumulo.core.data.Value.(Value.java:57)
at mil.nga.giat.geowave.accumulo.util.AccumuloUtils.buildMutations(AccumuloUtils.java:477)
at mil.nga.giat.geowave.accumulo.util.AccumuloUtils.write(AccumuloUtils.java:385)
at mil.nga.giat.geowave.accumulo.AccumuloDataStore.ingestInternal(AccumuloDataStore.java:260)
at mil.nga.giat.geowave.accumulo.AccumuloDataStore.ingest(AccumuloDataStore.java:197)
at mil.nga.giat.geowave.accumulo.AccumuloDataStore.ingest(AccumuloDataStore.java:167)
at mil.nga.giat.geowave.examples.ingest.BigIntIngest.main(BigIntIngest.java:135)
Here is the example code I built to prove this:
package mil.nga.giat.geowave.examples.ingest;
import java.math.BigInteger;
import java.net.URLDecoder;
import java.util.Random;
import org.geotools.feature.AttributeTypeBuilder;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import mil.nga.giat.geowave.accumulo.AccumuloDataStore;
import mil.nga.giat.geowave.accumulo.BasicAccumuloOperations;
import mil.nga.giat.geowave.accumulo.metadata.AccumuloAdapterStore;
import mil.nga.giat.geowave.accumulo.metadata.AccumuloDataStatisticsStore;
import mil.nga.giat.geowave.accumulo.metadata.AccumuloIndexStore;
import mil.nga.giat.geowave.store.GeometryUtils;
import mil.nga.giat.geowave.store.index.Index;
import mil.nga.giat.geowave.store.index.IndexType;
import mil.nga.giat.geowave.vector.adapter.FeatureDataAdapter;
public class BigIntIngest {
public static void showUse(String m){
StringBuffer sb = new StringBuffer();
String path = BigIntIngest.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path);
sb.append(m + "\n");
sb.append("usage: java -cp " + decodedPath);
sb.append(" " + BigIntIngest.class.getCanonicalName() + " \\\n");
sb.append("\t-z zookeeper \\\n");
sb.append("\t-i instance \\\n");
sb.append("\t-u username \\\n");
sb.append("\t-p password \\\n");
sb.append("\t-n namespace\n");
System.out.println(sb.toString());
} // end showUse
public static void main(String[] args) throws Exception{
String zookeepers = null;
String instance = null;
String username = null;
String password = null;
String namespace = null;
// zookeepers instance user password namespace
for(int x = 0; x < args.length; x++){
if(args[x].equals("-z")){
zookeepers = args[x+1];
} else if(args[x].equals("-i")){
instance = args[x+1];
} else if(args[x].equals("-u")){
username = args[x+1];
} else if(args[x].equals("-p")){
password = args[x+1];
} else if(args[x].equals("-n")){
namespace = args[x+1];
}
}
if(zookeepers == null ||
instance == null ||
username == null ||
password == null ||
namespace == null){
showUse("Need to make sure all values are set.");
System.exit(-1);
}
BasicAccumuloOperations bao = new BasicAccumuloOperations(
zookeepers,
instance,
username,
password,
namespace);
AccumuloDataStore ads = new AccumuloDataStore(
new AccumuloIndexStore(bao),
new AccumuloAdapterStore(bao),
new AccumuloDataStatisticsStore(bao),
bao);
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
AttributeTypeBuilder ab = new AttributeTypeBuilder();
builder.setName("BigIntPoint");
// geo
builder.add(ab.binding(Geometry.class).nillable(false).buildDescriptor("geometry"));
// long
builder.add(ab.binding(Long.class).nillable(false).buildDescriptor("timestamp"));
// bigint
builder.add(ab.binding(BigInteger.class).nillable(true).buildDescriptor("bigint"));
SimpleFeatureType point = builder.buildFeatureType();
SimpleFeatureBuilder sfBuilder = new SimpleFeatureBuilder(point);
FeatureDataAdapter adapter = new FeatureDataAdapter(point);
Index index = IndexType.SPATIAL_VECTOR.createDefaultIndex();
int featureId = 0;
double minX = -180.0;
double maxX = 180.0;
double minY = -90.0;
double maxY = 90.0;
String bigStr = "1";
Random r = new Random(System.currentTimeMillis());
for(int x = 0; x < 30; x++){
Long l = new Long(System.currentTimeMillis());
double f1 = r.nextFloat();
double f2 = r.nextFloat();
double lon = f1 * (maxX - minX) + minX;
double lat = f2 * (maxY - minY) + minY;
Point p = GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(lon, lat));
int i = r.nextInt(10);
bigStr += i;
BigInteger bi = new BigInteger(bigStr);
System.out.println(featureId + "\t" +
l.toString() +
" " +
bi.toString());
sfBuilder.set("geometry", p);
sfBuilder.set("timestamp", l);
sfBuilder.set("bigint", bi);
SimpleFeature sf = sfBuilder.buildFeature(featureId + "-" + l.toString() + "-" + bi.toString());
featureId++;
ads.ingest(adapter, index, sf);
}
} // end main
} // end BigIntIngest
The use of the BigInteger class in the SimpleFeature will cause an error:
Exception in thread "main" java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
at org.apache.accumulo.core.data.Value.(Value.java:86)
at org.apache.accumulo.core.data.Value.(Value.java:57)
at mil.nga.giat.geowave.accumulo.util.AccumuloUtils.buildMutations(AccumuloUtils.java:477)
at mil.nga.giat.geowave.accumulo.util.AccumuloUtils.write(AccumuloUtils.java:385)
at mil.nga.giat.geowave.accumulo.AccumuloDataStore.ingestInternal(AccumuloDataStore.java:260)
at mil.nga.giat.geowave.accumulo.AccumuloDataStore.ingest(AccumuloDataStore.java:197)
at mil.nga.giat.geowave.accumulo.AccumuloDataStore.ingest(AccumuloDataStore.java:167)
at mil.nga.giat.geowave.examples.ingest.BigIntIngest.main(BigIntIngest.java:135)
Here is the example code I built to prove this:
package mil.nga.giat.geowave.examples.ingest;
import java.math.BigInteger;
import java.net.URLDecoder;
import java.util.Random;
import org.geotools.feature.AttributeTypeBuilder;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import mil.nga.giat.geowave.accumulo.AccumuloDataStore;
import mil.nga.giat.geowave.accumulo.BasicAccumuloOperations;
import mil.nga.giat.geowave.accumulo.metadata.AccumuloAdapterStore;
import mil.nga.giat.geowave.accumulo.metadata.AccumuloDataStatisticsStore;
import mil.nga.giat.geowave.accumulo.metadata.AccumuloIndexStore;
import mil.nga.giat.geowave.store.GeometryUtils;
import mil.nga.giat.geowave.store.index.Index;
import mil.nga.giat.geowave.store.index.IndexType;
import mil.nga.giat.geowave.vector.adapter.FeatureDataAdapter;
public class BigIntIngest {
} // end BigIntIngest