use of com.google.firestore.admin.v1beta1.Index in project SOS by 52North.
the class AbstractNetcdfEncoder method populateHeightDepthArray.
private Double populateHeightDepthArray(AbstractSensorDataset sensorDataset, Array heightDephtArray, Variable v) throws EncodingException {
Index index = heightDephtArray.getIndex();
int indexCounter = 0;
Double consistentBinHeight = null;
for (SubSensor subSensor : sensorDataset.getSubSensors()) {
if (subSensor instanceof ProfileSubSensor) {
index.setDim(0, indexCounter++);
heightDephtArray.setDouble(index, checkValue(v, ((ProfileSubSensor) subSensor).getHeight()));
// check for consistent bin size
if (subSensor instanceof BinProfileSubSensor) {
double binHeight = checkValue(v, ((BinProfileSubSensor) subSensor).getBinHeight());
if (consistentBinHeight == null) {
consistentBinHeight = binHeight;
} else if (consistentBinHeight != getNetcdfHelper().getFillValue() && consistentBinHeight != binHeight) {
// mark bin height as inconsistent
consistentBinHeight = getNetcdfHelper().getFillValue();
}
}
} else {
throw new EncodingException("Non-profile subsensors not supported.");
}
}
return consistentBinHeight;
}
use of com.google.firestore.admin.v1beta1.Index in project SOS by 52North.
the class AbstractNetcdfEncoder method getLatitudeArray.
protected Array getLatitudeArray(AbstractSensorDataset sensorDataset) throws EncodingException {
if (sensorDataset instanceof StaticLocationDataset) {
StaticLocationDataset locationDataset = (StaticLocationDataset) sensorDataset;
if (locationDataset.getLat() != null) {
Array array = getArray();
initArrayWithFillValue(array, getNetcdfHelper().getFillValue());
Index index = array.getIndex();
index.set(0);
array.setDouble(index, locationDataset.getLat());
}
} else {
// TODO support varying lat
throw new EncodingException("Varying lat are not yet supported.");
}
return null;
}
use of com.google.firestore.admin.v1beta1.Index in project grpc-gcp-java by GoogleCloudPlatform.
the class DrawIndex method drawIndex.
public void drawIndex(Index index) {
System.out.println("Index Name: " + index.getName() + "\nIndex State: " + index.getState());
List<IndexField> indexFieldList = index.getFieldsList();
for (IndexField field : indexFieldList) {
System.out.println(" Field: " + field.getFieldPath() + " Mode: " + field.getMode().toString());
}
}
use of com.google.firestore.admin.v1beta1.Index in project grpc-gcp-java by GoogleCloudPlatform.
the class CreateIndex method createIndexCall.
public void createIndexCall() {
System.out.println(":: Creating New Index ::");
FirestoreAdminBlockingStub blockingStub = new GRPCFirebaseAdminClientFactory().createFirebaseAdminClient().getBlockingStub();
String indexField = "initial";
String indexMode = "initial";
Scanner sc = new Scanner(System.in);
ArrayList<IndexField> allIndexes = new ArrayList<>();
while (!indexField.matches("DONE")) {
System.out.print("Index Field Name: ");
indexField = sc.next();
if (!indexField.matches("DONE")) {
System.out.print("Mode (*ASCENDING*/DESCENDING - DONE to finish): ");
indexMode = sc.next();
if ((!indexMode.matches("ASCENDING")) && (!indexMode.matches("DESCENDING"))) {
System.out.println("Not Recognized, setting to default ASCENDING");
indexMode = "ASCENDING";
}
IndexField iff = IndexField.newBuilder().setFieldPath(indexField).setMode((indexMode.matches("ASCENDING") ? IndexField.Mode.ASCENDING : IndexField.Mode.DESCENDING)).build();
allIndexes.add(iff);
}
}
Index newIndex = Index.newBuilder().setCollectionId("GrpcTestData").addAllFields(allIndexes).build();
CreateIndexRequest createIndexRequest = CreateIndexRequest.newBuilder().setParent("projects/firestoretestclient/databases/(default)").setIndex(newIndex).build();
try {
blockingStub.createIndex(createIndexRequest);
} catch (Exception e) {
System.out.println("Error during call: " + e.getMessage() + e.getCause());
}
System.out.println("Successfully created new index!");
Menu menu = new Menu();
menu.draw();
}
use of com.google.firestore.admin.v1beta1.Index in project grpc-gcp-java by GoogleCloudPlatform.
the class DeleteIndex method deleteIndexCall.
public void deleteIndexCall() {
System.out.println("\n :: Deleting an Index :: \n");
FirestoreAdminBlockingStub blockingStub = new GRPCFirebaseAdminClientFactory().createFirebaseAdminClient().getBlockingStub();
Scanner sc = new Scanner(System.in);
System.out.print("Enter Index Name: ");
String indexName = "projects/firestoretestclient/databases/(default)/indexes/" + sc.next();
DeleteIndexRequest deleteIndexRequest = DeleteIndexRequest.newBuilder().setName(indexName).build();
try {
blockingStub.deleteIndex(deleteIndexRequest);
} catch (Exception e) {
System.out.println("Error during call: " + e.getMessage() + e.getCause());
return;
}
System.out.println("Successfully deleted index " + indexName);
Menu menu = new Menu();
menu.draw();
}
Aggregations