GVKun编程网logo

azure-devops-node-api:如何在 ProjectCollection 范围内设置DocumentByName(azure devops repos)

5

在这里,我们将给大家分享关于azure-devops-node-api:如何在ProjectCollection范围内设置DocumentByName的知识,让您更了解azuredevopsrepos

在这里,我们将给大家分享关于azure-devops-node-api:如何在 ProjectCollection 范围内设置DocumentByName的知识,让您更了解azure devops repos的本质,同时也会涉及到如何更有效地Azure DevOps React Container Production Build JavaScript heap out of memory 错误、Azure DevOps YAML 模板传递 hashset/map/dictioanry/object - 键值?、azure-devops – 在开发Azure DevOps扩展时无法使用resultSelector、com.amazonaws.services.dynamodbv2.document.ItemCollection的实例源码的内容。

本文目录一览:

azure-devops-node-api:如何在 ProjectCollection 范围内设置DocumentByName(azure devops repos)

azure-devops-node-api:如何在 ProjectCollection 范围内设置DocumentByName(azure devops repos)

我找到了解决方案!

对于 scopeType,我们需要使用 Default 而不是 UserCurrent 代表 scopeValue 而不是 Me

Azure DevOps React Container Production Build JavaScript heap out of memory 错误

Azure DevOps React Container Production Build JavaScript heap out of memory 错误

如何解决Azure DevOps React Container Production Build JavaScript heap out of memory 错误?

我正在尝试使用 Azure DevOps 管道构建 react prod docker 容器。升级构建环境和代码后,Pipeline 失败。经过一番研究,我在构建命令中添加了“--node-flags --max-old-space-size=8192”语句。不过没关系。我还尝试了构建的相关节点容器,但没有奏效。

> demo1@7.0.6 build /app
> react-scripts build

Creating an optimized production build...

    <--- Last few GCs --->
    
        
        [27:0x7f9033ec22b0]   518219 ms: Scavenge 1985.4 (2066.8) -> 1969.9 (2066.8) MB,3.7 / 0.0 ms  (average mu = 0.190,current mu = 0.078) allocation failure 
        [27:0x7f9033ec22b0]   518272 ms: Scavenge 1985.8 (2067.0) -> 1970.4 (2067.0) MB,5.7 / 0.0 ms  (average mu = 0.190,current mu = 0.078) allocation failure 
        [27:0x7f9033ec22b0]   520448 ms: Mark-sweep 1986.2 (2067.3) -> 1963.8 (2067.3) MB,2137.2 / 0.0 ms  (average mu = 0.257,current mu = 0.320) allocation failure scavenge might not succeed
        
        
        <--- JS stacktrace --->
        
        Fatal error: Ineffective mark-compacts near heap limit Allocation Failed - JavaScript heap out of memory
        npm ERR! code ELIFECYCLE
        npm ERR! errno 1
        npm ERR! demo1@7.0.6 build: `react-scripts build`
        npm ERR! Exit status 1
        npm ERR! 
        npm ERR! Failed at the demo1@7.0.6 build script.
        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
        
        npm ERR! A complete log of this run can be found in:
        npm ERR!     /root/.npm/_logs/2021-06-13T21_04_02_873Z-debug.log
        The command ''/bin/sh -c npm run-script build --node-flags --max-old-space-size=8192'' returned a non-zero code: 1
        ##[error]The command ''/bin/sh -c npm run-script build --node-flags --max-old-space-size=8192'' returned a non-zero code: 1
        ##[error]The process ''/usr/bin/docker'' Failed with exit code 1
        Finishing: Docker

Dockerfile:

# stage1 - build react app first 
FROM node:14.16.1-alpine3.13 as build
workdir /app
ENV PATH /app/node_modules/.bin:$PATH
copY ./package.json /app/
RUN apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make py3-pip git
RUN npm install --quiet node-gyp -g
RUN npm install
copY . /app
RUN npm run-script build --node-flags --max-old-space-size=8192

我的 package.json 文件:

