5.1.22 Meta-information

Overview


Container Infomation

Note: Explains the value that can be obtained in ContainerInfo.

List.1 Obtain of Multi-Query results(ContainerInfomation.java)
// Get Container Infomation
ContainerInfo containerInfo = store.getContainerInfo("weather_station");
System.out.println("WeatherStation Container Infomation ##########");
int collectionCount = containerInfo.getColumnCount();
System.out.println("Container Name:" + containerInfo.getName());
System.out.println("Container Type:" + containerInfo.getType());
System.out.println("Column Count:" + collectionCount);
System.out.println("DataAffinity:" + containerInfo.getDataAffinity());
System.out.println("Column Order Ignorable:" + containerInfo.isColumnOrderIgnorable());
System.out.println("RowKeyAssigned:" + containerInfo.isRowKeyAssigned());
List 2 Result of Multi-Query(ContainerDynamicCreate.java)
WeatherStation Container Infomation ##########
Container Name:weather_station
Container Type:COLLECTION
Column Count:5
DataAffinity:null
Column Order Ignorable:false
RowKeyAssigned:true

Dynamic Container creation

Note: It will be described schema definition and the container of the creation of the container using a ContainerInfo and ColumnInfo. There is such a method other than the method of schema defined using a static class, such as WeatherStation class, explaining the fact that.

List.3 Dynamic Container creation(ContainerDynamicCreate.java)
// Create Connection
store = logic.createGridStore();

List<ColumnInfo> columnInfoList = new ArrayList<ColumnInfo>();

// Define Container Key and Index
EnumSet<IndexType> indexSet = EnumSet.of(IndexType.HASH);
ColumnInfo keyColumn = new ColumnInfo("id", GSType.STRING, indexSet);
// Define Index
columnInfoList.add(keyColumn);

// Define Container Columns
columnInfoList.add(new ColumnInfo("name", GSType.STRING));
columnInfoList.add(new ColumnInfo("latitude", GSType.DOUBLE));
columnInfoList.add(new ColumnInfo("longitude", GSType.DOUBLE));
columnInfoList.add(new ColumnInfo("hasCamera", GSType.BOOL));

// Define Container
ContainerInfo containerInfo = new ContainerInfo("dynamic_weather_station",
        ContainerType.COLLECTION, columnInfoList, true);

// Create Container
Container<String, Row> dynamicWeatherStaton =
        store.putContainer("dynamic_weather_station", containerInfo, true);

Note: Explain the set and registration value way of using the Row.

List.4 Row registration of dynamic Container(ContainerDynamicCreate.java)
int columnCount = containerInfo.getColumnCount();
for (int rowIndex = 0; rowIndex < 5; rowIndex++) {
    Row row = dynamicWeatherStaton.createRow();
    for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
        ColumnInfo columnInfo = containerInfo.getColumnInfo(columnIndex);
        GSType columnType = columnInfo.getType();
        Object value = null;
        switch (columnType) {
            case STRING:
                if ("id".equals(columnInfo.getName())) {
                    value = String.valueOf(rowIndex + 1);
                } else {
                    value = "name_" + (rowIndex + 1) + "_" + columnIndex;
                }
                break;
            case DOUBLE:
                value = Double.valueOf(rowIndex + 1 + columnIndex);
                break;
            case BOOL:
                value = true;
                break;
            // Omitted other types
            default:
                break;
        }

        row.setValue(columnIndex, value);
    }

    // Register Row
    dynamicWeatherStaton.put(row);
}
List.5 Row acquisition of dynamic Container(ContainerDynamicCreate.java)
// Re-Get Container
Container<String, Row> weatherStationCol =
        store.getContainer("dynamic_weather_station");

// Retrieve Container
System.out.println("ID\tName\t\t\tLongitude\tLatitude\tCamera");
for (int i = 0; i < 5; i++) {
    // Retrieve Row by key
    Row row = weatherStationCol.get(String.valueOf(i + 1));
    String id = row.getString(0);
    String name = row.getString(1);
    double latitude = row.getDouble(2);
    double longitude = row.getDouble(3);
    boolean hasCamera = row.getBool(4);

    System.out.println(String.format("%-3s\t%-20s\t%-10s\t%-10s\t%-5s", id, name,
            latitude, longitude, hasCamera));
}
List.6 Row acquisition result of dynamic Container
ID      Name                    Longitude       Latitude        Camera
1       name_1_1                3.0             4.0             true
2       name_2_1                4.0             5.0             true
3       name_3_1                5.0             6.0             true
4       name_4_1                6.0             7.0             true
5       name_5_1                7.0             8.0             true

