carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ManoharVanam <...@git.apache.org>
Subject [GitHub] incubator-carbondata pull request #492: [CARBONDATA-440] Providing the updat...
Date Fri, 06 Jan 2017 12:07:49 GMT
Github user ManoharVanam commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/492#discussion_r94937329
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/updatestatus/SegmentStatusManager.java
---
    @@ -92,75 +112,87 @@ public static long getTableStatusLastModifiedTime(
        * @return
        * @throws IOException
        */
    -  public static SegmentStatus getSegmentStatus(AbsoluteTableIdentifier identifier)
    -      throws IOException {
    +  public ValidAndInvalidSegmentsInfo getValidAndInvalidSegments() throws IOException
{
     
         // @TODO: move reading LoadStatus file to separate class
    -    List<String> validSegments = new ArrayList<String>(10);
    -    List<String> validUpdatedSegments = new ArrayList<String>(10);
    -    List<String> invalidSegments = new ArrayList<String>(10);
    -    CarbonTablePath carbonTablePath = CarbonStorePath.getCarbonTablePath(identifier.getStorePath(),
    -        identifier.getCarbonTableIdentifier());
    +    List<String> listOfValidSegments = new ArrayList<String>(10);
    +    List<String> listOfValidUpdatedSegments = new ArrayList<String>(10);
    +    List<String> listOfInvalidSegments = new ArrayList<String>(10);
    +    CarbonTablePath carbonTablePath = CarbonStorePath
    +            .getCarbonTablePath(absoluteTableIdentifier.getStorePath(),
    +                    absoluteTableIdentifier.getCarbonTableIdentifier());
         String dataPath = carbonTablePath.getTableStatusFilePath();
         DataInputStream dataInputStream = null;
         Gson gsonObjectToRead = new Gson();
         AtomicFileOperations fileOperation =
    -        new AtomicFileOperationsImpl(dataPath, FileFactory.getFileType(dataPath));
    +            new AtomicFileOperationsImpl(dataPath, FileFactory.getFileType(dataPath));
         LoadMetadataDetails[] loadFolderDetailsArray;
         try {
           if (FileFactory.isFileExist(dataPath, FileFactory.getFileType(dataPath))) {
    +
             dataInputStream = fileOperation.openForRead();
    +
             BufferedReader buffReader =
    -            new BufferedReader(
    -                    new InputStreamReader(dataInputStream, CarbonCommonConstants.DEFAULT_CHARSET));
    +                new BufferedReader(new InputStreamReader(dataInputStream, "UTF-8"));
     
             loadFolderDetailsArray = gsonObjectToRead.fromJson(buffReader, LoadMetadataDetails[].class);
             //just directly iterate Array
             List<LoadMetadataDetails> loadFolderDetails = Arrays.asList(loadFolderDetailsArray);
     
             for (LoadMetadataDetails loadMetadataDetails : loadFolderDetails) {
    -          String loadStatus = loadMetadataDetails.getLoadStatus();
    -          if (CarbonCommonConstants.STORE_LOADSTATUS_SUCCESS.equalsIgnoreCase(loadStatus)
    -              || CarbonCommonConstants.MARKED_FOR_UPDATE.equalsIgnoreCase(loadStatus)
    -              || CarbonCommonConstants.STORE_LOADSTATUS_PARTIAL_SUCCESS.equalsIgnoreCase(
    -                  loadStatus)) {
    +          if (CarbonCommonConstants.STORE_LOADSTATUS_SUCCESS
    +                  .equalsIgnoreCase(loadMetadataDetails.getLoadStatus())
    +                  || CarbonCommonConstants.MARKED_FOR_UPDATE
    +                  .equalsIgnoreCase(loadMetadataDetails.getLoadStatus())
    +                  || CarbonCommonConstants.STORE_LOADSTATUS_PARTIAL_SUCCESS
    +                  .equalsIgnoreCase(loadMetadataDetails.getLoadStatus())) {
                 // check for merged loads.
                 if (null != loadMetadataDetails.getMergedLoadName()) {
    -              if (!validSegments.contains(loadMetadataDetails.getMergedLoadName())) {
    -                validSegments.add(loadMetadataDetails.getMergedLoadName());
    +              if (!listOfValidSegments.contains(loadMetadataDetails.getMergedLoadName()))
{
    +                listOfValidSegments.add(loadMetadataDetails.getMergedLoadName());
                   }
                   // if merged load is updated then put it in updated list
    -              if (CarbonCommonConstants.MARKED_FOR_UPDATE.equalsIgnoreCase(loadStatus))
{
    -                validUpdatedSegments.add(loadMetadataDetails.getMergedLoadName());
    +              if (CarbonCommonConstants.MARKED_FOR_UPDATE
    +                      .equalsIgnoreCase(loadMetadataDetails.getLoadStatus())) {
    +                listOfValidUpdatedSegments.add(loadMetadataDetails.getMergedLoadName());
                   }
                   continue;
                 }
    -            if (CarbonCommonConstants.MARKED_FOR_UPDATE.equalsIgnoreCase(loadStatus))
{
    -              validUpdatedSegments.add(loadMetadataDetails.getLoadName());
    +
    +            if (CarbonCommonConstants.MARKED_FOR_UPDATE
    +                    .equalsIgnoreCase(loadMetadataDetails.getLoadStatus())) {
    +
    +              listOfValidUpdatedSegments.add(loadMetadataDetails.getLoadName());
                 }
    -            validSegments.add(loadMetadataDetails.getLoadName());
    -          } else if (CarbonCommonConstants.STORE_LOADSTATUS_FAILURE.equalsIgnoreCase(loadStatus)
    -              || CarbonCommonConstants.SEGMENT_COMPACTED.equalsIgnoreCase(loadStatus)
    -              || CarbonCommonConstants.MARKED_FOR_DELETE.equalsIgnoreCase(loadStatus))
{
    -            invalidSegments.add(loadMetadataDetails.getLoadName());
    +            listOfValidSegments.add(loadMetadataDetails.getLoadName());
    +          } else if ((CarbonCommonConstants.STORE_LOADSTATUS_FAILURE
    +                  .equalsIgnoreCase(loadMetadataDetails.getLoadStatus())
    +                  || CarbonCommonConstants.COMPACTED
    +                  .equalsIgnoreCase(loadMetadataDetails.getLoadStatus())
    +                  || CarbonCommonConstants.MARKED_FOR_DELETE
    +                  .equalsIgnoreCase(loadMetadataDetails.getLoadStatus()))) {
    +            listOfInvalidSegments.add(loadMetadataDetails.getLoadName());
               }
    --- End diff --
    
    ok


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message