{
    "name": "demo1","version": "7.0.6","private": true,"homepage": "","scripts": {
        "start": "react-scripts start -o","build": "react-scripts build","test": "react-scripts test","eject": "react-scripts eject","lint": "eslint src","format": "prettier --write \"src/**/*.{js,css,scss,html}\"","rtl": "webpack"
    },"eslintConfig": {
        "extends": "react-app"
    },"browserslist": {
        "production": [
            ">0.2%","not dead","not op_mini all","ie 11"
        ],"development": [
            "last 1 chrome version","last 1 firefox version","last 1 safari version","last 1 edge version","IE 11"
        ]
    },"dependencies": {
        "@ant-design/charts": "^1.1.1","@ant-design/icons": "^4.6.2","@babel/standalone": "^7.14.4","@date-io/date-fns": "2.6.1","@emotion/react": "^11.4.0","@formatjs/intl-pluralrules": "1.3.5","@fortawesome/fontawesome-free": "5.13.0","@manaflair/redux-batch": "1.0.0","@material-ui/core": "4.9.14","@material-ui/icons": "4.9.1","@material-ui/lab": "4.0.0-alpha.53","@material-ui/pickers": "3.2.10","@material-ui/styles": "4.9.14","@phuocng/react-pdf-viewer": "^1.7.0","@react-google-maps/api": "^2.2.0","@reduxjs/toolkit": "1.3.6","@tanem/svg-injector": "8.0.50","antd": "^4.13.0","antd-mask-input": "^0.1.15","apexcharts": "3.19.2","axios": "0.19.2","axios-mock-adapter": "1.18.1","bootstrap": "4.5.0","bulma": "^0.9.2","bulma-helpers": "^0.4.0","chart.js": "^3.3.2","classnames": "^2.3.1","clipboard-copy": "3.1.0","clsx": "1.1.0","convert-units": "^2.3.4","cp-cli": "2.0.0","css-mediaquery": "0.1.2","date-fns": "2.8.1","dentist": "^1.0.3","dom-to-image": "^2.6.0","downshift": "3.4.2","email-validator": "^2.0.4","fg-loadcss": "2.1.0","formik": "2.1.4","frappe-gantt-react": "^0.2.2","fs": "*","html-react-parser": "^1.2.5","html2canvas": "*","inputmask-core": "^2.2.0","jquery": "^3.6.0","json2mq": "0.2.0","jspdf": "^2.3.1","jspdf-autotable": "^3.5.14","jss-rtl": "^0.3.0","lodash": "4.17.15","material-ui-popup-state": "1.4.1","node-sass": "^4.0.0","object-path": "0.11.4","pdfjs-dist": "^2.7.570","perfect-scrollbar": "1.5.0","primeicons": "^4.1.0","primereact": "^6.2.1","prop-types": "15.7.2","qrcode.react": "^1.0.1","quill": "^1.3.7","rc-year-calendar": "^1.0.2","react": "16.12.0","react-bootstrap": "1.0.1","react-bootstrap-table-next": "4.0.2","react-bootstrap-table2-editor": "^1.4.0","react-bootstrap-table2-filter": "^1.3.3","react-bootstrap-table2-paginator": "2.1.2","react-bootstrap-table2-toolkit": "^2.1.3","react-color": "^2.19.3","react-contexify": "^4.1.1","react-country-region-selector": "^3.1.0","react-data-table-component": "^6.11.7","react-date-picker": "^8.2.0","react-datepicker": "2.16.0","react-dom": "16.12.0","react-draggable": "4.4.2","react-export-excel": "^0.5.3","react-google-maps": "^9.4.5","react-helmet": "^6.1.0","react-highlight": "^0.14.0","react-highlight-words": "^0.17.0","react-horizontal-timeline": "^1.5.3","react-inlinesvg": "1.2.0","react-intl": "3.6.2","react-is": "16.13.1","react-jvectormap": "0.0.16","react-loader-spinner": "^4.0.0","react-moment": "^1.1.1","react-pdf": "^5.3.0","react-pdfjs-multi": "^0.5.1","react-perfect-scrollbar": "1.5.8","react-phone-input-2": "^2.14.0","react-portal": "4.2.0","react-qr-reader": "^2.2.1","react-qr-scanner": "*","react-redux": "7.1.3","react-router-dom": "5.1.2","react-router-last-location": "^2.0.1","react-scripts": "3.2.0","react-select": "3.1.0","react-share": "^4.4.0","react-swipeable-views": "0.13.9","react-Syntax-Highlighter": "12.2.1","react-to-print": "^2.12.6","react-toggle": "^4.1.2","react-transition-group": "^4.4.2","react-window": "1.8.5","reactjs-pdf-reader": "^1.0.12","reactstrap": "^8.9.0","redux": "4.0.5","redux-devtools-extension": "^2.13.9","redux-logger": "^3.0.6","redux-persist": "6.0.0","redux-promise-middleware": "^6.1.2","redux-saga": "1.1.3","redux-thunk": "^2.3.0","rsuite": "^4.10.2","socicon": "3.0.5","sockjs-client": "^1.4.0","stompjs": "^2.3.3","styled-components": "^5.3.0","xlsx": "0.13.4","yup": "0.29.0"
    },"devDependencies": {
        "@babel/plugin-transform-react-jsx": "^7.14.3","copyfiles": "2.1.1","node-sass": "4.14.0","prettier": "1.19.1","serve": "11.2.0","webpack-cli": "3.3.11","webpack-messages": "2.0.4","webpack-rtl-plugin": "2.0.0"
    }
}