Partition Information

Note: Description of each information that can be acquired in the PartitionController class

List.7 Partition information acquisition(PartitionInfomation.java)
// Create Connection
store = logic.createGridStore();

// Get PartitionController
PartitionController partitionController = store.getPartitionController();

// Show PartitionController has Infomation
int partitionCount = partitionController.getPartitionCount();
System.out.println("Partition Count:" + partitionCount);
for (int i = 0; i < partitionCount; i++) {
    System.out.println("Partition:" + (i + 1) + " ##########");
    System.out.println("BackupHosts:" + partitionController.getBackupHosts(i));
    System.out.println("ContainerCount:" + partitionController.getContainerCount(i));
    List<String> containerNames = partitionController.getContainerNames(i, 0, null);
    for (String containerName : containerNames) {
        System.out.println("Container Name:" + containerName);
    }
    System.out.println("Owner Node:" + partitionController.getOwnerHost(i));
    List<InetAddress> nodeHosts = partitionController.getHosts(i);
    for (InetAddress nodeHost : nodeHosts) {
        System.out.println("Node Host" + nodeHost);
    }
}

System.out.println("\nWeatherStation Partition:"
        + partitionController.getPartitionIndexOfContainer("weather_station"));
List.8 Partition information acquisition result
Partition Count:128
Partition:1 ##########
BackupHosts:[/192.168.11.12]
ContainerCount:0
Owner Node:/192.168.11.11
Node Host/192.168.11.11
Node Host/192.168.11.12
Partition:2 ##########
BackupHosts:[/192.168.11.11]
ContainerCount:0
Owner Node:/192.168.11.12
Node Host/192.168.11.12
Node Host/192.168.11.11

TimeSeries Container information

Note: It describes each property of TimeSeriesProperties. For a detailed explanation of CompressionMethod and RowExpirationTime, please refer to Technical Reference (Section 4.3.4).

List.9 TimeSeries Container information acquisition(TimeSeriesInfomation.java)
// Create Connection
store = logic.createGridStore();

// Get Container Infomation
ContainerInfo containerInfo = store.getContainerInfo("weather_station_1");
// Get TimeSeries Properties
TimeSeriesProperties tsProp = containerInfo.getTimeSeriesProperties();

// Show TimeSeriesProperties has values
System.out.println("########## TimeSeriesProperties");
System.out.println("CompressionMethod:" + tsProp.getCompressionMethod());
System.out.println(
        "CompressionRate(temperture):" + tsProp.getCompressionRate("temperture"));
System.out.println(
        "CompressionSpan(temperture):" + tsProp.getCompressionSpan("temperture"));
System.out.println(
        "CompressionWidth(temperture):" + tsProp.getCompressionWidth("temperture"));
System.out.println("CompressionWindowSize:" + tsProp.getCompressionWindowSize());
System.out
        .println("CompressionWindowSizeUnit:" + tsProp.getCompressionWindowSizeUnit());
System.out.println("ExpirationDivisionCount:" + tsProp.getExpirationDivisionCount());
System.out.println("RowExpirationTime:" + tsProp.getRowExpirationTime());
System.out.println("RowExpirationTimeUnit:" + tsProp.getRowExpirationTimeUnit());
System.out.println("SpecifiedColumns:");
Set<String> specifiedColumns = tsProp.getSpecifiedColumns();
for (String specifiedColumn : specifiedColumns) {
    System.out.println(specifiedColumn);
}
System.out.println("isCompressionRelative(temperture):"
        + tsProp.isCompressionRelative("temperture"));
List.10 TimeSeries Container information acquisition result
TimeSeriesProperties:
CompressionMethod:NO
CompressionRate(temperture):null
CompressionSpan(temperture):null
CompressionWidth(temperture):null
CompressionWindowSize:-1
CompressionWindowSizeUnit:null
ExpirationDivisionCount:8
RowExpirationTime:-1
RowExpirationTimeUnit:null
SpecifiedColumns:
isCompressionRelative(temperture):null

Source Code

Complete source code used in this sample can be downloaded from the following.

Download:meta-info.zip