Search in sources :

Example 6 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method createIndexExceptionTest2.

@Test
public void createIndexExceptionTest2() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockFirestoreAdmin.addException(exception);
    try {
        String parent = "parent-995424086";
        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) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 7 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listIndexesTest.

@Test
public void listIndexesTest() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.firestore.admin.v1.Index) CollectionGroupName(com.google.firestore.admin.v1.CollectionGroupName) ListIndexesRequest(com.google.firestore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Example 8 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listIndexesTest2.

@Test
public void listIndexesTest2() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.firestore.admin.v1.Index) ListIndexesRequest(com.google.firestore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Example 9 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index in project s1tbx by senbox-org.

the class NetCDFWriter method writeBandRasterData.

/**
 * {@inheritDoc}
 */
public void writeBandRasterData(final Band sourceBand, final int regionX, final int regionY, final int regionWidth, final int regionHeight, final ProductData regionData, ProgressMonitor pm) throws IOException {
    final int[] origin = new int[2];
    origin[1] = regionX;
    origin[0] = regionY;
    try {
        final ArrayDouble dataTemp = new ArrayDouble.D2(regionHeight, regionWidth);
        final Index index = dataTemp.getIndex();
        int i = 0;
        for (int y = 0; y < regionHeight; ++y) {
            for (int x = 0; x < regionWidth; ++x) {
                index.set(y, x);
                dataTemp.set(index, regionData.getElemDoubleAt(i));
                ++i;
            }
        }
        netCDFWriteable.write(sourceBand.getName(), origin, dataTemp);
        pm.worked(1);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}
Also used : ArrayDouble(ucar.ma2.ArrayDouble) Index(ucar.ma2.Index) IOException(java.io.IOException) InvalidRangeException(ucar.ma2.InvalidRangeException)

Example 10 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Index in project ncWMS by Unidata.

the class CdmUtils method readTimeseries.

public static List<Float> readTimeseries(NetcdfDataset nc, GridDatatype grid, HorizontalGrid horizGrid, List<Integer> tIndices, int zIndex, HorizontalPosition xy) throws IOException {
    GridCoordinates gridCoords = horizGrid.findNearestGridPoint(xy);
    if (gridCoords == null) {
        // a list of nulls
        return nullList(tIndices.size());
    }
    int i = gridCoords.getCoordinateValue(0);
    int j = gridCoords.getCoordinateValue(1);
    int firstTIndex = tIndices.get(0);
    int lastTIndex = tIndices.get(tIndices.size() - 1);
    RangesList rangesList = new RangesList(grid);
    rangesList.setTRange(firstTIndex, lastTIndex);
    rangesList.setZRange(zIndex, zIndex);
    rangesList.setYRange(j, j);
    rangesList.setXRange(i, i);
    // We read data for the whole time range.  This may mean grabbing
    // data we don't need.
    // TODO: use a datareadingstrategy here to read point-by-point for
    // local files?
    DataChunk dataChunk = DataChunk.readDataChunk(grid.getVariable(), rangesList);
    // Copy the data to the required array, discarding the points we
    // don't need
    List<Float> tsData = new ArrayList<Float>(tIndices.size());
    Index index = dataChunk.getIndex();
    index.set(new int[index.getRank()]);
    for (int tIndex : tIndices) {
        int tIndexOffset = tIndex - firstTIndex;
        // This will happen if the layer has no t axis
        if (tIndexOffset < 0)
            tIndexOffset = 0;
        index.setDim(rangesList.getTAxisIndex(), tIndexOffset);
        // Read the data from the chunk, applying enhancement if necessary
        float val = dataChunk.readFloatValue(index);
        // Replace missing values with nulls
        tsData.add(Float.isNaN(val) ? null : val);
    }
    return tsData;
}
Also used : GridCoordinates(org.opengis.coverage.grid.GridCoordinates) ArrayList(java.util.ArrayList) Index(ucar.ma2.Index) LatLonPoint(ucar.unidata.geoloc.LatLonPoint)

Aggregations

Index (ucar.ma2.Index)30 ArrayList (java.util.ArrayList)21 Array (ucar.ma2.Array)20 Test (org.junit.Test)12 IOException (java.io.IOException)11 Attribute (ucar.nc2.Attribute)11 AbstractMessage (com.google.protobuf.AbstractMessage)10 WritableRaster (java.awt.image.WritableRaster)10 ArrayFloat (ucar.ma2.ArrayFloat)10 Index (com.google.firestore.admin.v1.Index)9 Dimension (ucar.nc2.Dimension)9 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Tinyint)8 NetcdfFileWriteable (ucar.nc2.NetcdfFileWriteable)8 Variable (ucar.nc2.Variable)8 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column)7 File (java.io.File)5 List (java.util.List)5 ArrayDouble (ucar.ma2.ArrayDouble)5