感谢您的帮助!

解决方法

我知道“--max-old-space-size=8192”参数不会传递给构建。所以我决定在 Dockerfile 中添加 ENV,比如“ENV NODE_OPTIONS="--max-old-space-size=8192"”。最后我的 Dockerfile 转换为:

# stage1 - build react app first 
FROM node:14.16.1-alpine3.13 as build
WORKDIR /app
ENV NODE_OPTIONS="--max-old-space-size=8192"
ENV PATH /app/node_modules/.bin:$PATH
COPY ./package.json /app/
RUN apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make py3-pip git
RUN npm install --quiet node-gyp -g
RUN npm install
COPY . /app
RUN npm run-script build

然后问题就解决了。谢谢。

Azure DevOps YAML 模板传递 hashset/map/dictioanry/object - 键值?

Azure DevOps YAML 模板传递 hashset/map/dictioanry/object - 键值?

我怎样才能实现以下目标?

您确实可以使用对象类型参数。

但是在模板中,不能同时使用多个对象参数,所以需要使用每个表达式循环遍历每个对象。

例如:- ${{ each setting in parameters.appSettings }}:

这是我的示例,您可以参考:

Deploy.yml:

parameters:
  - name: azureServiceConnection
  - name: resourceGroupName
  - name: appServiceName 
  - name: appSettings
    type: object
    default: []

steps:

- task: AzureCLI@2
  displayName: Deploy zip
  name: deployZip
  inputs:
    azureSubscription: ${{ parameters.azureServiceConnection }}
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: |
      az webapp deployment source config-zip \
        -g ${{ parameters.resourceGroupName }} \
        -n ${{ parameters.appServiceName }} \
        --src ./deployment.zip


- ${{ each setting in parameters.appSettings }}: 
  - task: AzureCLI@2
    displayName: Deploy settings
    inputs:
      azureSubscription: ${{ parameters.azureServiceConnection }}
      scriptType: 'bash'
      scriptLocation: 'inlineScript'
      inlineScript: |
        az webapp config appsettings set \
          -g ${{ parameters.resourceGroupName }} \
          -n ${{ parameters.appServiceName }} \
          --settings ${{ setting }}

azure-pipelines.yml:

trigger:
 - none

parameters:
- name: InstanceArgs 
  type: object
  default: [key2=value2,key3=value3]
jobs:
- job: deploy
  pool:
    vmImage: windows-latest
  steps:

  - template: deploy.yml
    parameters:
      azureServiceConnection: '${{ parameters.azureServiceConnection }}'
      resourceGroupName: 'foo'
      appServiceName: 'bar'
      appSettings: ${{ parameters.InstanceArgs }}

注意:由于模板中的参数是对象类型,所以需要在主yaml文件中设置相同类型的参数才能传递对象。

工作流程:将对象类型参数传递给模板。该模板将首先运行 deploy zip 命令。然后它会遍历每一个传递过来的对象,并使用config settings命令将它们一一传递给webapp。

结果:

enter image description here

azure-devops – 在开发Azure DevOps扩展时无法使用resultSelector

azure-devops – 在开发Azure DevOps扩展时无法使用resultSelector

我正在为Azure Devops开发一个自定义扩展,它已经包含一个服务端点:

"type": "ms.vss-endpoint.service-endpoint-type"

另外,我想创建一个自定义的Release Artifact Source:

“type”: “ms.vss-releaseartifact.release-artifact-type”

在this documentation之后,我目前的努力是使用外部API填充Artifact Source下的字段.我在下面的’resultSelector’和’resultTemplate’中尝试了很多模式,但无法找到适合我的模式.

