Search in sources :

Example 1 with Index

use of com.google.firestore.admin.v1.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;
}
Also used : BinProfileSubSensor(org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor) EncodingException(org.n52.svalbard.encode.exception.EncodingException) Index(ucar.ma2.Index) ProfileSubSensor(org.n52.sos.netcdf.data.subsensor.ProfileSubSensor) SubSensor(org.n52.sos.netcdf.data.subsensor.SubSensor) BinProfileSubSensor(org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor) ArrayDouble(ucar.ma2.ArrayDouble) ProfileSubSensor(org.n52.sos.netcdf.data.subsensor.ProfileSubSensor) BinProfileSubSensor(org.n52.sos.netcdf.data.subsensor.BinProfileSubSensor)

Example 2 with Index

use of com.google.firestore.admin.v1.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;
}
Also used : Array(ucar.ma2.Array) StaticLocationDataset(org.n52.sos.netcdf.data.dataset.StaticLocationDataset) EncodingException(org.n52.svalbard.encode.exception.EncodingException) Index(ucar.ma2.Index)

Example 3 with Index

use of com.google.firestore.admin.v1.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();
}
Also used : Scanner(java.util.Scanner) FirestoreAdminBlockingStub(com.google.firestore.admin.v1beta1.FirestoreAdminGrpc.FirestoreAdminBlockingStub) ArrayList(java.util.ArrayList) Index(com.google.firestore.admin.v1beta1.Index) Menu(org.roguewave.grpc.util.gfx.Menu) GRPCFirebaseAdminClientFactory(org.roguewave.grpc.util.GRPCFirebaseAdminClientFactory) CreateIndexRequest(com.google.firestore.admin.v1beta1.CreateIndexRequest) IndexField(com.google.firestore.admin.v1beta1.IndexField)

Example 4 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method createIndexExceptionTest.

@Test
public void createIndexExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockFirestoreAdmin.addException(exception);
    try {
        CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
        Index index = Index.newBuilder().build();
        client.createIndexAsync(parent, index).get();
        Assert.fail("No exception raised");
    } catch (ExecutionException e) {
        Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
        InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
        Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Index(com.google.firestore.admin.v1.Index) CollectionGroupName(com.google.firestore.admin.v1.CollectionGroupName) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 5 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method deleteIndexTest.

@Test
public void deleteIndexTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
    client.deleteIndex(name);
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteIndexRequest actualRequest = ((DeleteIndexRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : IndexName(com.google.firestore.admin.v1.IndexName) Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteIndexRequest(com.google.firestore.admin.v1.DeleteIndexRequest) Test(org.junit.Test)

Aggregations

Index (ucar.ma2.Index)30 Array (ucar.ma2.Array)20 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)15 AbstractMessage (com.google.protobuf.AbstractMessage)11 Attribute (ucar.nc2.Attribute)11 WritableRaster (java.awt.image.WritableRaster)10 IOException (java.io.IOException)10 ArrayFloat (ucar.ma2.ArrayFloat)10 Index (com.google.firestore.admin.v1.Index)9 Dimension (ucar.nc2.Dimension)9 NetcdfFileWriteable (ucar.nc2.NetcdfFileWriteable)8 Variable (ucar.nc2.Variable)8 ArrayDouble (ucar.ma2.ArrayDouble)7 NetcdfFile (ucar.nc2.NetcdfFile)7 SampleModel (java.awt.image.SampleModel)5 Index (com.google.datastore.admin.v1.Index)4 IndexName (com.google.firestore.admin.v1.IndexName)4 Operation (com.google.longrunning.Operation)4 File (java.io.File)4