在我的示例中,我想在json响应中的’builds’下获取所有’uri’值,并将它们呈现在Artifact Source的’deFinition’inputDescriptor中.我的所有尝试都导致了一个空的组合框,即使我可以看到请求达到所需的API.

json我想解析到组合框:

{
"builds": [
    {
        "uri": "/build1","lastStarted": "2018-11-07T13:12:42.547+0000"
    },{
        "uri": "/build2","lastStarted": "2018-11-09T15:40:30.315+0000"
    },{
        "uri": "/build3","lastStarted": "2018-11-12T17:46:24.805+0000"
    }
],"uri": "https://<server-address>/api/build"
}

你能帮我创建一个Mustache模式来检索上面的“uri”值吗?
我试过了:

$.builds[*].uri

这似乎不起作用.

以下是一些有用的信息.

服务端点的数据源:

"dataSources": [
                {
                  "name": "TestConnection","endpointUrl": "{{endpoint.url}}/api/plugins","resourceUrl": "","resultSelector": "jsonpath:$.values[*]","headers": [],"authenticationScheme": null
                },{
                  "name": "BuildNames","endpointUrl": "{{endpoint.url}}/api/build","resultSelector": "jsonpath:$.builds[*].uri"
                },{
                  "name": "BuildNumbers","endpointUrl": "{{endpoint.url}}/api/builds/{{deFinition}}","resultSelector": "jsonpath:$.buildsNumbers[*].uri"
                }
]

神器来源:

"inputDescriptors": [
     {
       "id": "connection","name": "Artifactory service","inputMode": "combo","isConfidential": false,"hasDynamicValueinformation": true,"validation": {
            "isrequired": true,"dataType": "string","maxLength": 300
       }
     },{
       "id": "deFinition","name": "deFinition","description": "Name of the build.","dependencyInputIds": [
             "connection"
       ],"maxLength": 300
        }
      },{
        "id": "buildNumber","name": "Build Number","description": "Number of the build.","dependencyInputIds": [
            "connection"
         ],"validation": {
             "isrequired": true,"maxLength": 300
        }
       }
],"dataSourceBindings": [
   {
       "target": "deFinition","dataSourceName": "BuildNames","resultTemplate": "{ Value : \"{{uri}}\",displayValue : \"{{uri}}\" }"
    },{
       "target": "versions","dataSourceName": "BuildNumbers",{
       "target": "latestVersion",{
       "target": "artifactDetails","resultTemplate": "{ Name: \"{{version}}\",downloadUrl : \"{{endpoint.url}}\" }"
    },{
       "target": "buildNumber",displayValue : \"{{uri}}\" }"
    }
  ]
 }

我们将非常感谢您提供的任何帮助.

解决方法

这种情况的工作组合是:

数据源:

{
  "name": "BuildNames","resultSelector": "jsonpath:$.builds[*]"
}

dataSourceBindings:

{
  "target": "deFinition","resultTemplate": "{ \"Value\" : \"{{{uri}}}\",\"displayValue\" : \"{{{uri}}}\" }"
}

com.amazonaws.services.dynamodbv2.document.ItemCollection的实例源码

com.amazonaws.services.dynamodbv2.document.ItemCollection的实例源码

项目:aws-dynamodb-examples    文件:MoviesScan.java   
public static void main(String[] args) {

        AmazonDynamoDBClient client = new AmazonDynamoDBClient();
        client.setEndpoint("http://localhost:8000");
        DynamoDB dynamoDB = new DynamoDB(client);

        Table table = dynamoDB.getTable("Movies");

        ScanSpec scanSpec = new ScanSpec()
            .withProjectionExpression("#yr,title,info.rating")
            .withFilterExpression("#yr between :start_yr and :end_yr")
            .withNameMap(new NameMap().with("#yr","year"))
            .withValueMap(new ValueMap().withNumber(":start_yr",1950).withNumber(":end_yr",1959));

        ItemCollection<ScanOutcome> items = table.scan(scanSpec);

        Iterator<Item> iter = items.iterator();
        while (iter.hasNext()) {
            Item item = iter.next();
            System.out.println(item.toString());
        }
    }
项目:aws-dynamodb-examples    文件:DocumentAPIScan.java   
private static void findProductsForPriceLessthanZero() {

    Table table = dynamoDB.getTable(tableName);

    Map<String,Object> expressionAttributeValues = new HashMap<String,Object>();
    expressionAttributeValues.put(":pr",100);

    ItemCollection<ScanOutcome> items = table.scan(
        "Price < :pr",//FilterExpression
        "Id,Title,ProductCategory,Price",//ProjectionExpression
        null,//ExpressionAttributeNames - not used in this example 
        expressionAttributeValues);

    System.out.println("Scan of " + tableName + " for items with a price less than 100.");
    Iterator<Item> iterator = items.iterator();
    while (iterator.hasNext()) {
        System.out.println(iterator.next().toJSONPretty());
    }    
}
项目:aws-dynamodb-examples    文件:DocumentAPIQuery.java   
private static void findRepliesUsingAFilterExpression(String forumName,String threadSubject) {

        Table table = dynamoDB.getTable(tableName);

        String replyId = forumName + "#" + threadSubject;

        QuerySpec spec = new QuerySpec()
            .withProjectionExpression("Message,ReplyDateTime,PostedBy")
            .withKeyConditionExpression("Id = :v_id")
            .withFilterExpression("PostedBy = :v_postedby")
            .withValueMap(new ValueMap()
                .withString(":v_id",replyId)
                .withString(":v_postedby","User B"));

        ItemCollection<QueryOutcome> items = table.query(spec);

        System.out.println("\nfindRepliesUsingAFilterExpression results:");
        Iterator<Item> iterator = items.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next().toJSONPretty());
        }    
     }
项目:outland    文件:DefaultGroupStorage.java   
@Override public boolean queryRelationExists(String relationHashKey,String relationRangeKey) {

    Table table = dynamoDB.getTable(this.groupGraphTableName);

    QuerySpec querySpec = new QuerySpec()
        .withKeyConditionExpression("subject = :k_subject and object_relation = :k_object_relation")
        .withValueMap(new ValueMap()
            .withString(":k_subject",relationHashKey)
            .withString(":k_object_relation",relationRangeKey)
        )
        .withMaxResultSize(1)
        .withConsistentRead(true);

    DynamoDbCommand<ItemCollection<QueryOutcome>> cmd = new DynamoDbCommand<>("queryRelation",() -> queryTable(table,querySpec),() -> {
          throw new RuntimeException("queryRelation");
        },dynamodbnamespaceGraphQueryHystrix,metrics);

    // can't use getLastLowLevelResult directly; it's false unless the outcome is iterated first :|
    return cmd.execute().iterator().hasNext();
  }
项目:outland    文件:DefaultGroupStorage.java   
@Override public Optional<Group> loadByKey(String key) {
  Table table = dynamoDB.getTable(this.groupTableName);

  QuerySpec querySpec = new QuerySpec()
      .withKeyConditionExpression(HASH_KEY + " = :k_app_key")
      .withValueMap(new ValueMap()
          .withString(":k_app_key",key)
      )
      .withMaxResultSize(1)
      .withConsistentRead(true);

  DynamoDbCommand<ItemCollection<QueryOutcome>> cmd = new DynamoDbCommand<>("loadByKey",() -> {
        throw new RuntimeException("loadByKey");
      },metrics);

  final ItemCollection<QueryOutcome> items = cmd.execute();
  final IteratorSupport<Item,QueryOutcome> iterator = items.iterator();
  if (iterator.hasNext()) {
    return Optional.of(GroupSupport.toGroup(iterator.next().getString("json")));
  }

  return Optional.empty();
}
项目:outland    文件:DefaultFeatureStorage.java   
@Override public List<Feature> loadFeatures(String group) {
  logger.info("{}",kvp("op","loadFeatures","group",group));
  List<Feature> features = Lists.newArrayList();

  Table table = dynamoDB.getTable(featureTableName);

  QuerySpec querySpec = new QuerySpec()
      .withKeyConditionExpression(HASH_KEY + " = :k_" + HASH_KEY)
      .withValueMap(new ValueMap().withString(":k_" + HASH_KEY,group))
      .withConsistentRead(true);

  DynamoDbCommand<ItemCollection<QueryOutcome>> cmd = new DynamoDbCommand<>("loadFeatures",() -> {
        throw new RuntimeException("loadFeatureById");
      },hystrixReadConfiguration,metrics);

  ItemCollection<QueryOutcome> items = cmd.execute();

  for (Page<Item,QueryOutcome> page : items.pages()) {
    page.forEach(item -> features.add(FeatureSupport.toFeature(item.getString("json"))));
  }

  return features;
}
项目:java-persistence    文件:DdbIndex.java   
private ScanOutcome scan(ScanSpec scanSpec,PageIterator pageIterator) {
    if ( null == _convertMarker ) {
        throw new IllegalStateException("Index must first be initialized with ConvertMarker");
    }
    if ( pageIterator.getPageSize() <= 0 ) {
        return new ScanOutcome(new ScanResult());
    }
    ItemCollection<ScanOutcome> itemCollection =
        maybeBackoff(true,() -> _scan.scan(withMarker(scanSpec,pageIterator)));

    if ( null != itemCollection ) {
        Iterator<Page<Item,ScanOutcome>> iterator = itemCollection.pages().iterator();
        if ( iterator.hasNext() ) {
            ScanOutcome outcome = maybeBackoff(true,() -> iterator.next().getLowLevelResult());
            ScanResult result = outcome.getScanResult();
            Map<String,AttributeValue> lastKey = result.getLastEvaluatedKey();
            if ( null != lastKey && ! lastKey.isEmpty() ) {
                pageIterator.setMarker(toMarker(lastKey,false));
            } else {
                pageIterator.setMarker(null);
            }
            return outcome;
        }
    }
    pageIterator.setMarker(null);
    return new ScanOutcome(new ScanResult());
}
项目:java-persistence    文件:DdbIndex.java   
private QueryOutcome query(Object hk,QuerySpec querySpec,PageIterator pageIterator) {
    if ( null == _convertMarker ) {
        throw new IllegalStateException("Index must first be initialized with ConvertMarker");
    }
    if ( pageIterator.getPageSize() <= 0 ) {
        return new QueryOutcome(new QueryResult());
    }
    ItemCollection<QueryOutcome> itemCollection =
        maybeBackoff(true,() ->
                     _query.query(withMarker(querySpec.withHashKey(_hkName,hk),pageIterator,hk)));

    if ( null != itemCollection ) {
        Iterator<Page<Item,QueryOutcome>> iterator = itemCollection.pages().iterator();
        if ( iterator.hasNext() ) {
            QueryOutcome outcome = maybeBackoff(true,() -> iterator.next().getLowLevelResult());
            QueryResult result = outcome.getQueryResult();
            if ( null != pageIterator.getMarker() && null != result.getItems() && result.getItems().size() > 0 ) {
                pageIterator.setPrevMarker(toMarker(result.getItems().get(0),true));
            } else {
                pageIterator.setPrevMarker(null);
            }
            Map<String,true));
            } else {
                pageIterator.setMarker(null);
            }
            return outcome;
        }
    }
    pageIterator.setPrevMarker(null);
    pageIterator.setMarker(null);
    return new QueryOutcome(new QueryResult());
}
项目:aws-dynamodb-examples    文件:GettingStartedTryQuery.java   
private static void findRepliesInLast15DaysWithConfig(
    String tableName,String forumName,String threadSubject) {

    String replyId = forumName + "#" + threadSubject;
    long twoWeeksAgoMilli = (new Date()).getTime()
        - (15L * 24L * 60L * 60L * 1000L);
    Date twoWeeksAgo = new Date();
    twoWeeksAgo.setTime(twoWeeksAgoMilli);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    String twoWeeksAgoStr = df.format(twoWeeksAgo);

    Table table = dynamoDB.getTable(tableName);

    QuerySpec querySpec = new QuerySpec()
        .withKeyConditionExpression("Id = :v1 and ReplyDateTime > :v2")
        .withValueMap(new ValueMap()
            .withString(":v1",replyId)
            .withString(":v2",twoWeeksAgoStr))
        .withProjectionExpression("Message,PostedBy");

    ItemCollection<QueryOutcome> items = table.query(querySpec);
    Iterator<Item> iterator = items.iterator();

    System.out.println("Query: printing results...");

    while (iterator.hasNext()) {
        System.out.println(iterator.next().toJSONPretty());
    }
}
项目:aws-dynamodb-examples    文件:DocumentAPIParallelScan.java   
@Override
public void run() {
    System.out.println("Scanning " + tableName + " segment " + segment + " out of " + totalSegments + " segments " + itemLimit + " items at a time...");
    int totalScannedItemCount = 0;

    Table table = dynamoDB.getTable(tableName);

    try {
        ScanSpec spec = new ScanSpec()
            .withMaxResultSize(itemLimit)
            .withTotalSegments(totalSegments)
            .withSegment(segment);

        ItemCollection<ScanOutcome> items = table.scan(spec);
        Iterator<Item> iterator = items.iterator();

        Item currentItem = null;
        while (iterator.hasNext()) {
            totalScannedItemCount++;
            currentItem = iterator.next();
            System.out.println(currentItem.toString());
        }    

    } catch (Exception e) {
        System.err.println(e.getMessage());
    } finally {
        System.out.println("Scanned " + totalScannedItemCount 
            + " items from segment " + segment + " out of " 
            + totalSegments + " of " + tableName);
    }
}
项目:aws-dynamodb-examples    文件:DocumentAPIQuery.java   
private static void findRepliesForAThreadSpecifyOptionalLimit(String forumName,String threadSubject) {

        Table table = dynamoDB.getTable(tableName);

        String replyId = forumName + "#" + threadSubject;   

        QuerySpec spec = new QuerySpec()
            .withKeyConditionExpression("Id = :v_id")
            .withValueMap(new ValueMap()
                .withString(":v_id",replyId))
            .withMaxPageSize(1);

        ItemCollection<QueryOutcome> items = table.query(spec);

        System.out.println("\nfindRepliesForAThreadSpecifyOptionalLimit results:");

        // Process each page of results
        int pageNum = 0;
        for (Page<Item,QueryOutcome> page : items.pages()) {

            System.out.println("\nPage: " + ++pageNum);

            // Process each item on the current page
            Iterator<Item> item = page.iterator();
            while (item.hasNext()) {
                System.out.println(item.next().toJSONPretty());
            }
        }
    }
项目:aws-dynamodb-examples    文件:DocumentAPIQuery.java   
private static void findRepliesInLast15DaysWithConfig(String forumName,String threadSubject) {

        Table table = dynamoDB.getTable(tableName);

        long twoWeeksAgoMilli = (new Date()).getTime() - (15L*24L*60L*60L*1000L);
        Date twoWeeksAgo = new Date();
        twoWeeksAgo.setTime(twoWeeksAgoMilli);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        String twoWeeksAgoStr = df.format(twoWeeksAgo);

        String replyId = forumName + "#" + threadSubject;

        QuerySpec spec = new QuerySpec()
            .withProjectionExpression("Message,PostedBy")
            .withKeyConditionExpression("Id = :v_id and ReplyDateTime <= :v_reply_dt_tm")
            .withValueMap(new ValueMap()
                .withString(":v_id",replyId)
                .withString(":v_reply_dt_tm",twoWeeksAgoStr));

        ItemCollection<QueryOutcome> items = table.query(spec);

        System.out.println("\nfindRepliesInLast15DaysWithConfig results:");
        Iterator<Item> iterator = items.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next().toJSONPretty());
        }

    }
项目:aws-dynamodb-examples    文件:DocumentAPIQuery.java   
private static void findRepliesPostedWithinTimePeriod(String forumName,String threadSubject) {

        Table table = dynamoDB.getTable(tableName);

        long startDateMilli = (new Date()).getTime() - (15L*24L*60L*60L*1000L); 
        long endDateMilli = (new Date()).getTime() - (5L*24L*60L*60L*1000L);    
        java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        String startDate = df.format(startDateMilli);
        String endDate = df.format(endDateMilli);

        String replyId = forumName + "#" + threadSubject;

        QuerySpec spec = new QuerySpec()
            .withProjectionExpression("Message,PostedBy")
            .withKeyConditionExpression("Id = :v_id and ReplyDateTime between :v_start_dt and :v_end_dt")
            .withValueMap(new ValueMap()
                .withString(":v_id",replyId)
                .withString(":v_start_dt",startDate)
                .withString(":v_end_dt",endDate));

        ItemCollection<QueryOutcome> items = table.query(spec);

        System.out.println("\nfindRepliesPostedWithinTimePeriod results:");
        Iterator<Item> iterator = items.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next().toJSONPretty());
        }    
    }
项目:outland    文件:DefaultGroupStorage.java   
private ItemCollection<QueryOutcome> queryTable(Table table,QuerySpec querySpec) {
  return table.query(querySpec);
}
项目:outland    文件:DefaultFeatureStorage.java   
private ItemCollection<QueryOutcome> queryTable(Table table,QuerySpec querySpec) {
  return table.query(querySpec);
}
项目:aws-dynamodb-examples    文件:MoviesQuery.java   
public static void main(String[] args)  {

        AmazonDynamoDBClient client = new AmazonDynamoDBClient();
        client.setEndpoint("http://localhost:8000");
        DynamoDB dynamoDB = new DynamoDB(client);

        Table table = dynamoDB.getTable("Movies");

        HashMap<String,String> nameMap = new HashMap<String,String>();
        nameMap.put("#yr","year"); 

        HashMap<String,Object> valueMap = new HashMap<String,Object>();
        valueMap.put(":yyyy",1985);

        QuerySpec querySpec = new QuerySpec()
            .withKeyConditionExpression("#yr = :yyyy")
            .withNameMap(new NameMap().with("#yr","year"))
            .withValueMap(valueMap);

        ItemCollection<QueryOutcome> items = table.query(querySpec);

        Iterator<Item> iterator = items.iterator();
        Item item = null;

        System.out.println("Movies from 1985");
        while (iterator.hasNext()) {
            item = iterator.next();
            System.out.println(item.getNumber("year") + ": " + item.getString("title"));
        }

        valueMap.put(":yyyy",1992);
        valueMap.put(":letter1","A");
        valueMap.put(":letter2","L");

        querySpec
            .withProjectionExpression("#yr,info.genres,info.actors[0]")
            .withKeyConditionExpression("#yr = :yyyy and title between :letter1 and :letter2")
            .withNameMap(nameMap)
            .withValueMap(valueMap);

        items = table.query(querySpec);
        iterator = items.iterator();

        System.out.println("Movies from 1992 - titles A-L,with genres and lead actor");
        while (iterator.hasNext()) {
            item = iterator.next();
            System.out.println(item.toString());
        }

    }
项目:aws-dynamodb-examples    文件:DocumentAPIQuery.java   
private static void findRepliesForAThread(String forumName,String threadSubject) {

        Table table = dynamoDB.getTable(tableName);

        String replyId = forumName + "#" + threadSubject;

        QuerySpec spec = new QuerySpec()
            .withKeyConditionExpression("Id = :v_id")
            .withValueMap(new ValueMap()
                .withString(":v_id",replyId));

        ItemCollection<QueryOutcome> items = table.query(spec);

        System.out.println("\nfindRepliesForAThread results:");

        Iterator<Item> iterator = items.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next().toJSONPretty());
        }

    }
项目:aws-dynamodb-examples    文件:DocumentAPIGlobalSecondaryIndexExample.java   
public static void queryIndex(String indexName) {

    Table table = dynamoDB.getTable(tableName);

    System.out.println
    ("\n***********************************************************\n");
    System.out.print("Querying index " + indexName + "...");

    Index index = table.getIndex(indexName);

    ItemCollection<QueryOutcome> items = null;

    QuerySpec querySpec = new QuerySpec();

    if (indexName == "CreateDateIndex") {
        System.out.println("Issues filed on 2013-11-01");
        querySpec.withKeyConditionExpression("CreateDate = :v_date and begins_with(IssueId,:v_issue)")
            .withValueMap(new ValueMap()
                .withString(":v_date","2013-11-01")
                .withString(":v_issue","A-"));
        items = index.query(querySpec);
    } else if (indexName == "TitleIndex") {
        System.out.println("Compilation errors");
        querySpec.withKeyConditionExpression("Title = :v_title and begins_with(IssueId,:v_issue)")
            .withValueMap(new ValueMap()
                .withString(":v_title","Compilation error")
                .withString(":v_issue","A-"));
        items = index.query(querySpec);
    } else if (indexName == "DueDateIndex") {
        System.out.println("Items that are due on 2013-11-30");
        querySpec.withKeyConditionExpression("DueDate = :v_date")
            .withValueMap(new ValueMap()
                .withString(":v_date","2013-11-30"));
        items = index.query(querySpec);
    } else {
        System.out.println("\nNo valid index name provided");
        return;
    }

    Iterator<Item> iterator = items.iterator();

    System.out.println("Query: printing results...");

    while (iterator.hasNext()) {
        System.out.println(iterator.next().toJSONPretty());
    }


}

关于azure-devops-node-api:如何在 ProjectCollection 范围内设置DocumentByNameazure devops repos的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于Azure DevOps React Container Production Build JavaScript heap out of memory 错误、Azure DevOps YAML 模板传递 hashset/map/dictioanry/object - 键值?、azure-devops – 在开发Azure DevOps扩展时无法使用resultSelector、com.amazonaws.services.dynamodbv2.document.ItemCollection的实例源码的相关信息,请在本站寻找。

本文标签: